[PATCH] optimized SAME_PIXEL macro in glz code

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

 



SAME_PIXEL macro is used a lot for 32 bit images.
On such configuration the macro can be optimized quite a lot reading
and comparing the entire pixel instead of splitting the components
and comparing one by one.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/glz_encode_tmpl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/server/glz_encode_tmpl.c b/server/glz_encode_tmpl.c
index 46dd1d4..27fbe8a 100644
--- a/server/glz_encode_tmpl.c
+++ b/server/glz_encode_tmpl.c
@@ -72,6 +72,7 @@
 #define GET_g(pix) (((pix) >> 5) & 0x1f)
 #define GET_b(pix) ((pix) & 0x1f)
 #define ENCODE_PIXEL(e, pix) {encode(e, (pix) >> 8); encode(e, (pix) & 0xff);}
+#define SAME_PIXEL(p1, p2) ((((p1)^(p2))&0x7fffu)==0)
 #define MIN_REF_ENCODE_SIZE 2
 #define MAX_REF_ENCODE_SIZE 3
 #define HASH_FUNC(v, p) {                  \
@@ -122,7 +123,11 @@
     }
 #endif
 
-#if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32)
+#if defined(LZ_RGB32) && SPICE_ENDIAN == SPICE_ENDIAN_LITTLE
+#define SAME_PIXEL(p1,p2) ((((*(const uint32_t*)&(p1))^(*(const uint32_t*)&(p2)))&0xffffffu)==0)
+#elif defined(LZ_RGB32) && SPICE_ENDIAN == SPICE_ENDIAN_BIG
+#define SAME_PIXEL(p1,p2) ((((*(const uint32_t*)&(p1))^(*(const uint32_t*)&(p2)))&0xffffff00u)==0)
+#elif 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))
 
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]