Commit 3eeb607315 for ffmpeg
commit 3eeb607315a408f694a6dc1b00520bf822ce5b0b
Author: ksu-gitreaper807 <ksuksus708@gmail.com>
Date: Sun Nov 8 10:00:15 2026 +0000
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.
diff --git a/libswscale/slice.c b/libswscale/slice.c
index 44c3bd74b4..0dbd40624d 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);