[PATCH spice-common 4/6] quic: More template unification, unify macros

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

 



Start defining the macro the same for both templates.
Unify function initial declaration using DECLARE_CHANNEL_VARIABLES
and DECLARE_STATE_VARIABLES macros.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 common/quic_rgb_tmpl.c | 160 ++++++++++++++++++----------------
 common/quic_tmpl.c     | 192 ++++++++++++++++++++++++++++++++---------
 2 files changed, 234 insertions(+), 118 deletions(-)

diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index 0cdf010..ca735c1 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -19,18 +19,61 @@
 #include <config.h>
 #endif
 
+#define COMPRESS_IMP
+
+#if defined(ONE_BYTE) || defined(FOUR_BYTE)
+#  define CHANNEL_ARG_ Channel *channel_a,
+#  define CHANNEL_ channel_a,
+#  define UNCOMPRESS_PIX_START(row) do { } while (0)
+#  define SET_a(pix, val) ((pix)->a = val)
+#  define GET_a(pix) ((pix)->a)
+#  define SAME_PIXEL(p1, p2) (GET_a(p1) == GET_a(p2))
+#  define DECLARE_STATE_VARIABLES \
+    CommonState *state = &channel_a->state
+#  define DECLARE_CHANNEL_VARIABLES \
+    BYTE * const correlate_row_a = channel_a->correlate_row
+#  define APPLY_ALL_COMP(macro, ...) \
+    macro(a, ## __VA_ARGS__)
+#else
+#  define CHANNEL_ARG_
+#  define CHANNEL_
+#  define SAME_PIXEL(p1, p2)                               \
+    (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) &&   \
+     GET_b(p1) == GET_b(p2))
+#  define DECLARE_STATE_VARIABLES \
+    CommonState *state = &encoder->rgb_state
+#  define DECLARE_CHANNEL_VARIABLES \
+    Channel * const channel_r = encoder->channels; \
+    Channel * const channel_g = channel_r + 1; \
+    Channel * const channel_b = channel_g + 1; \
+    BYTE * const correlate_row_r = channel_r->correlate_row; \
+    BYTE * const correlate_row_g = channel_g->correlate_row; \
+    BYTE * const correlate_row_b = channel_b->correlate_row
+#  define APPLY_ALL_COMP(macro, ...) \
+    macro(r, ## __VA_ARGS__); \
+    macro(g, ## __VA_ARGS__); \
+    macro(b, ## __VA_ARGS__)
+#endif
+
+#ifdef ONE_BYTE
+#undef ONE_BYTE
+#define FNAME(name) quic_one_##name
+#define PIXEL one_byte_t
+#define BPC 8
+#endif
+
+#ifdef FOUR_BYTE
+#undef FOUR_BYTE
+#define FNAME(name) quic_four_##name
+#define PIXEL four_bytes_t
+#define BPC 8
+#endif
+
 #ifdef QUIC_RGB32
 #undef QUIC_RGB32
 #define PIXEL rgb32_pixel_t
 #define FNAME(name) quic_rgb32_##name
-#define golomb_coding golomb_coding_8bpc
-#define golomb_decoding golomb_decoding_8bpc
-#define update_model update_model_8bpc
-#define find_bucket find_bucket_8bpc
-#define family family_8bpc
 #define BPC 8
-#define BPC_MASK 0xffU
-#define COMPRESS_IMP
 #define SET_r(pix, val) ((pix)->r = val)
 #define GET_r(pix) ((pix)->r)
 #define SET_g(pix, val) ((pix)->g = val)
@@ -44,14 +87,7 @@
 #undef QUIC_RGB24
 #define PIXEL rgb24_pixel_t
 #define FNAME(name) quic_rgb24_##name
-#define golomb_coding golomb_coding_8bpc
-#define golomb_decoding golomb_decoding_8bpc
-#define update_model update_model_8bpc
-#define find_bucket find_bucket_8bpc
-#define family family_8bpc
 #define BPC 8
-#define BPC_MASK 0xffU
-#define COMPRESS_IMP
 #define SET_r(pix, val) ((pix)->r = val)
 #define GET_r(pix) ((pix)->r)
 #define SET_g(pix, val) ((pix)->g = val)
@@ -65,14 +101,7 @@
 #undef QUIC_RGB16
 #define PIXEL rgb16_pixel_t
 #define FNAME(name) quic_rgb16_##name
-#define golomb_coding golomb_coding_5bpc
-#define golomb_decoding golomb_decoding_5bpc
-#define update_model update_model_5bpc
-#define find_bucket find_bucket_5bpc
-#define family family_5bpc
 #define BPC 5
-#define BPC_MASK 0x1fU
-#define COMPRESS_IMP
 #define SET_r(pix, val) (*(pix) = (*(pix) & ~(0x1f << 10)) | ((val) << 10))
 #define GET_r(pix) ((*(pix) >> 10) & 0x1f)
 #define SET_g(pix, val) (*(pix) = (*(pix) & ~(0x1f << 5)) | ((val) << 5))
@@ -86,14 +115,8 @@
 #undef QUIC_RGB16_TO_32
 #define PIXEL rgb32_pixel_t
 #define FNAME(name) quic_rgb16_to_32_##name
-#define golomb_coding golomb_coding_5bpc
-#define golomb_decoding golomb_decoding_5bpc
-#define update_model update_model_5bpc
-#define find_bucket find_bucket_5bpc
-#define family family_5bpc
 #define BPC 5
-#define BPC_MASK 0x1fU
-
+#undef COMPRESS_IMP
 #define SET_r(pix, val) ((pix)->r = ((val) << 3) | (((val) & 0x1f) >> 2))
 #define GET_r(pix) ((pix)->r >> 3)
 #define SET_g(pix, val) ((pix)->g = ((val) << 3) | (((val) & 0x1f) >> 2))
@@ -103,13 +126,23 @@
 #define UNCOMPRESS_PIX_START(pix) ((pix)->pad = 0)
 #endif
 
-#define CHANNEL_ARG_
-#define CHANNEL_
-
-#define SAME_PIXEL(p1, p2)                                 \
-    (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) &&   \
-     GET_b(p1) == GET_b(p2))
-
+#if BPC == 5
+#  define golomb_coding golomb_coding_5bpc
+#  define golomb_decoding golomb_decoding_5bpc
+#  define update_model update_model_5bpc
+#  define find_bucket find_bucket_5bpc
+#  define family family_5bpc
+#  define BPC_MASK 0x1fU
+#elif BPC == 8
+#  define golomb_coding golomb_coding_8bpc
+#  define golomb_decoding golomb_decoding_8bpc
+#  define update_model update_model_8bpc
+#  define find_bucket find_bucket_8bpc
+#  define family family_8bpc
+#  define BPC_MASK 0xffU
+#else
+#  error BPC must be 5 or 8
+#endif
 
 #define _PIXEL_A(channel, curr) ((unsigned int)GET_##channel((curr) - 1))
 #define _PIXEL_B(channel, prev) ((unsigned int)GET_##channel(prev))
@@ -148,11 +181,6 @@
                  correlate_row_##channel[index])
 #define UPDATE_MODEL(index) APPLY_ALL_COMP(UPDATE_MODEL_COMP, index)
 
-#define APPLY_ALL_COMP(macro, ...) \
-    macro(r, ## __VA_ARGS__); \
-    macro(g, ## __VA_ARGS__); \
-    macro(b, ## __VA_ARGS__)
-
 #define RLE_PRED_IMP                                                                \
 if (SAME_PIXEL(&prev_row[i - 1], &prev_row[i])) {                                   \
     if (run_index != i && i > 2 && SAME_PIXEL(&cur_row[i - 1], &cur_row[i - 2])) {  \
@@ -169,14 +197,8 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                      SPICE_GNUC_UNUSED const unsigned int bpc,
                                      const unsigned int bpc_mask)
 {
-    CommonState *state = &encoder->rgb_state;
-    Channel * const channel_r = encoder->channels;
-    Channel * const channel_g = channel_r + 1;
-    Channel * const channel_b = channel_g + 1;
-
-    BYTE * const correlate_row_r = channel_r->correlate_row;
-    BYTE * const correlate_row_g = channel_g->correlate_row;
-    BYTE * const correlate_row_b = channel_b->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -216,7 +238,7 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
 static void FNAME(compress_row0)(Encoder *encoder, CHANNEL_ARG_ const PIXEL *cur_row,
                                  unsigned int width)
 {
-    CommonState *state = &encoder->rgb_state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     int pos = 0;
@@ -267,14 +289,8 @@ static void FNAME(compress_row_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                     SPICE_GNUC_UNUSED const unsigned int bpc,
                                     const unsigned int bpc_mask)
 {
-    CommonState *state = &encoder->rgb_state;
-    Channel * const channel_r = encoder->channels;
-    Channel * const channel_g = channel_r + 1;
-    Channel * const channel_b = channel_g + 1;
-
-    BYTE * const correlate_row_r = channel_r->correlate_row;
-    BYTE * const correlate_row_g = channel_g->correlate_row;
-    BYTE * const correlate_row_b = channel_b->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     int stopidx;
     int run_index = 0;
     int run_size;
@@ -336,7 +352,7 @@ static void FNAME(compress_row)(Encoder *encoder, CHANNEL_ARG_
                                 unsigned int width)
 
 {
-    CommonState *state = &encoder->rgb_state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
@@ -393,14 +409,8 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                        SPICE_GNUC_UNUSED const unsigned int bpc,
                                        const unsigned int bpc_mask)
 {
-    CommonState *state = &encoder->rgb_state;
-    Channel * const channel_r = encoder->channels;
-    Channel * const channel_g = channel_r + 1;
-    Channel * const channel_b = channel_g + 1;
-
-    BYTE * const correlate_row_r = channel_r->correlate_row;
-    BYTE * const correlate_row_g = channel_g->correlate_row;
-    BYTE * const correlate_row_b = channel_b->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -447,7 +457,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder, CHANNEL_ARG_
                                    unsigned int width)
 
 {
-    CommonState *state = &encoder->rgb_state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
@@ -505,14 +515,8 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, CHANNEL_ARG_
                                       SPICE_GNUC_UNUSED const unsigned int bpc,
                                       const unsigned int bpc_mask)
 {
-    CommonState *state = &encoder->rgb_state;
-    Channel * const channel_r = encoder->channels;
-    Channel * const channel_g = channel_r + 1;
-    Channel * const channel_b = channel_g + 1;
-
-    BYTE * const correlate_row_r = channel_r->correlate_row;
-    BYTE * const correlate_row_g = channel_g->correlate_row;
-    BYTE * const correlate_row_b = channel_b->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     const unsigned int waitmask = bppmask[state->wmidx];
     int stopidx;
     int run_index = 0;
@@ -587,7 +591,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_
                                   unsigned int width)
 
 {
-    CommonState *state = &encoder->rgb_state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
@@ -649,8 +653,12 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_
 #undef GET_g
 #undef SET_b
 #undef GET_b
+#undef SET_a
+#undef GET_a
 #undef UNCOMPRESS_PIX_START
 #undef UPDATE_MODEL_COMP
 #undef CHANNEL_ARG_
 #undef CHANNEL_
 #undef APPLY_ALL_COMP
+#undef DECLARE_STATE_VARIABLES
+#undef DECLARE_CHANNEL_VARIABLES
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index 37b15cf..513a0c6 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -19,35 +19,130 @@
 #include <config.h>
 #endif
 
+#define COMPRESS_IMP
+
+#if defined(ONE_BYTE) || defined(FOUR_BYTE)
+#  define CHANNEL_ARG_ Channel *channel_a,
+#  define CHANNEL_ channel_a,
+#  define UNCOMPRESS_PIX_START(row) do { } while (0)
+#  define SET_a(pix, val) ((pix)->a = val)
+#  define GET_a(pix) ((pix)->a)
+#  define SAME_PIXEL(p1, p2) (GET_a(p1) == GET_a(p2))
+#  define DECLARE_STATE_VARIABLES \
+    CommonState *state = &channel_a->state
+#  define DECLARE_CHANNEL_VARIABLES \
+    BYTE * const correlate_row_a = channel_a->correlate_row
+#  define APPLY_ALL_COMP(macro, ...) \
+    macro(a, ## __VA_ARGS__)
+#else
+#  define CHANNEL_ARG_
+#  define CHANNEL_
+#  define SAME_PIXEL(p1, p2)                               \
+    (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) &&   \
+     GET_b(p1) == GET_b(p2))
+#  define DECLARE_STATE_VARIABLES \
+    CommonState *state = &encoder->rgb_state
+#  define DECLARE_CHANNEL_VARIABLES \
+    Channel * const channel_r = encoder->channels; \
+    Channel * const channel_g = channel_r + 1; \
+    Channel * const channel_b = channel_g + 1; \
+    BYTE * const correlate_row_r = channel_r->correlate_row; \
+    BYTE * const correlate_row_g = channel_g->correlate_row; \
+    BYTE * const correlate_row_b = channel_b->correlate_row
+#  define APPLY_ALL_COMP(macro, ...) \
+    macro(r, ## __VA_ARGS__); \
+    macro(g, ## __VA_ARGS__); \
+    macro(b, ## __VA_ARGS__)
+#endif
+
 #ifdef ONE_BYTE
 #undef ONE_BYTE
 #define FNAME(name) quic_one_##name
 #define PIXEL one_byte_t
+#define BPC 8
 #endif
 
 #ifdef FOUR_BYTE
 #undef FOUR_BYTE
 #define FNAME(name) quic_four_##name
 #define PIXEL four_bytes_t
+#define BPC 8
 #endif
 
-#define golomb_coding golomb_coding_8bpc
-#define golomb_decoding golomb_decoding_8bpc
-#define update_model update_model_8bpc
-#define find_bucket find_bucket_8bpc
-#define family family_8bpc
+#ifdef QUIC_RGB32
+#undef QUIC_RGB32
+#define PIXEL rgb32_pixel_t
+#define FNAME(name) quic_rgb32_##name
+#define BPC 8
+#define SET_r(pix, val) ((pix)->r = val)
+#define GET_r(pix) ((pix)->r)
+#define SET_g(pix, val) ((pix)->g = val)
+#define GET_g(pix) ((pix)->g)
+#define SET_b(pix, val) ((pix)->b = val)
+#define GET_b(pix) ((pix)->b)
+#define UNCOMPRESS_PIX_START(pix) ((pix)->pad = 0)
+#endif
 
+#ifdef QUIC_RGB24
+#undef QUIC_RGB24
+#define PIXEL rgb24_pixel_t
+#define FNAME(name) quic_rgb24_##name
 #define BPC 8
-#define BPC_MASK 0xffU
+#define SET_r(pix, val) ((pix)->r = val)
+#define GET_r(pix) ((pix)->r)
+#define SET_g(pix, val) ((pix)->g = val)
+#define GET_g(pix) ((pix)->g)
+#define SET_b(pix, val) ((pix)->b = val)
+#define GET_b(pix) ((pix)->b)
+#define UNCOMPRESS_PIX_START(pix)
+#endif
 
-#define CHANNEL_ARG_ Channel *channel_a,
-#define CHANNEL_ channel_a,
+#ifdef QUIC_RGB16
+#undef QUIC_RGB16
+#define PIXEL rgb16_pixel_t
+#define FNAME(name) quic_rgb16_##name
+#define BPC 5
+#define SET_r(pix, val) (*(pix) = (*(pix) & ~(0x1f << 10)) | ((val) << 10))
+#define GET_r(pix) ((*(pix) >> 10) & 0x1f)
+#define SET_g(pix, val) (*(pix) = (*(pix) & ~(0x1f << 5)) | ((val) << 5))
+#define GET_g(pix) ((*(pix) >> 5) & 0x1f)
+#define SET_b(pix, val) (*(pix) = (*(pix) & ~0x1f) | (val))
+#define GET_b(pix) (*(pix) & 0x1f)
+#define UNCOMPRESS_PIX_START(pix) (*(pix) = 0)
+#endif
 
-#define SET_a(pix, val) ((pix)->a = val)
-#define GET_a(pix) ((pix)->a)
+#ifdef QUIC_RGB16_TO_32
+#undef QUIC_RGB16_TO_32
+#define PIXEL rgb32_pixel_t
+#define FNAME(name) quic_rgb16_to_32_##name
+#define BPC 5
+#undef COMPRESS_IMP
+#define SET_r(pix, val) ((pix)->r = ((val) << 3) | (((val) & 0x1f) >> 2))
+#define GET_r(pix) ((pix)->r >> 3)
+#define SET_g(pix, val) ((pix)->g = ((val) << 3) | (((val) & 0x1f) >> 2))
+#define GET_g(pix) ((pix)->g >> 3)
+#define SET_b(pix, val) ((pix)->b = ((val) << 3) | (((val) & 0x1f) >> 2))
+#define GET_b(pix) ((pix)->b >> 3)
+#define UNCOMPRESS_PIX_START(pix) ((pix)->pad = 0)
+#endif
 
-#define SAME_PIXEL(p1, p2)                                 \
-     (GET_a(p1) == GET_a(p2))
+#if BPC == 5
+#  define golomb_coding golomb_coding_5bpc
+#  define golomb_decoding golomb_decoding_5bpc
+#  define update_model update_model_5bpc
+#  define find_bucket find_bucket_5bpc
+#  define family family_5bpc
+#  define BPC_MASK 0x1fU
+#elif BPC == 8
+#  define golomb_coding golomb_coding_8bpc
+#  define golomb_decoding golomb_decoding_8bpc
+#  define update_model update_model_8bpc
+#  define find_bucket find_bucket_8bpc
+#  define family family_8bpc
+#  define BPC_MASK 0xffU
+#else
+#  error BPC must be 5 or 8
+#endif
 
 #define _PIXEL_A(channel, curr) ((unsigned int)GET_##channel((curr) - 1))
 #define _PIXEL_B(channel, prev) ((unsigned int)GET_##channel(prev))
@@ -66,11 +161,10 @@
     r = family.xlatU2L[(unsigned)((int)GET_##channel(curr) - (int)((_PIXEL_A(channel, curr) +  \
     _PIXEL_B(channel, prev)) >> 1)) & bpc_mask]
 
-static inline void FNAME(correlate)(const PIXEL *prev, PIXEL *curr, const BYTE correlate,
-                                    const unsigned int bpc_mask)
-{
-    curr->a = (family.xlatL2U[correlate] + (int)((_PIXEL_A(a, curr) + _PIXEL_B(a, prev)) >> 1)) & bpc_mask;
-}
+#define CORRELATE(channel, prev, curr, correlate, bpc_mask, r)                                  \
+    SET_##channel(r, ((family.xlatL2U[correlate] + \
+         (int)((_PIXEL_A(channel, curr) + _PIXEL_B(channel, prev)) >> 1)) & bpc_mask))
+
 
 #define COMPRESS_ONE_ROW0_0(channel)                                                  \
     correlate_row_##channel[0] = family.xlatU2L[GET_##channel(cur_row)];              \
@@ -87,9 +181,6 @@ static inline void FNAME(correlate)(const PIXEL *prev, PIXEL *curr, const BYTE c
                  correlate_row_##channel[index])
 #define UPDATE_MODEL(index) APPLY_ALL_COMP(UPDATE_MODEL_COMP, index)
 
-#define APPLY_ALL_COMP(macro, ...) \
-    macro(a, ## __VA_ARGS__)
-
 #define RLE_PRED_IMP                                                                \
 if (SAME_PIXEL(&prev_row[i - 1], &prev_row[i])) {                                   \
     if (run_index != i && i > 2 && SAME_PIXEL(&cur_row[i - 1], &cur_row[i - 2])) {  \
@@ -97,6 +188,8 @@ if (SAME_PIXEL(&prev_row[i - 1], &prev_row[i])) {
     }                                                                               \
 }
 
+#ifdef COMPRESS_IMP
+
 static void FNAME(compress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                      const PIXEL * const cur_row,
                                      const int end,
@@ -104,8 +197,8 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                      SPICE_GNUC_UNUSED const unsigned int bpc,
                                      const unsigned int bpc_mask)
 {
-    CommonState *state = &channel_a->state;
-    BYTE * const correlate_row_a = channel_a->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -145,7 +238,7 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
 static void FNAME(compress_row0)(Encoder *encoder, CHANNEL_ARG_ const PIXEL *cur_row,
                                  unsigned int width)
 {
-    CommonState *state = &channel_a->state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     int pos = 0;
@@ -196,8 +289,8 @@ static void FNAME(compress_row_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                     SPICE_GNUC_UNUSED const unsigned int bpc,
                                     const unsigned int bpc_mask)
 {
-    CommonState *state = &channel_a->state;
-    BYTE * const correlate_row_a = channel_a->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     int stopidx;
     int run_index = 0;
     int run_size;
@@ -259,7 +352,7 @@ static void FNAME(compress_row)(Encoder *encoder, CHANNEL_ARG_
                                 unsigned int width)
 
 {
-    CommonState *state = &channel_a->state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
@@ -291,7 +384,7 @@ static void FNAME(compress_row)(Encoder *encoder, CHANNEL_ARG_
     spice_assert(DEFwminext > 0);
 }
 
-#define UNCOMPRESS_PIX_START(row) do { } while (0)
+#endif
 
 #define UNCOMPRESS_ONE_ROW0_0(channel)                                                            \
     correlate_row_##channel[0] = (BYTE)golomb_decoding(find_bucket(channel_##channel,                              \
@@ -316,8 +409,8 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, CHANNEL_ARG_ int i,
                                        SPICE_GNUC_UNUSED const unsigned int bpc,
                                        const unsigned int bpc_mask)
 {
-    CommonState *state = &channel_a->state;
-    BYTE * const correlate_row_a = channel_a->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -364,7 +457,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder, CHANNEL_ARG_
                                    unsigned int width)
 
 {
-    CommonState *state = &channel_a->state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
@@ -410,7 +503,8 @@ static void FNAME(uncompress_row0)(Encoder *encoder, CHANNEL_ARG_
                                                                   correlate_row_##channel[i - 1])->bestcode,    \
                                                                   encoder->io_word,                             \
                                                                   &codewordlen);                                \
-    FNAME(correlate)(&prev_row[i], &cur_row[i], correlate_row_##channel[i], bpc_mask);                          \
+    CORRELATE(channel, &prev_row[i], &cur_row[i], correlate_row_##channel[i], bpc_mask,           \
+             &cur_row[i]);                                                                        \
     decode_eatbits(encoder, codewordlen);
 
 static void FNAME(uncompress_row_seg)(Encoder *encoder, CHANNEL_ARG_
@@ -421,8 +515,8 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, CHANNEL_ARG_
                                       SPICE_GNUC_UNUSED const unsigned int bpc,
                                       const unsigned int bpc_mask)
 {
-    CommonState *state = &channel_a->state;
-    BYTE * const correlate_row_a = channel_a->correlate_row;
+    DECLARE_STATE_VARIABLES;
+    DECLARE_CHANNEL_VARIABLES;
     const unsigned int waitmask = bppmask[state->wmidx];
     int stopidx;
     int run_index = 0;
@@ -495,7 +589,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_
                                   unsigned int width)
 
 {
-    CommonState *state = &channel_a->state;
+    DECLARE_STATE_VARIABLES;
     const unsigned int bpc = BPC;
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
@@ -532,6 +626,17 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_
 #undef _PIXEL_B
 #undef SAME_PIXEL
 #undef RLE_PRED_IMP
+#undef UPDATE_MODEL
+#undef DECORRELATE_0
+#undef DECORRELATE
+#undef COMPRESS_ONE_0
+#undef COMPRESS_ONE
+#undef CORRELATE_0
+#undef CORRELATE
+#undef UNCOMPRESS_ONE_ROW0_0
+#undef UNCOMPRESS_ONE_ROW0
+#undef UNCOMPRESS_ONE_0
+#undef UNCOMPRESS_ONE
 #undef golomb_coding
 #undef golomb_decoding
 #undef update_model
@@ -539,16 +644,19 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_
 #undef family
 #undef BPC
 #undef BPC_MASK
-#undef UPDATE_MODEL
-#undef UNCOMPRESS_PIX_START
-#undef COMPRESS_ONE_0
-#undef COMPRESS_ONE
-#undef UNCOMPRESS_ONE_ROW0
-#undef UNCOMPRESS_ONE_ROW0_0
-#undef UNCOMPRESS_ONE_0
-#undef UNCOMPRESS_ONE
+#undef COMPRESS_IMP
+#undef SET_r
+#undef GET_r
+#undef SET_g
+#undef GET_g
+#undef SET_b
+#undef GET_b
 #undef SET_a
 #undef GET_a
+#undef UNCOMPRESS_PIX_START
+#undef UPDATE_MODEL_COMP
 #undef CHANNEL_ARG_
 #undef CHANNEL_
 #undef APPLY_ALL_COMP
+#undef DECLARE_STATE_VARIABLES
+#undef DECLARE_CHANNEL_VARIABLES
-- 
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]