[Spice-devel] [PATCH 4/6] LZ4: Fix the row alignment when it is not on a 32bit boundary

Christophe Fergeau cfergeau at redhat.com
Fri Jan 30 02:36:08 PST 2015


On Wed, Jan 28, 2015 at 11:49:47AM +0100, Javier Celaya wrote:
> Fix the row alignment for 16/24 bpp images when it is not in a 32bit
> boundary. This is needed for 16bpp images when the width is an odd
> number, and for the future support of 24bpp images.
> ---
> @@ -620,6 +623,21 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int
>          data += enc_size;
>      } while (data < data_end);
>  
> +    if (stride_abs > stride_encoded) {
> +        // Fix the row alignment
> +        int row;
> +        uint32_t *dest_aligned, *dest_misaligned;
> +        dest = (uint8_t *)pixman_image_get_data(surface);
> +        if (!top_down) {
> +            dest -= (stride_abs * (height - 1));
> +        }
> +        for (row = height - 1; row > 0; --row) {
> +            dest_aligned = (uint32_t *)(dest + stride_abs*row);
> +            dest_misaligned = (uint32_t*)(dest + stride_encoded*row);
> +            memmove(dest_aligned, dest_misaligned, stride_encoded);
> +        }
> +    }
> +

Looking at common/canvas_utils.c:surface_create, we don't seem to align
rows when top_down is TRUE, it seems this code will need to be more
careful in this case :(

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150130/ce7651f8/attachment.sig>


More information about the Spice-devel mailing list