[Spice-devel] [spice-common 04/14] quic: Remove configurable RLE_PRED

Christophe Fergeau cfergeau at redhat.com
Wed Jul 5 08:20:38 UTC 2017


It's hardcoded at compile-time, and I don't think it was changed in
years...
---
 common/quic.c          |  3 ---
 common/quic_rgb_tmpl.c | 55 ++++++++------------------------------------------
 common/quic_tmpl.c     | 55 ++++++++------------------------------------------
 3 files changed, 16 insertions(+), 97 deletions(-)

diff --git a/common/quic.c b/common/quic.c
index 5fc0c0c..58fb2c0 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -32,9 +32,6 @@
 #define RLE
 #define RLE_STAT
 #define PRED_1
-//#define RLE_PRED_1
-#define RLE_PRED_2
-//#define RLE_PRED_3
 #define QUIC_RGB
 
 /* ASCII "QUIC" */
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index f240e95..3ca649a 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -185,36 +185,15 @@
                 correlate_row_b[index]);
 
 
-#ifdef RLE_PRED_1
-#define RLE_PRED_1_IMP                                                                          \
-if (SAME_PIXEL(&cur_row[i - 1], &prev_row[i])) {                                                \
-    if (run_index != i && SAME_PIXEL(&prev_row[i - 1], &prev_row[i]) &&                         \
-                                i + 1 < end && SAME_PIXEL(&prev_row[i], &prev_row[i + 1])) {    \
-        goto do_run;                                                                            \
-    }                                                                                           \
-}
-#else
-#define RLE_PRED_1_IMP
-#endif
-
-#ifdef RLE_PRED_2
-#define RLE_PRED_2_IMP                                                              \
+#ifdef RLE
+#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])) {  \
         goto do_run;                                                                \
     }                                                                               \
 }
 #else
-#define RLE_PRED_2_IMP
-#endif
-
-#ifdef RLE_PRED_3
-#define RLE_PRED_3_IMP                                                              \
-if (i > 1 &&  SAME_PIXEL(&cur_row[i - 1], &cur_row[i - 2]) && i != run_index) {     \
-    goto do_run;                                                                    \
-}
-#else
-#define RLE_PRED_3_IMP
+#define RLE_PRED_IMP
 #endif
 
 #ifdef COMPRESS_IMP
@@ -370,11 +349,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
         while (stopidx < end) {
             for (; i <= stopidx; i++) {
                 unsigned int codeword, codewordlen;
-#ifdef RLE
-                RLE_PRED_1_IMP;
-                RLE_PRED_2_IMP;
-                RLE_PRED_3_IMP;
-#endif
+                RLE_PRED_IMP;
                 COMPRESS_ONE(r, i);
                 COMPRESS_ONE(g, i);
                 COMPRESS_ONE(b, i);
@@ -386,11 +361,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
 
         for (; i < end; i++) {
             unsigned int codeword, codewordlen;
-#ifdef RLE
-            RLE_PRED_1_IMP;
-            RLE_PRED_2_IMP;
-            RLE_PRED_3_IMP;
-#endif
+            RLE_PRED_IMP;
             COMPRESS_ONE(r, i);
             COMPRESS_ONE(g, i);
             COMPRESS_ONE(b, i);
@@ -635,11 +606,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder,
         while (stopidx < end) {
             for (; i <= stopidx; i++) {
                 unsigned int codewordlen;
-#ifdef RLE
-                RLE_PRED_1_IMP;
-                RLE_PRED_2_IMP;
-                RLE_PRED_3_IMP;
-#endif
+                RLE_PRED_IMP;
                 UNCOMPRESS_PIX_START(&cur_row[i]);
                 UNCOMPRESS_ONE(r);
                 UNCOMPRESS_ONE(g);
@@ -653,11 +620,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder,
 
         for (; i < end; i++) {
             unsigned int codewordlen;
-#ifdef RLE
-            RLE_PRED_1_IMP;
-            RLE_PRED_2_IMP;
-            RLE_PRED_3_IMP;
-#endif
+            RLE_PRED_IMP;
             UNCOMPRESS_PIX_START(&cur_row[i]);
             UNCOMPRESS_ONE(r);
             UNCOMPRESS_ONE(g);
@@ -732,9 +695,7 @@ static void FNAME(uncompress_row)(Encoder *encoder,
 #undef _PIXEL_B
 #undef _PIXEL_C
 #undef SAME_PIXEL
-#undef RLE_PRED_1_IMP
-#undef RLE_PRED_2_IMP
-#undef RLE_PRED_3_IMP
+#undef RLE_PRED_IMP
 #undef UPDATE_MODEL
 #undef DECORRELATE_0
 #undef DECORRELATE
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index 3dccc77..3c4dea3 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -50,36 +50,15 @@
 #define _PIXEL_B ((unsigned int)prev[0].a)
 #define _PIXEL_C ((unsigned int)prev[-1].a)
 
-#ifdef RLE_PRED_1
-#define RLE_PRED_1_IMP                                                              \
-if (cur_row[i - 1].a == prev_row[i].a) {                                            \
-    if (run_index != i && prev_row[i - 1].a == prev_row[i].a &&                     \
-                        i + 1 < end && prev_row[i].a == prev_row[i + 1].a) {        \
-        goto do_run;                                                                \
-    }                                                                               \
-}
-#else
-#define RLE_PRED_1_IMP
-#endif
-
-#ifdef RLE_PRED_2
-#define RLE_PRED_2_IMP                                                     \
+#ifdef RLE
+#define RLE_PRED_IMP                                                       \
 if (prev_row[i - 1].a == prev_row[i].a) {                                  \
     if (run_index != i && i > 2 && cur_row[i - 1].a == cur_row[i - 2].a) { \
         goto do_run;                                                       \
     }                                                                      \
 }
 #else
-#define RLE_PRED_2_IMP
-#endif
-
-#ifdef RLE_PRED_3
-#define RLE_PRED_3_IMP                                                  \
-if (i > 1 && cur_row[i - 1].a == cur_row[i - 2].a && i != run_index) {  \
-    goto do_run;                                                        \
-}
-#else
-#define RLE_PRED_3_IMP
+#define RLE_PRED_IMP
 #endif
 
 /*  a  */
@@ -282,11 +261,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
         while (stopidx < end) {
             for (; i <= stopidx; i++) {
                 unsigned int codeword, codewordlen;
-#ifdef RLE
-                RLE_PRED_1_IMP;
-                RLE_PRED_2_IMP;
-                RLE_PRED_3_IMP;
-#endif
+                RLE_PRED_IMP;
                 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,
@@ -301,11 +276,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
 
         for (; i < end; i++) {
             unsigned int codeword, codewordlen;
-#ifdef RLE
-            RLE_PRED_1_IMP;
-            RLE_PRED_2_IMP;
-            RLE_PRED_3_IMP;
-#endif
+            RLE_PRED_IMP;
             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,
@@ -523,11 +494,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
 
             for (; i <= stopidx; i++) {
                 unsigned int codewordlen;
-#ifdef RLE
-                RLE_PRED_1_IMP;
-                RLE_PRED_2_IMP;
-                RLE_PRED_3_IMP;
-#endif
+                RLE_PRED_IMP;
                 pbucket = find_bucket(channel, correlate_row[i - 1]);
                 correlate_row[i] = (BYTE)golomb_decoding(pbucket->bestcode, encoder->io_word,
                                                          &codewordlen);
@@ -542,11 +509,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
 
         for (; i < end; i++) {
             unsigned int codewordlen;
-#ifdef RLE
-            RLE_PRED_1_IMP;
-            RLE_PRED_2_IMP;
-            RLE_PRED_3_IMP;
-#endif
+            RLE_PRED_IMP;
             correlate_row[i] = (BYTE)golomb_decoding(find_bucket(channel,
                                                                  correlate_row[i - 1])->bestcode,
                                                      encoder->io_word, &codewordlen);
@@ -623,9 +586,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
 #undef _PIXEL_A
 #undef _PIXEL_B
 #undef _PIXEL_C
-#undef RLE_PRED_1_IMP
-#undef RLE_PRED_2_IMP
-#undef RLE_PRED_3_IMP
+#undef RLE_PRED_IMP
 #undef golomb_coding
 #undef golomb_deoding
 #undef update_model
-- 
2.13.0



More information about the Spice-devel mailing list