答复: 答复: 答复: how to open jpg binary file (/tmp/spice_dump/x.jpg)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes. It works well.

 

发送自 Windows 10 邮件应用

 


发件人: Frediano Ziglio <fziglio@xxxxxxxxxx>
发送时间: Wednesday, June 20, 2018 8:11:58 PM
收件人: 谢昆明
抄送: 谢 昆明; spice-devel@xxxxxxxxxxxxxxxxxxxxx; Christophe Fergeau
主题: Re: 答复: 答复: how to open jpg binary file (/tmp/spice_dump/x.jpg)?
 
Can you try this patch?

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 957f887..ae064ca 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -438,9 +438,9 @@ 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(SpiceChunks* data, uint32_t data_size)
 {
+    static uint32_t jpeg_id = 0;
     char file_str[200];
     uint32_t id = ++jpeg_id;
 
@@ -455,9 +455,13 @@ 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);
 }
+#else
+static inline void dump_jpeg(SpiceChunks* data, uint32_t data_size) {}
 #endif
 
 static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
@@ -486,9 +490,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;
 }
 
@@ -665,9 +667,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;
 }
 
Frediano


Fix bug.

 

发送自 Windows 10 邮件应用

 

发件人: Frediano Ziglio
发送时间: 2018620 18:32
收件人: 昆明
抄送: spice-devel@xxxxxxxxxxxxxxxxxxxxx; Christophe Fergeau
主题: Re: 答复: how to open jpg binary file (/tmp/spice_dump/x.jpg)?

 

 

 

Yes. It is some spice code which is calling dump_jpeg.

 

After apply this patch, jpeg file can be open by eog.

 

The call is correct. What is wrong is dump_jpeg which should handle all chunks and not assume that pointer

is raw data.

Thanks for the report.

What are you trying to do dumping jpeg images?

 

Frediano

 

发送自 Windows 10 邮件应用

 

发件人: Christophe Fergeau
发送时间: 2018620 17:28
收件人: 昆明
抄送: spice-devel@xxxxxxxxxxxxxxxxxxxxx
主题: Re: how to open jpg binary file (/tmp/spice_dump/x.jpg)?

 

Hey,

 

On Wed, Jun 20, 2018 at 02:14:54AM +0000, 谢 昆明 wrote:

> Hey guys. I have dump some jpg file, but I cant open it with eog.

 

I don't understand how this relates to spice? Is this some spice code

which is calling dump_jpeg?

 

Christophe

 

>

>

> static int jpeg_id = 0;

> static void dump_jpeg(uint8_t* data, int data_size)

> {

>     char file_str[200];

>     uint32_t id = ++jpeg_id;

>

> #ifdef WIN32

>     sprintf(file_str, "c:\\tmp\\spice_dump\\%u.jpg", id);

> #else

>     sprintf(file_str, "/tmp/spice_dump/%u.jpg", id);

> #endif

>

>     FILE *f = fopen(file_str, "wb");

>     if (!f) {

>         return;

>     }

>

>     fwrite(data, 1, data_size, f);

>     fclose(f);

> }

>

>

> 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用

>

 


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]