From 057b94649f780b51d20114896edc0cba49f8f828 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 3 Aug 2025 13:44:03 +0200 Subject: [PATCH] swscale/swscale_unscaled: use 8 line alignment for planarCopyWrapper with dithering Dithering relies on a 8 line dithering table and the code always uses it from the beginning. So in order to make dithering independent from height of the slices used we must enforce a 8 line alignment. Fixes issue #20071. Signed-off-by: Marton Balint (cherry picked from commit b61e510e7500c27c7dee2b9c8cfa77689195f2a0) --- libswscale/swscale_unscaled.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 3d9a5c11a8..2c791e89fe 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -2676,10 +2676,13 @@ void ff_get_unscaled_swscale(SwsInternal *c) isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat) && isSwappedChroma(srcFormat) == isSwappedChroma(dstFormat)))) { - if (isPacked(c->opts.src_format)) + if (isPacked(c->opts.src_format)) { c->convert_unscaled = packedCopyWrapper; - else /* Planar YUV or gray */ + } else { /* Planar YUV or gray */ c->convert_unscaled = planarCopyWrapper; + if (c->opts.dither != SWS_DITHER_NONE) + c->dst_slice_align = 8 << c->chrDstVSubSample; + } } #if ARCH_PPC