This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 29b5a4f52d8dab4c2fae963582d84bc091c78f3f Author: Julius Bairaktaris <[email protected]> AuthorDate: Sun Aug 30 15:34:30 2026 +0200 Commit: ArazIusubov <[email protected]> CommitDate: Wed Sep 16 22:05:28 2026 +0000 avfilter/amf: pin the output format for components that cannot convert amf_init_filter_config() falls back to outlink->format for the output frames context when no format is requested. That is right for vpp_amf, whose converter is initialised from hwframes_out->sw_format and therefore makes the frames context true. The HQ scaler, the VQ enhancer and the frame rate converter have no output format property at all and emit the format they were initialised with, so whatever the output link happened to negotiate was attached to a surface that never had that layout. ffmpeg -init_hw_device amf -f lavfi -i testsrc2 \ -vf "format=nv12,hwupload,sr_amf=w=2560:h=1440,format=rgba" is enough to reach it: the link negotiates RGBA, the scaler emits NV12, and hwdownload then reads a two-plane surface as one packed plane. Take the input software format as the output format for those three filters. sr_amf keeps its explicit format= handling: a packed RGB target is still selectable for the algorithms that convert, and anything the scaler cannot emit is rejected rather than silently mislabelled. amf_inlink_sw_format() moves to vf_amf_common.c so all three can use it. sr_amf compares against the format the user asked for rather than the one a previous configuration resolved, so reconfiguring the graph with a different input format does not reject itself. Tested on Windows 11, RX 9070 XT, driver 32.0.31041.1004: for every sr_amf algorithm and for vqe_amf and frc_amf, with NV12, P010 and RGBA input, hwdownload now accepts exactly the format the component emits and rejects every other, where before the frames context could claim any format the output link negotiated. Assisted-by: Claude Opus 5 Signed-off-by: Julius Bairaktaris <[email protected]> --- libavfilter/vf_amf_common.c | 10 ++++++++++ libavfilter/vf_amf_common.h | 2 ++ libavfilter/vf_frc_amf.c | 2 ++ libavfilter/vf_sr_amf.c | 30 +++++++++++------------------- libavfilter/vf_vqe_amf.c | 2 ++ 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/libavfilter/vf_amf_common.c b/libavfilter/vf_amf_common.c index 0fbefbfbc0..9b80a7cd1b 100644 --- a/libavfilter/vf_amf_common.c +++ b/libavfilter/vf_amf_common.c @@ -53,6 +53,7 @@ int amf_filter_init(AVFilterContext *avctx) return AVERROR(EINVAL); } } + ctx->format_opt = ctx->format; return 0; } @@ -300,6 +301,15 @@ int amf_copy_surface(AVFilterContext *avctx, const AVFrame *frame, return 0; } +enum AVPixelFormat amf_inlink_sw_format(AVFilterLink *inlink) +{ + FilterLink *inl = ff_filter_link(inlink); + + if (inl->hw_frames_ctx) + return ((AVHWFramesContext*)inl->hw_frames_ctx->data)->sw_format; + return inlink->format; +} + int amf_init_filter_config(AVFilterLink *outlink, enum AVPixelFormat *in_format) { int err; diff --git a/libavfilter/vf_amf_common.h b/libavfilter/vf_amf_common.h index 7879403d06..0d323dd480 100644 --- a/libavfilter/vf_amf_common.h +++ b/libavfilter/vf_amf_common.h @@ -31,6 +31,7 @@ typedef struct AMFFilterContext { int width, height; enum AVPixelFormat format; + enum AVPixelFormat format_opt; int scale_type; int in_color_range; int in_primaries; @@ -71,6 +72,7 @@ typedef struct AMFFilterContext { int amf_filter_init(AVFilterContext *avctx); void amf_filter_uninit(AVFilterContext *avctx); +enum AVPixelFormat amf_inlink_sw_format(AVFilterLink *inlink); int amf_init_filter_config(AVFilterLink *outlink, enum AVPixelFormat *in_format); int amf_copy_surface(AVFilterContext *avctx, const AVFrame *frame, AMFSurface* surface); void amf_free_amfsurface(void *opaque, uint8_t *data); diff --git a/libavfilter/vf_frc_amf.c b/libavfilter/vf_frc_amf.c index 5b93f65ad1..1a84a2ee4f 100644 --- a/libavfilter/vf_frc_amf.c +++ b/libavfilter/vf_frc_amf.c @@ -110,6 +110,8 @@ static int amf_frc_filter_config_output(AVFilterLink *outlink) AMF_RESULT res; enum AVPixelFormat in_format; + amf_ctx->format = amf_inlink_sw_format(inlink); + err = amf_init_filter_config(outlink, &in_format); if (err < 0) return err; diff --git a/libavfilter/vf_sr_amf.c b/libavfilter/vf_sr_amf.c index d9ed1dcd8a..fcaf2c5d2a 100644 --- a/libavfilter/vf_sr_amf.c +++ b/libavfilter/vf_sr_amf.c @@ -53,15 +53,6 @@ #endif -static enum AVPixelFormat amf_inlink_sw_format(AVFilterLink *inlink) -{ - FilterLink *inl = ff_filter_link(inlink); - - if (inl->hw_frames_ctx) - return ((AVHWFramesContext*)inl->hw_frames_ctx->data)->sw_format; - return inlink->format; -} - static int amf_hq_scaler_needs_packed_rgb(int algorithm) { return algorithm == AMF_HQ_SCALER_ALGORITHM_VIDEOSR1_1 || @@ -140,21 +131,22 @@ static int amf_filter_config_output(AVFilterLink *outlink) needs_conversion = amf_hq_scaler_needs_packed_rgb(ctx->algorithm) && (in_sw_format == AV_PIX_FMT_NV12 || in_sw_format == AV_PIX_FMT_P010); - if (amf_hq_scaler_needs_packed_rgb(ctx->algorithm)) { - if (!needs_conversion) { - if (ctx->format != AV_PIX_FMT_NONE && ctx->format != in_sw_format) { - av_log(avctx, AV_LOG_ERROR, "The HQ scaler does not convert formats, format must be same or %s.\n", - av_get_pix_fmt_name(in_sw_format)); - return AVERROR(EINVAL); - } - ctx->format = in_sw_format; - } else if (ctx->format == AV_PIX_FMT_NONE) { + ctx->format = ctx->format_opt; + + if (needs_conversion) { + if (ctx->format == AV_PIX_FMT_NONE) ctx->format = in_sw_format == AV_PIX_FMT_P010 ? AV_PIX_FMT_X2BGR10 : AV_PIX_FMT_RGBA; - } else if (!amf_is_packed_rgb(ctx->format)) { + else if (!amf_is_packed_rgb(ctx->format)) { av_log(avctx, AV_LOG_ERROR, "This algorithm only outputs packed RGB, format=%s is not supported.\n", av_get_pix_fmt_name(ctx->format)); return AVERROR(EINVAL); } + } else if (ctx->format != AV_PIX_FMT_NONE && ctx->format != in_sw_format) { + av_log(avctx, AV_LOG_ERROR, "The HQ scaler does not convert formats, format must be same or %s.\n", + av_get_pix_fmt_name(in_sw_format)); + return AVERROR(EINVAL); + } else { + ctx->format = in_sw_format; } err = amf_init_filter_config(outlink, &in_format); diff --git a/libavfilter/vf_vqe_amf.c b/libavfilter/vf_vqe_amf.c index d53703ee58..901cfbdb5e 100644 --- a/libavfilter/vf_vqe_amf.c +++ b/libavfilter/vf_vqe_amf.c @@ -102,6 +102,8 @@ static int amf_vqe_filter_config_output(AVFilterLink *outlink) AMF_RESULT res; enum AVPixelFormat in_format; + amf_ctx->format = amf_inlink_sw_format(inlink); + err = amf_init_filter_config(outlink, &in_format); if (err < 0) return err; -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
