[Spice-commits] server/glz-encode.tmpl.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri May 20 10:51:29 UTC 2016


 server/glz-encode.tmpl.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

New commits:
commit b028c2e38aea6a69baa25afdb20c3314f7726c0a
Author: Uri Lublin <uril at redhat.com>
Date:   Wed May 18 21:20:48 2016 +0300

    glz: simplification of do_match and PIXEL_ID
    
    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>
    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


More information about the Spice-commits mailing list