swscale/swscale_unscaled: use 8 line alignment for planarCopyWrapper with dithering
authorMarton Balint <cus@passwd.hu>
Sun, 3 Aug 2025 11:44:03 +0000 (13:44 +0200)
committerMarton Balint <cus@passwd.hu>
Tue, 12 Aug 2025 22:28:22 +0000 (00:28 +0200)
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 <cus@passwd.hu>
(cherry picked from commit b61e510e7500c27c7dee2b9c8cfa77689195f2a0)

libswscale/swscale_unscaled.c

index 95cc42d7e4a3fec5554fd42a1d31d1cd64cc30b5..3adc26899da486aa855d1e0bf320c8f4af8b2f1c 100644 (file)
@@ -2220,10 +2220,13 @@ void ff_get_unscaled_swscale(SwsContext *c)
          c->chrDstVSubSample == c->chrSrcVSubSample &&
          !isSemiPlanarYUV(srcFormat) && !isSemiPlanarYUV(dstFormat))))
     {
-        if (isPacked(c->srcFormat))
+        if (isPacked(c->srcFormat)) {
             c->convert_unscaled = packedCopyWrapper;
-        else /* Planar YUV or gray */
+        } else { /* Planar YUV or gray */
             c->convert_unscaled = planarCopyWrapper;
+            if (c->dither != SWS_DITHER_NONE)
+                c->dst_slice_align = 8 << c->chrDstVSubSample;
+        }
     }
 
 #if ARCH_PPC