Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/dcc-encoders.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ server/dcc-encoders.h | 3 +++ server/dcc.c | 52 --------------------------------------------------- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c index 8790512..7b27aff 100644 --- a/server/dcc-encoders.c +++ b/server/dcc-encoders.c @@ -989,4 +989,54 @@ int image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest, return TRUE; } +#ifdef USE_LZ4 +int image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest, + SpiceBitmap *src, compress_send_data_t* o_comp_data, + stat_info_t *stats) +{ + Lz4Data *lz4_data = &enc->lz4_data; + Lz4EncoderContext *lz4 = enc->lz4; + int lz4_size = 0; + stat_start_time_t start_time; + stat_start_time_init(&start_time, stats); + +#ifdef COMPRESS_DEBUG + spice_info("LZ4 compress"); +#endif + encoder_data_init(&lz4_data->data); + + if (setjmp(lz4_data->data.jmp_env)) { + encoder_data_reset(&lz4_data->data); + return FALSE; + } + + if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) { + spice_chunks_linearize(src->data); + } + + lz4_data->data.u.lines_data.chunks = src->data; + lz4_data->data.u.lines_data.stride = src->stride; + lz4_data->data.u.lines_data.next = 0; + lz4_data->data.u.lines_data.reverse = 0; + + lz4_size = lz4_encode(lz4, src->y, src->stride, lz4_data->data.bufs_head->buf.bytes, + sizeof(lz4_data->data.bufs_head->buf), + 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)) { + longjmp(lz4_data->data.jmp_env, 1); + } + + dest->descriptor.type = SPICE_IMAGE_TYPE_LZ4; + dest->u.lz4.data_size = lz4_size; + + o_comp_data->comp_buf = lz4_data->data.bufs_head; + o_comp_data->comp_buf_size = lz4_size; + + stat_compress_add(stats, start_time, src->stride * src->y, + o_comp_data->comp_buf_size); + return TRUE; +} +#endif diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h index d540cd3..1fb9e7c 100644 --- a/server/dcc-encoders.h +++ b/server/dcc-encoders.h @@ -197,6 +197,9 @@ int image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest, SpiceBitmap *src, compress_send_data_t* o_comp_data, stat_info_t *jpeg_stats, stat_info_t *jpeg_alpha_stats); +int image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest, + SpiceBitmap *src, compress_send_data_t* o_comp_data, + stat_info_t *stats); #define RED_RELEASE_BUNCH_SIZE 64 diff --git a/server/dcc.c b/server/dcc.c index 4e65d55..0bc0e04 100644 --- a/server/dcc.c +++ b/server/dcc.c @@ -784,58 +784,6 @@ glz: return TRUE; } -#ifdef USE_LZ4 -static int image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest, - SpiceBitmap *src, compress_send_data_t* o_comp_data, - stat_info_t *stats) -{ - Lz4Data *lz4_data = &enc->lz4_data; - Lz4EncoderContext *lz4 = enc->lz4; - int lz4_size = 0; - stat_start_time_t start_time; - stat_start_time_init(&start_time, stats); - -#ifdef COMPRESS_DEBUG - spice_info("LZ4 compress"); -#endif - - encoder_data_init(&lz4_data->data); - - if (setjmp(lz4_data->data.jmp_env)) { - encoder_data_reset(&lz4_data->data); - return FALSE; - } - - if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) { - spice_chunks_linearize(src->data); - } - - lz4_data->data.u.lines_data.chunks = src->data; - lz4_data->data.u.lines_data.stride = src->stride; - lz4_data->data.u.lines_data.next = 0; - lz4_data->data.u.lines_data.reverse = 0; - - lz4_size = lz4_encode(lz4, src->y, src->stride, lz4_data->data.bufs_head->buf.bytes, - sizeof(lz4_data->data.bufs_head->buf), - 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)) { - longjmp(lz4_data->data.jmp_env, 1); - } - - dest->descriptor.type = SPICE_IMAGE_TYPE_LZ4; - dest->u.lz4.data_size = lz4_size; - - o_comp_data->comp_buf = lz4_data->data.bufs_head; - o_comp_data->comp_buf_size = lz4_size; - - stat_compress_add(stats, start_time, src->stride * src->y, - o_comp_data->comp_buf_size); - return TRUE; -} -#endif - #define MIN_DIMENSION_TO_QUIC 3 /** * quic doesn't handle: -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel