[Spice-devel] [PATCH spice-common] canvas_base: Rework DUMP_JPEG debugging
Christophe Fergeau
cfergeau at redhat.com
Tue Jun 26 09:49:46 UTC 2018
On Wed, Jun 20, 2018 at 03:21:02PM +0100, Frediano Ziglio wrote:
> 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>
> ---
> common/canvas_base.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> 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) {}
I'd jus trust the compiler to do the right thing here and drop the
'inline' ;)
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
> #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;
> }
>
> --
> 2.17.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180626/ec978679/attachment-0001.sig>
More information about the Spice-devel
mailing list