Browse code

swscale/input: fix 16bit gbrp input

Fixes Ticket2793

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit a4b55bbb6f8ba055bba1493f6872792503e47563)

Conflicts:
libswscale/input.c

Michael Niedermayer authored on 2013/07/19 11:19:23
Showing 1 changed files
... ...
@@ -724,12 +724,13 @@ static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_sr
724 724
     int i;
725 725
     const uint16_t **src = (const uint16_t **)_src;
726 726
     uint16_t *dst        = (uint16_t *)_dst;
727
+    int shift = bpc < 16 ? bpc : 14;
727 728
     for (i = 0; i < width; i++) {
728 729
         int g = rdpx(src[0] + i);
729 730
         int b = rdpx(src[1] + i);
730 731
         int r = rdpx(src[2] + i);
731 732
 
732
-        dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14));
733
+        dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
733 734
     }
734 735
 }
735 736
 
... ...
@@ -791,13 +792,14 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
791 791
     const uint16_t **src = (const uint16_t **)_src;
792 792
     uint16_t *dstU       = (uint16_t *)_dstU;
793 793
     uint16_t *dstV       = (uint16_t *)_dstV;
794
+    int shift = bpc < 16 ? bpc : 14;
794 795
     for (i = 0; i < width; i++) {
795 796
         int g = rdpx(src[0] + i);
796 797
         int b = rdpx(src[1] + i);
797 798
         int r = rdpx(src[2] + i);
798 799
 
799
-        dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
800
-        dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
800
+        dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
801
+        dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
801 802
     }
802 803
 }
803 804
 #undef rdpx