PR #25859 opened by ksu-gitreaper807 URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25859 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25859.patch
RGB input can still run its U/V conversion callbacks when the destination is grayscale: `ff_init_filters()` schedules the input chroma-conversion descriptor even though horizontal chroma scaling is already disabled. This patch excludes grayscale destinations from `need_chr_conv` and retains the existing no-chroma descriptor for slice metadata. For a 65x18 RGB0→GRAY8 diagnostic case, actual U/V converter calls dropped from 18 to zero with unchanged output. The source change is limited to `libswscale/slice.c`. Validation: - Baseline/patched active output bytes matched across 2,912 cases with native CPU dispatch and another 2,912 with dispatch forced to scalar, per tested target. - Another 112 modern frame API cases matched per target, using the legacy backend with one and three threads. - Targets: x86_64 Linux; physical ARM64 Android 13; QEMU AArch64 and big-endian PowerPC64. The matrix includes grayscale and color outputs, RGB0/BGR0/0RGB/0BGR layouts, planar inputs, endian-specific pixel formats, odd widths, scaling, negative strides, and sliced input. - `fate-sws-range-convert`, `fate-sws-unscaled-threaded`, and `fate-sws-floatimg-cmp` passed on baseline and patched non-x86 builds. - The configured `make -j6 fate` suite passed on the rebased x86 build (201 tests). Conversion-only timing on an Intel Core i7-12800H, single thread pinned to one CPU, native x86 dispatch, RGB0 input, BT.709/limited output range, bilinear, unchanged dimensions: | Output | Resolution | Baseline ms/frame | Patched ms/frame | |---|---|---:|---:| | GRAY8 | 1920x1080 | 7.498 | 5.707 | | GRAY8 | 3840x2160 | 30.813 | 24.729 | Values are medians of seven alternating baseline/patched runs, with five warmup and 60 timed frames per case. The unchanged YUV420P control varied by approximately -2% to +5%; no YUV420P speedup is claimed. No phone or emulated performance results are claimed. The detailed comparisons and timings were collected against `7afbfcbd92d6`. This branch is based on upstream `cc583787bbec`; there are no intervening `libswscale` changes. Diagnostic sources, per-target result hashes, individual timings, and the configured x86 FATE log are available in the [validation branch](https://github.com/ksu-gitreaper807/FFmpeg/tree/validation/sws-gray-chroma/validation/gray-chroma). From 5dea1542165c6946efcc6766088dc29000e1ac85 Mon Sep 17 00:00:00 2001 From: ksu-gitreaper807 <[email protected]> Date: Sun, 8 Nov 2026 10:00:15 +0000 Subject: [PATCH] swscale: skip chroma conversion for grayscale output Grayscale output already bypasses horizontal chroma scaling, but input conversion callbacks can still cause the chroma conversion descriptor to be scheduled. RGB input therefore computes U and V even though neither component is used by the output. Do not schedule the input chroma conversion for grayscale destinations. Keep the existing no-chroma descriptor to maintain slice metadata. For RGB0 to GRAY8 with native x86 dispatch, local conversion-only timing showed about 24% less time at 1920x1080 and 20% less at 3840x2160 on an Intel Core i7-12800H. Tested output is unchanged with native and scalar dispatch on x86_64, physical ARM64 Android, and QEMU AArch64 and big-endian PowerPC64. --- libswscale/slice.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libswscale/slice.c b/libswscale/slice.c index 44c3bd74b44..0dbd40624d9 100644 --- a/libswscale/slice.c +++ b/libswscale/slice.c @@ -251,7 +251,8 @@ int ff_init_filters(SwsInternal * c) int num_cdesc; int num_vdesc = isPlanarYUV(c->opts.dst_format) && !isGray(c->opts.dst_format) ? 2 : 1; int need_lum_conv = c->lumToYV12 || c->readLumPlanar || c->alpToYV12 || c->readAlpPlanar; - int need_chr_conv = c->chrToYV12 || c->readChrPlanar; + int need_chr_conv = !isGray(c->opts.dst_format) && + (c->chrToYV12 || c->readChrPlanar); int need_gamma = c->is_internal_gamma; int srcIdx, dstIdx; int dst_stride = FFALIGN(c->opts.dst_w * sizeof(int16_t) + 66, 16); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
