[Spice-devel] [PATCH 3/6] LZ4: Decode the image format from the stream
Javier Celaya
javier.celaya at flexvm.es
Wed Jan 28 02:49:46 PST 2015
---
common/canvas_base.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 0dd438a..d2162f2 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -557,6 +557,8 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int
uint8_t *dest, *data, *data_end;
int width, height, top_down;
LZ4_streamDecode_t *stream;
+ uint8_t spice_format;
+ pixman_format_code_t format;
spice_chunks_linearize(image->u.lz4.data);
data = image->u.lz4.data->chunk[0].data;
@@ -564,12 +566,28 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int
width = image->descriptor.width;
height = image->descriptor.height;
top_down = *(data++);
+ spice_format = *(data++);
+ switch (spice_format) {
+ case SPICE_BITMAP_FMT_16BIT:
+ format = PIXMAN_x1r5g5b5;
+ break;
+ case SPICE_BITMAP_FMT_24BIT:
+ case SPICE_BITMAP_FMT_32BIT:
+ format = PIXMAN_x8r8g8b8;
+ break;
+ case SPICE_BITMAP_FMT_RGBA:
+ format = PIXMAN_a8r8g8b8;
+ break;
+ default:
+ spice_warning("Unsupported bitmap format %d with LZ4\n", spice_format);
+ return NULL;
+ }
surface = surface_create(
#ifdef WIN32
canvas->dc,
#endif
- PIXMAN_a8r8g8b8,
+ format,
width, height, top_down);
if (surface == NULL) {
spice_warning("create surface failed");
--
1.9.3
More information about the Spice-devel
mailing list