Re: [PATCH spice-server] Use LZ4_compress_fast_continue if available

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

 



> 
> On 11/28/2016 07:50 PM, Frediano Ziglio wrote:
> > This make compression faster and avoids a warning on newer
> > lz4 versions.
> >
> > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > ---
> >  server/lz4-encoder.c | 9 ++++++++-
> >  spice-common         | 2 +-
> >  2 files changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/server/lz4-encoder.c b/server/lz4-encoder.c
> > index f193fd8..9fabc35 100644
> > --- a/server/lz4-encoder.c
> > +++ b/server/lz4-encoder.c
> 
> Hi Frediano,
> 
> Nitpick: Since the functions signatures are the same, I think
> a bit nicer is to "chose" the right function somewhere at the
> top and later use it in the code.
> 
> For example:
> 
> #ifdef HAVE_LZ4_COMPRESS_FAST_CONTINUE
> #define spice_lz4_compress_continue LZ4_compress_fast_continue
> #else
> #define spice_lz4_compress_continue LZ4_compress_continue
> #endif
> 

LZ4_compress_fast_continue have 2 additional parameters.
Perhaps however LZ4_compress_fast_continue can be implemented using
LZ4_compress_continue but looks confusing stripping a boundary
size (looks like looking for overflows).

> > @@ -75,9 +75,16 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int
> > stride, uint8_t *io_ptr,
> >          in_buf = lines;
> >          in_size = stride * num_lines;
> >          lines += in_size;
> > -        compressed_lines = (uint8_t *) malloc(LZ4_compressBound(in_size) +
> > 4);
> > +        int bound_size = LZ4_compressBound(in_size);
> > +        compressed_lines = (uint8_t *) malloc(bound_size + 4);
> > +#ifdef HAVE_LZ4_COMPRESS_FAST_CONTINUE
> > +        enc_size = LZ4_compress_fast_continue(stream, (const char *)
> > in_buf,
> > +                                              (char *) compressed_lines +
> > 4, in_size,
> > +                                              bound_size, 1);
> > +#else
> >          enc_size = LZ4_compress_continue(stream, (const char *) in_buf,
> >                                           (char *) compressed_lines + 4,
> >                                           in_size);
> > +#endif
> 
> 
> and here simply
>             enc_size = spice_lz4_compress_continue(stream, ...
> 
> Regards,
>      Uri.
> 

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