summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-05-17 19:47:10 +0000
committerjstebbins <[email protected]>2011-05-17 19:47:10 +0000
commita9005d4eec52d14e540a99078b5cd0ce227e79c3 (patch)
tree5bf988467a811551a1b1915cfc38493d657b4c2c /libhb
parent10b965d8b1dbe294a66214b01e23d48ababdc37b (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')
-rw-r--r--libhb/common.c16
-rw-r--r--libhb/decssasub.c4
2 files changed, 10 insertions, 10 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 )
diff --git a/libhb/decssasub.c b/libhb/decssasub.c
index 03fb495db..460a8ddc0 100644
--- a/libhb/decssasub.c
+++ b/libhb/decssasub.c
@@ -549,8 +549,8 @@ static hb_buffer_t *ssa_decode_line_to_picture( hb_work_object_t * w, uint8_t *i
int srcA = srcRgba[3];
*dstY = (srcYuv >> 16) & 0xff;
- *dstU = (srcYuv >> 8 ) & 0xff;
- *dstV = (srcYuv >> 0 ) & 0xff;
+ *dstV = (srcYuv >> 8 ) & 0xff;
+ *dstU = (srcYuv >> 0 ) & 0xff;
*dstA = srcA / 16; // HB's max alpha value is 16
}