mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-06 23:12:17 +00:00
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.
This commit is contained in:
parent
2e9604d00d
commit
ccbb922d5a
@ -290,7 +290,7 @@ VideoStream::VideoStream(RedClient& client, Canvas& canvas, DisplayChannel& chan
|
||||
_pixmap.width = src_width;
|
||||
_pixmap.height = src_height;
|
||||
|
||||
_mjpeg_decoder = new MJpegDecoder(stream_width, stream_height, _stride, _uncompressed_data);
|
||||
_mjpeg_decoder = new MJpegDecoder(stream_width, stream_height, _stride, _uncompressed_data, channel.get_peer_major() == 1);
|
||||
|
||||
#ifdef WIN32
|
||||
SetViewportOrgEx(_dc, 0, stream_height - src_height, NULL);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ extern "C" {
|
||||
class MJpegDecoder {
|
||||
public:
|
||||
MJpegDecoder(int width, int height, int stride,
|
||||
uint8_t *frame);
|
||||
uint8_t *frame, bool back_compat);
|
||||
~MJpegDecoder();
|
||||
|
||||
bool decode_data(uint8_t *data, size_t length);
|
||||
@ -63,6 +63,7 @@ private:
|
||||
int _height;
|
||||
int _stride;
|
||||
uint8_t *_frame;
|
||||
bool _back_compat;
|
||||
|
||||
int _y;
|
||||
uint8_t *_scanline;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user