Re: [PATCH 12/30] Move dcc_compress_image_lz4 to dcc-encoders.c

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

 



Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>


On Tue, 2016-06-07 at 11:17 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/dcc-encoders.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
>  server/dcc-encoders.h |  3 +++
>  server/dcc.c          | 52 --------------------------------------------------
> -
>  3 files changed, 53 insertions(+), 52 deletions(-)
> 
> diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
> index dadcb07..c4b85d3 100644
> --- a/server/dcc-encoders.c
> +++ b/server/dcc-encoders.c
> @@ -988,4 +988,54 @@ int dcc_compress_image_jpeg(EncodersData *enc, SpiceImage
> *dest,
>      return TRUE;
>  }
>  
> +#ifdef USE_LZ4
> +int dcc_compress_image_lz4(EncodersData *enc, SpiceImage *dest,
> +                           SpiceBitmap *src, compress_send_data_t*
> o_comp_data,
> +                           stat_info_t *stats)
> +{
> +    Lz4Data *lz4_data = &enc->lz4_data;
> +    Lz4EncoderContext *lz4 = enc->lz4;
> +    int lz4_size = 0;
> +    stat_start_time_t start_time;
> +    stat_start_time_init(&start_time, stats);
> +
> +#ifdef COMPRESS_DEBUG
> +    spice_info("LZ4 compress");
> +#endif
>  
> +    encoder_data_init(&lz4_data->data);
> +
> +    if (setjmp(lz4_data->data.jmp_env)) {
> +        encoder_data_reset(&lz4_data->data);
> +        return FALSE;
> +    }
> +
> +    if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) {
> +        spice_chunks_linearize(src->data);
> +    }
> +
> +    lz4_data->data.u.lines_data.chunks = src->data;
> +    lz4_data->data.u.lines_data.stride = src->stride;
> +    lz4_data->data.u.lines_data.next = 0;
> +    lz4_data->data.u.lines_data.reverse = 0;
> +
> +    lz4_size = lz4_encode(lz4, src->y, src->stride, lz4_data->data.bufs_head-
> >buf.bytes,
> +                          sizeof(lz4_data->data.bufs_head->buf),
> +                          src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN, src-
> >format);
> +
> +    // the compressed buffer is bigger than the original data
> +    if (lz4_size > (src->y * src->stride)) {
> +        longjmp(lz4_data->data.jmp_env, 1);
> +    }
> +
> +    dest->descriptor.type = SPICE_IMAGE_TYPE_LZ4;
> +    dest->u.lz4.data_size = lz4_size;
> +
> +    o_comp_data->comp_buf = lz4_data->data.bufs_head;
> +    o_comp_data->comp_buf_size = lz4_size;
> +
> +    stat_compress_add(stats, start_time, src->stride * src->y,
> +                      o_comp_data->comp_buf_size);
> +    return TRUE;
> +}
> +#endif
> diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
> index eb34785..e682b05 100644
> --- a/server/dcc-encoders.h
> +++ b/server/dcc-encoders.h
> @@ -198,6 +198,9 @@ int dcc_compress_image_jpeg(EncodersData *enc, SpiceImage
> *dest,
>                              SpiceBitmap *src, compress_send_data_t*
> o_comp_data,
>                              stat_info_t *jpeg_stats,
>                              stat_info_t *jpeg_alpha_stats);
> +int dcc_compress_image_lz4(EncodersData *enc, SpiceImage *dest,
> +                           SpiceBitmap *src, compress_send_data_t*
> o_comp_data,
> +                           stat_info_t *stats);
>  
>  #define RED_RELEASE_BUNCH_SIZE 64
>  
> diff --git a/server/dcc.c b/server/dcc.c
> index aeaa2eb..c59858c 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -784,58 +784,6 @@ glz:
>      return TRUE;
>  }
>  
> -#ifdef USE_LZ4
> -static int dcc_compress_image_lz4(EncodersData *enc, SpiceImage *dest,
> -                                  SpiceBitmap *src, compress_send_data_t*
> o_comp_data,
> -                                  stat_info_t *stats)
> -{
> -    Lz4Data *lz4_data = &enc->lz4_data;
> -    Lz4EncoderContext *lz4 = enc->lz4;
> -    int lz4_size = 0;
> -    stat_start_time_t start_time;
> -    stat_start_time_init(&start_time, stats);
> -
> -#ifdef COMPRESS_DEBUG
> -    spice_info("LZ4 compress");
> -#endif
> -
> -    encoder_data_init(&lz4_data->data);
> -
> -    if (setjmp(lz4_data->data.jmp_env)) {
> -        encoder_data_reset(&lz4_data->data);
> -        return FALSE;
> -    }
> -
> -    if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) {
> -        spice_chunks_linearize(src->data);
> -    }
> -
> -    lz4_data->data.u.lines_data.chunks = src->data;
> -    lz4_data->data.u.lines_data.stride = src->stride;
> -    lz4_data->data.u.lines_data.next = 0;
> -    lz4_data->data.u.lines_data.reverse = 0;
> -
> -    lz4_size = lz4_encode(lz4, src->y, src->stride, lz4_data->data.bufs_head-
> >buf.bytes,
> -                          sizeof(lz4_data->data.bufs_head->buf),
> -                          src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN, src-
> >format);
> -
> -    // the compressed buffer is bigger than the original data
> -    if (lz4_size > (src->y * src->stride)) {
> -        longjmp(lz4_data->data.jmp_env, 1);
> -    }
> -
> -    dest->descriptor.type = SPICE_IMAGE_TYPE_LZ4;
> -    dest->u.lz4.data_size = lz4_size;
> -
> -    o_comp_data->comp_buf = lz4_data->data.bufs_head;
> -    o_comp_data->comp_buf_size = lz4_size;
> -
> -    stat_compress_add(stats, start_time, src->stride * src->y,
> -                      o_comp_data->comp_buf_size);
> -    return TRUE;
> -}
> -#endif
> -
>  #define MIN_DIMENSION_TO_QUIC 3
>  /**
>   * quic doesn't handle:

_______________________________________________
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]