From 65730f227cd79d84ceed3e0e756ab40f44d7cca3 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 4 Jul 2006 16:31:08 +0000 Subject: Worked on the snapshot YUV 4:2:2 => RGBA conversion. It looks better now, but there are still something wrong with the colors! --- client/decoder.cc | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'client/decoder.cc') diff --git a/client/decoder.cc b/client/decoder.cc index ebd5087..c1f3aab 100644 --- a/client/decoder.cc +++ b/client/decoder.cc @@ -159,16 +159,44 @@ void Decoder::pframeRelease() pmutex.unlock(); } -void Decoder::snapshot(char *rgb) +void Decoder::snapshot(unsigned char *rgb) { /* - LibDVWrapper dv; - dv.setOutputBuffer(rgb, DV::BGR0); + R = Y + 1.4075 * (V - 128) + G = Y - (0.3455 * (U - 128) - (0.7169 * (V - 128)) + B = Y + 1.7790 * (U - 128) + */ pmutex.lock(); - dv.decode(pframe); + + unsigned char Y0, Y1, U, V; + + unsigned int byte = 0; + unsigned int pos = 0; + + while(pos < 720*576*4) { + // YUV 4:2:2 packing + // Y0 U0 Y1 V1 Y2 U2 Y3 V3 + // [Y0 U0 V1] [Y1 U0 V1] [Y2 U2 V3] [Y3 U2 V3] + + Y0 = pframe[byte]; byte++; + U = pframe[byte]; byte++; + Y1 = pframe[byte]; byte++; + 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 + 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 + pos+=4; + } pmutex.unlock(); - */ } bool Decoder::eventFilter(QObject *o, QEvent *e) @@ -214,3 +242,4 @@ Status Decoder::status() return s; } + -- cgit v1.2.3