[Spice-devel] [PATCH spice-gtk] mjpeg: fix blue-tinted video stream with old server

Christophe Fergeau cfergeau at redhat.com
Fri Mar 30 15:12:49 PDT 2012


On Fri, Mar 30, 2012 at 11:47:45PM +0200, Marc-André Lureau wrote:
> The major == 1 uses RGB colorspace for mjpeg streams.

This matches what spice-client does, ACK
> ---
>  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
> -- 
> 1.7.7.6
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120331/7082bce5/attachment.pgp>


More information about the Spice-devel mailing list