[Spice-commits] common/canvas_base.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 26 16:55:48 UTC 2018


 common/canvas_base.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 818b820644c9b294f7edc1cc6f1b607f7a71c851
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Jun 20 15:19:31 2018 +0100

    canvas_base: Rework DUMP_JPEG debugging
    
    The DUMP_JPEG compile time flag is used to dump all jpeg images
    to files.
    The code was saving garbage instead of proper data.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reported-by: 谢 昆明 <KunMing.Xie at hotmail.com>
    Tested-by: 谢 昆明 <KunMing.Xie at hotmail.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 8bd2fe1..62c458d 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -437,10 +437,11 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,
 
 
 //#define DUMP_JPEG
-#ifdef DUMP_JPEG
-static int jpeg_id = 0;
-static void dump_jpeg(uint8_t* data, int data_size)
+static void
+dump_jpeg(SPICE_GNUC_UNUSED SpiceChunks* data, SPICE_GNUC_UNUSED uint32_t data_size)
 {
+#ifdef DUMP_JPEG
+    static uint32_t jpeg_id = 0;
     char file_str[200];
     uint32_t id = ++jpeg_id;
 
@@ -455,10 +456,12 @@ static void dump_jpeg(uint8_t* data, int data_size)
         return;
     }
 
-    fwrite(data, 1, data_size, f);
+    for (uint32_t n = 0; n < data->num_chunks; ++n) {
+        fwrite(data->chunk[n].data, 1, data->chunk[n].len, f);
+    }
     fclose(f);
-}
 #endif
+}
 
 static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
 {
@@ -486,9 +489,7 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
 
     canvas->jpeg->ops->decode(canvas->jpeg, dest, stride, SPICE_BITMAP_FMT_32BIT);
 
-#ifdef DUMP_JPEG
     dump_jpeg(image->u.jpeg.data, image->u.jpeg.data_size);
-#endif
     return surface;
 }
 
@@ -652,9 +653,7 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *ima
     }
     lz_decode(lz_data->lz, LZ_IMAGE_TYPE_XXXA, decomp_alpha_buf);
 
-#ifdef DUMP_JPEG
     dump_jpeg(image->u.jpeg_alpha.data, image->u.jpeg_alpha.jpeg_size);
-#endif
     return surface;
 }
 


More information about the Spice-commits mailing list