[Spice-commits] 2 commits - common/lz_compress_tmpl.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 25 10:55:50 UTC 2018


 common/lz_compress_tmpl.c |   19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

New commits:
commit 5312ea3f359fbeeceef8be0a515d7600dba2b6c6
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Dec 24 13:31:47 2017 +0000

    lz: Inline GET_{r,g,b} macros
    
    With last changes are just used once and are straight forward.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: jonathon Jongsma <jjongsma at redhat.com>

diff --git a/common/lz_compress_tmpl.c b/common/lz_compress_tmpl.c
index 5c90311..4f4f6c6 100644
--- a/common/lz_compress_tmpl.c
+++ b/common/lz_compress_tmpl.c
@@ -134,9 +134,7 @@
 
 #if  defined(LZ_RGB24) || defined(LZ_RGB32)
 #define ENCODE_PIXEL(e, pix) {encode(e, (pix).b); encode(e, (pix).g); encode(e, (pix).r);}
-#define GET_r(pix) ((pix).r)
-#define GET_g(pix) ((pix).g)
-#define GET_b(pix) ((pix).b)
+#define SAME_PIXEL(p1, p2) ((p1).r == (p2).r && (p1).g == (p2).g && (p1).b == (p2).b)
 #define HASH_FUNC(v, p) {    \
     v = DJB2_START;          \
     DJB2_HASH(v, p[0].r);    \
@@ -152,12 +150,6 @@
     }
 #endif
 
-#if defined(LZ_RGB24) || defined(LZ_RGB32)
-#define SAME_PIXEL(p1, p2) (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \
-                            GET_b(p1) == GET_b(p2))
-
-#endif
-
 #define PIXEL_ID(pix_ptr, seg_ptr) (pix_ptr - ((PIXEL *)seg_ptr->lines) + seg_ptr->size_delta)
 
 // when encoding, the ref can be in previous segment, and we should check that it doesn't
@@ -521,9 +513,6 @@ static void FNAME(compress)(Encoder *encoder)
 #undef HASH_FUNC
 #undef BYTES_TO_16
 #undef HASH_FUNC_16
-#undef GET_r
-#undef GET_g
-#undef GET_b
 #undef GET_rgb
 #undef GET_CODE
 #undef LZ_PLT
commit 70aa6d39b61295d3a946bbc9be2f81132001d169
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Dec 24 13:27:25 2017 +0000

    lz: Optimise SAME_PIXEL for RGB16
    
    Do not extract all components and compare one by one, can be easily
    compared together.
    Performance measurements on a set of 16 bit images shown an improve of
    about 10%.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/lz_compress_tmpl.c b/common/lz_compress_tmpl.c
index 69e69a6..5c90311 100644
--- a/common/lz_compress_tmpl.c
+++ b/common/lz_compress_tmpl.c
@@ -105,9 +105,8 @@
 #ifdef LZ_RGB16
 #define PIXEL rgb16_pixel_t
 #define FNAME(name) lz_rgb16_##name
-#define GET_r(pix) (((pix) >> 10) & 0x1f)
-#define GET_g(pix) (((pix) >> 5) & 0x1f)
-#define GET_b(pix) ((pix) & 0x1f)
+#define GET_rgb(pix) ((pix) & 0x7fffu)
+#define SAME_PIXEL(p1, p2) (GET_rgb(p1) == GET_rgb(p2))
 #define ENCODE_PIXEL(e, pix) {encode(e, (pix) >> 8); encode(e, (pix) & 0xff);}
 
 #define HASH_FUNC(v, p) {                 \
@@ -153,7 +152,7 @@
     }
 #endif
 
-#if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32)
+#if defined(LZ_RGB24) || defined(LZ_RGB32)
 #define SAME_PIXEL(p1, p2) (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \
                             GET_b(p1) == GET_b(p2))
 
@@ -525,6 +524,7 @@ static void FNAME(compress)(Encoder *encoder)
 #undef GET_r
 #undef GET_g
 #undef GET_b
+#undef GET_rgb
 #undef GET_CODE
 #undef LZ_PLT
 #undef LZ_RGB_ALPHA


More information about the Spice-commits mailing list