[Spice-commits] 6 commits - common/quic.c common/quic_rgb_tmpl.c common/quic_tmpl.c

Christophe Fergau teuf at kemper.freedesktop.org
Wed Aug 2 07:18:25 UTC 2017


 common/quic.c          |   27 +++-------
 common/quic_rgb_tmpl.c |   76 ++++++++++++++--------------
 common/quic_tmpl.c     |  130 ++++++++++++++++++++++++-------------------------
 3 files changed, 112 insertions(+), 121 deletions(-)

New commits:
commit c39f2da17edcc99048d04e0b4d9852fbe00c8ce8
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Jul 4 14:55:10 2017 +0200

    quic: Use i == 0 rather than !i
    
    This helps to make quic_rgb_tmpl.c and quic_tmpl.c more consistent.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index 15d14b9..23dea39 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -237,7 +237,7 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, int i,
 
     spice_assert(end - i > 0);
 
-    if (!i) {
+    if (i == 0) {
         unsigned int codeword, codewordlen;
 
         COMPRESS_ONE_ROW0_0(r);
@@ -349,7 +349,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
 
     spice_assert(end - i > 0);
 
-    if (!i) {
+    if (i == 0) {
         unsigned int codeword, codewordlen;
 
         COMPRESS_ONE_0(r);
@@ -492,7 +492,7 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, int i,
 
     spice_assert(end - i > 0);
 
-    if (!i) {
+    if (i == 0) {
         unsigned int codewordlen;
 
         UNCOMPRESS_PIX_START(&cur_row[i]);
@@ -613,7 +613,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder,
 
     spice_assert(end - i > 0);
 
-    if (!i) {
+    if (i == 0) {
         unsigned int codewordlen;
 
         UNCOMPRESS_PIX_START(&cur_row[i]);
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index b77dc07..b9056bb 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -255,7 +255,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
 
     spice_assert(end - i > 0);
 
-    if (!i) {
+    if (i == 0) {
         unsigned int codeword, codewordlen;
 
         decorrelate_drow[0] = family.xlatU2L[(unsigned)((int)cur_row->a -
commit 8dd7374a1d416813d081a5a8c55c90b2bc9b61e3
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Jul 4 11:09:54 2017 +0200

    quic: Fix "corelate" typo
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index f3d07a5..15d14b9 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -114,20 +114,20 @@
 
 /*  a  */
 
-#define DECORELATE_0(channel, curr, bpc_mask)\
+#define DECORRELATE_0(channel, curr, bpc_mask)\
     family.xlatU2L[(unsigned)((int)GET_##channel(curr) - (int)_PIXEL_A(channel, curr)) & bpc_mask]
 
-#define CORELATE_0(channel, curr, correlate, bpc_mask)\
+#define CORRELATE_0(channel, curr, correlate, bpc_mask)\
     ((family.xlatL2U[correlate] + _PIXEL_A(channel, curr)) & bpc_mask)
 
 #ifdef PRED_1
 
 /*  (a+b)/2  */
-#define DECORELATE(channel, prev, curr, bpc_mask, r)                                            \
+#define DECORRELATE(channel, prev, curr, bpc_mask, r)                                           \
     r = family.xlatU2L[(unsigned)((int)GET_##channel(curr) - (int)((_PIXEL_A(channel, curr) +   \
                         _PIXEL_B(channel, prev)) >> 1)) & bpc_mask]
 
-#define CORELATE(channel, prev, curr, correlate, bpc_mask, r)                                   \
+#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))
 #endif
@@ -135,7 +135,7 @@
 #ifdef PRED_2
 
 /*  .75a+.75b-.5c  */
-#define DECORELATE(channel, prev, curr, bpc_mask, r) {                          \
+#define DECORRELATE(channel, prev, curr, bpc_mask, r) {                         \
     int p = ((int)(3 * (_PIXEL_A(channel, curr) + _PIXEL_B(channel, prev))) -   \
                         (int)(_PIXEL_C(channel, prev) << 1)) >> 2;              \
     if (p < 0) {                                                                \
@@ -146,7 +146,7 @@
     r = family.xlatU2L[(unsigned)((int)GET_##channel(curr) - p) & bpc_mask];    \
 }
 
-#define CORELATE(channel, prev, curr, correlate, bpc_mask, r) {                         \
+#define CORRELATE(channel, prev, curr, correlate, bpc_mask, r) {                        \
     const int p = ((int)(3 * (_PIXEL_A(channel, curr) + _PIXEL_B(channel, prev))) -     \
                         (int)(_PIXEL_C(channel, prev) << 1) ) >> 2;                     \
     const unsigned int s = family.xlatL2U[correlate];                                   \
@@ -170,7 +170,7 @@
     encode(encoder, codeword, codewordlen);
 
 #define COMPRESS_ONE_ROW0(channel, index)                                               \
-    correlate_row_##channel[index] = DECORELATE_0(channel, &cur_row[index], bpc_mask);  \
+    correlate_row_##channel[index] = DECORRELATE_0(channel, &cur_row[index], bpc_mask); \
     golomb_coding(correlate_row_##channel[index], find_bucket(channel_##channel,        \
                   correlate_row_##channel[index -1])->bestcode,                         \
                   &codeword, &codewordlen);                                             \
@@ -319,7 +319,7 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
     encode(encoder, codeword, codewordlen);
 
 #define COMPRESS_ONE(channel, index)                                                            \
-    DECORELATE(channel, &prev_row[index], &cur_row[index],bpc_mask,                             \
+    DECORRELATE(channel, &prev_row[index], &cur_row[index],bpc_mask,                            \
                correlate_row_##channel[index]);                                                 \
     golomb_coding(correlate_row_##channel[index],                                               \
                  find_bucket(channel_##channel, correlate_row_##channel[index - 1])->bestcode,  \
@@ -470,7 +470,7 @@ static void FNAME(compress_row)(Encoder *encoder,
                                                        correlate_row_##channel[i - 1])->bestcode, \
                                                        encoder->io_word,                          \
                                                        &codewordlen);                             \
-    SET_##channel(&cur_row[i], CORELATE_0(channel, &cur_row[i], correlate_row_##channel[i],       \
+    SET_##channel(&cur_row[i], CORRELATE_0(channel, &cur_row[i], correlate_row_##channel[i],      \
                   bpc_mask));                                                                     \
     decode_eatbits(encoder, codewordlen);
 
@@ -585,7 +585,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
                                                        correlate_row_##channel[i - 1])->bestcode, \
                                                        encoder->io_word,                          \
                                                        &codewordlen);                             \
-    CORELATE(channel, &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);
 
@@ -736,14 +736,14 @@ static void FNAME(uncompress_row)(Encoder *encoder,
 #undef RLE_PRED_2_IMP
 #undef RLE_PRED_3_IMP
 #undef UPDATE_MODEL
-#undef DECORELATE_0
-#undef DECORELATE
+#undef DECORRELATE_0
+#undef DECORRELATE
 #undef COMPRESS_ONE_ROW0_0
 #undef COMPRESS_ONE_ROW0
 #undef COMPRESS_ONE_0
 #undef COMPRESS_ONE
-#undef CORELATE_0
-#undef CORELATE
+#undef CORRELATE_0
+#undef CORRELATE
 #undef UNCOMPRESS_ONE_ROW0_0
 #undef UNCOMPRESS_ONE_ROW0
 #undef UNCOMPRESS_ONE_0
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index 4f76743..b77dc07 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -83,31 +83,31 @@ if (i > 1 && cur_row[i - 1].a == cur_row[i - 2].a && i != run_index) {  \
 #endif
 
 /*  a  */
-static inline BYTE FNAME(decorelate_0)(const PIXEL * const curr, const unsigned int bpc_mask)
+static inline BYTE FNAME(decorrelate_0)(const PIXEL * const curr, const unsigned int bpc_mask)
 {
     return family.xlatU2L[(unsigned)((int)curr[0].a - (int)_PIXEL_A) & bpc_mask];
 }
 
-static inline void FNAME(corelate_0)(PIXEL *curr, const BYTE corelate,
-                                     const unsigned int bpc_mask)
+static inline void FNAME(correlate_0)(PIXEL *curr, const BYTE correlate,
+                                      const unsigned int bpc_mask)
 {
-    curr->a = (family.xlatL2U[corelate] + _PIXEL_A) & bpc_mask;
+    curr->a = (family.xlatL2U[correlate] + _PIXEL_A) & bpc_mask;
 }
 
 #ifdef PRED_1
 
 /*  (a+b)/2  */
-static inline BYTE FNAME(decorelate)(const PIXEL *const prev, const PIXEL * const curr,
-                                     const unsigned int bpc_mask)
+static inline BYTE FNAME(decorrelate)(const PIXEL *const prev, const PIXEL * const curr,
+                                      const unsigned int bpc_mask)
 {
     return family.xlatU2L[(unsigned)((int)curr->a - (int)((_PIXEL_A + _PIXEL_B) >> 1)) & bpc_mask];
 }
 
 
-static inline void FNAME(corelate)(const PIXEL *prev, PIXEL *curr, const BYTE corelate,
-                                   const unsigned int bpc_mask)
+static inline void FNAME(correlate)(const PIXEL *prev, PIXEL *curr, const BYTE correlate,
+                                    const unsigned int bpc_mask)
 {
-    curr->a = (family.xlatL2U[corelate] + (int)((_PIXEL_A + _PIXEL_B) >> 1)) & bpc_mask;
+    curr->a = (family.xlatL2U[correlate] + (int)((_PIXEL_A + _PIXEL_B) >> 1)) & bpc_mask;
 }
 
 #endif
@@ -115,8 +115,8 @@ static inline void FNAME(corelate)(const PIXEL *prev, PIXEL *curr, const BYTE co
 #ifdef PRED_2
 
 /*  .75a+.75b-.5c  */
-static inline BYTE FNAME(decorelate)(const PIXEL *const prev, const PIXEL * const curr,
-                                     const unsigned int bpc_mask)
+static inline BYTE FNAME(decorrelate)(const PIXEL *const prev, const PIXEL * const curr,
+                                      const unsigned int bpc_mask)
 {
     int p = ((int)(3 * (_PIXEL_A + _PIXEL_B)) - (int)(_PIXEL_C << 1)) >> 2;
 
@@ -131,11 +131,11 @@ static inline BYTE FNAME(decorelate)(const PIXEL *const prev, const PIXEL * cons
     }
 }
 
-static inline void FNAME(corelate)(const PIXEL *prev, PIXEL *curr, const BYTE corelate,
-                                   const unsigned int bpc_mask)
+static inline void FNAME(correlate)(const PIXEL *prev, PIXEL *curr, const BYTE correlate,
+                                    const unsigned int bpc_mask)
 {
     const int p = ((int)(3 * (_PIXEL_A + _PIXEL_B)) - (int)(_PIXEL_C << 1)) >> 2;
-    const unsigned int s = family.xlatL2U[corelate];
+    const unsigned int s = family.xlatL2U[correlate];
 
     if (!(p & ~bpc_mask)) {
         curr->a = (s + (unsigned)p) & bpc_mask;
@@ -155,7 +155,7 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
                                      SPICE_GNUC_UNUSED const unsigned int bpc,
                                      const unsigned int bpc_mask)
 {
-    BYTE * const decorelate_drow = channel->correlate_row;
+    BYTE * const decorrelate_drow = channel->correlate_row;
     int stopidx;
 
     spice_assert(end - i > 0);
@@ -163,8 +163,8 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
     if (i == 0) {
         unsigned int codeword, codewordlen;
 
-        decorelate_drow[0] = family.xlatU2L[cur_row->a];
-        golomb_coding(decorelate_drow[0], find_bucket(channel, decorelate_drow[-1])->bestcode,
+        decorrelate_drow[0] = family.xlatU2L[cur_row->a];
+        golomb_coding(decorrelate_drow[0], find_bucket(channel, decorrelate_drow[-1])->bestcode,
                       &codeword, &codewordlen);
         encode(encoder, codeword, codewordlen);
 
@@ -172,8 +172,8 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
             channel->state.waitcnt--;
         } else {
             channel->state.waitcnt = (tabrand(&channel->state.tabrand_seed) & waitmask);
-            update_model(&channel->state, find_bucket(channel, decorelate_drow[-1]),
-                         decorelate_drow[i]);
+            update_model(&channel->state, find_bucket(channel, decorrelate_drow[-1]),
+                         decorrelate_drow[i]);
         }
         stopidx = ++i + channel->state.waitcnt;
     } else {
@@ -183,22 +183,22 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
     while (stopidx < end) {
         for (; i <= stopidx; i++) {
             unsigned int codeword, codewordlen;
-            decorelate_drow[i] = FNAME(decorelate_0)(&cur_row[i], bpc_mask);
-            golomb_coding(decorelate_drow[i],
-                          find_bucket(channel, decorelate_drow[i - 1])->bestcode, &codeword,
+            decorrelate_drow[i] = FNAME(decorrelate_0)(&cur_row[i], bpc_mask);
+            golomb_coding(decorrelate_drow[i],
+                          find_bucket(channel, decorrelate_drow[i - 1])->bestcode, &codeword,
                           &codewordlen);
             encode(encoder, codeword, codewordlen);
         }
 
-        update_model(&channel->state, find_bucket(channel, decorelate_drow[stopidx - 1]),
-                     decorelate_drow[stopidx]);
+        update_model(&channel->state, find_bucket(channel, decorrelate_drow[stopidx - 1]),
+                     decorrelate_drow[stopidx]);
         stopidx = i + (tabrand(&channel->state.tabrand_seed) & waitmask);
     }
 
     for (; i < end; i++) {
         unsigned int codeword, codewordlen;
-        decorelate_drow[i] = FNAME(decorelate_0)(&cur_row[i], bpc_mask);
-        golomb_coding(decorelate_drow[i], find_bucket(channel, decorelate_drow[i - 1])->bestcode,
+        decorrelate_drow[i] = FNAME(decorrelate_0)(&cur_row[i], bpc_mask);
+        golomb_coding(decorrelate_drow[i], find_bucket(channel, decorrelate_drow[i - 1])->bestcode,
                       &codeword, &codewordlen);
         encode(encoder, codeword, codewordlen);
     }
@@ -246,7 +246,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
                                     SPICE_GNUC_UNUSED const unsigned int bpc,
                                     const unsigned int bpc_mask)
 {
-    BYTE * const decorelate_drow = channel->correlate_row;
+    BYTE * const decorrelate_drow = channel->correlate_row;
     int stopidx;
 #ifdef RLE
     int run_index = 0;
@@ -258,11 +258,11 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
     if (!i) {
         unsigned int codeword, codewordlen;
 
-        decorelate_drow[0] = family.xlatU2L[(unsigned)((int)cur_row->a -
+        decorrelate_drow[0] = family.xlatU2L[(unsigned)((int)cur_row->a -
                                                        (int)prev_row->a) & bpc_mask];
 
-        golomb_coding(decorelate_drow[0],
-                      find_bucket(channel, decorelate_drow[-1])->bestcode,
+        golomb_coding(decorrelate_drow[0],
+                      find_bucket(channel, decorrelate_drow[-1])->bestcode,
                       &codeword,
                       &codewordlen);
         encode(encoder, codeword, codewordlen);
@@ -271,8 +271,8 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
             channel->state.waitcnt--;
         } else {
             channel->state.waitcnt = (tabrand(&channel->state.tabrand_seed) & waitmask);
-            update_model(&channel->state, find_bucket(channel, decorelate_drow[-1]),
-                         decorelate_drow[0]);
+            update_model(&channel->state, find_bucket(channel, decorrelate_drow[-1]),
+                         decorrelate_drow[0]);
         }
         stopidx = ++i + channel->state.waitcnt;
     } else {
@@ -287,15 +287,15 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
                 RLE_PRED_2_IMP;
                 RLE_PRED_3_IMP;
 #endif
-                decorelate_drow[i] = FNAME(decorelate)(&prev_row[i], &cur_row[i], bpc_mask);
-                golomb_coding(decorelate_drow[i],
-                              find_bucket(channel, decorelate_drow[i - 1])->bestcode, &codeword,
+                decorrelate_drow[i] = FNAME(decorrelate)(&prev_row[i], &cur_row[i], bpc_mask);
+                golomb_coding(decorrelate_drow[i],
+                              find_bucket(channel, decorrelate_drow[i - 1])->bestcode, &codeword,
                               &codewordlen);
                 encode(encoder, codeword, codewordlen);
             }
 
-            update_model(&channel->state, find_bucket(channel, decorelate_drow[stopidx - 1]),
-                         decorelate_drow[stopidx]);
+            update_model(&channel->state, find_bucket(channel, decorrelate_drow[stopidx - 1]),
+                         decorrelate_drow[stopidx]);
             stopidx = i + (tabrand(&channel->state.tabrand_seed) & waitmask);
         }
 
@@ -306,9 +306,9 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
             RLE_PRED_2_IMP;
             RLE_PRED_3_IMP;
 #endif
-            decorelate_drow[i] = FNAME(decorelate)(&prev_row[i], &cur_row[i], bpc_mask);
-            golomb_coding(decorelate_drow[i], find_bucket(channel,
-                                                          decorelate_drow[i - 1])->bestcode,
+            decorrelate_drow[i] = FNAME(decorrelate)(&prev_row[i], &cur_row[i], bpc_mask);
+            golomb_coding(decorrelate_drow[i], find_bucket(channel,
+                                                          decorrelate_drow[i - 1])->bestcode,
                           &codeword, &codewordlen);
             encode(encoder, codeword, codewordlen);
         }
@@ -422,7 +422,7 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, Channel *channel, int i
             pbucket = find_bucket(channel, correlate_row[i - 1]);
             correlate_row[i] = (BYTE)golomb_decoding(pbucket->bestcode, encoder->io_word,
                                                      &codewordlen);
-            FNAME(corelate_0)(&cur_row[i], correlate_row[i], bpc_mask);
+            FNAME(correlate_0)(&cur_row[i], correlate_row[i], bpc_mask);
             decode_eatbits(encoder, codewordlen);
         }
 
@@ -437,7 +437,7 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, Channel *channel, int i
         correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,
                                                              correlate_row[i - 1])->bestcode,
                                                  encoder->io_word, &codewordlen);
-        FNAME(corelate_0)(&cur_row[i], correlate_row[i], bpc_mask);
+        FNAME(correlate_0)(&cur_row[i], correlate_row[i], bpc_mask);
         decode_eatbits(encoder, codewordlen);
     }
     channel->state.waitcnt = stopidx - end;
@@ -531,7 +531,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
                 pbucket = find_bucket(channel, correlate_row[i - 1]);
                 correlate_row[i] = (BYTE)golomb_decoding(pbucket->bestcode, encoder->io_word,
                                                          &codewordlen);
-                FNAME(corelate)(&prev_row[i], &cur_row[i], correlate_row[i], bpc_mask);
+                FNAME(correlate)(&prev_row[i], &cur_row[i], correlate_row[i], bpc_mask);
                 decode_eatbits(encoder, codewordlen);
             }
 
@@ -550,7 +550,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
             correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,
                                                                  correlate_row[i - 1])->bestcode,
                                                      encoder->io_word, &codewordlen);
-            FNAME(corelate)(&prev_row[i], &cur_row[i], correlate_row[i], bpc_mask);
+            FNAME(correlate)(&prev_row[i], &cur_row[i], correlate_row[i], bpc_mask);
             decode_eatbits(encoder, codewordlen);
         }
 
commit 9574246403a6a1a52d849e8333414426ba8637d9
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Aug 1 14:54:51 2017 +0200

    quic: Use SPICE_VERIFY for static check
    
    DEFevol is known at compile-time, so we can use SPICE_VERIFY to check
    its value.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/quic.c b/common/quic.c
index 049a5cd..8567368 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -254,7 +254,7 @@ static void set_wm_trigger(CommonState *state)
         wm = 10;
     }
 
-    spice_assert(DEFevol < 6);
+    SPICE_VERIFY(DEFevol < 6);
 
     state->wm_trigger = besttrigtab[DEFevol / 2][wm];
 
commit 5684ed10be4f7596b2c6325f7a77446680804e51
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Aug 1 15:06:37 2017 +0200

    quic: Use DEFwmimax constant rather than wmimax variable
    
    We never change its value, so we basically have 2 constants for the
    same thing, DEFwmimax and wmimax. This commit removes the latter.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/quic.c b/common/quic.c
index 04fdd62..049a5cd 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -172,9 +172,6 @@ struct Encoder {
     CommonState rgb_state;
 };
 
-/* target wait mask index */
-static const int wmimax = DEFwmimax;
-
 /* bppmask[i] contains i ones as lsb-s */
 static const unsigned long int bppmask[33] = {
     0x00000000, /* [0] */
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index bd2a70a..f3d07a5 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -284,7 +284,7 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
     const unsigned int bpc_mask = BPC_MASK;
     int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((DEFwmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(compress_row0_seg)(encoder, pos, cur_row, pos + encoder->rgb_state.wmileft,
                                      bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
@@ -300,12 +300,12 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
     if (width) {
         FNAME(compress_row0_seg)(encoder, pos, cur_row, pos + width,
                                  bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (DEFwmimax > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= DEFwmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
@@ -428,7 +428,7 @@ static void FNAME(compress_row)(Encoder *encoder,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((DEFwmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(compress_row_seg)(encoder, pos, prev_row, cur_row,
                                     pos + encoder->rgb_state.wmileft,
@@ -446,12 +446,12 @@ static void FNAME(compress_row)(Encoder *encoder,
     if (width) {
         FNAME(compress_row_seg)(encoder, pos, prev_row, cur_row, pos + width,
                                 bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (DEFwmimax > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= DEFwmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
@@ -544,7 +544,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((DEFwmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(uncompress_row0_seg)(encoder, pos, cur_row,
                                        pos + encoder->rgb_state.wmileft,
@@ -562,12 +562,12 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
     if (width) {
         FNAME(uncompress_row0_seg)(encoder, pos, cur_row, pos + width,
                                    bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (DEFwmimax > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= DEFwmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
@@ -700,7 +700,7 @@ static void FNAME(uncompress_row)(Encoder *encoder,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((DEFwmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(uncompress_row_seg)(encoder, prev_row, cur_row, pos,
                                       pos + encoder->rgb_state.wmileft, bpc, bpc_mask);
@@ -716,12 +716,12 @@ static void FNAME(uncompress_row)(Encoder *encoder,
     if (width) {
         FNAME(uncompress_row_seg)(encoder, prev_row, cur_row, pos,
                                   pos + width, bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (DEFwmimax > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= DEFwmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index 0ad9dd6..4f76743 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -212,7 +212,7 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
     const unsigned int bpc_mask = BPC_MASK;
     int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((DEFwmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(compress_row0_seg)(encoder, channel, pos, cur_row, pos + channel->state.wmileft,
                                      bppmask[channel->state.wmidx], bpc, bpc_mask);
@@ -228,12 +228,12 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
     if (width) {
         FNAME(compress_row0_seg)(encoder, channel, pos, cur_row, pos + width,
                                  bppmask[channel->state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (DEFwmimax > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= DEFwmimax);
     spice_assert(channel->state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
@@ -353,7 +353,7 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((DEFwmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(compress_row_seg)(encoder, channel, pos, prev_row, cur_row,
                                     pos + channel->state.wmileft, bppmask[channel->state.wmidx],
@@ -370,12 +370,12 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
     if (width) {
         FNAME(compress_row_seg)(encoder, channel, pos, prev_row, cur_row, pos + width,
                                 bppmask[channel->state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (DEFwmimax > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= DEFwmimax);
     spice_assert(channel->state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
@@ -453,7 +453,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
     BYTE * const correlate_row = channel->correlate_row;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((DEFwmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(uncompress_row0_seg)(encoder, channel, pos, correlate_row, cur_row,
                                        pos + channel->state.wmileft, bppmask[channel->state.wmidx],
@@ -470,12 +470,12 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
     if (width) {
         FNAME(uncompress_row0_seg)(encoder, channel, pos, correlate_row, cur_row, pos + width,
                                    bppmask[channel->state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (DEFwmimax > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= DEFwmimax);
     spice_assert(channel->state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
@@ -592,7 +592,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
     BYTE * const correlate_row = channel->correlate_row;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((DEFwmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(uncompress_row_seg)(encoder, channel, correlate_row, prev_row, cur_row, pos,
                                       pos + channel->state.wmileft, bpc, bpc_mask);
@@ -608,12 +608,12 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
     if (width) {
         FNAME(uncompress_row_seg)(encoder, channel, correlate_row, prev_row, cur_row, pos,
                                   pos + width, bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (DEFwmimax > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= DEFwmimax);
     spice_assert(channel->state.wmidx <= 32);
     spice_assert(DEFwminext > 0);
 }
commit f122d3dadc4dab8d11d32707292018e9e8809319
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Aug 1 15:03:37 2017 +0200

    quic: Use DEFwminext constant rather than wminext variable
    
    We never change its value, so we basically have 2 constants for the
    same thing, DEFwminext and wminext. This commit removes the latter
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/quic.c b/common/quic.c
index 1deda47..04fdd62 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -175,9 +175,6 @@ struct Encoder {
 /* target wait mask index */
 static const int wmimax = DEFwmimax;
 
-/* number of symbols to encode before increasing wait mask index */
-static const int wminext = DEFwminext;
-
 /* bppmask[i] contains i ones as lsb-s */
 static const unsigned long int bppmask[33] = {
     0x00000000, /* [0] */
@@ -1066,7 +1063,7 @@ static int encoder_reset(Encoder *encoder, uint32_t *io_ptr, uint32_t *io_ptr_en
     encoder->rgb_state.waitcnt = 0;
     encoder->rgb_state.tabrand_seed = stabrand();
     encoder->rgb_state.wmidx = DEFwmistart;
-    encoder->rgb_state.wmileft = wminext;
+    encoder->rgb_state.wmileft = DEFwminext;
     set_wm_trigger(&encoder->rgb_state);
 
 #if defined(RLE) && defined(RLE_STAT)
@@ -1130,7 +1127,7 @@ static int encoder_reset_channels(Encoder *encoder, int channels, int width, int
         encoder->channels[i].state.waitcnt = 0;
         encoder->channels[i].state.tabrand_seed = stabrand();
         encoder->channels[i].state.wmidx = DEFwmistart;
-        encoder->channels[i].state.wmileft = wminext;
+        encoder->channels[i].state.wmileft = DEFwminext;
         set_wm_trigger(&encoder->channels[i].state);
 
 #if defined(RLE) && defined(RLE_STAT)
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index f807a0c..bd2a70a 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -294,7 +294,7 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -307,7 +307,7 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
 
     spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 #define COMPRESS_ONE_0(channel) \
@@ -440,7 +440,7 @@ static void FNAME(compress_row)(Encoder *encoder,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -453,7 +453,7 @@ static void FNAME(compress_row)(Encoder *encoder,
 
     spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 #endif
@@ -556,7 +556,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -569,7 +569,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
 
     spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 #define UNCOMPRESS_ONE_0(channel) \
@@ -710,7 +710,7 @@ static void FNAME(uncompress_row)(Encoder *encoder,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -723,7 +723,7 @@ static void FNAME(uncompress_row)(Encoder *encoder,
 
     spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 #undef PIXEL
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index e839346..0ad9dd6 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -222,7 +222,7 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -235,7 +235,7 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
 
     spice_assert((int)channel->state.wmidx <= wmimax);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
@@ -364,7 +364,7 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -377,7 +377,7 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
 
     spice_assert((int)channel->state.wmidx <= wmimax);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 static void FNAME(uncompress_row0_seg)(Encoder *encoder, Channel *channel, int i,
@@ -464,7 +464,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -477,7 +477,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
 
     spice_assert((int)channel->state.wmidx <= wmimax);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
@@ -602,7 +602,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = DEFwminext;
     }
 
     if (width) {
@@ -615,7 +615,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
 
     spice_assert((int)channel->state.wmidx <= wmimax);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(DEFwminext > 0);
 }
 
 #undef PIXEL
commit db5bff3728257a364341d2c8bd4ebaa4c1bab2b7
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Jul 3 18:32:53 2017 +0200

    quic: Use DEFevol constant rather than evol variable
    
    We never change 'evol' value, and this is currently causing issues with
    gcc 7.1.1: quic.c is checking at compile-time that 'evol' is 1, 3 or 5.
    This is a constant, so a static check should be good, but the compiler (gcc
    7.1.1) is unable to know 'evol' value at compile-time. Since the removal
    of spice_static_assert in favour of SPICE_VERIFY, this causes a
    compile-time failure.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/quic.c b/common/quic.c
index c188ed2..1deda47 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -178,9 +178,6 @@ static const int wmimax = DEFwmimax;
 /* number of symbols to encode before increasing wait mask index */
 static const int wminext = DEFwminext;
 
-/* model evolution mode */
-static const int evol = DEFevol;
-
 /* bppmask[i] contains i ones as lsb-s */
 static const unsigned long int bppmask[33] = {
     0x00000000, /* [0] */
@@ -248,14 +245,14 @@ static unsigned int tabrand(unsigned int *tabrand_seed)
     return tabrand_chaos[++*tabrand_seed & TABRAND_SEEDMASK];
 }
 
-static const unsigned short besttrigtab[3][11] = { /* array of wm_trigger for waitmask and evol,
+static const unsigned short besttrigtab[3][11] = { /* array of wm_trigger for waitmask and DEFevol,
                                                     used by set_wm_trigger() */
     /* 1 */ { 550, 900, 800, 700, 500, 350, 300, 200, 180, 180, 160},
     /* 3 */ { 110, 550, 900, 800, 550, 400, 350, 250, 140, 160, 140},
     /* 5 */ { 100, 120, 550, 900, 700, 500, 400, 300, 220, 250, 160}
 };
 
-/* set wm_trigger knowing waitmask (param) and evol (glob)*/
+/* set wm_trigger knowing waitmask (param) and DEFevol (glob)*/
 static void set_wm_trigger(CommonState *state)
 {
     unsigned int wm = state->wmidx;
@@ -263,9 +260,9 @@ static void set_wm_trigger(CommonState *state)
         wm = 10;
     }
 
-    spice_assert(evol < 6);
+    spice_assert(DEFevol < 6);
 
-    state->wm_trigger = besttrigtab[evol / 2][wm];
+    state->wm_trigger = besttrigtab[DEFevol / 2][wm];
 
     spice_assert(state->wm_trigger <= 2000);
     spice_assert(state->wm_trigger >= 1);
@@ -878,7 +875,7 @@ static void find_model_params(Encoder *encoder,
     /* The only valid values are 1, 3 and 5.
        0, 2 and 4 are obsolete and the rest of the
        values are considered out of the range. */
-    SPICE_VERIFY(evol == 1 || evol == 3 || evol == 5);
+    SPICE_VERIFY(DEFevol == 1 || DEFevol == 3 || DEFevol == 5);
     spice_assert(bpc <= 8 && bpc > 0);
 
     *ncounters = 8;
@@ -887,7 +884,7 @@ static void find_model_params(Encoder *encoder,
 
     *n_buckets_ptrs = 0;  /* ==0 means: not set yet */
 
-    switch (evol) {   /* set repfirst firstsize repnext mulsize */
+    switch (DEFevol) {   /* set repfirst firstsize repnext mulsize */
     case 1: /* buckets contain following numbers of contexts: 1 1 1 2 2 4 4 8 8 ... */
         *repfirst = 3;
         *firstsize = 1;
@@ -907,7 +904,7 @@ static void find_model_params(Encoder *encoder,
         *mulsize = 4;
         break;
     default:
-        encoder->usr->error(encoder->usr, "findmodelparams(): evol out of range!!!\n");
+        encoder->usr->error(encoder->usr, "findmodelparams(): DEFevol out of range!!!\n");
         return;
     }
 


More information about the Spice-commits mailing list