mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-common
synced 2025-12-26 14:18:36 +00:00
quic: Call encode from golomb_coding
golomb_coding is always followed by a encode call. Simplify code calling directly it, no reason to pass back output using pointers. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
75863fb69f
commit
cd932df7a2
@ -93,6 +93,8 @@ typedef struct s_bucket {
|
||||
|
||||
typedef struct Encoder Encoder;
|
||||
|
||||
static inline void encode(Encoder *encoder, unsigned int word, unsigned int len);
|
||||
|
||||
typedef struct CommonState {
|
||||
unsigned int waitcnt;
|
||||
unsigned int tabrand_seed;
|
||||
|
||||
@ -44,11 +44,9 @@ static inline unsigned int FNAME(golomb_code_len)(const BYTE n, const unsigned i
|
||||
return VNAME(family).golomb_code_len[n][l];
|
||||
}
|
||||
|
||||
static void FNAME(golomb_coding)(const BYTE n, const unsigned int l, unsigned int * const codeword,
|
||||
unsigned int * const codewordlen)
|
||||
static void FNAME(golomb_coding)(Encoder *encoder, const BYTE n, const unsigned int l)
|
||||
{
|
||||
*codeword = FNAME(golomb_code)(n, l);
|
||||
*codewordlen = FNAME(golomb_code_len)(n, l);
|
||||
encode(encoder, FNAME(golomb_code)(n, l), FNAME(golomb_code_len)(n, l));
|
||||
}
|
||||
|
||||
static unsigned int FNAME(golomb_decoding)(const unsigned int l, const unsigned int bits,
|
||||
|
||||
@ -130,19 +130,15 @@
|
||||
(int)((_PIXEL_A(channel, curr) + _PIXEL_B(channel, prev)) >> 1)) & bpc_mask))
|
||||
|
||||
|
||||
#define COMPRESS_ONE_ROW0_0(channel) \
|
||||
correlate_row_##channel[0] = family.xlatU2L[GET_##channel(cur_row)]; \
|
||||
golomb_coding(correlate_row_##channel[0], find_bucket(channel_##channel, \
|
||||
correlate_row_##channel[-1])->bestcode, \
|
||||
&codeword, &codewordlen); \
|
||||
encode(encoder, codeword, codewordlen);
|
||||
#define COMPRESS_ONE_ROW0_0(channel) \
|
||||
correlate_row_##channel[0] = family.xlatU2L[GET_##channel(cur_row)]; \
|
||||
golomb_coding(encoder, correlate_row_##channel[0], find_bucket(channel_##channel, \
|
||||
correlate_row_##channel[-1])->bestcode)
|
||||
|
||||
#define COMPRESS_ONE_ROW0(channel, index) \
|
||||
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); \
|
||||
encode(encoder, codeword, codewordlen);
|
||||
#define COMPRESS_ONE_ROW0(channel, index) \
|
||||
correlate_row_##channel[index] = DECORRELATE_0(channel, &cur_row[index], bpc_mask); \
|
||||
golomb_coding(encoder, correlate_row_##channel[index], find_bucket(channel_##channel, \
|
||||
correlate_row_##channel[index -1])->bestcode)
|
||||
|
||||
#define UPDATE_MODEL(index) \
|
||||
update_model(state, find_bucket(channel_r, correlate_row_r[index - 1]), \
|
||||
@ -182,8 +178,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, int i,
|
||||
spice_assert(end - i > 0);
|
||||
|
||||
if (i == 0) {
|
||||
unsigned int codeword, codewordlen;
|
||||
|
||||
COMPRESS_ONE_ROW0_0(r);
|
||||
COMPRESS_ONE_ROW0_0(g);
|
||||
COMPRESS_ONE_ROW0_0(b);
|
||||
@ -201,7 +195,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, int i,
|
||||
|
||||
while (stopidx < end) {
|
||||
for (; i <= stopidx; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
COMPRESS_ONE_ROW0(r, i);
|
||||
COMPRESS_ONE_ROW0(g, i);
|
||||
COMPRESS_ONE_ROW0(b, i);
|
||||
@ -212,8 +205,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, int i,
|
||||
}
|
||||
|
||||
for (; i < end; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
|
||||
COMPRESS_ONE_ROW0(r, i);
|
||||
COMPRESS_ONE_ROW0(g, i);
|
||||
COMPRESS_ONE_ROW0(b, i);
|
||||
@ -258,18 +249,14 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
|
||||
#define COMPRESS_ONE_0(channel) \
|
||||
correlate_row_##channel[0] = family.xlatU2L[(unsigned)((int)GET_##channel(cur_row) - \
|
||||
(int)GET_##channel(prev_row) ) & bpc_mask]; \
|
||||
golomb_coding(correlate_row_##channel[0], \
|
||||
find_bucket(channel_##channel, correlate_row_##channel[-1])->bestcode, \
|
||||
&codeword, &codewordlen); \
|
||||
encode(encoder, codeword, codewordlen);
|
||||
golomb_coding(encoder, correlate_row_##channel[0], \
|
||||
find_bucket(channel_##channel, correlate_row_##channel[-1])->bestcode)
|
||||
|
||||
#define COMPRESS_ONE(channel, index) \
|
||||
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, \
|
||||
&codeword, &codewordlen); \
|
||||
encode(encoder, codeword, codewordlen);
|
||||
golomb_coding(encoder, correlate_row_##channel[index], \
|
||||
find_bucket(channel_##channel, correlate_row_##channel[index - 1])->bestcode)
|
||||
|
||||
static void FNAME(compress_row_seg)(Encoder *encoder, int i,
|
||||
const PIXEL * const prev_row,
|
||||
@ -294,8 +281,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
|
||||
spice_assert(end - i > 0);
|
||||
|
||||
if (i == 0) {
|
||||
unsigned int codeword, codewordlen;
|
||||
|
||||
COMPRESS_ONE_0(r);
|
||||
COMPRESS_ONE_0(g);
|
||||
COMPRESS_ONE_0(b);
|
||||
@ -313,7 +298,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
|
||||
for (;;) {
|
||||
while (stopidx < end) {
|
||||
for (; i <= stopidx; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
RLE_PRED_IMP;
|
||||
COMPRESS_ONE(r, i);
|
||||
COMPRESS_ONE(g, i);
|
||||
@ -325,7 +309,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, int i,
|
||||
}
|
||||
|
||||
for (; i < end; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
RLE_PRED_IMP;
|
||||
COMPRESS_ONE(r, i);
|
||||
COMPRESS_ONE(g, i);
|
||||
|
||||
@ -82,19 +82,15 @@ static inline void FNAME(correlate)(const PIXEL *prev, PIXEL *curr, const BYTE c
|
||||
|
||||
#define COMPRESS_ONE_ROW0_0(channel) \
|
||||
channel->correlate_row[0] = family.xlatU2L[cur_row->a]; \
|
||||
golomb_coding(channel->correlate_row[0], \
|
||||
golomb_coding(encoder, channel->correlate_row[0], \
|
||||
find_bucket(channel, \
|
||||
channel->correlate_row[-1])->bestcode, \
|
||||
&codeword, &codewordlen); \
|
||||
encode(encoder, codeword, codewordlen);
|
||||
channel->correlate_row[-1])->bestcode)
|
||||
|
||||
#define COMPRESS_ONE_ROW0(channel, index) \
|
||||
channel->correlate_row[index] = FNAME(decorrelate_0)(&cur_row[index], bpc_mask); \
|
||||
golomb_coding(channel->correlate_row[index], \
|
||||
golomb_coding(encoder, channel->correlate_row[index], \
|
||||
find_bucket(channel, \
|
||||
channel->correlate_row[index - 1])->bestcode, \
|
||||
&codeword, &codewordlen); \
|
||||
encode(encoder, codeword, codewordlen);
|
||||
channel->correlate_row[index - 1])->bestcode)
|
||||
|
||||
#define UPDATE_MODEL(index) \
|
||||
update_model(state, find_bucket(channel, channel->correlate_row[index - 1]), \
|
||||
@ -113,8 +109,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
spice_assert(end - i > 0);
|
||||
|
||||
if (i == 0) {
|
||||
unsigned int codeword, codewordlen;
|
||||
|
||||
COMPRESS_ONE_ROW0_0(channel);
|
||||
|
||||
if (state->waitcnt) {
|
||||
@ -130,7 +124,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
|
||||
while (stopidx < end) {
|
||||
for (; i <= stopidx; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
COMPRESS_ONE_ROW0(channel, i);
|
||||
}
|
||||
|
||||
@ -139,8 +132,6 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
}
|
||||
|
||||
for (; i < end; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
|
||||
COMPRESS_ONE_ROW0(channel, i);
|
||||
}
|
||||
state->waitcnt = stopidx - end;
|
||||
@ -186,17 +177,13 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
|
||||
#define COMPRESS_ONE_0(channel) \
|
||||
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);
|
||||
golomb_coding(encoder, channel->correlate_row[0], \
|
||||
find_bucket(channel, channel->correlate_row[-1])->bestcode)
|
||||
|
||||
#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);
|
||||
#define COMPRESS_ONE(channel, index) \
|
||||
channel->correlate_row[index] = FNAME(decorrelate)(&prev_row[index], &cur_row[index], bpc_mask); \
|
||||
golomb_coding(encoder, channel->correlate_row[index], \
|
||||
find_bucket(channel, channel->correlate_row[index - 1])->bestcode)
|
||||
|
||||
static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
const PIXEL * const prev_row,
|
||||
@ -214,8 +201,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
spice_assert(end - i > 0);
|
||||
|
||||
if (i == 0) {
|
||||
unsigned int codeword, codewordlen;
|
||||
|
||||
COMPRESS_ONE_0(channel);
|
||||
|
||||
if (state->waitcnt) {
|
||||
@ -232,7 +217,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
for (;;) {
|
||||
while (stopidx < end) {
|
||||
for (; i <= stopidx; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
RLE_PRED_IMP;
|
||||
COMPRESS_ONE(channel, i);
|
||||
}
|
||||
@ -242,7 +226,6 @@ static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
|
||||
}
|
||||
|
||||
for (; i < end; i++) {
|
||||
unsigned int codeword, codewordlen;
|
||||
RLE_PRED_IMP;
|
||||
COMPRESS_ONE(channel, i);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user