summaryrefslogtreecommitdiffstats
path: root/client/mjpeg_decoder.cpp
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-07-20 11:45:37 +0200
committerAlexander Larsson <alexl@redhat.com>2010-07-20 11:45:37 +0200
commitccbb922d5ae5757343df64c4184ef3927e680bf9 (patch)
tree579dc4018c879ff9c9eb0ffff8d1bf43b472a6cf /client/mjpeg_decoder.cpp
parent2e9604d00d655f276f22b9ad1cce4fb631ac06a8 (diff)
downloadspice-ccbb922d5ae5757343df64c4184ef3927e680bf9.tar.gz
spice-ccbb922d5ae5757343df64c4184ef3927e680bf9.tar.xz
spice-ccbb922d5ae5757343df64c4184ef3927e680bf9.zip
Swap red and blue when decoding 0.4 mjpeg streams
There was an error in how this was encoded in 0.4, which we need to handle. There is still some issues with the old streams as the luminocity handling in 0.4 was not correct.
Diffstat (limited to 'client/mjpeg_decoder.cpp')
-rw-r--r--client/mjpeg_decoder.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/client/mjpeg_decoder.cpp b/client/mjpeg_decoder.cpp
index 42bf2f97..8a3aedea 100644
--- a/client/mjpeg_decoder.cpp
+++ b/client/mjpeg_decoder.cpp
@@ -65,7 +65,8 @@ extern "C" {
MJpegDecoder::MJpegDecoder(int width, int height,
int stride,
- uint8_t *frame) :
+ uint8_t *frame,
+ bool back_compat) :
_data(NULL)
, _data_size(0)
, _data_start(0)
@@ -75,6 +76,7 @@ MJpegDecoder::MJpegDecoder(int width, int height,
, _height(height)
, _stride(stride)
, _frame(frame)
+ , _back_compat(back_compat)
, _y(0)
, _state(0)
{
@@ -114,16 +116,23 @@ void MJpegDecoder::convert_scanline(void)
row = (uint32_t *)(_frame + _y * _stride);
s = _scanline;
- /* TODO after major bump.
- We need to check for the old major and for backwards compat
- a) swap r and b
- b) to-yuv with right values and then from-yuv with old wrong values
- */
- for (x = 0; x < _width; x++) {
- c = s[0] << 16 | s[1] << 8 | s[2];
- s += 3;
- *row++ = c;
+ if (_back_compat) {
+ /* We need to check for the old major and for backwards compat
+ a) swap r and b (done)
+ b) to-yuv with right values and then from-yuv with old wrong values (TODO)
+ */
+ for (x = 0; x < _width; x++) {
+ c = s[2] << 16 | s[1] << 8 | s[0];
+ s += 3;
+ *row++ = c;
+ }
+ } else {
+ for (x = 0; x < _width; x++) {
+ c = s[0] << 16 | s[1] << 8 | s[2];
+ s += 3;
+ *row++ = c;
+ }
}
}