From c7cf091d673b8a3322f42624ea5151bb8bd4fd8e Mon Sep 17 00:00:00 2001 From: softworkz Date: Wed, 12 Aug 2026 02:13:03 +0200 Subject: [PATCH] avfilter/hwmap: Set default BindFlags for reverse hw mapping to d3d11 When reverse mapping, hwmap creates a new hw frames context with default parameters. In case of d3d11, the default for BindFlags is 0, for which fixed-size pool allocation fails and for which textures are hardly usable for anything in terms of video acceleration. While the author would have preferred a solution in hwcontext_d3d11va, the discussion ended up favoring this way. See here: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24046 Signed-off-by: softworkz --- libavfilter/vf_hwmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index 5d37e1551f..1193ac8adc 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -22,6 +22,10 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#if CONFIG_D3D11VA +#include "libavutil/hwcontext_d3d11va.h" +#endif + #include "avfilter.h" #include "filters.h" #include "formats.h" @@ -151,6 +155,12 @@ static int hwmap_config_output(AVFilterLink *outlink) if (avctx->extra_hw_frames >= 0) frames->initial_pool_size = 2 + avctx->extra_hw_frames; +#if CONFIG_D3D11VA + if (frames->format == AV_PIX_FMT_D3D11) { + AVD3D11VAFramesContext *frames_d3d11 = frames->hwctx; + frames_d3d11->BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE; + } +#endif err = av_hwframe_ctx_init(ctx->hwframes_ref); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to initialise "