[spice-common v2 12/15] quic: Introduce COPY_PIXEL macro

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

 



From: Frediano Ziglio <fziglio@xxxxxxxxxx>

Define and reuse a COPY_PIXEL macro to copy a pixel.
This will help in making quic_tmpl.c and quic_rgb_tmpl.c identical.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---
 common/quic_rgb_tmpl.c | 9 ++++++---
 common/quic_tmpl.c     | 5 ++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index 3625728..2221201 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -87,6 +87,10 @@
 #define SAME_PIXEL(p1, p2)                                 \
     (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) &&   \
      GET_b(p1) == GET_b(p2))
+#define COPY_PIXEL(dest, src) \
+    SET_r(dest, GET_r(src)); \
+    SET_g(dest, GET_g(src)); \
+    SET_b(dest, GET_b(src))
 #define DECLARE_STATE_VARIABLES \
     CommonState *state = &encoder->rgb_state
 #define DECLARE_CHANNEL_VARIABLES \
@@ -541,9 +545,7 @@ do_run:
 
         for (; i < run_end; i++) {
             UNCOMPRESS_PIX_START(&cur_row[i]);
-            SET_r(&cur_row[i], GET_r(&cur_row[i - 1]));
-            SET_g(&cur_row[i], GET_g(&cur_row[i - 1]));
-            SET_b(&cur_row[i], GET_b(&cur_row[i - 1]));
+            COPY_PIXEL(&cur_row[i], &cur_row[i - 1]);
         }
 
         if (i == end) {
@@ -632,3 +634,4 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row,
 #undef APPLY_ALL_COMP
 #undef DECLARE_STATE_VARIABLES
 #undef DECLARE_CHANNEL_VARIABLES
+#undef COPY_PIXEL
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index d21f059..525eb99 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -43,6 +43,8 @@
 
 #define SAME_PIXEL(p1, p2)                                 \
      (GET_a(p1) == GET_a(p2))
+#define COPY_PIXEL(dest, src) \
+    SET_a(dest, GET_a(src));
 #define DECLARE_STATE_VARIABLES \
     CommonState *state = &channel_a->state
 #define DECLARE_CHANNEL_VARIABLES \
@@ -483,7 +485,7 @@ do_run:
 
         for (; i < run_end; i++) {
             UNCOMPRESS_PIX_START(&cur_row[i]);
-            SET_a(&cur_row[i], GET_a(&cur_row[i - 1]));
+            COPY_PIXEL(&cur_row[i], &cur_row[i - 1]);
         }
 
         if (i == end) {
@@ -565,3 +567,4 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row,
 #undef APPLY_ALL_COMP
 #undef DECLARE_STATE_VARIABLES
 #undef DECLARE_CHANNEL_VARIABLES
+#undef COPY_PIXEL
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]