[Spice-devel] [PATCH v2 01/30] Encapsulate quic information in a new ImageEncoders structure

Jonathon Jongsma jjongsma at redhat.com
Thu Jun 9 19:42:53 UTC 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>



On Thu, 2016-06-09 at 13:31 +0100, Frediano Ziglio wrote:
> Start putting all encoding code into dcc-encoders.c.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/dcc-encoders.c | 29 ++++++++++++++++-------------
>  server/dcc-encoders.h |  6 ++++++
>  server/dcc.c          |  4 ++--
>  server/dcc.h          |  5 +++--
>  4 files changed, 27 insertions(+), 17 deletions(-)
> 
> 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                           (DisplayChannelC
> lient *dcc);
>  void             dcc_encoders_free                           (DisplayChannelC
> lient *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-devel mailing list