This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new d43b1efd2e avfilter/vf_amf_common: fix component Init() format with 
hwaccel input frames
d43b1efd2e is described below

commit d43b1efd2e948f44cfac91f7a4325a3d927d6718
Author:     Julius Bairaktaris <[email protected]>
AuthorDate: Thu Jul 23 01:18:23 2026 +0200
Commit:     ArazIusubov <[email protected]>
CommitDate: Wed Jul 29 08:52:27 2026 +0000

    avfilter/vf_amf_common: fix component Init() format with hwaccel input 
frames
    
    amf_init_filter_config() returned the hardware pixel format (e.g.
    AV_PIX_FMT_D3D11) as in_format when the input link carries D3D11VA or
    DXVA2 hw frames. av_av_to_amf_format() maps hw formats to
    AMF_SURFACE_UNKNOWN, so every AMF filter failed its component Init()
    with AMF_INVALID_ARG (VQEnhancer, FRC) or AMF_NOT_SUPPORTED
    (Converter, HQScaler). Return the underlying software format instead,
    which is already validated against AMF a few lines above. Apply the
    same mapping to the default output sw format, which otherwise ends up
    as the hw pixel format in hwframes_out->sw_format when the output link
    uses a hwaccel format.
    
    Fixes e.g.:
      ffmpeg -hwaccel d3d11va -hwaccel_output_format d3d11 -i in.mp4          
-vf frc_amf -c:v hevc_amf out.mp4
    
    Note: with D3D11VA input, the compute-based components (VQEnhancer,
    HQScaler, VideoConverter) additionally require decode textures created
    with D3D11_BIND_SHADER_RESOURCE, e.g.:
      -init_hw_device d3d11va=dx11:,SHADER=1 -hwaccel_device dx11
    FRC and DXVA2 input work with default decode textures.
---
 libavfilter/vf_amf_common.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_amf_common.c b/libavfilter/vf_amf_common.c
index e18c858eda..40c6fbceea 100644
--- a/libavfilter/vf_amf_common.c
+++ b/libavfilter/vf_amf_common.c
@@ -24,6 +24,7 @@
 #include "formats.h"
 #include "libavutil/mem.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/pixdesc.h"
 
 #include "AMF/components/VideoDecoderUVD.h"
 #include "libavutil/hwcontext_amf.h"
@@ -333,8 +334,9 @@ int amf_init_filter_config(AVFilterLink *outlink, enum 
AVPixelFormat *in_format)
         AMF_RETURN_IF_FALSE(avctx, res == 0, res, "Failed to create  hardware 
device context (AMF) : %s\n", av_err2str(res));
 
     }
-    if(out_sw_format == AV_PIX_FMT_NONE){
-        if(outlink->format == AV_PIX_FMT_AMF_SURFACE)
+    if (out_sw_format == AV_PIX_FMT_NONE) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
+        if (desc && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
             out_sw_format = in_sw_format;
         else
             out_sw_format = outlink->format;
@@ -351,11 +353,10 @@ int amf_init_filter_config(AVFilterLink *outlink, enum 
AVPixelFormat *in_format)
     hwframes_out->format    = AV_PIX_FMT_AMF_SURFACE;
     hwframes_out->sw_format = out_sw_format;
 
-    if (inlink->format == AV_PIX_FMT_AMF_SURFACE) {
-        *in_format = in_sw_format;
-    } else {
-        *in_format = inlink->format;
-    }
+    // in_sw_format is inlink->format for software input and the underlying
+    // sw_format for any hw frames input (AMF, D3D11, DXVA2); the component
+    // must always be initialized with a software surface format.
+    *in_format = in_sw_format;
     outlink->w = ctx->width;
     outlink->h = ctx->height;
 

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

Reply via email to