summaryrefslogtreecommitdiff
path: root/libswscale/input.c
diff options
context:
space:
mode:
authorMark Reid <mindmark@gmail.com>2020-10-03 16:31:58 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2020-10-06 17:56:52 +0200
commita48adcd1369131ebadd1c928fe790c72795182a7 (patch)
treea30fec676173eeaa7e5fc7b89655e3d9456a101e /libswscale/input.c
parent214998c55ff99586b57c1ccd34a7e6f15c4fcdb8 (diff)
libswcale/input: use more accurate planer rgb16 yuv conversions
These conversion appears to be exhibiting the same rounding error as the rgbf32 formats where. I seperated the rounding value from the 16 and 128 offsets, I think it makes it a little more clear. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswscale/input.c')
-rw-r--r--libswscale/input.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libswscale/input.c b/libswscale/input.c
index 67a85b0418..6850801a44 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -924,7 +924,7 @@ static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_sr
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 + shift - 14));
+ dst[i] = (ry*r + gy*g + by*b + (16 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
}
}
@@ -957,8 +957,8 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
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 + shift - 14);
- dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
+ dstU[i] = (ru*r + gu*g + bu*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
+ dstV[i] = (rv*r + gv*g + bv*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
}
}
#undef rdpx