[Spice-devel] [spice-common 06/14] quic: Get rid of QUIC_RGB #define

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


It's always set, no need to have conditional compilation based on it.
---
 common/quic.c      | 151 -----------------------------------------------------
 common/quic_tmpl.c |   6 ---
 2 files changed, 157 deletions(-)

diff --git a/common/quic.c b/common/quic.c
index f779afb..c561faa 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -31,7 +31,6 @@
 
 #define RLE
 #define RLE_STAT
-#define QUIC_RGB
 
 /* ASCII "QUIC" */
 #define QUIC_MAGIC 0x43495551
@@ -315,10 +314,8 @@ static unsigned int cnt_l_zeroes(const unsigned int bits)
 #define QUIC_FAMILY_8BPC
 #include "quic_family_tmpl.c"
 
-#ifdef QUIC_RGB
 #define QUIC_FAMILY_5BPC
 #include "quic_family_tmpl.c"
-#endif
 
 static void decorelate_init(QuicFamily *family, int bpc)
 {
@@ -539,7 +536,6 @@ static void encoder_init_rle(CommonState *state)
     state->melcorder = 1 << state->melclen;
 }
 
-#ifdef QUIC_RGB
 
 static void encode_run(Encoder *encoder, unsigned int runlen) //todo: try use end of line
 {
@@ -570,8 +566,6 @@ static void encode_run(Encoder *encoder, unsigned int runlen) //todo: try use en
     }
 }
 
-#endif
-
 static void encode_channel_run(Encoder *encoder, Channel *channel, unsigned int runlen)
 {
     //todo: try use end of line
@@ -605,7 +599,6 @@ static void encode_channel_run(Encoder *encoder, Channel *channel, unsigned int
 /* decoding routine: reads bits from the input and returns a run length. */
 /* argument is the number of pixels left to end-of-line (bound on run length) */
 
-#ifdef QUIC_RGB
 static int decode_run(Encoder *encoder)
 {
     int runlen = 0;
@@ -645,7 +638,6 @@ static int decode_run(Encoder *encoder)
     return runlen;
 }
 
-#endif
 
 static int decode_channel_run(Encoder *encoder, Channel *channel)
 {
@@ -779,8 +771,6 @@ typedef uint16_t rgb16_pixel_t;
 #define FOUR_BYTE
 #include "quic_tmpl.c"
 
-#ifdef QUIC_RGB
-
 #define QUIC_RGB32
 #include "quic_rgb_tmpl.c"
 
@@ -793,13 +783,6 @@ typedef uint16_t rgb16_pixel_t;
 #define QUIC_RGB16_TO_32
 #include "quic_rgb_tmpl.c"
 
-#else
-
-#define THREE_BYTE
-#include "quic_tmpl.c"
-
-#endif
-
 static void fill_model_structures(SPICE_GNUC_UNUSED Encoder *encoder, FamilyStat *family_stat,
                                   unsigned int rep_first, unsigned int first_size,
                                   unsigned int rep_next, unsigned int mul_size,
@@ -1150,9 +1133,6 @@ static void quic_image_params(Encoder *encoder, QuicImageType type, int *channel
     case QUIC_IMAGE_TYPE_RGB16:
         *channels = 3;
         *bpc = 5;
-#ifndef QUIC_RGB
-        encoder->usr->error(encoder->usr, "not implemented\n");
-#endif
         break;
     case QUIC_IMAGE_TYPE_RGB24:
         *channels = 3;
@@ -1217,9 +1197,6 @@ int quic_encode(QuicContext *quic, QuicImageType type, int width, int height,
     uint8_t *prev;
     int channels;
     int bpc;
-#ifndef QUIC_RGB
-    int i;
-#endif
 
     lines_end = line + num_lines * stride;
     if (line == NULL && lines_end != line) {
@@ -1246,7 +1223,6 @@ int quic_encode(QuicContext *quic, QuicImageType type, int width, int height,
     FILL_LINES();
 
     switch (type) {
-#ifdef QUIC_RGB
     case QUIC_IMAGE_TYPE_RGB32:
         spice_assert(ABS(stride) >= width * 4);
         QUIC_COMPRESS_RGB(32);
@@ -1286,47 +1262,6 @@ int quic_encode(QuicContext *quic, QuicImageType type, int width, int height,
             encoder->rows_completed++;
         }
         break;
-#else
-    case QUIC_IMAGE_TYPE_RGB24:
-        spice_assert(ABS(stride) >= width * 3);
-        for (i = 0; i < 3; i++) {
-            encoder->channels[i].correlate_row[-1] = 0;
-            quic_three_compress_row0(encoder, &encoder->channels[i], (three_bytes_t *)(line + i),
-                                     width);
-        }
-        encoder->rows_completed++;
-        for (row = 1; row < height; row++) {
-            prev = line;
-            NEXT_LINE();
-            for (i = 0; i < 3; i++) {
-                encoder->channels[i].correlate_row[-1] = encoder->channels[i].correlate_row[0];
-                quic_three_compress_row(encoder, &encoder->channels[i], (three_bytes_t *)(prev + i),
-                                        (three_bytes_t *)(line + i), width);
-            }
-            encoder->rows_completed++;
-        }
-        break;
-    case QUIC_IMAGE_TYPE_RGB32:
-    case QUIC_IMAGE_TYPE_RGBA:
-        spice_assert(ABS(stride) >= width * 4);
-        for (i = 0; i < channels; i++) {
-            encoder->channels[i].correlate_row[-1] = 0;
-            quic_four_compress_row0(encoder, &encoder->channels[i], (four_bytes_t *)(line + i),
-                                    width);
-        }
-        encoder->rows_completed++;
-        for (row = 1; row < height; row++) {
-            prev = line;
-            NEXT_LINE();
-            for (i = 0; i < channels; i++) {
-                encoder->channels[i].correlate_row[-1] = encoder->channels[i].correlate_row[0];
-                quic_four_compress_row(encoder, &encoder->channels[i], (four_bytes_t *)(prev + i),
-                                       (four_bytes_t *)(line + i), width);
-            }
-            encoder->rows_completed++;
-        }
-        break;
-#endif
     case QUIC_IMAGE_TYPE_GRAY:
         spice_assert(ABS(stride) >= width);
         encoder->channels[0].correlate_row[-1] = 0;
@@ -1406,19 +1341,6 @@ int quic_decode_begin(QuicContext *quic, uint32_t *io_ptr, unsigned int num_io_w
     return QUIC_OK;
 }
 
-#ifndef QUIC_RGB
-static void clear_row(four_bytes_t *row, int width)
-{
-    four_bytes_t *end;
-    for (end = row + width; row < end; row++) {
-        row->a = 0;
-    }
-}
-
-#endif
-
-#ifdef QUIC_RGB
-
 static void uncompress_rgba(Encoder *encoder, uint8_t *buf, int stride)
 {
     unsigned int row;
@@ -1452,8 +1374,6 @@ static void uncompress_rgba(Encoder *encoder, uint8_t *buf, int stride)
     }
 }
 
-#endif
-
 static void uncompress_gray(Encoder *encoder, uint8_t *buf, int stride)
 {
     unsigned int row;
@@ -1494,14 +1414,10 @@ int quic_decode(QuicContext *quic, QuicImageType type, uint8_t *buf, int stride)
     Encoder *encoder = (Encoder *)quic;
     unsigned int row;
     uint8_t *prev;
-#ifndef QUIC_RGB
-    int i;
-#endif
 
     spice_assert(buf);
 
     switch (encoder->type) {
-#ifdef QUIC_RGB
     case QUIC_IMAGE_TYPE_RGB32:
     case QUIC_IMAGE_TYPE_RGB24:
         if (type == QUIC_IMAGE_TYPE_RGB32) {
@@ -1537,73 +1453,6 @@ int quic_decode(QuicContext *quic, QuicImageType type, uint8_t *buf, int stride)
         spice_assert(ABS(stride) >= (int)encoder->width * 4);
         uncompress_rgba(encoder, buf, stride);
         break;
-#else
-    case QUIC_IMAGE_TYPE_RGB24:
-        spice_assert(ABS(stride) >= (int)encoder->width * 3);
-        for (i = 0; i < 3; i++) {
-            encoder->channels[i].correlate_row[-1] = 0;
-            quic_three_uncompress_row0(encoder, &encoder->channels[i], (three_bytes_t *)(buf + i),
-                                       encoder->width);
-        }
-        encoder->rows_completed++;
-        for (row = 1; row < encoder->height; row++) {
-            prev = buf;
-            buf += stride;
-            for (i = 0; i < 3; i++) {
-                encoder->channels[i].correlate_row[-1] = encoder->channels[i].correlate_row[0];
-                quic_three_uncompress_row(encoder, &encoder->channels[i],
-                                          (three_bytes_t *)(prev + i),
-                                          (three_bytes_t *)(buf + i),
-                                          encoder->width);
-            }
-            encoder->rows_completed++;
-        }
-        break;
-    case QUIC_IMAGE_TYPE_RGB32:
-        spice_assert(ABS(stride) >= encoder->width * 4);
-        for (i = 0; i < 3; i++) {
-            encoder->channels[i].correlate_row[-1] = 0;
-            quic_four_uncompress_row0(encoder, &encoder->channels[i], (four_bytes_t *)(buf + i),
-                                      encoder->width);
-        }
-        clear_row((four_bytes_t *)(buf + 3), encoder->width);
-        encoder->rows_completed++;
-        for (row = 1; row < encoder->height; row++) {
-            prev = buf;
-            buf += stride;
-            for (i = 0; i < 3; i++) {
-                encoder->channels[i].correlate_row[-1] = encoder->channels[i].correlate_row[0];
-                quic_four_uncompress_row(encoder, &encoder->channels[i],
-                                         (four_bytes_t *)(prev + i),
-                                         (four_bytes_t *)(buf + i),
-                                         encoder->width);
-            }
-            clear_row((four_bytes_t *)(buf + 3), encoder->width);
-            encoder->rows_completed++;
-        }
-        break;
-    case QUIC_IMAGE_TYPE_RGBA:
-        spice_assert(ABS(stride) >= encoder->width * 4);
-        for (i = 0; i < 4; i++) {
-            encoder->channels[i].correlate_row[-1] = 0;
-            quic_four_uncompress_row0(encoder, &encoder->channels[i], (four_bytes_t *)(buf + i),
-                                      encoder->width);
-        }
-        encoder->rows_completed++;
-        for (row = 1; row < encoder->height; row++) {
-            prev = buf;
-            buf += stride;
-            for (i = 0; i < 4; i++) {
-                encoder->channels[i].correlate_row[-1] = encoder->channels[i].correlate_row[0];
-                quic_four_uncompress_row(encoder, &encoder->channels[i],
-                                         (four_bytes_t *)(prev + i),
-                                         (four_bytes_t *)(buf + i),
-                                         encoder->width);
-            }
-            encoder->rows_completed++;
-        }
-        break;
-#endif
     case QUIC_IMAGE_TYPE_GRAY:
 
         if (type != QUIC_IMAGE_TYPE_GRAY) {
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index be8f6dd..0bcca47 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -25,12 +25,6 @@
 #define PIXEL one_byte_t
 #endif
 
-#ifdef THREE_BYTE
-#undef THREE_BYTE
-#define FNAME(name) quic_three_##name
-#define PIXEL three_bytes_t
-#endif
-
 #ifdef FOUR_BYTE
 #undef FOUR_BYTE
 #define FNAME(name) quic_four_##name
-- 
2.13.0



More information about the Spice-devel mailing list