Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/dcc-encoders.c | 16 ++++++++-------- server/dcc-encoders.h | 5 +++++ server/dcc.c | 8 ++++---- server/dcc.h | 3 --- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c index e795065..279c134 100644 --- a/server/dcc-encoders.c +++ b/server/dcc-encoders.c @@ -360,14 +360,14 @@ static void dcc_init_glz_data(DisplayChannelClient *dcc) dcc->glz_data.usr.free_image = glz_usr_free_image; } -static void dcc_init_jpeg(DisplayChannelClient *dcc) +static void image_encoders_init_jpeg(ImageEncoders *enc) { - dcc->jpeg_data.usr.more_space = jpeg_usr_more_space; - dcc->jpeg_data.usr.more_lines = jpeg_usr_more_lines; + enc->jpeg_data.usr.more_space = jpeg_usr_more_space; + enc->jpeg_data.usr.more_lines = jpeg_usr_more_lines; - dcc->jpeg = jpeg_encoder_create(&dcc->jpeg_data.usr); + enc->jpeg = jpeg_encoder_create(&enc->jpeg_data.usr); - if (!dcc->jpeg) { + if (!enc->jpeg) { spice_critical("create jpeg encoder failed"); } } @@ -405,7 +405,7 @@ void dcc_encoders_init(DisplayChannelClient *dcc) dcc_init_glz_data(dcc); image_encoders_init_quic(enc); image_encoders_init_lz(enc); - dcc_init_jpeg(dcc); + image_encoders_init_jpeg(enc); #ifdef USE_LZ4 dcc_init_lz4(dcc); #endif @@ -422,8 +422,8 @@ void dcc_encoders_free(DisplayChannelClient *dcc) enc->quic = NULL; lz_destroy(enc->lz); enc->lz = NULL; - jpeg_encoder_destroy(dcc->jpeg); - dcc->jpeg = NULL; + jpeg_encoder_destroy(enc->jpeg); + enc->jpeg = NULL; #ifdef USE_LZ4 lz4_encoder_destroy(dcc->lz4); dcc->lz4 = NULL; diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h index 21e2fa4..5bb0208 100644 --- a/server/dcc-encoders.h +++ b/server/dcc-encoders.h @@ -167,6 +167,11 @@ struct ImageEncoders { LzData lz_data; LzContext *lz; + + int jpeg_quality; + + JpegData jpeg_data; + JpegEncoderContext *jpeg; }; typedef struct compress_send_data_t { diff --git a/server/dcc.c b/server/dcc.c index 2d715d9..b5fbb09 100644 --- a/server/dcc.c +++ b/server/dcc.c @@ -379,7 +379,7 @@ DisplayChannelClient *dcc_new(DisplayChannel *display, dcc->jpeg_state = jpeg_state; dcc->zlib_glz_state = zlib_glz_state; // TODO: tune quality according to bandwidth - dcc->jpeg_quality = 85; + dcc->encoders.jpeg_quality = 85; size_t stream_buf_size; stream_buf_size = 32*1024; @@ -787,9 +787,9 @@ glz: 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; + JpegData *jpeg_data = &dcc->encoders.jpeg_data; LzData *lz_data = &dcc->encoders.lz_data; - JpegEncoderContext *jpeg = dcc->jpeg; + JpegEncoderContext *jpeg = dcc->encoders.jpeg; LzContext *lz = dcc->encoders.lz; volatile JpegEncoderImageType jpeg_in_type; int jpeg_size = 0; @@ -846,7 +846,7 @@ static int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest, jpeg_data->data.u.lines_data.reverse = 1; stride = -src->stride; } - jpeg_size = jpeg_encode(jpeg, dcc->jpeg_quality, jpeg_in_type, + jpeg_size = jpeg_encode(jpeg, dcc->encoders.jpeg_quality, jpeg_in_type, src->x, src->y, NULL, 0, stride, jpeg_data->data.bufs_head->buf.bytes, sizeof(jpeg_data->data.bufs_head->buf)); diff --git a/server/dcc.h b/server/dcc.h index d10ba87..034b9b1 100644 --- a/server/dcc.h +++ b/server/dcc.h @@ -60,14 +60,11 @@ struct DisplayChannelClient { SpiceImageCompression image_compression; spice_wan_compression_t jpeg_state; spice_wan_compression_t zlib_glz_state; - int jpeg_quality; ImageEncoders encoders; int zlib_level; - JpegData jpeg_data; - JpegEncoderContext *jpeg; #ifdef USE_LZ4 Lz4Data lz4_data; Lz4EncoderContext *lz4; -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel