Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/dcc-encoders.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ server/dcc-encoders.h | 10 +++++++ server/dcc.c | 74 ------------------------------------------------- server/dcc.h | 7 ----- 4 files changed, 86 insertions(+), 81 deletions(-) diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c index 1ccfdc1..a17efe6 100644 --- a/server/dcc-encoders.c +++ b/server/dcc-encoders.c @@ -707,3 +707,79 @@ void dcc_release_glz(DisplayChannelClient *dcc) glz_enc_dictionary_destroy(shared_dict->dict, &dcc->glz_data.usr); free(shared_dict); } + +int image_encoders_compress_quic(ImageEncoders *enc, SpiceImage *dest, + SpiceBitmap *src, compress_send_data_t* o_comp_data, + stat_info_t *stats) +{ + QuicData *quic_data = &enc->quic_data; + QuicContext *quic = enc->quic; + volatile QuicImageType type; + int size, stride; + stat_start_time_t start_time; + stat_start_time_init(&start_time, stats); + +#ifdef COMPRESS_DEBUG + spice_info("QUIC compress"); +#endif + + switch (src->format) { + case SPICE_BITMAP_FMT_32BIT: + type = QUIC_IMAGE_TYPE_RGB32; + break; + case SPICE_BITMAP_FMT_RGBA: + type = QUIC_IMAGE_TYPE_RGBA; + break; + case SPICE_BITMAP_FMT_16BIT: + type = QUIC_IMAGE_TYPE_RGB16; + break; + case SPICE_BITMAP_FMT_24BIT: + type = QUIC_IMAGE_TYPE_RGB24; + break; + default: + return FALSE; + } + + encoder_data_init(&quic_data->data); + + if (setjmp(quic_data->data.jmp_env)) { + encoder_data_reset(&quic_data->data); + return FALSE; + } + + if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) { + spice_chunks_linearize(src->data); + } + + quic_data->data.u.lines_data.chunks = src->data; + quic_data->data.u.lines_data.stride = src->stride; + if ((src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) { + quic_data->data.u.lines_data.next = 0; + quic_data->data.u.lines_data.reverse = 0; + stride = src->stride; + } else { + quic_data->data.u.lines_data.next = src->data->num_chunks - 1; + quic_data->data.u.lines_data.reverse = 1; + stride = -src->stride; + } + size = quic_encode(quic, type, src->x, src->y, NULL, 0, stride, + quic_data->data.bufs_head->buf.words, + G_N_ELEMENTS(quic_data->data.bufs_head->buf.words)); + + // the compressed buffer is bigger than the original data + if ((size << 2) > (src->y * src->stride)) { + longjmp(quic_data->data.jmp_env, 1); + } + + dest->descriptor.type = SPICE_IMAGE_TYPE_QUIC; + dest->u.quic.data_size = size << 2; + + o_comp_data->comp_buf = quic_data->data.bufs_head; + o_comp_data->comp_buf_size = size << 2; + + 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 8ca66c9..8d00409 100644 --- a/server/dcc-encoders.h +++ b/server/dcc-encoders.h @@ -166,6 +166,16 @@ struct ImageEncoders { QuicContext *quic; }; +typedef struct compress_send_data_t { + void* comp_buf; + uint32_t comp_buf_size; + SpicePalette *lzplt_palette; + int is_lossy; +} compress_send_data_t; + +int image_encoders_compress_quic(ImageEncoders *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 5019bdf..17809d4 100644 --- a/server/dcc.c +++ b/server/dcc.c @@ -1026,80 +1026,6 @@ static int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest, } #endif -static int image_encoders_compress_quic(ImageEncoders *enc, SpiceImage *dest, - SpiceBitmap *src, compress_send_data_t* o_comp_data, - stat_info_t *stats) -{ - QuicData *quic_data = &enc->quic_data; - QuicContext *quic = enc->quic; - volatile QuicImageType type; - int size, stride; - stat_start_time_t start_time; - stat_start_time_init(&start_time, stats); - -#ifdef COMPRESS_DEBUG - spice_info("QUIC compress"); -#endif - - switch (src->format) { - case SPICE_BITMAP_FMT_32BIT: - type = QUIC_IMAGE_TYPE_RGB32; - break; - case SPICE_BITMAP_FMT_RGBA: - type = QUIC_IMAGE_TYPE_RGBA; - break; - case SPICE_BITMAP_FMT_16BIT: - type = QUIC_IMAGE_TYPE_RGB16; - break; - case SPICE_BITMAP_FMT_24BIT: - type = QUIC_IMAGE_TYPE_RGB24; - break; - default: - return FALSE; - } - - encoder_data_init(&quic_data->data); - - if (setjmp(quic_data->data.jmp_env)) { - encoder_data_reset(&quic_data->data); - return FALSE; - } - - if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) { - spice_chunks_linearize(src->data); - } - - quic_data->data.u.lines_data.chunks = src->data; - quic_data->data.u.lines_data.stride = src->stride; - if ((src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) { - quic_data->data.u.lines_data.next = 0; - quic_data->data.u.lines_data.reverse = 0; - stride = src->stride; - } else { - quic_data->data.u.lines_data.next = src->data->num_chunks - 1; - quic_data->data.u.lines_data.reverse = 1; - stride = -src->stride; - } - size = quic_encode(quic, type, src->x, src->y, NULL, 0, stride, - quic_data->data.bufs_head->buf.words, - G_N_ELEMENTS(quic_data->data.bufs_head->buf.words)); - - // the compressed buffer is bigger than the original data - if ((size << 2) > (src->y * src->stride)) { - longjmp(quic_data->data.jmp_env, 1); - } - - dest->descriptor.type = SPICE_IMAGE_TYPE_QUIC; - dest->u.quic.data_size = size << 2; - - o_comp_data->comp_buf = quic_data->data.bufs_head; - o_comp_data->comp_buf_size = size << 2; - - stat_compress_add(stats, start_time, src->stride * src->y, - o_comp_data->comp_buf_size); - return TRUE; -} - #define MIN_DIMENSION_TO_QUIC 3 /** * quic doesn't handle: diff --git a/server/dcc.h b/server/dcc.h index e1cc099..62f1851 100644 --- a/server/dcc.h +++ b/server/dcc.h @@ -216,13 +216,6 @@ RedPipeItem * dcc_gl_scanout_item_new (RedChannel RedPipeItem * dcc_gl_draw_item_new (RedChannelClient *rcc, void *data, int num); -typedef struct compress_send_data_t { - void* comp_buf; - uint32_t comp_buf_size; - SpicePalette *lzplt_palette; - int is_lossy; -} compress_send_data_t; - int dcc_compress_image (DisplayChannelClient *dcc, SpiceImage *dest, SpiceBitmap *src, Drawable *drawable, int can_lossy, -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel