[Spice-commits] 2 commits - server/jpeg-encoder.c server/mjpeg-encoder.c server/red-parse-qxl.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 19 09:37:14 UTC 2019


 server/jpeg-encoder.c  |    2 ++
 server/mjpeg-encoder.c |   16 ++++++++++++++--
 server/red-parse-qxl.c |    4 ++--
 3 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 1a3c0b1ee6782a9bae1bf48c7794e629a18e531d
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Jun 5 00:26:48 2018 +0100

    jpeg: Support big endian machines
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/jpeg-encoder.c b/server/jpeg-encoder.c
index 269ed8aa..341ab7e1 100644
--- a/server/jpeg-encoder.c
+++ b/server/jpeg-encoder.c
@@ -118,6 +118,7 @@ static void convert_RGB16_to_RGB24(void *line, int width, uint8_t **out_line)
 
     for (x = 0; x < width; x++) {
        uint16_t pixel = *src_line++;
+       pixel = GUINT16_FROM_LE(pixel);
        *out_pix++ = ((pixel >> 7) & 0xf8) | ((pixel >> 12) & 0x7);
        *out_pix++ = ((pixel >> 2) & 0xf8) | ((pixel >> 7) & 0x7);
        *out_pix++ = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x7);
@@ -153,6 +154,7 @@ static void convert_BGRX32_to_RGB24(void *line, int width, uint8_t **out_line)
 
     for (x = 0; x < width; x++) {
         uint32_t pixel = *src_line++;
+        pixel = GUINT32_FROM_LE(pixel);
         *out_pix++ = (pixel >> 16) & 0xff;
         *out_pix++ = (pixel >> 8) & 0xff;
         *out_pix++ = pixel & 0xff;
diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index e629adae..6b658966 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -70,6 +70,16 @@ static const int mjpeg_quality_samples[MJPEG_QUALITY_SAMPLE_NUM] = {20, 30, 40,
 /* The compressed buffer initial size. */
 #define MJPEG_INITIAL_BUFFER_SIZE (32 * 1024)
 
+#ifdef JCS_EXTENSIONS
+#  ifndef WORDS_BIGENDIAN
+#    define JCS_EXT_LE_BGRX JCS_EXT_BGRX
+#    define JCS_EXT_LE_BGR JCS_EXT_BGR
+#  else
+#    define JCS_EXT_LE_BGRX JCS_EXT_XRGB
+#    define JCS_EXT_LE_BGR JCS_EXT_RGB
+#  endif
+#endif
+
 enum {
     MJPEG_QUALITY_EVAL_TYPE_SET,
     MJPEG_QUALITY_EVAL_TYPE_UPGRADE,
@@ -232,6 +242,7 @@ static void pixel_rgb24bpp_to_24(void *src_ptr, uint8_t *dest)
 static void pixel_rgb32bpp_to_24(void *src, uint8_t *dest)
 {
     uint32_t pixel = *(uint32_t *)src;
+    pixel = GUINT32_FROM_LE(pixel);
     *dest++ = (pixel >> 16) & 0xff;
     *dest++ = (pixel >>  8) & 0xff;
     *dest++ = (pixel >>  0) & 0xff;
@@ -241,6 +252,7 @@ static void pixel_rgb32bpp_to_24(void *src, uint8_t *dest)
 static void pixel_rgb16bpp_to_24(void *src, uint8_t *dest)
 {
     uint16_t pixel = *(uint16_t *)src;
+    pixel = GUINT16_FROM_LE(pixel);
     *dest++ = ((pixel >> 7) & 0xf8) | ((pixel >> 12) & 0x7);
     *dest++ = ((pixel >> 2) & 0xf8) | ((pixel >> 7) & 0x7);
     *dest++ = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x7);
@@ -753,7 +765,7 @@ static int mjpeg_encoder_start_frame(MJpegEncoder *encoder,
     case SPICE_BITMAP_FMT_RGBA:
         encoder->bytes_per_pixel = 4;
 #ifdef JCS_EXTENSIONS
-        encoder->cinfo.in_color_space   = JCS_EXT_BGRX;
+        encoder->cinfo.in_color_space   = JCS_EXT_LE_BGRX;
         encoder->cinfo.input_components = 4;
 #else
         encoder->pixel_converter = pixel_rgb32bpp_to_24;
@@ -766,7 +778,7 @@ static int mjpeg_encoder_start_frame(MJpegEncoder *encoder,
     case SPICE_BITMAP_FMT_24BIT:
         encoder->bytes_per_pixel = 3;
 #ifdef JCS_EXTENSIONS
-        encoder->cinfo.in_color_space = JCS_EXT_BGR;
+        encoder->cinfo.in_color_space = JCS_EXT_LE_BGR;
 #else
         encoder->pixel_converter = pixel_rgb24bpp_to_24;
 #endif
commit 641276087360ceab726d1268c2c4f697f50a61b3
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Jun 5 00:27:37 2018 +0100

    Remove a warning on MIPS machine
    
    The formula is here to make sure glyph is aligned to 4 bytes so
    tell to the compiler to avoid a warning.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index afae9431..cfef9e6d 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -941,9 +941,9 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
         spice_assert(glyph_size <= (char*) end - (char*) &start->data[0]);
         memcpy(glyph->data, start->data, glyph_size);
         start = (QXLRasterGlyph*)(&start->data[glyph_size]);
-        glyph = (SpiceRasterGlyph*)
+        glyph = SPICE_ALIGNED_CAST(SpiceRasterGlyph*,
             (((uint8_t *)glyph) +
-             SPICE_ALIGN(sizeof(SpiceRasterGlyph) + glyph_size, 4));
+             SPICE_ALIGN(sizeof(SpiceRasterGlyph) + glyph_size, 4)));
     }
 
     if (free_data) {


More information about the Spice-commits mailing list