summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2006-07-05 09:35:53 +0000
committerdeva <deva>2006-07-05 09:35:53 +0000
commit7b997e9a988e1ef6fe41680dc90be545a9ed1710 (patch)
treec82adbc8bc2658e0acfacfad44769b3260ae2d8d
parent65730f227cd79d84ceed3e0e756ab40f44d7cca3 (diff)
Fixed the YUV 4:2:2 to RGBA conversion. (misplaced parenthesis)
-rw-r--r--client/decoder.cc35
1 files changed, 24 insertions, 11 deletions
diff --git a/client/decoder.cc b/client/decoder.cc
index c1f3aab..c456e78 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -159,13 +159,26 @@ void Decoder::pframeRelease()
pmutex.unlock();
}
+/*
+ R = Y + 1.4075 * (V - 128)
+ G = Y - (0.3455 * (U - 128) - (0.7169 * (V - 128))
+ B = Y + 1.7790 * (U - 128)
+*/
+#define RED(y, u, v) (y + 1.4075 * (v - 128))
+#define GREEN(y, u, v) (y - (0.3455 * (u - 128)) - (0.7169 * (v - 128)))
+#define BLUE(y, u, v) (y + 1.7790 * (u - 128))
+
+/*
+ R = 1.164(Y - 16) + 1.596(V - 128)
+ G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
+ B = 1.164(Y - 16) + 2.018(U - 128)
+*/
+//#define RED(y, u, v) (1.164 * (y - 16) + 1.596 * (v - 128))
+//#define GREEN(y, u, v) (1.164 * (y - 16) - 0.813 * (v - 128) - 0.391 * (u - 128))
+//#define BLUE(y, u, v) (1.164 * (y - 16) + 2.018 * (u - 128))
+
void Decoder::snapshot(unsigned char *rgb)
{
- /*
- R = Y + 1.4075 * (V - 128)
- G = Y - (0.3455 * (U - 128) - (0.7169 * (V - 128))
- B = Y + 1.7790 * (U - 128)
- */
pmutex.lock();
@@ -185,15 +198,15 @@ void Decoder::snapshot(unsigned char *rgb)
V = pframe[byte]; byte++;
rgb[pos+3] = 0; // Alpha
- rgb[pos+2] = (unsigned char)(Y0 + 1.4075 * (V - 128)); // Red
- rgb[pos+1] = (unsigned char)(Y0 - (0.3455 * (U - 128) - (0.7169 * (V - 128)))); // Green
- rgb[pos+0] = (unsigned char)(Y0 + 1.7790 * (U - 128)); // Blue
+ rgb[pos+2] = (unsigned char)RED(Y0, U, V); //(Y0 + 1.4075 * (V - 128)); // Red
+ rgb[pos+1] = (unsigned char)GREEN(Y0, U, V); //(Y0 - (0.3455 * (U - 128) - (0.7169 * (V - 128)))); // Green
+ rgb[pos+0] = (unsigned char)BLUE(Y0, U, V); //(Y0 + 1.7790 * (U - 128)); // Blue
pos+=4;
rgb[pos+3] = 0; // Alpha
- rgb[pos+2] = (unsigned char)(Y1 + 1.4075 * (V - 128)); // Red
- rgb[pos+1] = (unsigned char)(Y1 - (0.3455 * (U - 128) - (0.7169 * (V - 128)))); // Green
- rgb[pos+0] = (unsigned char)(Y1 + 1.7790 * (U - 128)); // Blue
+ rgb[pos+2] = (unsigned char)RED(Y1, U, V); //(Y1 + 1.4075 * (V - 128)); // Red
+ rgb[pos+1] = (unsigned char)GREEN(Y1, U, V); //(Y1 - (0.3455 * (U - 128) - (0.7169 * (V - 128)))); // Green
+ rgb[pos+0] = (unsigned char)BLUE(Y1, U, V); //(Y1 + 1.7790 * (U - 128)); // Blue
pos+=4;
}
pmutex.unlock();