Re: [PATCH v2 13/30] Encapsulate zlib information in ImageEncoders structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

On Thu, 2016-06-09 at 13:31 +0100, Frediano Ziglio wrote:
> This change is less clean the other similar patches as zlib and
> glz require more steps.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/dcc-encoders.c | 18 +++++++++---------
>  server/dcc-encoders.h |  5 +++++
>  server/dcc.c          |  4 ++--
>  server/dcc.h          |  5 -----
>  4 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
> index 7b27aff..04bb60c 100644
> --- a/server/dcc-encoders.c
> +++ b/server/dcc-encoders.c
> @@ -386,14 +386,14 @@ static inline void image_encoders_init_lz4(ImageEncoders
> *enc)
>  }
>  #endif
>  
> -static void dcc_init_zlib(DisplayChannelClient *dcc)
> +static void image_encoders_init_zlib(ImageEncoders *enc)
>  {
> -    dcc->zlib_data.usr.more_space = zlib_usr_more_space;
> -    dcc->zlib_data.usr.more_input = zlib_usr_more_input;
> +    enc->zlib_data.usr.more_space = zlib_usr_more_space;
> +    enc->zlib_data.usr.more_input = zlib_usr_more_input;
>  
> -    dcc->zlib = zlib_encoder_create(&dcc->zlib_data.usr,
> ZLIB_DEFAULT_COMPRESSION_LEVEL);
> +    enc->zlib = zlib_encoder_create(&enc->zlib_data.usr,
> ZLIB_DEFAULT_COMPRESSION_LEVEL);
>  
> -    if (!dcc->zlib) {
> +    if (!enc->zlib) {
>          spice_critical("create zlib encoder failed");
>      }
>  }
> @@ -409,10 +409,10 @@ void dcc_encoders_init(DisplayChannelClient *dcc)
>  #ifdef USE_LZ4
>      image_encoders_init_lz4(enc);
>  #endif
> -    dcc_init_zlib(dcc);
> +    image_encoders_init_zlib(enc);
>  
>      // todo: tune level according to bandwidth
> -    dcc->zlib_level = ZLIB_DEFAULT_COMPRESSION_LEVEL;
> +    enc->zlib_level = ZLIB_DEFAULT_COMPRESSION_LEVEL;
>  }
>  
>  void dcc_encoders_free(DisplayChannelClient *dcc)
> @@ -428,8 +428,8 @@ void dcc_encoders_free(DisplayChannelClient *dcc)
>      lz4_encoder_destroy(enc->lz4);
>      enc->lz4 = NULL;
>  #endif
> -    zlib_encoder_destroy(dcc->zlib);
> -    dcc->zlib = NULL;
> +    zlib_encoder_destroy(enc->zlib);
> +    enc->zlib = NULL;
>  }
>  
>  /* Remove from the to_free list and the instances_list.
> diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
> index 1fb9e7c..092e213 100644
> --- a/server/dcc-encoders.h
> +++ b/server/dcc-encoders.h
> @@ -177,6 +177,11 @@ struct ImageEncoders {
>      Lz4Data lz4_data;
>      Lz4EncoderContext *lz4;
>  #endif
> +
> +    int zlib_level;
> +
> +    ZlibData zlib_data;
> +    ZlibEncoder *zlib;
>  };
>  
>  typedef struct compress_send_data_t {
> diff --git a/server/dcc.c b/server/dcc.c
> index 0bc0e04..ee21bb1 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -746,14 +746,14 @@ static int dcc_compress_image_glz(DisplayChannelClient
> *dcc,
>          goto glz;
>      }
>      stat_start_time_init(&start_time, &display_channel->zlib_glz_stat);
> -    zlib_data = &dcc->zlib_data;
> +    zlib_data = &dcc->encoders.zlib_data;
>  
>      encoder_data_init(&zlib_data->data);
>  
>      zlib_data->data.u.compressed_data.next = glz_data->data.bufs_head;
>      zlib_data->data.u.compressed_data.size_left = glz_size;
>  
> -    zlib_size = zlib_encode(dcc->zlib, dcc->zlib_level,
> +    zlib_size = zlib_encode(dcc->encoders.zlib, dcc->encoders.zlib_level,
>                              glz_size, zlib_data->data.bufs_head->buf.bytes,
>                              sizeof(zlib_data->data.bufs_head->buf));
>  
> diff --git a/server/dcc.h b/server/dcc.h
> index bdfc001..c6c9903 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -63,11 +63,6 @@ struct DisplayChannelClient {
>  
>      ImageEncoders encoders;
>  
> -    int zlib_level;
> -
> -    ZlibData zlib_data;
> -    ZlibEncoder *zlib;
> -
>      int expect_init;
>  
>      PixmapCache *pixmap_cache;
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]