diff options
author | jstebbins <[email protected]> | 2011-05-17 19:47:10 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-05-17 19:47:10 +0000 |
commit | a9005d4eec52d14e540a99078b5cd0ce227e79c3 (patch) | |
tree | 5bf988467a811551a1b1915cfc38493d657b4c2c /libhb/common.c | |
parent | 10b965d8b1dbe294a66214b01e23d48ababdc37b (diff) |
Fix some problems with rgb2yuv and yuv2rgb
yuv2rgb converted incorrectly. Cb and Cr were swapped in 2 of the 3 conversion
expressions.
rgb2yuv was setting the color channels in the incorrect order in the output.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3981 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/common.c')
-rw-r--r-- | libhb/common.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libhb/common.c b/libhb/common.c index 9c06d783b..b2581ec5e 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -1502,7 +1502,7 @@ hb_attachment_t *hb_attachment_copy(const hb_attachment_t *src) /********************************************************************** * hb_yuv2rgb ********************************************************************** - * Converts a YCbCr pixel to an RGB pixel. + * Converts a YCrCb pixel to an RGB pixel. * * This conversion is lossy (due to rounding and clamping). * @@ -1515,12 +1515,12 @@ int hb_yuv2rgb(int yuv) int r, g, b; y = (yuv >> 16) & 0xff; - Cb = (yuv >> 8) & 0xff; - Cr = (yuv ) & 0xff; + Cr = (yuv >> 8) & 0xff; + Cb = (yuv ) & 0xff; - r = 1.164 * (y - 16) + 2.018 * (Cb - 128); - g = 1.164 * (y - 16) - 0.813 * (Cr - 128) - 0.391 * (Cb - 128); - b = 1.164 * (y - 16) + 1.596 * (Cr - 128); + r = 1.164 * (y - 16) + 1.596 * (Cr - 128); + g = 1.164 * (y - 16) - 0.392 * (Cb - 128) - 0.813 * (Cr - 128); + b = 1.164 * (y - 16) + 2.017 * (Cb - 128); r = (r < 0) ? 0 : r; g = (g < 0) ? 0 : g; @@ -1536,7 +1536,7 @@ int hb_yuv2rgb(int yuv) /********************************************************************** * hb_rgb2yuv ********************************************************************** - * Converts an RGB pixel to a YCbCr pixel. + * Converts an RGB pixel to a YCrCb pixel. * * This conversion is lossy (due to rounding and clamping). * @@ -1564,7 +1564,7 @@ int hb_rgb2yuv(int rgb) Cb = (Cb > 255) ? 255 : Cb; Cr = (Cr > 255) ? 255 : Cr; - return (y << 16) | (Cb << 8) | Cr; + return (y << 16) | (Cr << 8) | Cb; } const char * hb_subsource_name( int source ) |