[Spice-devel] [PATCH spice-server 2/3] glz: Optimize SAME_PIXEL for RGB16

Frediano Ziglio fziglio at redhat.com
Tue Jun 19 08:55:25 UTC 2018


Do not extract all components and compare one by one, can be easily
compared together.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/glz-encode.tmpl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/server/glz-encode.tmpl.c b/server/glz-encode.tmpl.c
index 8e2dc03e..c9b39360 100644
--- a/server/glz-encode.tmpl.c
+++ b/server/glz-encode.tmpl.c
@@ -68,9 +68,8 @@
 #ifdef LZ_RGB16
 #define PIXEL rgb16_pixel_t
 #define FNAME(name) glz_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 MIN_REF_ENCODE_SIZE 2
 #define MAX_REF_ENCODE_SIZE 3
@@ -119,7 +118,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))
 
@@ -535,6 +534,7 @@ static void FNAME(compress)(Encoder *encoder)
 #undef GET_r
 #undef GET_g
 #undef GET_b
+#undef GET_rgb
 #undef LZ_PLT
 #undef LZ_RGB_ALPHA
 #undef LZ_RGB16
-- 
2.17.1



More information about the Spice-devel mailing list