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

The AMF decoders advertise the hw_frames_ctx method but never call 
ff_get_format(). A caller that uses that method gets system memory frames from 
a private device.

- `avcodec/amfdec: do not advertise the hw_frames_ctx method`

Not covered: the Linux AMF runtime and other GPU generations.

mpv `--hwdec=amf` on H.264, HEVC, HEVC Main10, VP9 and AV1: the decoder output 
changes from `nv12` to `amf[nv12]` / `amf[p010]`. 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 9d1b4831c17df04091ff1a33c62590241f653ee5 Mon Sep 17 00:00:00 2001
From: Julius Bairaktaris <[email protected]>
Date: Mon, 28 Sep 2026 01:55:31 +0200
Subject: [PATCH] avcodec/amfdec: do not advertise the hw_frames_ctx method

The AMF decoders advertise AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX but
never call ff_get_format(), so a caller using that method never gets to
set hw_frames_ctx. The decoder then creates a private device and returns
system memory frames. Advertise only
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, which is what the code
implements. ffmpeg -hwaccel amf already uses the device method and is
unaffected.

Assisted-by: Claude Opus 5.5
Signed-off-by: Julius Bairaktaris <[email protected]>
---
 libavcodec/amfdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/amfdec.c b/libavcodec/amfdec.c
index 00a17360f5..9db5663aff 100644
--- a/libavcodec/amfdec.c
+++ b/libavcodec/amfdec.c
@@ -46,8 +46,7 @@ static const AVCodecHWConfigInternal *const amf_hw_configs[] 
= {
     &(const AVCodecHWConfigInternal) {
         .public = {
             .pix_fmt     = AV_PIX_FMT_AMF_SURFACE,
-            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
-                           AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
+            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
             .device_type = AV_HWDEVICE_TYPE_AMF,
         },
         .hwaccel = NULL,
-- 
2.54.0

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

Reply via email to