Files
FFmpeg/doc
Julius Bairaktaris 7db554bacf avfilter/vf_sr_amf: convert YUV input on the GPU for sr1-1 and point
sr1-1 and point need a packed RGB surface. Software input was handled by
restricting the negotiated formats so libavfilter inserts a converter,
but a hardware surface backed by NV12 or P010 could only be rejected,
which made both algorithms unusable with any AMF or D3D11VA producer
upstream - including every player that hands libavfilter its decoder
frames.

Chain an AMFVideoConverter ahead of the scaler in that case instead. The
conversion stays on the GPU, so no download is introduced, and the
component is driven from the shared filter_frame path through a new
pre_converter field.

The HQ scaler has no output format property and emits the format it was
initialised with, so one packed RGB target drives the converter output
format, AMFHQScaler::Init() and the output frames context alike. P010
converts to X2BGR10 and NV12 to RGBA by default; an explicit format= is
kept when it names a packed RGB format and rejected otherwise. Where no
conversion is needed the scaler cannot change the format at all, so an
explicit format= differing from the input is rejected and the target is
pinned to the input format, rather than letting the output link negotiate
a frames context that disagrees with the surface the scaler produces.

AMD's Video Converter programming guide has the caller poll for output and
stop submitting while the component reports AMF_INPUT_FULL, so both calls
are retried instead of turning a valid asynchronous state into a dropped
frame or an error. The component runs synchronously on the tested device
and the retry never triggers there.

The converter is asked for full range output, and the converted frame is
tagged AVCOL_SPC_RGB with AVCOL_RANGE_JPEG rather than inheriting the
input's YUV matrix.

The output frames context follows the converted format, so the filter
emits packed RGB where it previously emitted NV12; with format=same this
is only reachable for the two algorithms that cannot produce YUV anyway.

Tested on Windows 11, RX 9070 XT, driver 32.0.31041.1004, with
-hwaccel amf -hwaccel_output_format amf: point and sr1-1 measure
YMIN=YAVG=YMAX=0 before this change and match the plain decode to within
0.6/255 after, while bilinear, bicubic and sr1-0 keep their NV12 output.
point at 2x scores 36.5 dB PSNR against a software neighbour reference,
the converted frame is tagged pc/gbr, P010 reaches X2BGR10, the accepted
and rejected format= values behave as described, and 300 frames run
through the converter for both algorithms.

Assisted-by: Claude Opus 5
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
2026-09-16 22:05:28 +00:00
..
…
2026-09-10 18:23:50 +00:00
2026-03-20 22:01:43 +01:00
2026-01-18 03:33:04 +00:00
…
2026-09-11 22:31:03 +00:00
2026-05-22 08:20:13 -05:00
2026-07-13 16:13:47 +00:00
…
2024-03-18 17:59:19 +01:00
…
2026-07-13 18:57:37 +09:00
…
…
2026-09-12 23:52:20 +00:00
2025-08-03 13:48:47 +02:00