PR #25150 opened by JuliusBairaktaris URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25150 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25150.patch
Without `engine_type`, frc_amf runs AMFFRC's default DX12 engine on a DX11 context. The interpolated frames come back as DX12 surfaces, and the filter is about three times slower. - `avfilter/vf_frc_amf: use the DX11 engine on a DX11 device` (with the filters.texi default) Not covered: d3d11va devices at feature level 11_0, which hwcontext_d3d11va creates; they keep the default because the DX11 engine fails Init() on them. 1080p H.264 software input, 600 output frames, median of 3: 6.28 s before, 2.00 s after, with identical framemd5. d3d11va on a feature level 11_1 device went from 2.11 s to 1.94 s. Tested on Windows 11, RX 9070 XT, driver 32.0.31041.1004. Written with Claude Opus 5.5 in Claude Code; `Assisted-by` trailer on the commit. >From ed1329ce6b750f468d19fc7592f35b9a77b16434 Mon Sep 17 00:00:00 2001 From: Julius Bairaktaris <[email protected]> Date: Mon, 28 Sep 2026 11:38:02 +0200 Subject: [PATCH] avfilter/vf_frc_amf: use the DX11 engine on a DX11 device Without engine_type, frc_amf uses the runtime's default DX12 engine even on a DX11 AMF context. The interpolated frames then come back as DX12 surfaces, and the filter runs about three times slower. Select FRC_ENGINE_DX11 on a DX11 context whose device has feature level 11_1 or higher, and keep an explicit engine_type. The DX11 engine fails Init() on 11_0, which is what hwcontext_d3d11va creates, so those devices keep the default. Assisted-by: Claude Opus 5.5 Signed-off-by: Julius Bairaktaris <[email protected]> --- doc/filters.texi | 6 +++++- libavfilter/vf_frc_amf.c | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 7ab0cfaab7..ed487f6d97 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -14952,9 +14952,13 @@ Specify the engine used to run shaders. DirectX 11. @item dx12 -DirectX 12 (Default value). +DirectX 12. @end table +By default DirectX 11 is used when the AMF device runs on a DirectX 11 +device with feature level 11_1 or higher, which the DirectX 11 engine +requires, and the AMF runtime default (DirectX 12) otherwise. + @item enable Boolean value: enable/disable FRC. Dynamic value, can be altered at a runtime without re-initializing the filter. (Default value: enabled). diff --git a/libavfilter/vf_frc_amf.c b/libavfilter/vf_frc_amf.c index c7ef58b429..0cd90e42c7 100644 --- a/libavfilter/vf_frc_amf.c +++ b/libavfilter/vf_frc_amf.c @@ -95,7 +95,7 @@ static int amf_frc_filter_config_output(AVFilterLink *outlink) AMFFilterContext *amf_ctx = &frc_ctx->common; AVAMFDeviceContext *device_ctx = NULL; - int err; + int err, engine_type; AMF_RESULT res; enum AVPixelFormat in_format; @@ -122,8 +122,16 @@ static int amf_frc_filter_config_output(AVFilterLink *outlink) // Possible bug: FRC must be initialized enabled to be toggleable on the fly after init. AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_MODE, FRC_x2_PRESENT); - if (frc_ctx->engine_type != -1) - AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_ENGINE_TYPE, frc_ctx->engine_type); + engine_type = frc_ctx->engine_type; +#if CONFIG_D3D11VA + if (engine_type == -1 && av_amf_get_memory_type(device_ctx) == AMF_MEMORY_DX11) { + ID3D11Device *d3d11 = AMF_IFACE_CALL(device_ctx->context, GetDX11Device, AMF_DX11_0); + if (d3d11 && d3d11->lpVtbl->GetFeatureLevel(d3d11) >= D3D_FEATURE_LEVEL_11_1) + engine_type = FRC_ENGINE_DX11; + } +#endif + if (engine_type != -1) + AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_ENGINE_TYPE, engine_type); AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_ENABLE_FALLBACK, frc_ctx->fallback); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
