[Spice-devel] [PATCH spice-gtk v3] channel-display-mjpeg: Fix encoding for big endian machines

Frediano Ziglio fziglio at redhat.com
Thu Nov 15 20:21:50 UTC 2018


Make sure components are ordered in the same way in memory.
This was tested with a virtual MIPS machine.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/channel-display-mjpeg.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Changes since v2:
- use if instead of #if, compile all code and compiler will
  strip unwanted code (condition is always comparing 2 compile
  time constants)

diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c
index 83cd391b..3bb832d8 100644
--- a/src/channel-display-mjpeg.c
+++ b/src/channel-display-mjpeg.c
@@ -108,7 +108,11 @@ static gboolean mjpeg_decoder_decode_frame(gpointer video_decoder)
 
 #ifdef JCS_EXTENSIONS
     // requires jpeg-turbo
-    decoder->mjpeg_cinfo.out_color_space = JCS_EXT_BGRX;
+    if (SPICE_ENDIAN == SPICE_ENDIAN_LITTLE) {
+        decoder->mjpeg_cinfo.out_color_space = JCS_EXT_BGRX;
+    } else {
+        decoder->mjpeg_cinfo.out_color_space = JCS_EXT_XRGB;
+    }
 #else
 #warning "You should consider building with libjpeg-turbo"
     decoder->mjpeg_cinfo.out_color_space = JCS_RGB;
-- 
2.17.2



More information about the Spice-devel mailing list