[FFmpeg-cvslog] swscale/input: fix 16bit gbrp input

Michael Niedermayer git at videolan.org
Fri Jul 19 15:00:13 CEST 2013


ffmpeg | branch: release/1.2 | Michael Niedermayer <michaelni at gmx.at> | Fri Jul 19 04:19:23 2013 +0200| [d83ab33715cbf25ed552306a436d39531b07c55b] | committer: Carl Eugen Hoyos

swscale/input: fix 16bit gbrp input

Fixes Ticket2793

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

Conflicts:
	libswscale/input.c

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d83ab33715cbf25ed552306a436d39531b07c55b
---

 libswscale/input.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index 2def2de..acf56b3 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -724,12 +724,13 @@ static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_sr
     int i;
     const uint16_t **src = (const uint16_t **)_src;
     uint16_t *dst        = (uint16_t *)_dst;
+    int shift = bpc < 16 ? bpc : 14;
     for (i = 0; i < width; i++) {
         int g = rdpx(src[0] + i);
         int b = rdpx(src[1] + i);
         int r = rdpx(src[2] + i);
 
-        dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14));
+        dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
     }
 }
 
@@ -791,13 +792,14 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
     const uint16_t **src = (const uint16_t **)_src;
     uint16_t *dstU       = (uint16_t *)_dstU;
     uint16_t *dstV       = (uint16_t *)_dstV;
+    int shift = bpc < 16 ? bpc : 14;
     for (i = 0; i < width; i++) {
         int g = rdpx(src[0] + i);
         int b = rdpx(src[1] + i);
         int r = rdpx(src[2] + i);
 
-        dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
-        dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
+        dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
+        dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
     }
 }
 #undef rdpx



More information about the ffmpeg-cvslog mailing list