Browse code

swscale/yuv2rgb: Fix vertical dither offset with slices

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2020/04/03 05:38:46
Showing 1 changed files
... ...
@@ -138,10 +138,11 @@ const int *sws_getCoefficients(int colorspace)
138 138
             srcStride[2] *= 2;                                              \
139 139
         }                                                                   \
140 140
         for (y = 0; y < srcSliceH; y += 2) {                                \
141
+            int yd = y + srcSliceY;                                         \
141 142
             dst_type *dst_1 =                                               \
142
-                (dst_type *)(dst[0] + (y + srcSliceY)     * dstStride[0]);  \
143
+                (dst_type *)(dst[0] + (yd)     * dstStride[0]);             \
143 144
             dst_type *dst_2 =                                               \
144
-                (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]);  \
145
+                (dst_type *)(dst[0] + (yd + 1) * dstStride[0]);             \
145 146
             dst_type av_unused *r, *g, *b;                                  \
146 147
             const uint8_t *py_1 = src[0] +  y       * srcStride[0];         \
147 148
             const uint8_t *py_2 = py_1   +            srcStride[0];         \
... ...
@@ -498,8 +499,8 @@ CLOSEYUV2RGBFUNC(8)
498 498
 
499 499
 // r, g, b, dst_1, dst_2
500 500
 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
501
-    const uint8_t *d32 = ff_dither_8x8_32[y & 7];
502
-    const uint8_t *d64 = ff_dither_8x8_73[y & 7];
501
+    const uint8_t *d32 = ff_dither_8x8_32[yd & 7];
502
+    const uint8_t *d64 = ff_dither_8x8_73[yd & 7];
503 503
 
504 504
 #define PUTRGB8(dst, src, i, o)                     \
505 505
     Y              = src[2 * i];                    \
... ...
@@ -528,8 +529,8 @@ YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
528 528
     PUTRGB8(dst_1, py_1, 3, 6);
529 529
 
530 530
 ENDYUV2RGBLINE(8, 0)
531
-    const uint8_t *d32 = ff_dither_8x8_32[y & 7];
532
-    const uint8_t *d64 = ff_dither_8x8_73[y & 7];
531
+    const uint8_t *d32 = ff_dither_8x8_32[yd & 7];
532
+    const uint8_t *d64 = ff_dither_8x8_73[yd & 7];
533 533
     LOADCHROMA(0);
534 534
     PUTRGB8(dst_1, py_1, 0, 0);
535 535
     PUTRGB8(dst_2, py_2, 0, 0 + 8);
... ...
@@ -539,8 +540,8 @@ ENDYUV2RGBLINE(8, 0)
539 539
     PUTRGB8(dst_1, py_1, 1, 2);
540 540
 
541 541
 ENDYUV2RGBLINE(8, 1)
542
-    const uint8_t *d32 = ff_dither_8x8_32[y & 7];
543
-    const uint8_t *d64 = ff_dither_8x8_73[y & 7];
542
+    const uint8_t *d32 = ff_dither_8x8_32[yd & 7];
543
+    const uint8_t *d64 = ff_dither_8x8_73[yd & 7];
544 544
     LOADCHROMA(0);
545 545
     PUTRGB8(dst_1, py_1, 0, 0);
546 546
     PUTRGB8(dst_2, py_2, 0, 0 + 8);
... ...
@@ -549,8 +550,8 @@ ENDYUV2RGBFUNC()
549 549
 
550 550
 
551 551
 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
552
-    const uint8_t * d64 = ff_dither_8x8_73[y & 7];
553
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
552
+    const uint8_t * d64 = ff_dither_8x8_73[yd & 7];
553
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
554 554
     int acc;
555 555
 
556 556
 #define PUTRGB4D(dst, src, i, o)                    \
... ...
@@ -581,8 +582,8 @@ YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
581 581
     PUTRGB4D(dst_1, py_1, 3, 6);
582 582
 
583 583
 ENDYUV2RGBLINE(4, 0)
584
-    const uint8_t * d64 = ff_dither_8x8_73[y & 7];
585
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
584
+    const uint8_t * d64 = ff_dither_8x8_73[yd & 7];
585
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
586 586
     int acc;
587 587
     LOADCHROMA(0);
588 588
     PUTRGB4D(dst_1, py_1, 0, 0);
... ...
@@ -593,8 +594,8 @@ ENDYUV2RGBLINE(4, 0)
593 593
     PUTRGB4D(dst_1, py_1, 1, 2);
594 594
 
595 595
 ENDYUV2RGBLINE(4, 1)
596
-    const uint8_t * d64 = ff_dither_8x8_73[y & 7];
597
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
596
+    const uint8_t * d64 = ff_dither_8x8_73[yd & 7];
597
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
598 598
     int acc;
599 599
     LOADCHROMA(0);
600 600
     PUTRGB4D(dst_1, py_1, 0, 0);
... ...
@@ -602,8 +603,8 @@ ENDYUV2RGBLINE(4, 1)
602 602
 ENDYUV2RGBFUNC()
603 603
 
604 604
 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
605
-    const uint8_t *d64  = ff_dither_8x8_73[y & 7];
606
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
605
+    const uint8_t *d64  = ff_dither_8x8_73[yd & 7];
606
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
607 607
 
608 608
 #define PUTRGB4DB(dst, src, i, o)                   \
609 609
     Y              = src[2 * i];                    \
... ...
@@ -631,8 +632,8 @@ YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
631 631
     PUTRGB4DB(dst_2, py_2, 3, 6 + 8);
632 632
     PUTRGB4DB(dst_1, py_1, 3, 6);
633 633
 ENDYUV2RGBLINE(8, 0)
634
-    const uint8_t *d64  = ff_dither_8x8_73[y & 7];
635
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
634
+    const uint8_t *d64  = ff_dither_8x8_73[yd & 7];
635
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
636 636
     LOADCHROMA(0);
637 637
     PUTRGB4DB(dst_1, py_1, 0, 0);
638 638
     PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
... ...
@@ -641,15 +642,15 @@ ENDYUV2RGBLINE(8, 0)
641 641
     PUTRGB4DB(dst_2, py_2, 1, 2 + 8);
642 642
     PUTRGB4DB(dst_1, py_1, 1, 2);
643 643
 ENDYUV2RGBLINE(8, 1)
644
-    const uint8_t *d64  = ff_dither_8x8_73[y & 7];
645
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
644
+    const uint8_t *d64  = ff_dither_8x8_73[yd & 7];
645
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
646 646
     LOADCHROMA(0);
647 647
     PUTRGB4DB(dst_1, py_1, 0, 0);
648 648
     PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
649 649
 ENDYUV2RGBFUNC()
650 650
 
651 651
 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
652
-    const uint8_t *d128 = ff_dither_8x8_220[y & 7];
652
+    const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
653 653
     char out_1 = 0, out_2 = 0;
654 654
     g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
655 655