[Spice-devel] [PATCH spice-common v2] canvas-base: Fix width computation for palette images

Frediano Ziglio fziglio at redhat.com
Fri Dec 22 10:02:37 UTC 2017


Palette images are encoded using a slightly larger number of pixel than
width. This causes a wrong calculation of stride_encoded value which
causes a wrong stride adjustment.

Before commit 5603961ff "fix 16 bpp LZ image decompression", the output
stride was always computed as "stride = (n_comp_pixels / height) * 4"
that is assuming 4 bytes for pixel which was wrong for some output
however computing starting from width was wrong for palette images.

This commit was added to spice-gtk in v0.32~58, which nicely matches the
"client regression when upgrading from spice-gtk v0.31 to spice-gtk
v0.33".

This fix bug https://bugzilla.redhat.com/show_bug.cgi?id=1508847.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 common/canvas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Changes since v1:
- improve commit message

diff --git a/common/canvas_base.c b/common/canvas_base.c
index a9d7855..2ecd276 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -824,7 +824,7 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
     lz_decode_begin(lz_data->lz, comp_buf, comp_size, &type,
                     &width, &height, &n_comp_pixels, &top_down, palette);
 
-    stride_encoded = width;
+    stride_encoded = n_comp_pixels / height;
     switch (type) {
     case LZ_IMAGE_TYPE_RGBA:
         as_type = LZ_IMAGE_TYPE_RGBA;
-- 
2.14.3



More information about the Spice-devel mailing list