Commit a4b55bbb authored by Michael Niedermayer's avatar Michael Niedermayer

swscale/input: fix 16bit gbrp input

Fixes Ticket2793
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 72f5a6d0
...@@ -754,12 +754,13 @@ static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_sr ...@@ -754,12 +754,13 @@ static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_sr
const uint16_t **src = (const uint16_t **)_src; const uint16_t **src = (const uint16_t **)_src;
uint16_t *dst = (uint16_t *)_dst; uint16_t *dst = (uint16_t *)_dst;
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX]; int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
int shift = bpc < 16 ? bpc : 14;
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
int g = rdpx(src[0] + i); int g = rdpx(src[0] + i);
int b = rdpx(src[1] + i); int b = rdpx(src[1] + i);
int r = rdpx(src[2] + 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));
} }
} }
...@@ -773,13 +774,14 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV, ...@@ -773,13 +774,14 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
uint16_t *dstV = (uint16_t *)_dstV; uint16_t *dstV = (uint16_t *)_dstV;
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX]; int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
int shift = bpc < 16 ? bpc : 14;
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
int g = rdpx(src[0] + i); int g = rdpx(src[0] + i);
int b = rdpx(src[1] + i); int b = rdpx(src[1] + i);
int r = rdpx(src[2] + i); int r = rdpx(src[2] + i);
dstU[i] = (ru*r + gu*g + bu*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 + bpc - 14); dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
} }
} }
#undef rdpx #undef rdpx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment