[Spice-devel] [PATCH] glz: simplification of do_match and PIXEL_ID

Fabiano FidĂȘncio fabiano at fidencio.org
Thu May 19 06:03:22 UTC 2016


On Wed, May 18, 2016 at 8:20 PM, Uri Lublin <uril at redhat.com> wrote:
> Following commit e8017dd366afabbd099a13d7d455a37fd50be124 here
> are some more ifdef simplification.
>
> For PIXEL_ID and PIXEL_DIST macros,
> the ifndef LZ_PLT defines are special cases of the LZ_PLT
> (#else) defines, when pix_per_byte is 1
>
> Now do_match can accept pix_per_byte param for all different
> definitions (implementations).
>
> Signed-off-by: Uri Lublin <uril at redhat.com>
> ---
>
> If people prefer I can split it to two patches, one for
> the macros and one for do_match
>
> ---
>  server/glz-encode.tmpl.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)

Patch looks good, but II didn't try to build the patch.
I'm assuming you did, you have my ACK.

Acked-by: Fabiano FidĂȘncio <fidencio at redhat.com>

>
> diff --git a/server/glz-encode.tmpl.c b/server/glz-encode.tmpl.c
> index 6d2b000..033a810 100644
> --- a/server/glz-encode.tmpl.c
> +++ b/server/glz-encode.tmpl.c
> @@ -128,18 +128,12 @@
>
>  #endif
>
> -#ifndef LZ_PLT
> -#define PIXEL_ID(pix_ptr, seg_ptr) \
> -    ((pix_ptr) - ((PIXEL *)(seg_ptr)->lines) + (seg_ptr)->pixels_so_far)
> -#define PIXEL_DIST(src_pix_ptr, src_seg_ptr, ref_pix_ptr, ref_seg_ptr, pix_per_byte) \
> -    (PIXEL_ID(src_pix_ptr,src_seg_ptr) - PIXEL_ID(ref_pix_ptr, ref_seg_ptr))
> -#else
>  #define PIXEL_ID(pix_ptr, seg_ptr, pix_per_byte) \
>      (((pix_ptr) - ((PIXEL *)(seg_ptr)->lines)) * pix_per_byte + (seg_ptr)->pixels_so_far)
> +
>  #define PIXEL_DIST(src_pix_ptr, src_seg_ptr, ref_pix_ptr, ref_seg_ptr, pix_per_byte) \
>      ((PIXEL_ID(src_pix_ptr,src_seg_ptr, pix_per_byte) - \
>      PIXEL_ID(ref_pix_ptr, ref_seg_ptr, pix_per_byte)) / pix_per_byte)
> -#endif
>
>  /* returns the length of the match. 0 if no match.
>    if image_distance = 0, pixel_distance is the distance between the matching pixels.
> @@ -149,9 +143,7 @@ static inline size_t FNAME(do_match)(SharedDictionary *dict,
>                                       const PIXEL *ref_limit,
>                                       WindowImageSegment *ip_seg,  const PIXEL *ip,
>                                       const PIXEL *ip_limit,
> -#ifdef  LZ_PLT
>                                       int pix_per_byte,
> -#endif
>                                       size_t *o_image_dist, size_t *o_pix_distance)
>  {
>      int encode_size;
> @@ -262,6 +254,8 @@ static void FNAME(compress_seg)(Encoder *encoder, uint32_t seg_idx, PIXEL *from,
>      int copy = copied;
>  #ifdef  LZ_PLT
>      int pix_per_byte = PLT_PIXELS_PER_BYTE[encoder->cur_image.type];
> +#else
> +    int pix_per_byte = 1;
>  #endif
>
>  #ifdef DEBUG_ENCODE
> @@ -342,9 +336,7 @@ static void FNAME(compress_seg)(Encoder *encoder, uint32_t seg_idx, PIXEL *from,
>                  ref_limit = (PIXEL *)ref_seg->lines_end;
>
>                  len = FNAME(do_match)(encoder->dict, ref_seg, ref, ref_limit, seg, ip, ip_bound,
> -#ifdef  LZ_PLT
>                                        pix_per_byte,
> -#endif
>                                        &image_dist, &pix_dist);
>
>  #ifdef CHAINED_HASH
> --
> 2.5.5
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Fabiano FidĂȘncio


More information about the Spice-devel mailing list