diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-03-30 23:46:33 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-03-31 02:02:51 +0200 |
commit | d19e1b0f21be63697e32f8de4a51482caf5444d5 (patch) | |
tree | 685967a34433310fb2f7a8bd6542d9b509f00c16 | |
parent | 9f7c12da84d63280767ba7175043bcb29404458d (diff) |
mjpeg: fix blue-tinted video stream with old server
The major == 1 uses RGB colorspace for mjpeg streams.
-rw-r--r-- | gtk/channel-display-mjpeg.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gtk/channel-display-mjpeg.c b/gtk/channel-display-mjpeg.c index cb1bc87..aed3adf 100644 --- a/gtk/channel-display-mjpeg.c +++ b/gtk/channel-display-mjpeg.c @@ -65,6 +65,7 @@ G_GNUC_INTERNAL void stream_mjpeg_data(display_stream *st) { SpiceMsgDisplayStreamCreate *info = spice_msg_in_parsed(st->msg_create); + gboolean back_compat = st->channel->priv->peer_hdr.major_version == 1; int width = info->stream_width; int height = info->stream_height; uint8_t *dest; @@ -80,7 +81,10 @@ void stream_mjpeg_data(display_stream *st) jpeg_read_header(&st->mjpeg_cinfo, 1); #ifdef JCS_EXTENSIONS // requires jpeg-turbo - st->mjpeg_cinfo.out_color_space = JCS_EXT_BGRX; + if (back_compat) + st->mjpeg_cinfo.out_color_space = JCS_EXT_RGBX; + else + st->mjpeg_cinfo.out_color_space = JCS_EXT_BGRX; #else #warning "You should consider building with libjpeg-turbo" st->mjpeg_cinfo.out_color_space = JCS_RGB; @@ -121,11 +125,20 @@ void stream_mjpeg_data(display_stream *st) uint8_t *s = lines[0]; uint32_t *d = (uint32_t *)s; - for (unsigned int j = lines_read * width; j > 0; ) { - j -= 1; // reverse order, bad for cache? - d[j] = s[j * 3 + 0] << 16 | - s[j * 3 + 1] << 8 | - s[j * 3 + 2]; + if (back_compat) { + for (unsigned int j = lines_read * width; j > 0; ) { + j -= 1; // reverse order, bad for cache? + d[j] = s[j * 3 + 0] | + s[j * 3 + 1] << 8 | + s[j * 3 + 2] << 16; + } + } else { + for (unsigned int j = lines_read * width; j > 0; ) { + j -= 1; // reverse order, bad for cache? + d[j] = s[j * 3 + 0] << 16 | + s[j * 3 + 1] << 8 | + s[j * 3 + 2]; + } } } #endif |