[Spice-devel] [PATCH 4/4] LZ4: Send the original format with the compressed data

Javier Celaya javier.celaya at flexvm.es
Mon Jan 26 08:22:48 PST 2015


---
 server/lz4_encoder.c | 9 +++++----
 server/lz4_encoder.h | 2 +-
 server/red_worker.c  | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/server/lz4_encoder.c b/server/lz4_encoder.c
index 2327e9a..b3e38b2 100644
--- a/server/lz4_encoder.c
+++ b/server/lz4_encoder.c
@@ -50,7 +50,7 @@ void lz4_encoder_destroy(Lz4EncoderContext* encoder)
 }
 
 int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
-               unsigned int num_io_bytes, int top_down)
+               unsigned int num_io_bytes, int top_down, uint8_t format)
 {
     Lz4Encoder *enc = (Lz4Encoder *)lz4;
     uint8_t *lines;
@@ -61,10 +61,11 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
     uint8_t *out_buf = io_ptr;
     LZ4_stream_t *stream = LZ4_createStream();
 
-    // Encode direction
+    // Encode direction and format
     *(out_buf++) = top_down ? 1 : 0;
-    num_io_bytes--;
-    out_size = 1;
+    *(out_buf++) = format;
+    num_io_bytes -= 2;
+    out_size = 2;
 
     do {
         num_lines = enc->usr->more_lines(enc->usr, &lines);
diff --git a/server/lz4_encoder.h b/server/lz4_encoder.h
index 97b8dc8..f1de12a 100644
--- a/server/lz4_encoder.h
+++ b/server/lz4_encoder.h
@@ -45,5 +45,5 @@ void lz4_encoder_destroy(Lz4EncoderContext *encoder);
 
 /* returns the total size of the encoded data. */
 int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
-               unsigned int num_io_bytes, int top_down);
+               unsigned int num_io_bytes, int top_down, uint8_t format);
 #endif
diff --git a/server/red_worker.c b/server/red_worker.c
index 922a459..58cc827 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -6459,7 +6459,7 @@ static int red_lz4_compress_image(DisplayChannelClient *dcc, SpiceImage *dest,
 
     lz4_size = lz4_encode(lz4, src->y, src->stride, (uint8_t*)lz4_data->data.bufs_head->buf,
                           sizeof(lz4_data->data.bufs_head->buf),
-                          src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN);
+                          src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN, src->format);
 
     // the compressed buffer is bigger than the original data
     if (lz4_size > (src->y * src->stride)) {
-- 
1.9.3



More information about the Spice-devel mailing list