[Spice-commits] 3 commits - server/dcc-encoders.c server/dcc-encoders.h server/dcc.c server/dcc.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Jun 9 20:15:38 UTC 2016
server/dcc-encoders.c | 105 +++++++++++++++++++++++++++++++++++++++++++-------
server/dcc-encoders.h | 16 +++++++
server/dcc.c | 76 ------------------------------------
server/dcc.h | 12 +----
4 files changed, 113 insertions(+), 96 deletions(-)
New commits:
commit fa0a579a65fcea41909d4105b8fa08e326adb166
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Jun 3 15:17:41 2016 +0100
Move image_encoders_compress_quic to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
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..00191a0 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,
commit 645b8af35b1c4d48586d4b883c93b28366b33d99
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Jun 9 11:34:46 2016 +0100
Prepare to move dcc_compress_image_quic to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index f911bb0..5019bdf 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -1026,15 +1026,16 @@ static int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
}
#endif
-static int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data)
+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 = &dcc->encoders.quic_data;
- QuicContext *quic = dcc->encoders.quic;
+ 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, &DCC_TO_DC(dcc)->quic_stat);
+ stat_start_time_init(&start_time, stats);
#ifdef COMPRESS_DEBUG
spice_info("QUIC compress");
@@ -1094,7 +1095,7 @@ static int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
o_comp_data->comp_buf = quic_data->data.bufs_head;
o_comp_data->comp_buf_size = size << 2;
- stat_compress_add(&DCC_TO_DC(dcc)->quic_stat, start_time, src->stride * src->y,
+ stat_compress_add(stats, start_time, src->stride * src->y,
o_comp_data->comp_buf_size);
return TRUE;
}
@@ -1205,7 +1206,8 @@ int dcc_compress_image(DisplayChannelClient *dcc,
success = dcc_compress_image_jpeg(dcc, dest, src, o_comp_data);
break;
}
- success = dcc_compress_image_quic(dcc, dest, src, o_comp_data);
+ success = image_encoders_compress_quic(&dcc->encoders, dest, src, o_comp_data,
+ &display_channel->quic_stat);
break;
case SPICE_IMAGE_COMPRESSION_GLZ:
if ((src->x * src->y) < glz_enc_dictionary_get_size(dcc->glz_dict->dict)) {
commit d7fb16c80e6c8e1558c37752d1688f047f829ec4
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Jun 9 11:33:28 2016 +0100
Encapsulate quic information in a new ImageEncoders structure
Start putting all encoding code into dcc-encoders.c.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index a657887..1ccfdc1 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -291,19 +291,19 @@ static int zlib_usr_more_input(ZlibEncoderUsrContext *usr, uint8_t** input)
return buf_size;
}
-static void dcc_init_quic(DisplayChannelClient *dcc)
+static void image_encoders_init_quic(ImageEncoders *enc)
{
- dcc->quic_data.usr.error = quic_usr_error;
- dcc->quic_data.usr.warn = quic_usr_warn;
- dcc->quic_data.usr.info = quic_usr_warn;
- dcc->quic_data.usr.malloc = quic_usr_malloc;
- dcc->quic_data.usr.free = quic_usr_free;
- dcc->quic_data.usr.more_space = quic_usr_more_space;
- dcc->quic_data.usr.more_lines = quic_usr_more_lines;
+ enc->quic_data.usr.error = quic_usr_error;
+ enc->quic_data.usr.warn = quic_usr_warn;
+ enc->quic_data.usr.info = quic_usr_warn;
+ enc->quic_data.usr.malloc = quic_usr_malloc;
+ enc->quic_data.usr.free = quic_usr_free;
+ enc->quic_data.usr.more_space = quic_usr_more_space;
+ enc->quic_data.usr.more_lines = quic_usr_more_lines;
- dcc->quic = quic_create(&dcc->quic_data.usr);
+ enc->quic = quic_create(&enc->quic_data.usr);
- if (!dcc->quic) {
+ if (!enc->quic) {
spice_critical("create quic failed");
}
}
@@ -400,8 +400,10 @@ static void dcc_init_zlib(DisplayChannelClient *dcc)
void dcc_encoders_init(DisplayChannelClient *dcc)
{
+ ImageEncoders *enc = &dcc->encoders;
+
dcc_init_glz_data(dcc);
- dcc_init_quic(dcc);
+ image_encoders_init_quic(enc);
dcc_init_lz(dcc);
dcc_init_jpeg(dcc);
#ifdef USE_LZ4
@@ -415,8 +417,9 @@ void dcc_encoders_init(DisplayChannelClient *dcc)
void dcc_encoders_free(DisplayChannelClient *dcc)
{
- quic_destroy(dcc->quic);
- dcc->quic = NULL;
+ ImageEncoders *enc = &dcc->encoders;
+ quic_destroy(enc->quic);
+ enc->quic = NULL;
lz_destroy(dcc->lz);
dcc->lz = NULL;
jpeg_encoder_destroy(dcc->jpeg);
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 8c3f22f..8ca66c9 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -34,6 +34,7 @@
typedef struct RedCompressBuf RedCompressBuf;
typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem;
typedef struct RedGlzDrawable RedGlzDrawable;
+typedef struct ImageEncoders ImageEncoders;
void dcc_encoders_init (DisplayChannelClient *dcc);
void dcc_encoders_free (DisplayChannelClient *dcc);
@@ -160,6 +161,11 @@ struct RedGlzDrawable {
DisplayChannelClient *dcc;
};
+struct ImageEncoders {
+ QuicData quic_data;
+ QuicContext *quic;
+};
+
#define RED_RELEASE_BUNCH_SIZE 64
#endif /* DCC_ENCODERS_H_ */
diff --git a/server/dcc.c b/server/dcc.c
index a88f8e6..f911bb0 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -1029,8 +1029,8 @@ static int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
static int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
SpiceBitmap *src, compress_send_data_t* o_comp_data)
{
- QuicData *quic_data = &dcc->quic_data;
- QuicContext *quic = dcc->quic;
+ QuicData *quic_data = &dcc->encoders.quic_data;
+ QuicContext *quic = dcc->encoders.quic;
volatile QuicImageType type;
int size, stride;
stat_start_time_t start_time;
diff --git a/server/dcc.h b/server/dcc.h
index a11d25a..e1cc099 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -61,10 +61,11 @@ struct DisplayChannelClient {
spice_wan_compression_t jpeg_state;
spice_wan_compression_t zlib_glz_state;
int jpeg_quality;
+
+ ImageEncoders encoders;
+
int zlib_level;
- QuicData quic_data;
- QuicContext *quic;
LzData lz_data;
LzContext *lz;
JpegData jpeg_data;
More information about the Spice-commits
mailing list