[Spice-commits] 5 commits - common/quic.c common/quic_rgb_tmpl.c common/quic_tmpl.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 24 10:01:53 UTC 2018
common/quic.c | 219 -------------------------------------------------
common/quic_rgb_tmpl.c | 96 +--------------------
common/quic_tmpl.c | 121 +--------------------------
3 files changed, 12 insertions(+), 424 deletions(-)
New commits:
commit d240af18a4a14cee6aa66333133a2e37a0b73396
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Aug 3 16:24:31 2017 +0200
quic: Get rid of RLE #define
It's always set, no need to have conditional compilation based on it.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/common/quic.c b/common/quic.c
index 189f2e1..a3a1208 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -29,8 +29,6 @@
#include "spice_common.h"
#include "bitops.h"
-#define RLE
-
/* ASCII "QUIC" */
#define QUIC_MAGIC 0x43495551
#define QUIC_VERSION_MAJOR 0U
@@ -488,8 +486,6 @@ static inline void decode_eat32bits(Encoder *encoder)
decode_eatbits(encoder, 16);
}
-#ifdef RLE
-
static inline void encode_ones(Encoder *encoder, unsigned int n)
{
unsigned int count;
@@ -658,7 +654,6 @@ static int decode_channel_run(Encoder *encoder, Channel *channel)
return runlen;
}
-#endif
static inline void init_decode_io(Encoder *encoder)
{
@@ -979,9 +974,7 @@ static int encoder_reset(Encoder *encoder, uint32_t *io_ptr, uint32_t *io_ptr_en
encoder->rgb_state.wmileft = DEFwminext;
set_wm_trigger(&encoder->rgb_state);
-#if defined(RLE)
encoder_init_rle(&encoder->rgb_state);
-#endif
encoder->io_words_count = io_ptr_end - io_ptr;
encoder->io_now = io_ptr;
@@ -1041,9 +1034,7 @@ static int encoder_reset_channels(Encoder *encoder, int channels, int width, int
encoder->channels[i].state.wmileft = DEFwminext;
set_wm_trigger(&encoder->channels[i].state);
-#if defined(RLE)
encoder_init_rle(&encoder->channels[i].state);
-#endif
}
return TRUE;
}
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index 04f3cbf..0a1b9e5 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -153,16 +153,12 @@
correlate_row_b[index]);
-#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_IMP
-#endif
#ifdef COMPRESS_IMP
@@ -289,10 +285,8 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
BYTE * const correlate_row_g = channel_g->correlate_row;
BYTE * const correlate_row_b = channel_b->correlate_row;
int stopidx;
-#ifdef RLE
int run_index = 0;
int run_size;
-#endif
spice_assert(end - i > 0);
@@ -338,7 +332,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
return;
-#ifdef RLE
do_run:
run_index = i;
encoder->rgb_state.waitcnt = stopidx - i;
@@ -353,7 +346,6 @@ do_run:
}
encode_run(encoder, run_size);
stopidx = i + encoder->rgb_state.waitcnt;
-#endif
}
}
@@ -545,10 +537,8 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder,
BYTE * const correlate_row_b = channel_b->correlate_row;
const unsigned int waitmask = bppmask[encoder->rgb_state.wmidx];
int stopidx;
-#ifdef RLE
int run_index = 0;
int run_end;
-#endif
spice_assert(end - i > 0);
@@ -599,7 +589,6 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder,
return;
-#ifdef RLE
do_run:
encoder->rgb_state.waitcnt = stopidx - i;
run_index = i;
@@ -617,7 +606,6 @@ do_run:
}
stopidx = i + encoder->rgb_state.waitcnt;
-#endif
}
}
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index 4ea0631..d025627 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -43,16 +43,12 @@
#define _PIXEL_A ((unsigned int)curr[-1].a)
#define _PIXEL_B ((unsigned int)prev[0].a)
-#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_IMP
-#endif
/* a */
static inline BYTE FNAME(decorrelate_0)(const PIXEL * const curr, const unsigned int bpc_mask)
@@ -182,10 +178,8 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
{
BYTE * const decorrelate_drow = channel->correlate_row;
int stopidx;
-#ifdef RLE
int run_index = 0;
int run_size;
-#endif
spice_assert(end - i > 0);
@@ -242,7 +236,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
return;
-#ifdef RLE
do_run:
run_index = i;
channel->state.waitcnt = stopidx - i;
@@ -257,7 +250,6 @@ do_run:
}
encode_channel_run(encoder, channel, run_size);
stopidx = i + channel->state.waitcnt;
-#endif
}
}
@@ -409,10 +401,8 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
{
const unsigned int waitmask = bppmask[channel->state.wmidx];
int stopidx;
-#ifdef RLE
int run_index = 0;
int run_end;
-#endif
spice_assert(end - i > 0);
@@ -468,7 +458,6 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
return;
-#ifdef RLE
do_run:
channel->state.waitcnt = stopidx - i;
run_index = i;
@@ -483,7 +472,6 @@ do_run:
}
stopidx = i + channel->state.waitcnt;
-#endif
}
}
commit fce119be44a5a155c76429b319080c4b8274429b
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Aug 3 16:24:30 2017 +0200
quic: Get rid of RLE_STAT #define
It's always set, no need to have conditional compilation based on it.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/common/quic.c b/common/quic.c
index 38bd822..189f2e1 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -30,7 +30,6 @@
#include "bitops.h"
#define RLE
-#define RLE_STAT
/* ASCII "QUIC" */
#define QUIC_MAGIC 0x43495551
@@ -104,7 +103,6 @@ typedef struct CommonState {
unsigned int wmidx;
unsigned int wmileft;
-#ifdef RLE_STAT
int melcstate; /* index to the state array */
int melclen; /* contents of the state array location
@@ -115,7 +113,6 @@ typedef struct CommonState {
of melclen bits */
unsigned long melcorder; /* 2^ melclen */
-#endif
} CommonState;
@@ -493,8 +490,6 @@ static inline void decode_eat32bits(Encoder *encoder)
#ifdef RLE
-#ifdef RLE_STAT
-
static inline void encode_ones(Encoder *encoder, unsigned int n)
{
unsigned int count;
@@ -663,50 +658,6 @@ static int decode_channel_run(Encoder *encoder, Channel *channel)
return runlen;
}
-
-#else
-
-static inline void encode_run(Encoder *encoder, unsigned int len)
-{
- int odd = len & 1U;
- int msb;
-
- len &= ~1U;
-
- while ((msb = spice_bit_find_msb(len))) {
- len &= ~(1 << (msb - 1));
- spice_assert(msb < 32);
- encode(encoder, (1 << (msb)) - 1, msb);
- encode(encoder, 0, 1);
- }
-
- if (odd) {
- encode(encoder, 2, 2);
- } else {
- encode(encoder, 0, 1);
- }
-}
-
-static inline unsigned int decode_run(Encoder *encoder)
-{
- unsigned int len = 0;
- int count;
-
- do {
- count = 0;
- while (encoder->io_word & (1U << 31)) {
- decode_eatbits(encoder, 1);
- count++;
- spice_assert(count < 32);
- }
- decode_eatbits(encoder, 1);
- len += (1U << count) >> 1;
- } while (count > 1);
-
- return len;
-}
-
-#endif
#endif
static inline void init_decode_io(Encoder *encoder)
@@ -1028,7 +979,7 @@ static int encoder_reset(Encoder *encoder, uint32_t *io_ptr, uint32_t *io_ptr_en
encoder->rgb_state.wmileft = DEFwminext;
set_wm_trigger(&encoder->rgb_state);
-#if defined(RLE) && defined(RLE_STAT)
+#if defined(RLE)
encoder_init_rle(&encoder->rgb_state);
#endif
@@ -1090,7 +1041,7 @@ static int encoder_reset_channels(Encoder *encoder, int channels, int width, int
encoder->channels[i].state.wmileft = DEFwminext;
set_wm_trigger(&encoder->channels[i].state);
-#if defined(RLE) && defined(RLE_STAT)
+#if defined(RLE)
encoder_init_rle(&encoder->channels[i].state);
#endif
}
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index b9e979f..4ea0631 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -251,19 +251,11 @@ do_run:
while (cur_row[i].a == cur_row[i - 1].a) {
run_size++;
if (++i == end) {
-#ifdef RLE_STAT
encode_channel_run(encoder, channel, run_size);
-#else
- encode_run(encoder, run_size);
-#endif
return;
}
}
-#ifdef RLE_STAT
encode_channel_run(encoder, channel, run_size);
-#else
- encode_run(encoder, run_size);
-#endif
stopidx = i + channel->state.waitcnt;
#endif
}
@@ -480,11 +472,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
do_run:
channel->state.waitcnt = stopidx - i;
run_index = i;
-#ifdef RLE_STAT
run_end = i + decode_channel_run(encoder, channel);
-#else
- run_end = i + decode_run(encoder);
-#endif
for (; i < run_end; i++) {
cur_row[i].a = cur_row[i - 1].a;
commit 7b2c2e620ee1372b96c23852ad7eee56d454ca47
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Aug 3 16:24:29 2017 +0200
quic: Get rid of QUIC_RGB #define
It's always set, no need to have conditional compilation based on it.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/common/quic.c b/common/quic.c
index f66a80d..38bd822 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
@@ -301,10 +300,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 decorrelate_init(QuicFamily *family, int bpc)
{
@@ -525,7 +522,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
{
@@ -556,8 +552,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
@@ -591,7 +585,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;
@@ -631,7 +624,6 @@ static int decode_run(Encoder *encoder)
return runlen;
}
-#endif
static int decode_channel_run(Encoder *encoder, Channel *channel)
{
@@ -729,12 +721,6 @@ typedef struct SPICE_ATTR_PACKED one_byte_pixel_t {
BYTE a;
} one_byte_t;
-typedef struct SPICE_ATTR_PACKED three_bytes_pixel_t {
- BYTE a;
- BYTE b;
- BYTE c;
-} three_bytes_t;
-
typedef struct SPICE_ATTR_PACKED four_bytes_pixel_t {
BYTE a;
BYTE b;
@@ -765,8 +751,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"
@@ -779,13 +763,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,
@@ -1131,9 +1108,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;
@@ -1198,9 +1172,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) {
@@ -1227,7 +1198,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);
@@ -1267,47 +1237,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;
@@ -1387,19 +1316,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;
@@ -1433,8 +1349,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;
@@ -1475,14 +1389,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) {
@@ -1518,73 +1428,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 62f1899..b9e979f 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
commit 763735d636a2e051be4ae6e477ef17a2e1daf39c
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Aug 3 16:24:28 2017 +0200
quic: Remove configurable PRED
It's hardcoded at compile-time, and I don't think it was changed in
years...
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/common/quic.c b/common/quic.c
index b463116..f66a80d 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -31,7 +31,6 @@
#define RLE
#define RLE_STAT
-#define PRED_1
#define QUIC_RGB
/* ASCII "QUIC" */
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index cc3c045..04f3cbf 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -110,7 +110,6 @@
#define _PIXEL_A(channel, curr) ((unsigned int)GET_##channel((curr) - 1))
#define _PIXEL_B(channel, prev) ((unsigned int)GET_##channel(prev))
-#define _PIXEL_C(channel, prev) ((unsigned int)GET_##channel((prev) - 1))
/* a */
@@ -120,7 +119,6 @@
#define CORRELATE_0(channel, curr, correlate, bpc_mask)\
((family.xlatL2U[correlate] + _PIXEL_A(channel, curr)) & bpc_mask)
-#ifdef PRED_1
/* (a+b)/2 */
#define DECORRELATE(channel, prev, curr, bpc_mask, r) \
@@ -130,36 +128,6 @@
#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
-
-#ifdef PRED_2
-
-/* .75a+.75b-.5c */
-#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) { \
- p = 0; \
- } else if ((unsigned)p > bpc_mask) { \
- p = bpc_mask; \
- } \
- r = family.xlatU2L[(unsigned)((int)GET_##channel(curr) - p) & bpc_mask]; \
-}
-
-#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]; \
- if (!(p & ~bpc_mask)) { \
- SET_##channel(r, (s + (unsigned)p) & bpc_mask); \
- } else if (p < 0) { \
- SET_##channel(r, s); \
- } else { \
- SET_##channel(r, (s + bpc_mask) & bpc_mask); \
- } \
-}
-
-#endif
#define COMPRESS_ONE_ROW0_0(channel) \
@@ -693,7 +661,6 @@ static void FNAME(uncompress_row)(Encoder *encoder,
#undef FNAME
#undef _PIXEL_A
#undef _PIXEL_B
-#undef _PIXEL_C
#undef SAME_PIXEL
#undef RLE_PRED_IMP
#undef UPDATE_MODEL
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index d49a408..62f1899 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -48,7 +48,6 @@
#define _PIXEL_A ((unsigned int)curr[-1].a)
#define _PIXEL_B ((unsigned int)prev[0].a)
-#define _PIXEL_C ((unsigned int)prev[-1].a)
#ifdef RLE
#define RLE_PRED_IMP \
@@ -73,7 +72,6 @@ static inline void FNAME(correlate_0)(PIXEL *curr, const BYTE correlate,
curr->a = (family.xlatL2U[correlate] + _PIXEL_A) & bpc_mask;
}
-#ifdef PRED_1
/* (a+b)/2 */
static inline BYTE FNAME(decorrelate)(const PIXEL *const prev, const PIXEL * const curr,
@@ -89,43 +87,6 @@ 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;
}
-#endif
-
-#ifdef PRED_2
-
-/* .75a+.75b-.5c */
-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;
-
- if (p < 0) {
- p = 0;
- } else if ((unsigned)p > bpc_mask) {
- p = bpc_mask;
- }
-
- {
- return family.xlatU2L[(unsigned)((int)curr->a - p) & 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[correlate];
-
- if (!(p & ~bpc_mask)) {
- curr->a = (s + (unsigned)p) & bpc_mask;
- } else if (p < 0) {
- curr->a = s;
- } else {
- curr->a = (s + bpc_mask) & bpc_mask;
- }
-}
-
-#endif
static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
const PIXEL * const cur_row,
@@ -585,7 +546,6 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
#undef FNAME
#undef _PIXEL_A
#undef _PIXEL_B
-#undef _PIXEL_C
#undef RLE_PRED_IMP
#undef golomb_coding
#undef golomb_decoding
commit 0629153699ee12cbf08dcba8e0a781ad4d78c45d
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Aug 3 16:24:27 2017 +0200
quic: Remove configurable RLE_PRED
It's hardcoded at compile-time, and I don't think it was changed in
years...
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/common/quic.c b/common/quic.c
index e097064..b463116 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 23dea39..cc3c045 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 3c84791..d49a408 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_decoding
#undef update_model
More information about the Spice-commits
mailing list