PR #25460 opened by JuliusBairaktaris
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25460
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25460.patch

With a D3D11VA or DXVA2 `hw_device_ctx`, the AMF filters offer only D3D11 or 
DXVA2 frames on their input, so the AMF surfaces another AMF filter outputs 
cannot be negotiated:

```
ffmpeg -init_hw_device d3d11va=dx:,SHADER=1 -hwaccel d3d11va -hwaccel_device dx 
-hwaccel_output_format d3d11 -i in.h264 -vf 
vqe_amf,frc_amf,hwdownload,format=nv12 -f null -
Impossible to convert between the formats supported by the filter 
'Parsed_vqe_amf_0' and the filter 'auto_scale_0'
```

ffmpeg passes its only hardware device to the filters, and applications such as 
mpv give their D3D11VA device to every filter, so on those devices the AMF 
filters cannot be chained at all. The input path already takes AMF surfaces, 
and the filter derives its AMF device from the input frames' device, so both 
filters run on the same AMF device. This adds `AV_PIX_FMT_AMF_SURFACE` to both 
input lists.

Tested on Windows 11, RX 9070 XT, driver 32.0.32015.7029:
- `vqe_amf,frc_amf` and `vpp_amf,sr_amf` on d3d11va input, and 
`vqe_amf,frc_amf` on dxva2 input, failed before and now work.
- Their output is identical to the same chain with a download and upload 
between the filters (for dxva2, vqe_amf's output uploaded to D3D11 for frc_amf, 
since DXVA2 has no upload).
- framemd5 of vqe_amf, vpp_amf and frc_amf alone is unchanged.

#24365 changes the same function, but only the branch without a device, so the 
two do not conflict.

Written with Claude Opus 5.5 in Claude Code; `Assisted-by` trailer on the 
commit.



>From bbf15d5e9f61c52797501c99db17d62919381b37 Mon Sep 17 00:00:00 2001
From: Julius Bairaktaris <[email protected]>
Date: Sun, 25 Oct 2026 22:43:32 +0100
Subject: [PATCH] avfilter/amf: accept AMF surfaces on a D3D11VA or DXVA2
 device

With a D3D11VA or DXVA2 hw_device_ctx, the AMF filters offer only D3D11
or DXVA2 frames on their input, so the AMF surfaces that another AMF
filter outputs cannot be negotiated, and a chain such as
vqe_amf,frc_amf fails with "Impossible to convert between the formats".
ffmpeg passes its only hardware device to the filters, and applications
such as mpv give their D3D11VA device to every filter, so on those
devices the AMF filters cannot be chained at all.

The input path already takes AMF surfaces, and the filter derives its
AMF device from the input frames' device, so both filters run on the
same AMF device. Add AV_PIX_FMT_AMF_SURFACE to both input lists.

Tested on Windows 11, RX 9070 XT, driver 32.0.32015.7029:
vqe_amf,frc_amf and vpp_amf,sr_amf on d3d11va input and vqe_amf,frc_amf
on dxva2 input, which failed before, now work, and their output is
identical to the same chain with a download and upload between the
filters. framemd5 of vqe_amf, vpp_amf and frc_amf alone is unchanged.

Assisted-by: Claude Opus 5.5
Signed-off-by: Julius Bairaktaris <[email protected]>
---
 libavfilter/vf_amf_common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/vf_amf_common.c b/libavfilter/vf_amf_common.c
index e1d0b42ee37..84fcb588586 100644
--- a/libavfilter/vf_amf_common.c
+++ b/libavfilter/vf_amf_common.c
@@ -403,6 +403,7 @@ int amf_setup_input_output_formats(AVFilterContext *avctx,
             {
                 static const enum AVPixelFormat pix_fmts_d3d11[] = {
                     AV_PIX_FMT_D3D11,
+                    AV_PIX_FMT_AMF_SURFACE,
                     AV_PIX_FMT_NONE,
                 };
                 input_pix_fmts  = pix_fmts_d3d11;
@@ -414,6 +415,7 @@ int amf_setup_input_output_formats(AVFilterContext *avctx,
             {
                 static const enum AVPixelFormat pix_fmts_dxva2[] = {
                     AV_PIX_FMT_DXVA2_VLD,
+                    AV_PIX_FMT_AMF_SURFACE,
                     AV_PIX_FMT_NONE,
                 };
                 input_pix_fmts  = pix_fmts_dxva2;
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to