PR #26175 opened by Forgejo_Fairy URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26175 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26175.patch
With a 24×16 input carrying SAR 2:1, `scale=24:16:reset_sar=1` returns SAR 2:1 because the no-op path discards the output frame containing the computed SAR. Copy that SAR to the returned input frame before freeing the output frame. Fixes #26105. The omission was masked by the filter core's SAR overwrite until 0c3afc7e56434; building that commit and its parent confirms the transition from SAR 1:1 to 2:1. Adds the self-contained FATE test `filter-scale-reset-sar-noop`, with expected output in `tests/ref/fate`. It fails before the fix solely on SAR and passes afterward, with an unchanged pixel checksum. Validation on AArch64 Linux with GCC 13.3.0: the original NUT/ffprobe reproducer now reports SAR 1:1 and DAR 3:2; the new FATE test and three existing scale tests pass. Sixty combinations covering RGB24/YUV420P, three input SARs, reset enabled/disabled and five output widths pass, as does a frame-evaluated size sequence crossing the no-op size. The reported behavior also reproduces on release/8.1, release/9.0 and release/9.1; release/8.0 retains the expected output. From 15249aff9073607190c31f2106db49f2c3091e08 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Wed, 18 Nov 2026 15:25:12 +0000 Subject: [PATCH] avfilter/vf_scale: preserve output SAR on the no-op path When reset_sar is enabled, scale computes a square-pixel output SAR, but discards it when sws_is_noop() allows the input frame to be returned. Copy the computed SAR to the returned frame, as is already done for chroma location. This was masked by the filter core overwriting frame SAR with link SAR until 0c3afc7e56434a5e4ee16cf277113ddd3eac7cb4. Its parent outputs SAR 1:1 for a 24x16 SAR 2:1 input with scale=24:16:reset_sar=1; that commit outputs SAR 2:1. Add a self-contained FATE test that fails before this fix, with only the SAR differing from the reference. The frame checksum remains unchanged. Fixes: #26105 Assisted-by: Fairy --- libavfilter/vf_scale.c | 1 + tests/fate/filter-video.mak | 3 +++ tests/ref/fate/filter-scale-reset-sar-noop | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 tests/ref/fate/filter-scale-reset-sar-noop diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 6c1bf888796..8f2c047dd3a 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -884,6 +884,7 @@ scale: if (sws_is_noop(out, in)) { in->chroma_location = out->chroma_location; + in->sample_aspect_ratio = out->sample_aspect_ratio; av_frame_free(&out); in->flags = flags_orig; *frame_out = in; diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 7862b54981b..e0c331d454a 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -181,6 +181,9 @@ FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC FORMAT CONCAT SCALE, LAVFI_INDEV FILE fate-filter-lavd-scalenorm: tests/data/filtergraphs/scalenorm fate-filter-lavd-scalenorm: CMD = framecrc -f lavfi -graph_file $(TARGET_PATH)/tests/data/filtergraphs/scalenorm -i dummy +FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC SETSAR SCALE) += fate-filter-scale-reset-sar-noop +fate-filter-scale-reset-sar-noop: CMD = framecrc -lavfi testsrc=s=24x16:r=1:d=1,setsar=2/1,scale=24:16:reset_sar=1 + FATE_FILTER-$(call FILTERFRAMECRC, COLOR FORMAT SCALE CROP) += fate-filter-scale-fast-bilinear-wide-edge fate-filter-scale-fast-bilinear-wide-edge: CMD = framecrc -flags bitexact -lavfi color=c=red:s=40000x1:r=1:d=1,format=yuv444p,scale=40032:1:flags=fast_bilinear,crop=1:1:40031:0 -frames:v 1 diff --git a/tests/ref/fate/filter-scale-reset-sar-noop b/tests/ref/fate/filter-scale-reset-sar-noop new file mode 100644 index 00000000000..ca631259755 --- /dev/null +++ b/tests/ref/fate/filter-scale-reset-sar-noop @@ -0,0 +1,6 @@ +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 24x16 +#sar 0: 1/1 +0, 0, 0, 1, 1152, 0x0a3f20fb -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
