[Spice-devel] [PATCH v2 04/30] Encapsulate lz information in ImageEncoders structure
Frediano Ziglio
fziglio at redhat.com
Thu Jun 9 12:31:24 UTC 2016
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/dcc-encoders.c | 26 +++++++++++++-------------
server/dcc-encoders.h | 3 +++
server/dcc.c | 8 ++++----
server/dcc.h | 2 --
4 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index a17efe6..2ccbb66 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -308,19 +308,19 @@ static void image_encoders_init_quic(ImageEncoders *enc)
}
}
-static void dcc_init_lz(DisplayChannelClient *dcc)
+static void image_encoders_init_lz(ImageEncoders *enc)
{
- dcc->lz_data.usr.error = lz_usr_error;
- dcc->lz_data.usr.warn = lz_usr_warn;
- dcc->lz_data.usr.info = lz_usr_warn;
- dcc->lz_data.usr.malloc = lz_usr_malloc;
- dcc->lz_data.usr.free = lz_usr_free;
- dcc->lz_data.usr.more_space = lz_usr_more_space;
- dcc->lz_data.usr.more_lines = lz_usr_more_lines;
+ enc->lz_data.usr.error = lz_usr_error;
+ enc->lz_data.usr.warn = lz_usr_warn;
+ enc->lz_data.usr.info = lz_usr_warn;
+ enc->lz_data.usr.malloc = lz_usr_malloc;
+ enc->lz_data.usr.free = lz_usr_free;
+ enc->lz_data.usr.more_space = lz_usr_more_space;
+ enc->lz_data.usr.more_lines = lz_usr_more_lines;
- dcc->lz = lz_create(&dcc->lz_data.usr);
+ enc->lz = lz_create(&enc->lz_data.usr);
- if (!dcc->lz) {
+ if (!enc->lz) {
spice_critical("create lz failed");
}
}
@@ -404,7 +404,7 @@ void dcc_encoders_init(DisplayChannelClient *dcc)
dcc_init_glz_data(dcc);
image_encoders_init_quic(enc);
- dcc_init_lz(dcc);
+ image_encoders_init_lz(enc);
dcc_init_jpeg(dcc);
#ifdef USE_LZ4
dcc_init_lz4(dcc);
@@ -420,8 +420,8 @@ void dcc_encoders_free(DisplayChannelClient *dcc)
ImageEncoders *enc = &dcc->encoders;
quic_destroy(enc->quic);
enc->quic = NULL;
- lz_destroy(dcc->lz);
- dcc->lz = NULL;
+ lz_destroy(enc->lz);
+ enc->lz = NULL;
jpeg_encoder_destroy(dcc->jpeg);
dcc->jpeg = NULL;
#ifdef USE_LZ4
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 8d00409..03d5ee7 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -164,6 +164,9 @@ struct RedGlzDrawable {
struct ImageEncoders {
QuicData quic_data;
QuicContext *quic;
+
+ LzData lz_data;
+ LzContext *lz;
};
typedef struct compress_send_data_t {
diff --git a/server/dcc.c b/server/dcc.c
index 17809d4..04ef5fb 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -788,8 +788,8 @@ static int dcc_compress_image_lz(DisplayChannelClient *dcc,
SpiceImage *dest, SpiceBitmap *src,
compress_send_data_t* o_comp_data)
{
- LzData *lz_data = &dcc->lz_data;
- LzContext *lz = dcc->lz;
+ LzData *lz_data = &dcc->encoders.lz_data;
+ LzContext *lz = dcc->encoders.lz;
LzImageType type = bitmap_fmt_to_lz_image_type[src->format];
int size; // size of the compressed data
@@ -854,9 +854,9 @@ static int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
SpiceBitmap *src, compress_send_data_t* o_comp_data)
{
JpegData *jpeg_data = &dcc->jpeg_data;
- LzData *lz_data = &dcc->lz_data;
+ LzData *lz_data = &dcc->encoders.lz_data;
JpegEncoderContext *jpeg = dcc->jpeg;
- LzContext *lz = dcc->lz;
+ LzContext *lz = dcc->encoders.lz;
volatile JpegEncoderImageType jpeg_in_type;
int jpeg_size = 0;
volatile int has_alpha = FALSE;
diff --git a/server/dcc.h b/server/dcc.h
index 62f1851..d10ba87 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -66,8 +66,6 @@ struct DisplayChannelClient {
int zlib_level;
- LzData lz_data;
- LzContext *lz;
JpegData jpeg_data;
JpegEncoderContext *jpeg;
#ifdef USE_LZ4
--
2.7.4
More information about the Spice-devel
mailing list