This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 25055dfba69847ba8bae60b7288f91628c73df43 Author: Julius Bairaktaris <[email protected]> AuthorDate: Mon Aug 31 16:07:36 2026 +0200 Commit: ArazIusubov <[email protected]> CommitDate: Wed Sep 16 22:05:28 2026 +0000 avfilter/vf_sr_amf: let format= choose the packed format the scaler runs on For point and sr1-1 the input link offered all four packed RGB formats regardless of format=, so a software producer was converted to whichever one libavfilter picked, RGBA for NV12 and X2BGR10 for P010. The input was then already packed, no GPU conversion was set up, and a different explicit target was rejected as a format the scaler cannot produce: ffmpeg -f lavfi -i testsrc2,format=nv12 \ -vf sr_amf=w=2560:h=1440:algorithm=point:format=bgra ... failed with "The HQ scaler does not convert formats" for a format the documentation advertises. Offer only the requested format on the input link when format= names one the filter accepts, next to the hardware formats, so libavfilter converts software input to that format directly. The hardware path reaches the same target through the GPU converter, which now also runs when a hardware surface is packed RGB but not the requested one, instead of being limited to NV12 and P010 sources. Tested on Windows 11, RX 9070 XT, driver 32.0.31041.1004: software and AMF surface NV12 and P010 input crossed with format=rgba, bgra and x2bgr10le, and hardware input for rgbaf16le, all produce a frame matching the source. rgbaf16le from software input stays unreachable because libswscale has no conversion to it, from any format. Assisted-by: Claude Opus 5 Signed-off-by: Julius Bairaktaris <[email protected]> --- doc/filters.texi | 10 +++++++--- libavfilter/vf_sr_amf.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 9c00ffeca8..070df58779 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -23300,9 +23300,13 @@ pixel format is used. The @code{point} and @code{sr1-1} algorithms emit the packed RGB format the scaler receives, so for them this option must name one of @code{rgba}, -@code{bgra}, @code{x2bgr10le} or @code{rgbaf16le}. When the input is converted -automatically, @code{x2bgr10le} is selected for @code{p010} input and -@code{rgba} otherwise, and the result is tagged as full range RGB. +@code{bgra}, @code{x2bgr10le} or @code{rgbaf16le}. A named format also decides +what software input is converted to, and what a hardware surface in another +format is converted to on the GPU. Without it, @code{x2bgr10le} is selected for +@code{p010} input and @code{rgba} for other non-RGB input, and the result is +tagged as full range RGB. libswscale cannot convert other software formats to +@code{rgbaf16le}; use software input already in that format or a hardware +input for GPU conversion. @item keep-ratio Force the scaler to keep the aspect ratio of the input image when the output size has a different aspect ratio. diff --git a/libavfilter/vf_sr_amf.c b/libavfilter/vf_sr_amf.c index cfde4886b1..8ecfcbb1fe 100644 --- a/libavfilter/vf_sr_amf.c +++ b/libavfilter/vf_sr_amf.c @@ -102,6 +102,14 @@ static int amf_filter_query_formats(AVFilterContext *avctx) AV_PIX_FMT_DXVA2_VLD, AV_PIX_FMT_NONE, }; + enum AVPixelFormat pix_fmts_requested[] = { + AV_PIX_FMT_NONE, + AV_PIX_FMT_AMF_SURFACE, + AV_PIX_FMT_D3D11, + AV_PIX_FMT_DXVA2_VLD, + AV_PIX_FMT_NONE, + }; + int i; if (amf_hq_scaler_needs_packed_rgb(ctx->algorithm)) { input_pix_fmts = pix_fmts_packed_rgb; @@ -111,6 +119,17 @@ static int amf_filter_query_formats(AVFilterContext *avctx) output_pix_fmts = output_pix_fmts_default; } + if (ctx->format_opt != AV_PIX_FMT_NONE) { + for (i = 0; input_pix_fmts[i] != AV_PIX_FMT_NONE; i++) { + if (input_pix_fmts[i] == ctx->format_opt) { + pix_fmts_requested[0] = ctx->format_opt; + input_pix_fmts = pix_fmts_requested; + output_pix_fmts = pix_fmts_requested; + break; + } + } + } + return amf_setup_input_output_formats(avctx, input_pix_fmts, output_pix_fmts); } @@ -128,25 +147,27 @@ static int amf_filter_config_output(AVFilterLink *outlink) int needs_conversion; in_sw_format = amf_inlink_sw_format(inlink); - needs_conversion = amf_hq_scaler_needs_packed_rgb(ctx->algorithm) && - (in_sw_format == AV_PIX_FMT_NV12 || in_sw_format == AV_PIX_FMT_P010); - 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)) { + if (amf_hq_scaler_needs_packed_rgb(ctx->algorithm)) { + if (ctx->format == AV_PIX_FMT_NONE) { + if (amf_is_packed_rgb(in_sw_format)) + ctx->format = in_sw_format; + else + 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)) { 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); } + needs_conversion = ctx->format != in_sw_format; } 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; + needs_conversion = 0; } err = amf_init_filter_config(outlink, &in_format); -- 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]
