summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2006-07-04 16:31:08 +0000
committerdeva <deva>2006-07-04 16:31:08 +0000
commit65730f227cd79d84ceed3e0e756ab40f44d7cca3 (patch)
treedd640dac73ca0f43039bdb002357b366243f7407
parent0f07334126048f16cf631e72e8708c2bf3c8a8e6 (diff)
Worked on the snapshot YUV 4:2:2 => RGBA conversion.
It looks better now, but there are still something wrong with the colors!
-rw-r--r--client/decoder.cc39
-rw-r--r--client/decoder.h2
-rw-r--r--client/mainwindow.cc2
3 files changed, 36 insertions, 7 deletions
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;
}
+
diff --git a/client/decoder.h b/client/decoder.h
index f156884..99cdd58 100644
--- a/client/decoder.h
+++ b/client/decoder.h
@@ -49,7 +49,7 @@ public:
void run();
- void snapshot(char *rgb);
+ void snapshot(unsigned char *rgb);
void setPFrameData(char *pframe);
void pframeAcquire();
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index 88eae63..79d6b7e 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -192,7 +192,7 @@ void MainWindow::snapshot_clicked()
MIaV::control.shoot();
QImage screenshot(720, 576, QImage::Format_RGB32);
- decoder->snapshot((char*)screenshot.bits());
+ decoder->snapshot(screenshot.bits());
QPixmap *p = new QPixmap();
*p = QPixmap::fromImage(screenshot);