PR #26178 opened by Forgejo_Fairy URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26178 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26178.patch
LLM-GPT-6-ASTRA investigation of #26108. A lone width option such as `scale=w=48` or `scale=w=iw*2` is unconditionally interpreted as a complete video size, causing initialization to fail before height can default to `ih`. For a 24×16 input, these options should produce 48×16. Only move the width expression into `size_str` when `av_parse_video_size()` accepts it. Preserve existing size shorthand, explicit size validation, and rejection of conflicting size/dimension options. This also preserves the legacy ambiguity whereby `w=24*2` denotes a 24×2 size; supplying `h=ih` forces expression interpretation. The regression was introduced by 9ab796127a38, verified by building and running that commit and its parent 710b0aa8012. It also reproduces on master and all active release branches. Validation on AArch64 Linux: the new generated-input `fate-filter-scale-size-expressions` covers 11 option combinations, fails without the production fix, and passes with it. Reference dimensions and black-frame checksums were independently checked. All 17 focused FATE tests passed, including existing scale/chroma/premultiplication coverage. Additional CLI checks covered invalid expressions, conflicting options, size aliases, and width-only scale2ref. Fixes #26108. From d9ee79fd47c95218fa38197f2fee04b869bd85d1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Wed, 18 Nov 2026 15:39:48 +0000 Subject: [PATCH] avfilter/scale: preserve width-only expressions Only interpret a lone width as a video size if av_parse_video_size() accepts it. Otherwise retain the width expression and let height default to ih, as documented. Keep the existing size shorthand and the rejection of size combined with explicit width or height. Add generated-input FATE coverage for width and height defaults, width aliases and expressions, special width values, and size shorthand. Fixes: 9ab796127a38e047bc76eb0a825ba6c90fb945da Fixes: #26108 Assisted-by: Fairy --- libavfilter/vf_scale.c | 3 +- tests/fate/filter-video.mak | 4 ++ tests/filtergraphs/scale-size-expressions | 13 ++++ tests/ref/fate/filter-scale-size-expressions | 66 ++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 tests/filtergraphs/scale-size-expressions create mode 100644 tests/ref/fate/filter-scale-size-expressions diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 6c1bf888796..1036aafb3bc 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -339,7 +339,8 @@ static av_cold int init(AVFilterContext *ctx) return AVERROR(EINVAL); } - if (scale->w_expr && !scale->h_expr) + if (scale->w_expr && !scale->h_expr && + av_parse_video_size(&scale->w, &scale->h, scale->w_expr) >= 0) FFSWAP(char *, scale->w_expr, scale->size_str); if (scale->size_str) { diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 7862b54981b..46d9d7a4064 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -181,6 +181,10 @@ 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, COLOR SPLIT SCALE, LAVFI_INDEV FILE_PROTOCOL WRAPPED_AVFRAME_DECODER) += fate-filter-scale-size-expressions +fate-filter-scale-size-expressions: tests/data/filtergraphs/scale-size-expressions +fate-filter-scale-size-expressions: CMD = framecrc -f lavfi -graph_file $(TARGET_PATH)/tests/data/filtergraphs/scale-size-expressions -i dummy -map 0 + 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/filtergraphs/scale-size-expressions b/tests/filtergraphs/scale-size-expressions new file mode 100644 index 00000000000..d9f88f1ef01 --- /dev/null +++ b/tests/filtergraphs/scale-size-expressions @@ -0,0 +1,13 @@ +sws_flags=+accurate_rnd+bitexact; +color=c=black:s=24x16:r=1:d=1, split=11 [a][b][c][d][e][f][g][h][i][j][k]; +[a] scale=w=48 [out0]; +[b] scale=width=48 [out1]; +[c] scale=w=iw*2 [out2]; +[d] scale=w=0 [out3]; +[e] scale=w=-2 [out4]; +[f] scale=h=32 [out5]; +[g] scale=hd720 [out6]; +[h] scale=48x32 [out7]; +[i] scale=size=48x32 [out8]; +[j] scale=w=48:h=32 [out9]; +[k] scale [out10] diff --git a/tests/ref/fate/filter-scale-size-expressions b/tests/ref/fate/filter-scale-size-expressions new file mode 100644 index 00000000000..c3554b855d8 --- /dev/null +++ b/tests/ref/fate/filter-scale-size-expressions @@ -0,0 +1,66 @@ +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 48x16 +#sar 0: 1/2 +#tb 1: 1/1 +#media_type 1: video +#codec_id 1: rawvideo +#dimensions 1: 48x16 +#sar 1: 1/2 +#tb 2: 1/1 +#media_type 2: video +#codec_id 2: rawvideo +#dimensions 2: 48x16 +#sar 2: 1/2 +#tb 3: 1/1 +#media_type 3: video +#codec_id 3: rawvideo +#dimensions 3: 24x16 +#sar 3: 1/1 +#tb 4: 1/1 +#media_type 4: video +#codec_id 4: rawvideo +#dimensions 4: 24x16 +#sar 4: 1/1 +#tb 5: 1/1 +#media_type 5: video +#codec_id 5: rawvideo +#dimensions 5: 24x32 +#sar 5: 2/1 +#tb 6: 1/1 +#media_type 6: video +#codec_id 6: rawvideo +#dimensions 6: 1280x720 +#sar 6: 27/32 +#tb 7: 1/1 +#media_type 7: video +#codec_id 7: rawvideo +#dimensions 7: 48x32 +#sar 7: 1/1 +#tb 8: 1/1 +#media_type 8: video +#codec_id 8: rawvideo +#dimensions 8: 48x32 +#sar 8: 1/1 +#tb 9: 1/1 +#media_type 9: video +#codec_id 9: rawvideo +#dimensions 9: 48x32 +#sar 9: 1/1 +#tb 10: 1/1 +#media_type 10: video +#codec_id 10: rawvideo +#dimensions 10: 24x16 +#sar 10: 1/1 +0, 0, 0, 1, 1152, 0x88e0f000 +1, 0, 0, 1, 1152, 0x88e0f000 +2, 0, 0, 1, 1152, 0x88e0f000 +3, 0, 0, 1, 576, 0x40387800 +4, 0, 0, 1, 576, 0x40387800 +5, 0, 0, 1, 1152, 0x88e0f000 +6, 0, 0, 1, 1382400, 0x3c0e41eb +7, 0, 0, 1, 2304, 0x338fe00f +8, 0, 0, 1, 2304, 0x338fe00f +9, 0, 0, 1, 2304, 0x338fe00f +10, 0, 0, 1, 576, 0x40387800 -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
