From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2747C475E5 for ; Mon, 12 Feb 2024 00:03:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8182468D14B; Mon, 12 Feb 2024 02:02:43 +0200 (EET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2059.outbound.protection.outlook.com [40.92.59.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F66768D145 for ; Mon, 12 Feb 2024 02:02:40 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZnQTQQoZFZmEy7UCGqj3wmsmykz9rYpbaMk5d4uDjjW1ti8sgdlw3LJYUsadERrTFnrQ+hv85jNoNFNBsRfqrZZ24T+ZuQj+rSPdUY3WVz/q79pT8tAno9Mo8o26xU65zSbx3WpxUAWoCNNhJU+zAhYke9xQP97f7hgWYj2xGwHnZgbfh+gQxiT/cvCzLcncF3yreImyGnwnJ0ERbsMtBoXvgTpvpofLAp2jUJCcJzB2Q/8ciKWT2aH6YPj3LwRVSI4KRtAUoY9B2FfS0b/hodLlPD4lhF49A2pYi2PRF707tKbOGZyHg9sGWWlTAnimm82On86GNbY5fKVRvyoLlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CgsmnX8df1TU/dE+E8TXtujyQAItO78Yj7axXi+zw3g=; b=FrlLho0LH+DaUx1W6f3H0LTY5iJAQhxUYcTomxSrg32BdORIuTogzND92esXHTQRfNhwgkGAt4pJUJdrfnqABiQ8qle3rDTpiyXOhQgbNqUeRkRu98KbRexTp+HQXChMEmUlKILx6DSvkiFX/vdO7QI2Md2fPIq0ulEYGdE8anJJaEC+LpBGJcVwFA/vkI02T+Gcv9TdWzq5pnegz10cj1B0Gp5fBzm/B9wmYHybCSjUOFk3jp3kHgkop9/7UfshmS7/wln6WLhba7eyCvBMaJu1ejhxs5ssHxq4O6OZOoYOzQpkvvB3iaDiTrTd8YGq47X6LE0taXnnTl2zgSWb+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CgsmnX8df1TU/dE+E8TXtujyQAItO78Yj7axXi+zw3g=; b=E6hZfjwfgFgw8C6Bt5yo4eAsq5abQEGqy8DpukyquCAsZDwQDLh0AQrb2y8DbdV3qu++tVPmaJlFbaYzL5B53pQ4KTWFhSEf+LG8HSPgvWdIxLuLFBRrZc/mVahW8Pe+oBSjdWvzSe/d1Be73pSg/+Y1yVeiHRID5FWdP8T2MUXA2YzUzoQEPY13lmFkeHAegqFbYzVG3aLQVMvBAAgYcHeeodMQrRcj6LFuLKbPEdD15bI95GONSFcWpJ6nHn0YDvxkTFxzSoeSjCSrGqugEwpHbUPrdvF+G31W93rjBPdM2oNXT4cV6VskKdSsyJsHpmrwhXgOfRVrKa3cydg8kQ== Received: from DU0P250MB0747.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3cb::16) by PR3P250MB0257.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.35; Mon, 12 Feb 2024 00:02:37 +0000 Received: from DU0P250MB0747.EURP250.PROD.OUTLOOK.COM ([fe80::db07:87f6:7c75:38cc]) by DU0P250MB0747.EURP250.PROD.OUTLOOK.COM ([fe80::db07:87f6:7c75:38cc%3]) with mapi id 15.20.7270.036; Mon, 12 Feb 2024 00:02:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Feb 2024 01:03:22 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [KrAVtOmSMhIpah9mUpP0EqiibsSnMKaA3MFLRwJW+iQ=] X-ClientProxiedBy: FR3P281CA0146.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::18) To DU0P250MB0747.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3cb::16) X-Microsoft-Original-Message-ID: <20240212000335.27984-9-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0P250MB0747:EE_|PR3P250MB0257:EE_ X-MS-Office365-Filtering-Correlation-Id: f6265646-2087-4116-a5da-08dc2b5debdc X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO87oPFJ6NqZfVGd+0JvB+2cqVz8KqbD4GLWy42wyoOI0uEyE55ETG/19mqwetNt6oBnmJRkW0JESoxn7A7Mt+2B+k/4PDJbw7Vt3LvZCTp/qQ24S8lkHB8PGr0WvdRjB1YlHG+axxP5WEWjnsOD7BUlC9vUxkWk07Y3PD0U5RVc1vj9UUk9+hjdTf32rDs95g95bO3tn8Us3lGUUSOX2EyEn15CcmTcnCnMkA+cX8WuLVWmuK87IYw2HhrrpdzJtOahCWUXSfosLujMg9pzYBsx2Hi+cLVMoZlgipA3ILzfOFCjF35ihsxmH/Q+H2w/2ARrp3JQh18RVTUnHhEFN+QouSTVsFGFlkwVU0a6bd607aE3aXMiFnNZQFwq+tuzwBOLRGpFBz/HEOY4cX/ASehTfKLsFdTJNWEE5SjcYtzDWDGVC3uHsGI8CImp1Ghq3iF08EAg1oGcXtnN6tSV6o0VhHPjJqx9SdydW9TFqZSDSK9URZNkjvEA7nPZAiRgbwXAZ2BCgJRljJ5eyzoV1Vo2n6jfbsSDPThJIeknnjuG2RbtCqr6XK11jmWW6/adUJOVB0nM6zmOUgdqNoId8uiknbwUTqg+TktUWdfrjmlT3T4+68RNLCF/mxPmCeNmt1H2t1vYQg9brFU0M79tvxnWbwlcYeV4569z2Dd0LAlr94Km53e/qw836qMTNiHCQeRAAMpFgxL+0w== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G0lXV3NFtigCHUPwuXeto2m52JWeO/Sw6/TTsDPM3lryk5DCX5vJiJROnvkzWAnynFEYm0VX/6PaafdfKveKb/74ehy1hymS9Y3c9iNFkEIEVhBKwk87PRjA9MMX4WnYWCiEa/XOekyn6+WME9b2nzNu589h3p4xNox6EQM9ftLUbB8kg0ITRJllSyO9NERczxegedLTovnAtG/KeoW/Yxnm+KVLKRaONHI2I6hrsl2LBC3dMl2CRYOFfaFtzKXAkhQFLXoQ8Q2+9gtpqAPSxB/axESQUPc4LPY8hJizoT1igGEFKef4+5MdAKdE8uDPBF9rxjXtaw/GzJ8nXIXHwCxxog/fbC6YjRf7w78c2AOyzchc3wM2eZuXfYokR4FPwv1pFlfbTeOxozAapqfapVpMxpw0LAdT/ViJpVblKU2Df6Zmcrad5rHnGGjBc0weljYdSgvuOSeZicvD1XudqgRW+2efyBLoaxjf4yenmkOoQpBYsjgzEyIBjjdvz8lzPdJF9s3cIH5AQwiBBZbDw2fJhtIvwjRKeSaodFwT5HVelDaVruXcNI1A/z8WfmZvFZKLFuWzAIUo1VxdIU2xc50m2BXNDa8Wsjq64ho1tk+nZxjw0bAfWkq0tCU4k2IM X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6kmHrRwzR1yV7ONJ1cqc01J723cNoO8VTG48Cc1d88x3fyb204d0IwaNvtxG?= =?us-ascii?Q?HsKtL0aIyf5rJuPc2iPnXAhZNoC/vMJlEkGgkGlmAcdBSzCv+FXKduZuc/1n?= =?us-ascii?Q?aI6qkfzRYrShF5kzNtvaX5aduV4D6EB8nWIlj/Wr9Nzw7SsYGRFk2YLNf+QO?= =?us-ascii?Q?7ERWxAPNw5kc1y0q70gBhSnywLXCgyIoqCcM6W3WPrIUfhrOK2pJPUup5xim?= =?us-ascii?Q?qvz/i/UYPncKjbpWqK4Y6+T7hiOUA5NphnaZ9kkvQiq0tVVgTQuNgB5ZrxAk?= =?us-ascii?Q?7eSwq348JFrT7mOZQTWsqdShwhI1cb+krumIIo5179KBLkEj9pQ/Mx5lxz8L?= =?us-ascii?Q?rQphklN7+NzzSD5Xdw1HwLiw0nVRrF7tOkcvxJnXHc9NHDl6NgS/4z76pZrb?= =?us-ascii?Q?JKv5sAOjpnuIauviGwlCNXmOq5jBCK0j9E1PWIMuFkvslcdeczfuMAUTCOZb?= =?us-ascii?Q?6jVRy17mZCN7jvPC2wP45BSIjo+iJznNnOolTSLfEY8rpW31Q8gm7Aj1Wm3Y?= =?us-ascii?Q?KM5WUbv/FLZUfQu+Eg7Sts1yYcAdKmEAhPBMbn/smJS2bkGOom+lCOAl33Ll?= =?us-ascii?Q?bXrOqGNOgtQ/qoOkmR1TskGwgzSIIGgfTDbKVndlyhz3qtDbU9k1rBcvQ21G?= =?us-ascii?Q?c3HqAYIdQU61+LBxoJgpg4xuW2/ek+qSlPoNAO6Rysz33UoY60GPYDNW/8N+?= =?us-ascii?Q?m21cs7SohkKn3cYUSJaArvnUkztfuLdFdQhlddOUzHPoA8J5LkqblNiJDiqv?= =?us-ascii?Q?eUTmNYQKa50i3Tvc2eNvgyb+ouLjvxE7D4+5SCAcTjUfabCA0WZyEJsvs8ZT?= =?us-ascii?Q?fOB8v99m6WpgWlVzFFt9Z61+kyDHU+pHxCmwhZFbgBXiyzW+E0lrlrAAmkJU?= =?us-ascii?Q?xIE270fRfFfyPL49f+UOJq//0NiTBlfYo+3HMPxJzW61KUQPb7ghhKd1vykc?= =?us-ascii?Q?rWe868it9KE1JZ25ASn2X1vJRrYlRmpk8Qok5F41ZatnG7qSaAsVFKgmA/9x?= =?us-ascii?Q?iXTm29b2HLemh1uSHK3hJoUm7LaChoR4d/TMHwfwyMPk+8QW+vewYR3JkQEM?= =?us-ascii?Q?eq92PY8w2oK8hvLg7QC98n/NsZ0M84LcXV1Ntv8fu8NfYzlT9Rpd0QjSzZjb?= =?us-ascii?Q?RO9f2jHSgHRIBqrBzAIPQEhd7QApRc7tTCB6d8o+/jfDuA1FssmCZeM+EqZx?= =?us-ascii?Q?jAu5ou8TypLfBXNltDCS7utekqXubqwEexWJGGaO63+FeYE5ZiKNfDlgfZJ7?= =?us-ascii?Q?m8s5vkqEmYm+wwXU09RFxRnDytzcQBYnZ6stamrgYA=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6265646-2087-4116-a5da-08dc2b5debdc X-MS-Exchange-CrossTenant-AuthSource: DU0P250MB0747.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2024 00:02:37.0513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0257 Subject: [FFmpeg-devel] [PATCH 10/23] avutil/hwcontext: Allocate AVHWDevCtx jointly with its internals X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This is possible because the lifetime of these structures coincide. It has the advantage of allowing to remove the AVHWDeviceInternal from the public header; given that AVHWDeviceInternal.priv is no more, all accesses to it happen in hwcontext.c, so that this commit moves the joint structure there. Signed-off-by: Andreas Rheinhardt --- libavutil/hwcontext.c | 102 ++++++++++++++++++--------------- libavutil/hwcontext.h | 8 --- libavutil/hwcontext_internal.h | 10 ---- 3 files changed, 57 insertions(+), 63 deletions(-) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 02e9668c31..c962c19f3e 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -84,6 +84,21 @@ static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", }; +typedef struct FFHWDeviceContext { + /** + * The public AVHWDeviceContext. See hwcontext.h for it. + */ + AVHWDeviceContext p; + + const HWContextType *hw_type; + + /** + * For a derived device, a reference to the original device + * context it was derived from. + */ + AVBufferRef *source_device; +} FFHWDeviceContext; + enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) { int type; @@ -126,25 +141,26 @@ static const AVClass hwdevice_ctx_class = { static void hwdevice_ctx_free(void *opaque, uint8_t *data) { - AVHWDeviceContext *ctx = (AVHWDeviceContext*)data; + FFHWDeviceContext *ctxi = (FFHWDeviceContext*)data; + AVHWDeviceContext *ctx = &ctxi->p; /* uninit might still want access the hw context and the user * free() callback might destroy it, so uninit has to be called first */ - if (ctx->internal->hw_type->device_uninit) - ctx->internal->hw_type->device_uninit(ctx); + if (ctxi->hw_type->device_uninit) + ctxi->hw_type->device_uninit(ctx); if (ctx->free) ctx->free(ctx); - av_buffer_unref(&ctx->internal->source_device); + av_buffer_unref(&ctxi->source_device); av_freep(&ctx->hwctx); - av_freep(&ctx->internal); av_freep(&ctx); } AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type) { + FFHWDeviceContext *ctxi; AVHWDeviceContext *ctx; AVBufferRef *buf; const HWContextType *hw_type = NULL; @@ -159,13 +175,10 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type) if (!hw_type) return NULL; - ctx = av_mallocz(sizeof(*ctx)); - if (!ctx) + ctxi = av_mallocz(sizeof(*ctxi)); + if (!ctxi) return NULL; - - ctx->internal = av_mallocz(sizeof(*ctx->internal)); - if (!ctx->internal) - goto fail; + ctx = &ctxi->p; if (hw_type->device_hwctx_size) { ctx->hwctx = av_mallocz(hw_type->device_hwctx_size); @@ -182,12 +195,11 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type) ctx->type = type; ctx->av_class = &hwdevice_ctx_class; - ctx->internal->hw_type = hw_type; + ctxi->hw_type = hw_type; return buf; fail: - av_freep(&ctx->internal); av_freep(&ctx->hwctx); av_freep(&ctx); return NULL; @@ -195,19 +207,20 @@ fail: int av_hwdevice_ctx_init(AVBufferRef *ref) { - AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data; + FFHWDeviceContext *ctxi = (FFHWDeviceContext*)ref->data; + AVHWDeviceContext *ctx = &ctxi->p; int ret; - if (ctx->internal->hw_type->device_init) { - ret = ctx->internal->hw_type->device_init(ctx); + if (ctxi->hw_type->device_init) { + ret = ctxi->hw_type->device_init(ctx); if (ret < 0) goto fail; } return 0; fail: - if (ctx->internal->hw_type->device_uninit) - ctx->internal->hw_type->device_uninit(ctx); + if (ctxi->hw_type->device_uninit) + ctxi->hw_type->device_uninit(ctx); return ret; } @@ -242,8 +255,8 @@ static void hwframe_ctx_free(void *opaque, uint8_t *data) AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ref_in) { - AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref_in->data; - const HWContextType *hw_type = device_ctx->internal->hw_type; + FFHWDeviceContext *device_ctx = (FFHWDeviceContext*)device_ref_in->data; + const HWContextType *hw_type = device_ctx->hw_type; AVHWFramesContext *ctx; AVBufferRef *buf, *device_ref = NULL; @@ -279,7 +292,7 @@ AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ref_in) ctx->av_class = &hwframe_ctx_class; ctx->device_ref = device_ref; - ctx->device_ctx = device_ctx; + ctx->device_ctx = &device_ctx->p; ctx->format = AV_PIX_FMT_NONE; ctx->sw_format = AV_PIX_FMT_NONE; @@ -563,8 +576,8 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags) void *av_hwdevice_hwconfig_alloc(AVBufferRef *ref) { - AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data; - const HWContextType *hw_type = ctx->internal->hw_type; + FFHWDeviceContext *ctx = (FFHWDeviceContext*)ref->data; + const HWContextType *hw_type = ctx->hw_type; if (hw_type->device_hwconfig_size == 0) return NULL; @@ -575,8 +588,8 @@ void *av_hwdevice_hwconfig_alloc(AVBufferRef *ref) AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, const void *hwconfig) { - AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data; - const HWContextType *hw_type = ctx->internal->hw_type; + FFHWDeviceContext *ctx = (FFHWDeviceContext*)ref->data; + const HWContextType *hw_type = ctx->hw_type; AVHWFramesConstraints *constraints; if (!hw_type->frames_get_constraints) @@ -589,7 +602,7 @@ AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, constraints->min_width = constraints->min_height = 0; constraints->max_width = constraints->max_height = INT_MAX; - if (hw_type->frames_get_constraints(ctx, hwconfig, constraints) >= 0) { + if (hw_type->frames_get_constraints(&ctx->p, hwconfig, constraints) >= 0) { return constraints; } else { av_hwframe_constraints_free(&constraints); @@ -610,7 +623,7 @@ int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags) { AVBufferRef *device_ref = NULL; - AVHWDeviceContext *device_ctx; + FFHWDeviceContext *device_ctx; int ret = 0; device_ref = av_hwdevice_ctx_alloc(type); @@ -618,15 +631,15 @@ int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, ret = AVERROR(ENOMEM); goto fail; } - device_ctx = (AVHWDeviceContext*)device_ref->data; + device_ctx = (FFHWDeviceContext*)device_ref->data; - if (!device_ctx->internal->hw_type->device_create) { + if (!device_ctx->hw_type->device_create) { ret = AVERROR(ENOSYS); goto fail; } - ret = device_ctx->internal->hw_type->device_create(device_ctx, device, - opts, flags); + ret = device_ctx->hw_type->device_create(&device_ctx->p, device, + opts, flags); if (ret < 0) goto fail; @@ -648,13 +661,13 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, AVDictionary *options, int flags) { AVBufferRef *dst_ref = NULL, *tmp_ref; - AVHWDeviceContext *dst_ctx, *tmp_ctx; + FFHWDeviceContext *dst_ctx; int ret = 0; tmp_ref = src_ref; while (tmp_ref) { - tmp_ctx = (AVHWDeviceContext*)tmp_ref->data; - if (tmp_ctx->type == type) { + FFHWDeviceContext *tmp_ctx = (FFHWDeviceContext*)tmp_ref->data; + if (tmp_ctx->p.type == type) { dst_ref = av_buffer_ref(tmp_ref); if (!dst_ref) { ret = AVERROR(ENOMEM); @@ -662,7 +675,7 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, } goto done; } - tmp_ref = tmp_ctx->internal->source_device; + tmp_ref = tmp_ctx->source_device; } dst_ref = av_hwdevice_ctx_alloc(type); @@ -670,19 +683,18 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, ret = AVERROR(ENOMEM); goto fail; } - dst_ctx = (AVHWDeviceContext*)dst_ref->data; + dst_ctx = (FFHWDeviceContext*)dst_ref->data; tmp_ref = src_ref; while (tmp_ref) { - tmp_ctx = (AVHWDeviceContext*)tmp_ref->data; - if (dst_ctx->internal->hw_type->device_derive) { - ret = dst_ctx->internal->hw_type->device_derive(dst_ctx, - tmp_ctx, - options, - flags); + FFHWDeviceContext *tmp_ctx = (FFHWDeviceContext*)tmp_ref->data; + if (dst_ctx->hw_type->device_derive) { + ret = dst_ctx->hw_type->device_derive(&dst_ctx->p, + &tmp_ctx->p, + options, flags); if (ret == 0) { - dst_ctx->internal->source_device = av_buffer_ref(src_ref); - if (!dst_ctx->internal->source_device) { + dst_ctx->source_device = av_buffer_ref(src_ref); + if (!dst_ctx->source_device) { ret = AVERROR(ENOMEM); goto fail; } @@ -694,7 +706,7 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, if (ret != AVERROR(ENOSYS)) goto fail; } - tmp_ref = tmp_ctx->internal->source_device; + tmp_ref = tmp_ctx->source_device; } ret = AVERROR(ENOSYS); diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 2b33721a97..d91391294b 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -40,8 +40,6 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_D3D12VA, }; -typedef struct AVHWDeviceInternal AVHWDeviceInternal; - /** * This struct aggregates all the (hardware/vendor-specific) "high-level" state, * i.e. state that is not tied to a concrete processing configuration. @@ -65,12 +63,6 @@ typedef struct AVHWDeviceContext { */ const AVClass *av_class; - /** - * Private data used internally by libavutil. Must not be accessed in any - * way by the caller. - */ - AVHWDeviceInternal *internal; - /** * This field identifies the underlying API used for hardware access. * diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h index 374c6dde2f..3745867283 100644 --- a/libavutil/hwcontext_internal.h +++ b/libavutil/hwcontext_internal.h @@ -95,16 +95,6 @@ typedef struct HWContextType { AVHWFramesContext *src_ctx, int flags); } HWContextType; -struct AVHWDeviceInternal { - const HWContextType *hw_type; - - /** - * For a derived device, a reference to the original device - * context it was derived from. - */ - AVBufferRef *source_device; -}; - struct AVHWFramesInternal { const HWContextType *hw_type; void *priv; -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".