[spice-common v3 11/12] quic: Use channel->correlate_row in macros

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

 



This avoids the need for a local variable with the right name (which
was decorrelate_drow in some cases in quic_tmpl.c...)

Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---
 common/quic_tmpl.c | 100 ++++++++++++++++++++++++++---------------------------
 1 file changed, 49 insertions(+), 51 deletions(-)

diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index e10c940..a0ebabf 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -81,22 +81,25 @@ static inline void FNAME(correlate)(const PIXEL *prev, PIXEL *curr, const BYTE c
     curr->a = (family.xlatL2U[correlate] + (int)((_PIXEL_A + _PIXEL_B) >> 1)) & bpc_mask;
 }
 
-#define COMPRESS_ONE_ROW0_0(channel)                                                      \
-    correlate_row[0] = family.xlatU2L[cur_row->a];                                        \
-    golomb_coding(correlate_row[0], find_bucket(channel, correlate_row[-1])->bestcode,    \
-                  &codeword, &codewordlen);                                               \
+#define COMPRESS_ONE_ROW0_0(channel)                                 \
+    channel->correlate_row[0] = family.xlatU2L[cur_row->a];          \
+    golomb_coding(channel->correlate_row[0],                         \
+                  find_bucket(channel,                               \
+                              channel->correlate_row[-1])->bestcode, \
+                  &codeword, &codewordlen);                          \
     encode(encoder, codeword, codewordlen);
 
-#define COMPRESS_ONE_ROW0(channel, index)                                            \
-    correlate_row[index] = FNAME(decorrelate_0)(&cur_row[index], bpc_mask);          \
-    golomb_coding(correlate_row[index], find_bucket(channel,                         \
-                  correlate_row[index-1])->bestcode,                                 \
-                  &codeword, &codewordlen);                                          \
+#define COMPRESS_ONE_ROW0(channel, index)                                               \
+    channel->correlate_row[index] = FNAME(decorrelate_0)(&cur_row[index], bpc_mask);    \
+    golomb_coding(channel->correlate_row[index],                                        \
+                  find_bucket(channel,                                                  \
+                              channel->correlate_row[index - 1])->bestcode,             \
+                  &codeword, &codewordlen);                                             \
     encode(encoder, codeword, codewordlen);
 
-#define UPDATE_MODEL(index)                                                          \
-    update_model(state, find_bucket(channel, correlate_row[index - 1]),              \
-                 correlate_row[index]);
+#define UPDATE_MODEL(index)                                                             \
+    update_model(state, find_bucket(channel, channel->correlate_row[index - 1]),        \
+                 channel->correlate_row[index]);
 
 static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
                                      const PIXEL * const cur_row,
@@ -106,7 +109,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
                                      const unsigned int bpc_mask)
 {
     CommonState *state = &channel->state;
-    BYTE * const correlate_row = channel->correlate_row;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -183,18 +185,18 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
 }
 
 #define COMPRESS_ONE_0(channel) \
-    correlate_row[0] = family.xlatU2L[(unsigned)((int)GET_a(cur_row) -                  \
-                                                    (int)GET_a(prev_row) ) & bpc_mask]; \
-        golomb_coding(correlate_row[0],                                                 \
-                      find_bucket(channel, correlate_row[-1])->bestcode,                \
-                      &codeword, &codewordlen);                                         \
-        encode(encoder, codeword, codewordlen);
-
-#define COMPRESS_ONE(channel, index)                                                            \
-     correlate_row[index] = FNAME(decorrelate)(&prev_row[index], &cur_row[index], bpc_mask);    \
-     golomb_coding(correlate_row[index],                                                        \
-                  find_bucket(channel, correlate_row[index - 1])->bestcode,                     \
+    channel->correlate_row[0] = family.xlatU2L[(unsigned)((int)GET_a(cur_row) -                 \
+                                                          (int)GET_a(prev_row) ) & bpc_mask];   \
+    golomb_coding(channel->correlate_row[0],                                                    \
+                  find_bucket(channel, channel->correlate_row[-1])->bestcode,                   \
                   &codeword, &codewordlen);                                                     \
+    encode(encoder, codeword, codewordlen);
+
+#define COMPRESS_ONE(channel, index)                                                            \
+     channel->correlate_row[index] = FNAME(decorrelate)(&prev_row[index], &cur_row[index], bpc_mask);   \
+     golomb_coding(channel->correlate_row[index],                                                       \
+                  find_bucket(channel, channel->correlate_row[index - 1])->bestcode,                    \
+                  &codeword, &codewordlen);                                                             \
      encode(encoder, codeword, codewordlen);
 
 static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
@@ -206,7 +208,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
                                     const unsigned int bpc_mask)
 {
     CommonState *state = &channel->state;
-    BYTE * const correlate_row = channel->correlate_row;
     int stopidx;
     int run_index = 0;
     int run_size;
@@ -222,8 +223,8 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
             state->waitcnt--;
         } else {
             state->waitcnt = (tabrand(&state->tabrand_seed) & waitmask);
-            update_model(state, find_bucket(channel, correlate_row[-1]),
-                         correlate_row[0]);
+            update_model(state, find_bucket(channel, channel->correlate_row[-1]),
+                         channel->correlate_row[0]);
         }
         stopidx = ++i + state->waitcnt;
     } else {
@@ -307,19 +308,19 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
 
 #define UNCOMPRESS_PIX_START(row) do { } while (0)
 
-#define UNCOMPRESS_ONE_ROW0_0(channel)                                                          \
-    correlate_row[0] = (BYTE)golomb_decoding(find_bucket(channel,                               \
-                                                         correlate_row[-1])->bestcode,          \
-                                                         encoder->io_word, &codewordlen);       \
-    SET_a(&cur_row[0], (BYTE)family.xlatL2U[correlate_row[0]]);                                 \
+#define UNCOMPRESS_ONE_ROW0_0(channel)                                                                  \
+    channel->correlate_row[0] = (BYTE)golomb_decoding(find_bucket(channel,                              \
+                                                                  channel->correlate_row[-1])->bestcode,\
+                                                      encoder->io_word, &codewordlen);                  \
+    SET_a(&cur_row[0], (BYTE)family.xlatL2U[channel->correlate_row[0]]);                                \
     decode_eatbits(encoder, codewordlen);
 
-#define UNCOMPRESS_ONE_ROW0(channel)                                            \
-    correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,               \
-                                             correlate_row[i - 1])->bestcode,   \
-                                             encoder->io_word,                  \
-                                             &codewordlen);                     \
-    FNAME(correlate_0)(&cur_row[i], correlate_row[i], bpc_mask);                \
+#define UNCOMPRESS_ONE_ROW0(channel)                                                                            \
+    channel->correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,                                      \
+                                                                  channel->correlate_row[i - 1])->bestcode,     \
+                                                                  encoder->io_word,                             \
+                                                                  &codewordlen);                                \
+    FNAME(correlate_0)(&cur_row[i], channel->correlate_row[i], bpc_mask);                                                \
     decode_eatbits(encoder, codewordlen);
 
 static void FNAME(uncompress_row0_seg)(Encoder *encoder, Channel *channel, int i,
@@ -330,7 +331,6 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, Channel *channel, int i
                                        const unsigned int bpc_mask)
 {
     CommonState *state = &channel->state;
-    BYTE * const correlate_row = channel->correlate_row;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -412,19 +412,18 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
 }
 
 #define UNCOMPRESS_ONE_0(channel) \
-    correlate_row[0] = (BYTE)golomb_decoding(find_bucket(channel,                               \
-                                                         correlate_row[-1])->bestcode,          \
-                                                         encoder->io_word, &codewordlen);       \
-    SET_a(&cur_row[0], (family.xlatL2U[correlate_row[0]] +                                      \
-                  GET_a(prev_row)) & bpc_mask);                                                 \
+    channel->correlate_row[0] = (BYTE)golomb_decoding(find_bucket(channel,                              \
+                                                                  channel->correlate_row[-1])->bestcode,\
+                                                      encoder->io_word, &codewordlen);                  \
+    SET_a(&cur_row[0], (family.xlatL2U[channel->correlate_row[0]] +                                     \
+                  GET_a(prev_row)) & bpc_mask);                                                         \
     decode_eatbits(encoder, codewordlen);
 
-#define UNCOMPRESS_ONE(channel)                                                                 \
-    correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,                               \
-                                                         correlate_row[i - 1])->bestcode,       \
-                                                         encoder->io_word,                      \
-                                                         &codewordlen);                         \
-    FNAME(correlate)(&prev_row[i], &cur_row[i], correlate_row[i], bpc_mask);                    \
+#define UNCOMPRESS_ONE(channel)                                                                                 \
+    channel->correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,                                      \
+                                                                  channel->correlate_row[i - 1])->bestcode,     \
+                                                      encoder->io_word, &codewordlen);                          \
+    FNAME(correlate)(&prev_row[i], &cur_row[i], channel->correlate_row[i], bpc_mask);                           \
     decode_eatbits(encoder, codewordlen);
 
 static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
@@ -436,7 +435,6 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
                                       const unsigned int bpc_mask)
 {
     CommonState *state = &channel->state;
-    BYTE * const correlate_row = channel->correlate_row;
     const unsigned int waitmask = bppmask[state->wmidx];
     int stopidx;
     int run_index = 0;
-- 
2.13.3

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