From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 4BE514BDFB for ; Thu, 22 May 2025 17:58:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 4CAE668DCE9; Thu, 22 May 2025 20:57:56 +0300 (EEST) Received: from PNYPR01CU001.outbound.protection.outlook.com (mail-centralindiaazon11020102.outbound.protection.outlook.com [52.101.225.102]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 1532568D5CC for ; Thu, 22 May 2025 20:57:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AkllMGrdpPsSgXP7m9xsoav1Kn4/C/nBQAEs0JCHigRXUc87ZJupysBgCHl3aV3RkibXteNdKDKWBLrwI/QdPJuUotyCmXZK76mGmyqZYL/O9cjr88UjZMZBTfePV4wTPK7yRKVwc73kLoDaIRKVH7YlzMMgf6FirVmZkphKqA7bmO+fElJSJoXkksmNuBvuMjW0gVxUMJ76SNlj82f7InpkJ+0tM7Y8f8MewX0IQwdErasslZZFvG5OjVzuJmnfKEdeZPIceRn8qqOmzcaM86WEcZ5QimS7NliRGuHK8svjs8fPIWmgo00FMa5ROjizY2FxCGoEB362GkC8L3K5Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wc6GD9+fUv5zITBAAHMIvUCMsyKKd1Gwn5fqIzZ/snE=; b=OjAmUUN201QH0KPeuAZrw1HxJwP9bxKlq04LJVc9y5jozJihzaXKOsxZnb0YcMIZItqCAPujT1B8teJOBNMaitAphZJUDUfmlmqDzhmNKXsdbuiHtcepBEHxYoQ4GDAWG3792mDjN/pLq/9WmsJigeTtp49lAK9H1E6cvBf3TQYkdb4lLqTD29xA2610jWfR3YvNpMOj8KrSPiMtAHOYnaD6K7RgbxZIky9DvpXxvyToaJeW/YkNxo/woL8DZl6jS6bdP2d5moNSm1uyUSSdbgiDTt64+sxM9WC5jc/XdTSYTDxmj3HEn/sH1P3wgkQ+x/UufNbnILLP36ER2pK0qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=multicorewareinc.com; dmarc=pass action=none header.from=multicorewareinc.com; dkim=pass header.d=multicorewareinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=multicorewareinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wc6GD9+fUv5zITBAAHMIvUCMsyKKd1Gwn5fqIzZ/snE=; b=XIn2/Y4GpfuYgaQdqYyIWDnPZPOvC3SjIxuAEhYJiFwRC+yKBkey/FVwbfcucjWS8yjDf+Dz4Bp12hKqKb6TTfc7K+Tpg3nwg0S9Ylx+SN1wj0e4zDMuGSBexkRUJvTkh7OkGdwWCRfq56locRzZQwsnr4o0kM6bxviRqkAtW1yJgadanavV2v5vgMh7tc+J4MO7mpypMvAfB7wbBt0zHV7RK1zYWHu0dDimp3urUvf8+qbGYVFzscl7rohBMRhL+oSlrBweBYg2Q+MdjqPHEEPjqY0SBl91RRN0a3wuHA8Cn7jelPWL5qWTQ3tQoI6M/J7vJsUCmrHh8WjmQaTFkA== Received: from PN0P287MB1494.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:186::9) by PNYP287MB4103.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:28f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8769.21; Thu, 22 May 2025 17:57:45 +0000 Received: from PN0P287MB1494.INDP287.PROD.OUTLOOK.COM ([fe80::1a78:65d:b254:359]) by PN0P287MB1494.INDP287.PROD.OUTLOOK.COM ([fe80::1a78:65d:b254:359%3]) with mapi id 15.20.8769.019; Thu, 22 May 2025 17:57:45 +0000 From: Dash Santosh Sathyanarayanan To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [FFmpeg-devel] [PATCH 1/2] avfilter: add scale_d3d11 filter Thread-Index: AQHbyxskU+BZwNxA8Uak9GOiqoIdXbPexSsAgAAmAgA= Date: Thu, 22 May 2025 17:57:44 +0000 Message-ID: References: <12837948-f6cc-4204-bf40-91cf7cafeea5@rothenpieler.org> In-Reply-To: <12837948-f6cc-4204-bf40-91cf7cafeea5@rothenpieler.org> Accept-Language: en-IN, en-US Content-Language: en-IN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: undefined: 2322682 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=multicorewareinc.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PN0P287MB1494:EE_|PNYP287MB4103:EE_ x-ms-office365-filtering-correlation-id: 1e8005b5-377d-4452-8139-08dd995a27ca x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|10070799003|366016|4022899009|376014|38070700018|13003099007; x-microsoft-antispam-message-info: =?iso-8859-1?Q?UQKFBBMdhsv6PK5mJoaEE6gsx/A1dd4gbB3Fkl7u6mPogGfDycRMPNEdXG?= =?iso-8859-1?Q?7VNKpsB9plqdtwzp/tjKqcwN97waC/DPFeVe3RC29o0U1D9g/2nJwMFDlR?= =?iso-8859-1?Q?Oc4ywt899tgt5NZ7cjNuYZfvI6apx/4Y0nQ7ljZOTSldCbaDP2C1RxAk7T?= =?iso-8859-1?Q?w6BeSxu78aPhJ78GxxoczyTbxekozBdJ5JqTXzC7MA3fEkDMBqrEmzerXv?= =?iso-8859-1?Q?ZuHhuhkI3BM7GE3T2I5v7tUDEU/Urk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?= =?iso-8859-1?Q?JV6dOFLxOOFrPGbiRIFY68WcYm6mh9HANs+IB9azHaJN0lI6QDZwEZMuAd?= =?iso-8859-1?Q?1fwL2IoS22zOtQXalZ1+VXLv+S9lfVgtcIGGEuGnAOxysDggWIq2Wy7nRA?= =?iso-8859-1?Q?10uqjCyZx2K8KCxm12z807Y4NjHKieiCwkd8i+MSXHKDZZJHYJEUnFyHQ9?= =?iso-8859-1?Q?/PmpvWFirYxKQ+f0Xz1dBWTngDhHK2aOu0iaAty9UfRb6j4UqWoFj+hZ0V?= =?iso-8859-1?Q?FipsPVC6b4txg4JbvZjyuinhxRnUn5w0ZJtAj9dy/osLWgTAwzi86rr+jO?= =?iso-8859-1?Q?+sacU6hnYaCDfK6a4Y+Op0JtqGyn0OW1PBs4XcrQuMP24oVXYCaRlWlxnG?= =?iso-8859-1?Q?6t3YausxYiUTtzudeNGNBwuqpu6aq6NSxi0h8omhw8gCqbx6zTV/EmNZmp?= =?iso-8859-1?Q?j1NOcY0=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PN0P287MB1494.INDP287.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(10070799003)(366016)(4022899009)(376014)(38070700018)(13003099007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?fUtkMtE3zNXv9TOdBFnCU3LcpVDj/jV9sdsvDqN3O1QDl1sBnjJzszgJtU?= =?iso-8859-1?Q?Kqwt216brv8VAxYJLpiRGLJwxVD8ct3k8qJY3sXxr2xpXHxkAQ50kAROzj?= =?iso-8859-1?Q?MDsHhh88Eb+eriOxkSQ7Cb4fgJjU23qmA6LLEXh8JBPUB7ZxlVSbytt22g?= =?iso-8859-1?Q?xyBqv4uyk8U+zzOBIdT4hF5tRT5cxy800UF9BP/Pm0++mHf4dFeCBf18Ja?=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j2eiFJckmF/qegGsBICB3+W6GOglsOJbKmzt+xYpRTo?= =?iso-8859-1?Q?3Pyy4o3QmvsCHdzOXr9DJCv2O0crDOdqoW9YzBNg59lzm4fMQxQsCeqeWf?= =?iso-8859-1?Q?coQGbc4IKpbhmpHHrMOm3EdGk1rD9+b7BaIOO2k92Qip65S6OJn2Jxq3H+?= =?iso-8859-1?Q?SK2St402qMCTxOH6KewrIRDJ/ce8cCg+Lb3lo9bkRPWhiJdkP54N7CKqyA?= =?iso-8859-1?Q?9YAyA4E4Eq+1/rekU1bBTwehMwYp66Uofd1yr/jgZVzuRQV1Wsd6nXxQaU?= =?iso-8859-1?Q?gqv7mZzg+ihDvh4rsgl8uRioVi1GUMg72/qFZvbOIy3u6CSX122VlCVFuM?= =?iso-8859-1?Q?g5hbCXiPhj4oTnbB/PiWfwnuB1eS9/rhfRKNN0c6gFv3opqPW7SvLwobcQ?= =?iso-8859-1?Q?p6zmQaj51kD9w21WOlVS9kID3bvP97qUzHE3DCCU70W/Rh7pKWk9d9YPqT?= =?iso-8859-1?Q?g2VcK0kZkCmD+ZBlb2iKqlC67pxrnyO63luwjE3A+66/cOlHTAzOzlzu1B?= =?iso-8859-1?Q?LCfIdCh+1h4dasf0ygkBVcQbIi1ACV/kO4IyYxfTRmhHX0ZMZDzX4GE5yl?= =?iso-8859-1?Q?xIZ7/uwQUAzElK47GvAeJE/kXdL9cJLGtCs+emhbyCr8qRvSNAvTaJXzEE?= =?iso-8859-1?Q?jZm26cpuOZXPNzNaXpcEAFWWw=3D?= Content-ID: <7F3E15A8F1EB9E4BBCFEC2FD3279BFF6@INDP287.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: multicorewareinc.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PN0P287MB1494.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 1e8005b5-377d-4452-8139-08dd995a27ca X-MS-Exchange-CrossTenant-originalarrivaltime: 22 May 2025 17:57:44.9744 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: ffc5e88b-3fa2-4d69-a468-344b6b766e7d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2wZloOMLQbMkBT2ChEaZlSknWuM4K+aTekNob1++cVylPeBYTMo8JntWe/QTwA6P3Zfo664a1RBrvL/qJ3vlePGvBJU9PkTF+zVBtppnQQ1ikg1aQvZ6L5HbZDO8NiFSFmmwRC4ueNlBoZx8ZguyqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PNYP287MB4103 Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add scale_d3d11 filter 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 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 22-05-2025 20:55, Timo Rothenpieler wrote: > On 22/05/2025 15:20, Dash Santosh Sathyanarayanan wrote: >> This commit introduces a new hardware-accelerated video filter, = >> scale_d3d11, >> which performs scaling and format conversion using Direct3D 11. The = >> filter enables >> efficient GPU-based scaling and pixel format conversion (p010 to = >> nv12), reducing >> CPU overhead and latency in video pipelines. >> --- >> =A0 Changelog=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 |=A0=A0 1 + >> =A0 libavcodec/decode.c=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0 2 +- >> =A0 libavcodec/dxva2.c=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0 3 + >> =A0 libavfilter/Makefile=A0=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0 1 + >> =A0 libavfilter/allfilters.c=A0=A0=A0=A0=A0 |=A0=A0 1 + >> =A0 libavfilter/vf_scale_d3d11.c=A0 | 480 ++++++++++++++++++++++++++++++= ++++ >> =A0 libavutil/hwcontext_d3d11va.c |=A0 40 ++- >> =A0 7 files changed, 514 insertions(+), 14 deletions(-) >> =A0 create mode 100644 libavfilter/vf_scale_d3d11.c >> >> diff --git a/Changelog b/Changelog >> index 4217449438..68610a63d0 100644 >> --- a/Changelog >> +++ b/Changelog >> @@ -18,6 +18,7 @@ version : >> =A0 - APV encoding support through a libopenapv wrapper >> =A0 - VVC decoder supports all content of SCC (Screen Content Coding): >> =A0=A0=A0 IBC (Inter Block Copy), Palette Mode and ACT (Adaptive Color = >> Transform >> +- vf_scale_d3d11 filter > > Bit of a nit, this could at last say "Added". Oops, sorry. My bad. > >> =A0 =A0 =A0 version 7.1: >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c >> index c2b2dd6e3b..a796ae7930 100644 >> --- a/libavcodec/decode.c >> +++ b/libavcodec/decode.c >> @@ -1079,7 +1079,7 @@ int ff_decode_get_hw_frames_ctx(AVCodecContext = >> *avctx, >> =A0=A0=A0=A0=A0 if (frames_ctx->initial_pool_size) { >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 // We guarantee 4 base work surfaces. The fu= nction above = >> guarantees 1 >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 // (the absolute minimum), so add the missin= g count. >> -=A0=A0=A0=A0=A0=A0=A0 frames_ctx->initial_pool_size +=3D 3; >> +=A0=A0=A0=A0=A0=A0=A0 frames_ctx->initial_pool_size +=3D 33; > > This seems a bit extreme, and can potentially drastically increase = > VRAM usage of anything using d3d11va. In full hardware pipeline, when all surfaces are in use, we hit pool = exhaustion and 'static pool size exceeded' error occurs. Hence the = change. The increase in memory footprint was about ~100mb with this change. > >> =A0=A0=A0=A0=A0 } >> =A0 =A0=A0=A0=A0=A0 ret =3D av_hwframe_ctx_init(avctx->hw_frames_ctx); >> diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c >> index 22ecd5acaf..37dab6cd68 100644 >> --- a/libavcodec/dxva2.c >> +++ b/libavcodec/dxva2.c >> @@ -647,6 +647,9 @@ int ff_dxva2_common_frame_params(AVCodecContext = >> *avctx, >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 AVD3D11VAFramesContext *frames_hwctx =3D fra= mes_ctx->hwctx; >> =A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0 frames_hwctx->BindFlags |=3D D3D11_BIND_= DECODER; >> +=A0=A0=A0=A0=A0=A0=A0 if (frames_ctx->sw_format =3D=3D AV_PIX_FMT_NV12)= { >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 frames_hwctx->BindFlags |=3D D3D11_BI= ND_VIDEO_ENCODER; >> +=A0=A0=A0=A0=A0=A0=A0 } > > This change also seems a bit random here. Using NV12 does not = > automatically mean you'll encode with it. The encoder requires D3D11_BIND_VIDEO_ENCODER to be set in the input = surface, when sending the D3D11 surface directly to MF encoder. = Currently MF encoder supports only 8bit (NV12). Hence the change. If the = input is 10bit (P010), scale_d3d11 can be configured to output 8bit NV12 = frames. > > > Did not look at the rest yet. >> +=A0=A0=A0=A0=A0=A0=A0 return AVERROR_EXTERNAL; >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 ///< Set up output frame >> +=A0=A0=A0 ret =3D av_frame_copy_props(out, in); >> +=A0=A0=A0 if (ret < 0) { >> +=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Failed to copy frame p= roperties\n"); >> +=A0=A0=A0=A0=A0=A0=A0 videoContext->lpVtbl->Release(videoContext); >> +=A0=A0=A0=A0=A0=A0=A0 inputView->lpVtbl->Release(inputView); >> +=A0=A0=A0=A0=A0=A0=A0 av_frame_free(&in); >> +=A0=A0=A0=A0=A0=A0=A0 av_frame_free(&out); >> +=A0=A0=A0=A0=A0=A0=A0 return ret; >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 out->data[0] =3D (uint8_t *)output_texture; >> +=A0=A0=A0 out->data[1] =3D (uint8_t *)(intptr_t)0; >> +=A0=A0=A0 out->width =3D s->width; >> +=A0=A0=A0 out->height =3D s->height; >> +=A0=A0=A0 out->format =3D AV_PIX_FMT_D3D11; >> + >> +=A0=A0=A0 ///< Clean up resources >> +=A0=A0=A0 inputView->lpVtbl->Release(inputView); >> +=A0=A0=A0 videoContext->lpVtbl->Release(videoContext); >> +=A0=A0=A0 if (s->outputView) { >> + s->outputView->lpVtbl->Release(s->outputView); >> +=A0=A0=A0=A0=A0=A0=A0 s->outputView =3D NULL; >> +=A0=A0=A0 } >> +=A0=A0=A0 av_frame_free(&in); >> + >> +=A0=A0=A0 ///< Forward the frame >> +=A0=A0=A0 return ff_filter_frame(outlink, out); >> +} >> + >> +static int scale_d3d11_config_props(AVFilterLink *outlink) >> +{ >> +=A0=A0=A0 AVFilterContext *ctx =3D outlink->src; >> +=A0=A0=A0 ScaleD3D11Context *s =3D ctx->priv; >> +=A0=A0=A0 AVFilterLink *inlink =3D ctx->inputs[0]; >> +=A0=A0=A0 FilterLink *inl =3D ff_filter_link(inlink); >> +=A0=A0=A0 FilterLink *outl =3D ff_filter_link(outlink); >> +=A0=A0=A0 int ret; >> + >> +=A0=A0=A0 ///< Clean up any previous resources >> +=A0=A0=A0 release_d3d11_resources(s); >> + >> +=A0=A0=A0 ///< Evaluate output dimensions >> +=A0=A0=A0 ret =3D ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inl= ink, = >> outlink, &s->width, &s->height); >> +=A0=A0=A0 if (ret < 0) { >> +=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Failed to evaluate dim= ensions\n"); >> +=A0=A0=A0=A0=A0=A0=A0 return ret; >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 outlink->w =3D s->width; >> +=A0=A0=A0 outlink->h =3D s->height; >> + >> +=A0=A0=A0 ///< Validate input hw_frames_ctx >> +=A0=A0=A0 if (!inl->hw_frames_ctx) { >> +=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "No hw_frames_ctx avail= able on = >> input link\n"); >> +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(EINVAL); >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 ///< Propagate hw_frames_ctx to output >> +=A0=A0=A0 outl->hw_frames_ctx =3D av_buffer_ref(inl->hw_frames_ctx); >> +=A0=A0=A0 if (!outl->hw_frames_ctx) { >> +=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Failed to propagate hw= _frames_ctx = >> to output\n"); >> +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(ENOMEM); >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 ///< Initialize filter's hardware device context >> +=A0=A0=A0 if (!s->hw_device_ctx) { >> +=A0=A0=A0=A0=A0=A0=A0 AVHWFramesContext *in_frames_ctx =3D (AVHWFramesC= ontext = >> *)inl->hw_frames_ctx->data; >> +=A0=A0=A0=A0=A0=A0=A0 s->hw_device_ctx =3D av_buffer_ref(in_frames_ctx-= >device_ref); >> +=A0=A0=A0=A0=A0=A0=A0 if (!s->hw_device_ctx) { >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Failed to = initialize filter = >> hardware device context\n"); >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return AVERROR(ENOMEM); >> +=A0=A0=A0=A0=A0=A0=A0 } >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 ///< Get D3D11 device and context (but don't initialize = >> processor yet - done in filter_frame) >> +=A0=A0=A0 AVHWDeviceContext *hwctx =3D (AVHWDeviceContext = >> *)s->hw_device_ctx->data; >> +=A0=A0=A0 AVD3D11VADeviceContext *d3d11_hwctx =3D (AVD3D11VADeviceConte= xt = >> *)hwctx->hwctx; >> + >> +=A0=A0=A0 s->device =3D d3d11_hwctx->device; >> +=A0=A0=A0 s->context =3D d3d11_hwctx->device_context; >> + >> +=A0=A0=A0 if (!s->device || !s->context) { >> +=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Failed to get valid D3= D11 device = >> or context\n"); >> +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(EINVAL); >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 ///< Create new hardware frames context for output >> +=A0=A0=A0 AVHWFramesContext *in_frames_ctx =3D (AVHWFramesContext = >> *)inl->hw_frames_ctx->data; >> +=A0=A0=A0 s->hw_frames_ctx_out =3D av_hwframe_ctx_alloc(s->hw_device_ct= x); >> +=A0=A0=A0 if (!s->hw_frames_ctx_out) >> +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(ENOMEM); >> + >> +=A0=A0=A0 enum AVPixelFormat sw_format; >> +=A0=A0=A0 switch (s->output_format_opt) { >> +=A0=A0=A0=A0=A0=A0=A0 case OUTPUT_NV12: >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sw_format =3D AV_PIX_FMT_NV12; >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break; >> +=A0=A0=A0=A0=A0=A0=A0 case OUTPUT_P010: >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sw_format =3D AV_PIX_FMT_P010; >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break; >> +=A0=A0=A0=A0=A0=A0=A0 default: >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return AVERROR(EINVAL); >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 AVHWFramesContext *frames_ctx =3D (AVHWFramesContext = >> *)s->hw_frames_ctx_out->data; >> +=A0=A0=A0 frames_ctx->format =3D AV_PIX_FMT_D3D11; >> +=A0=A0=A0 frames_ctx->sw_format =3D sw_format; >> +=A0=A0=A0 frames_ctx->width =3D s->width; >> +=A0=A0=A0 frames_ctx->height =3D s->height; >> +=A0=A0=A0 frames_ctx->initial_pool_size =3D 30; ///< Adjust pool size a= s needed >> + >> +=A0=A0=A0 AVD3D11VAFramesContext *frames_hwctx =3D frames_ctx->hwctx; >> +=A0=A0=A0 frames_hwctx->MiscFlags =3D 0; >> +=A0=A0=A0 frames_hwctx->BindFlags =3D D3D11_BIND_RENDER_TARGET | = >> D3D11_BIND_VIDEO_ENCODER; >> + >> +=A0=A0=A0 ret =3D av_hwframe_ctx_init(s->hw_frames_ctx_out); >> +=A0=A0=A0 if (ret < 0) { >> +=A0=A0=A0=A0=A0=A0=A0 av_buffer_unref(&s->hw_frames_ctx_out); >> +=A0=A0=A0=A0=A0=A0=A0 return ret; >> +=A0=A0=A0 } >> + >> +=A0=A0=A0 outl->hw_frames_ctx =3D av_buffer_ref(s->hw_frames_ctx_out); >> +=A0=A0=A0 if (!outl->hw_frames_ctx) >> +=A0=A0=A0=A0=A0=A0=A0 return AVERROR(ENOMEM); >> + >> +=A0=A0=A0 av_log(ctx, AV_LOG_VERBOSE, "D3D11 scale config: %dx%d -> %dx= %d\n", >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 inlink->w, inlink->h, outlink->w, outlin= k->h); >> +=A0=A0=A0 return 0; >> +} >> + >> +static av_cold void scale_d3d11_uninit(AVFilterContext *ctx) { >> +=A0=A0=A0 ScaleD3D11Context *s =3D ctx->priv; >> + >> +=A0=A0=A0 ///< Release D3D11 resources >> +=A0=A0=A0 release_d3d11_resources(s); >> + >> +=A0=A0=A0 ///< Free the hardware device context reference >> +=A0=A0=A0 av_buffer_unref(&s->hw_frames_ctx_out); >> +=A0=A0=A0 av_buffer_unref(&s->hw_device_ctx); >> + >> +=A0=A0=A0 ///< Free option strings >> +=A0=A0=A0 av_freep(&s->w_expr); >> +=A0=A0=A0 av_freep(&s->h_expr); >> +} >> + >> +static const AVFilterPad scale_d3d11_inputs[] =3D { >> +=A0=A0=A0 { >> +=A0=A0=A0=A0=A0=A0=A0 .name=A0=A0=A0=A0=A0=A0=A0=A0 =3D "default", >> +=A0=A0=A0=A0=A0=A0=A0 .type=A0=A0=A0=A0=A0=A0=A0=A0 =3D AVMEDIA_TYPE_VI= DEO, >> +=A0=A0=A0=A0=A0=A0=A0 .filter_frame =3D scale_d3d11_filter_frame, >> +=A0=A0=A0 }, >> +}; >> + >> +static const AVFilterPad scale_d3d11_outputs[] =3D { >> +=A0=A0=A0 { >> +=A0=A0=A0=A0=A0=A0=A0 .name=A0=A0=A0=A0=A0=A0=A0=A0 =3D "default", >> +=A0=A0=A0=A0=A0=A0=A0 .type=A0=A0=A0=A0=A0=A0=A0=A0 =3D AVMEDIA_TYPE_VI= DEO, >> +=A0=A0=A0=A0=A0=A0=A0 .config_props =3D scale_d3d11_config_props, >> +=A0=A0=A0 }, >> +}; >> + >> +#define OFFSET(x) offsetof(ScaleD3D11Context, x) >> +#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM) >> + >> +static const AVOption scale_d3d11_options[] =3D { >> +=A0=A0=A0 { "width",=A0 "Output video width",=A0 OFFSET(w_expr), = >> AV_OPT_TYPE_STRING, {.str =3D "iw"}, .flags =3D FLAGS }, >> +=A0=A0=A0 { "height", "Output video height", OFFSET(h_expr), = >> AV_OPT_TYPE_STRING, {.str =3D "ih"}, .flags =3D FLAGS }, >> +=A0=A0=A0 { "output_fmt", "Output format", OFFSET(output_format_opt), = >> AV_OPT_TYPE_INT, {.i64 =3D OUTPUT_NV12}, 0, OUTPUT_P010, FLAGS, "fmt" }, >> +=A0=A0=A0 { "nv12", "NV12 format", 0, AV_OPT_TYPE_CONST, {.i64 =3D = >> OUTPUT_NV12}, 0, 0, FLAGS, "fmt" }, >> +=A0=A0=A0 { "p010", "P010 format", 0, AV_OPT_TYPE_CONST, {.i64 =3D = >> OUTPUT_P010}, 0, 0, FLAGS, "fmt" }, >> +=A0=A0=A0 { NULL } >> +}; >> + >> +AVFILTER_DEFINE_CLASS(scale_d3d11); >> + >> +const FFFilter ff_vf_scale_d3d11 =3D { >> +=A0=A0=A0 .p.name=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D "scale_d3d11", >> +=A0=A0=A0 .p.description=A0=A0=A0 =3D NULL_IF_CONFIG_SMALL("Scale video= using = >> Direct3D11"), >> +=A0=A0=A0 .priv_size=A0=A0=A0=A0=A0=A0=A0 =3D sizeof(ScaleD3D11Context), >> +=A0=A0=A0 .p.priv_class=A0=A0=A0=A0 =3D &scale_d3d11_class, >> +=A0=A0=A0 .init=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D scale_d3d11_ini= t, >> +=A0=A0=A0 .uninit=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D scale_d3d11_uninit, >> +=A0=A0=A0 FILTER_INPUTS(scale_d3d11_inputs), >> +=A0=A0=A0 FILTER_OUTPUTS(scale_d3d11_outputs), >> +=A0=A0=A0 FILTER_SINGLE_PIXFMT(AV_PIX_FMT_D3D11), >> +=A0=A0=A0 .p.flags=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D AVFILTER_FLAG_HWDEVIC= E, >> +=A0=A0=A0 .flags_internal=A0=A0 =3D FF_FILTER_FLAG_HWFRAME_AWARE, >> +}; >> \ No newline at end of file >> diff --git a/libavutil/hwcontext_d3d11va.c = >> b/libavutil/hwcontext_d3d11va.c >> index 1a047ce57b..36694896e4 100644 >> --- a/libavutil/hwcontext_d3d11va.c >> +++ b/libavutil/hwcontext_d3d11va.c >> @@ -82,6 +82,8 @@ typedef struct D3D11VAFramesContext { >> =A0 =A0=A0=A0=A0=A0 int nb_surfaces; >> =A0=A0=A0=A0=A0 int nb_surfaces_used; >> +=A0=A0=A0 int retries; >> +=A0=A0=A0 int max_retries; >> =A0 =A0=A0=A0=A0=A0 DXGI_FORMAT format; >> =A0 @@ -258,7 +260,9 @@ static AVBufferRef *d3d11va_pool_alloc(void = >> *opaque, size_t size) >> =A0=A0=A0=A0=A0 ID3D11Texture2D_GetDesc(hwctx->texture, &texDesc); >> =A0 =A0=A0=A0=A0=A0 if (s->nb_surfaces_used >=3D texDesc.ArraySize) { >> -=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Static surface pool si= ze = >> exceeded.\n"); >> +=A0=A0=A0=A0=A0=A0=A0 if (s->retries >=3D s->max_retries) { >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 av_log(ctx, AV_LOG_ERROR, "Static sur= face pool size = >> exceeded.\n"); >> +=A0=A0=A0=A0=A0=A0=A0 } >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 return NULL; >> =A0=A0=A0=A0=A0 } >> =A0 @@ -339,20 +343,30 @@ static int = >> d3d11va_frames_init(AVHWFramesContext *ctx) >> =A0 static int d3d11va_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) >> =A0 { >> =A0=A0=A0=A0=A0 AVD3D11FrameDescriptor *desc; >> +=A0=A0=A0 D3D11VAFramesContext=A0=A0=A0=A0=A0=A0 *s =3D ctx->hwctx; >> +=A0=A0=A0 s->retries =3D 0; >> +=A0=A0=A0 s->max_retries =3D 50; >> + >> +=A0=A0=A0 while (s->retries < s->max_retries) { >> + >> +=A0=A0=A0=A0=A0=A0=A0 frame->buf[0] =3D av_buffer_pool_get(ctx->pool); >> +=A0=A0=A0=A0=A0=A0=A0 if (frame->buf[0]) { >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 desc =3D (AVD3D11FrameDescriptor *)fr= ame->buf[0]->data; >> + >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 frame->data[0] =3D (uint8_t *)desc->t= exture; >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 frame->data[1] =3D (uint8_t *)desc->i= ndex; >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 frame->format=A0 =3D AV_PIX_FMT_D3D11; >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 frame->width=A0=A0 =3D ctx->width; >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 frame->height=A0 =3D ctx->height; >> + >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0; >> +=A0=A0=A0=A0=A0=A0=A0 } >> =A0 -=A0=A0=A0 frame->buf[0] =3D av_buffer_pool_get(ctx->pool); >> -=A0=A0=A0 if (!frame->buf[0]) >> -=A0=A0=A0=A0=A0=A0=A0 return AVERROR(ENOMEM); >> - >> -=A0=A0=A0 desc =3D (AVD3D11FrameDescriptor *)frame->buf[0]->data; >> - >> -=A0=A0=A0 frame->data[0] =3D (uint8_t *)desc->texture; >> -=A0=A0=A0 frame->data[1] =3D (uint8_t *)desc->index; >> -=A0=A0=A0 frame->format=A0 =3D AV_PIX_FMT_D3D11; >> -=A0=A0=A0 frame->width=A0=A0 =3D ctx->width; >> -=A0=A0=A0 frame->height=A0 =3D ctx->height; >> +=A0=A0=A0=A0=A0=A0=A0 av_usleep(1000); >> +=A0=A0=A0=A0=A0=A0=A0 s->retries++; >> +=A0=A0=A0 } >> =A0 -=A0=A0=A0 return 0; >> +=A0=A0=A0 return AVERROR(ENOMEM); >> =A0 } >> =A0 =A0 static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, >> >> >> _______________________________________________ >> 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". > > _______________________________________________ > 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". _______________________________________________ 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".