[PATCH 08/30] Move dcc_compress_image_lz to dcc-encoders.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/dcc-encoders.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 server/dcc-encoders.h |  5 ++++
 server/dcc.c          | 66 ------------------------------------------
 3 files changed, 85 insertions(+), 66 deletions(-)

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 54b970a..015f677 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -781,4 +781,84 @@ int dcc_compress_image_quic(EncodersData *enc, SpiceImage *dest,
     return TRUE;
 }
 
+static const LzImageType bitmap_fmt_to_lz_image_type[] = {
+    LZ_IMAGE_TYPE_INVALID,
+    LZ_IMAGE_TYPE_PLT1_LE,
+    LZ_IMAGE_TYPE_PLT1_BE,
+    LZ_IMAGE_TYPE_PLT4_LE,
+    LZ_IMAGE_TYPE_PLT4_BE,
+    LZ_IMAGE_TYPE_PLT8,
+    LZ_IMAGE_TYPE_RGB16,
+    LZ_IMAGE_TYPE_RGB24,
+    LZ_IMAGE_TYPE_RGB32,
+    LZ_IMAGE_TYPE_RGBA,
+    LZ_IMAGE_TYPE_A8
+};
+
+int dcc_compress_image_lz(EncodersData *enc,
+                          SpiceImage *dest, SpiceBitmap *src,
+                          compress_send_data_t* o_comp_data,
+                          stat_info_t *stats)
+{
+    LzData *lz_data = &enc->lz_data;
+    LzContext *lz = enc->lz;
+    LzImageType type = bitmap_fmt_to_lz_image_type[src->format];
+    int size;            // size of the compressed data
+
+    stat_start_time_t start_time;
+    stat_start_time_init(&start_time, stats);
+
+#ifdef COMPRESS_DEBUG
+    spice_info("LZ LOCAL compress");
+#endif
+
+    encoder_data_init(&lz_data->data);
+
+    if (setjmp(lz_data->data.jmp_env)) {
+        encoder_data_reset(&lz_data->data);
+        return FALSE;
+    }
+
+    lz_data->data.u.lines_data.chunks = src->data;
+    lz_data->data.u.lines_data.stride = src->stride;
+    lz_data->data.u.lines_data.next = 0;
+    lz_data->data.u.lines_data.reverse = 0;
+
+    size = lz_encode(lz, type, src->x, src->y,
+                     !!(src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN),
+                     NULL, 0, src->stride,
+                     lz_data->data.bufs_head->buf.bytes,
+                     sizeof(lz_data->data.bufs_head->buf));
+
+    // the compressed buffer is bigger than the original data
+    if (size > (src->y * src->stride)) {
+        longjmp(lz_data->data.jmp_env, 1);
+    }
+
+    if (bitmap_fmt_is_rgb(src->format)) {
+        dest->descriptor.type = SPICE_IMAGE_TYPE_LZ_RGB;
+        dest->u.lz_rgb.data_size = size;
+
+        o_comp_data->comp_buf = lz_data->data.bufs_head;
+        o_comp_data->comp_buf_size = size;
+    } else {
+        /* masks are 1BIT bitmaps without palettes, but they are not compressed
+         * (see fill_mask) */
+        spice_assert(src->palette);
+        dest->descriptor.type = SPICE_IMAGE_TYPE_LZ_PLT;
+        dest->u.lz_plt.data_size = size;
+        dest->u.lz_plt.flags = src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN;
+        dest->u.lz_plt.palette = src->palette;
+        dest->u.lz_plt.palette_id = src->palette->unique;
+        o_comp_data->comp_buf = lz_data->data.bufs_head;
+        o_comp_data->comp_buf_size = size;
+
+        o_comp_data->lzplt_palette = dest->u.lz_plt.palette;
+    }
+
+    stat_compress_add(stats, start_time, src->stride * src->y,
+                      o_comp_data->comp_buf_size);
+    return TRUE;
+}
+
 
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 21049cd..f008bf6 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -180,6 +180,11 @@ typedef struct compress_send_data_t {
 int dcc_compress_image_quic(EncodersData *enc, SpiceImage *dest,
                             SpiceBitmap *src, compress_send_data_t* o_comp_data,
                             stat_info_t *stats);
+int dcc_compress_image_lz(EncodersData *enc,
+                          SpiceImage *dest, SpiceBitmap *src,
+                          compress_send_data_t* o_comp_data,
+                          stat_info_t *stats);
+
 #define RED_RELEASE_BUNCH_SIZE 64
 
 #endif /* DCC_ENCODERS_H_ */
diff --git a/server/dcc.c b/server/dcc.c
index 05a511d..7bdb2bd 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -784,72 +784,6 @@ glz:
     return TRUE;
 }
 
-static int dcc_compress_image_lz(EncodersData *enc,
-                                 SpiceImage *dest, SpiceBitmap *src,
-                                 compress_send_data_t* o_comp_data,
-                                 stat_info_t *stats)
-{
-    LzData *lz_data = &enc->lz_data;
-    LzContext *lz = enc->lz;
-    LzImageType type = bitmap_fmt_to_lz_image_type[src->format];
-    int size;            // size of the compressed data
-
-    stat_start_time_t start_time;
-    stat_start_time_init(&start_time, stats);
-
-#ifdef COMPRESS_DEBUG
-    spice_info("LZ LOCAL compress");
-#endif
-
-    encoder_data_init(&lz_data->data);
-
-    if (setjmp(lz_data->data.jmp_env)) {
-        encoder_data_reset(&lz_data->data);
-        return FALSE;
-    }
-
-    lz_data->data.u.lines_data.chunks = src->data;
-    lz_data->data.u.lines_data.stride = src->stride;
-    lz_data->data.u.lines_data.next = 0;
-    lz_data->data.u.lines_data.reverse = 0;
-
-    size = lz_encode(lz, type, src->x, src->y,
-                     !!(src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN),
-                     NULL, 0, src->stride,
-                     lz_data->data.bufs_head->buf.bytes,
-                     sizeof(lz_data->data.bufs_head->buf));
-
-    // the compressed buffer is bigger than the original data
-    if (size > (src->y * src->stride)) {
-        longjmp(lz_data->data.jmp_env, 1);
-    }
-
-    if (bitmap_fmt_is_rgb(src->format)) {
-        dest->descriptor.type = SPICE_IMAGE_TYPE_LZ_RGB;
-        dest->u.lz_rgb.data_size = size;
-
-        o_comp_data->comp_buf = lz_data->data.bufs_head;
-        o_comp_data->comp_buf_size = size;
-    } else {
-        /* masks are 1BIT bitmaps without palettes, but they are not compressed
-         * (see fill_mask) */
-        spice_assert(src->palette);
-        dest->descriptor.type = SPICE_IMAGE_TYPE_LZ_PLT;
-        dest->u.lz_plt.data_size = size;
-        dest->u.lz_plt.flags = src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN;
-        dest->u.lz_plt.palette = src->palette;
-        dest->u.lz_plt.palette_id = src->palette->unique;
-        o_comp_data->comp_buf = lz_data->data.bufs_head;
-        o_comp_data->comp_buf_size = size;
-
-        o_comp_data->lzplt_palette = dest->u.lz_plt.palette;
-    }
-
-    stat_compress_add(stats, start_time, src->stride * src->y,
-                      o_comp_data->comp_buf_size);
-    return TRUE;
-}
-
 static int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
                                    SpiceBitmap *src, compress_send_data_t* o_comp_data)
 {
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]