summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2018-07-10 11:02:18 +0200
committerFrediano Ziglio <fziglio@redhat.com>2018-07-10 10:34:57 +0100
commitc0cc563e10863d73935319f8ef9dd7ef4a5a4d3c (patch)
treeb8ce8a383ed752ad4f2377dc91380b3cd89113a8
parent8b21fc5ea1dca1af39597cd375537d56400dba53 (diff)
quic: Add DECLARE_*_VARIABLES macros
They will help unify quic_rgb_tmpl.c and quic_tmpl.c Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
-rw-r--r--common/quic_rgb_tmpl.c59
-rw-r--r--common/quic_tmpl.c34
2 files changed, 44 insertions, 49 deletions
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index fcb56ff..3625728 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -87,6 +87,15 @@
#define SAME_PIXEL(p1, p2) \
(GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \
GET_b(p1) == GET_b(p2))
+#define DECLARE_STATE_VARIABLES \
+ CommonState *state = &encoder->rgb_state
+#define DECLARE_CHANNEL_VARIABLES \
+ Channel * const channel_r = encoder->channels; \
+ Channel * const channel_g = channel_r + 1; \
+ Channel * const channel_b = channel_g + 1; \
+ BYTE * const correlate_row_r = channel_r->correlate_row; \
+ BYTE * const correlate_row_g = channel_g->correlate_row; \
+ BYTE * const correlate_row_b = channel_b->correlate_row
#if BPC == 5
# define golomb_coding golomb_coding_5bpc
@@ -164,14 +173,8 @@ static void FNAME_DECL(compress_row0_seg)(int i,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &encoder->rgb_state;
- Channel * const channel_r = encoder->channels;
- Channel * const channel_g = channel_r + 1;
- Channel * const channel_b = channel_g + 1;
-
- BYTE * const correlate_row_r = channel_r->correlate_row;
- BYTE * const correlate_row_g = channel_g->correlate_row;
- BYTE * const correlate_row_b = channel_b->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
int stopidx;
spice_assert(end - i > 0);
@@ -207,7 +210,7 @@ static void FNAME_DECL(compress_row0_seg)(int i,
static void FNAME_DECL(compress_row0)(const PIXEL *cur_row, unsigned int width)
{
- CommonState *state = &encoder->rgb_state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
int pos = 0;
@@ -258,14 +261,8 @@ static void FNAME_DECL(compress_row_seg)(int i,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &encoder->rgb_state;
- Channel * const channel_r = encoder->channels;
- Channel * const channel_g = channel_r + 1;
- Channel * const channel_b = channel_g + 1;
-
- BYTE * const correlate_row_r = channel_r->correlate_row;
- BYTE * const correlate_row_g = channel_g->correlate_row;
- BYTE * const correlate_row_b = channel_b->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
int stopidx;
int run_index = 0;
int run_size;
@@ -326,7 +323,7 @@ static void FNAME_DECL(compress_row)(const PIXEL * const prev_row,
unsigned int width)
{
- CommonState *state = &encoder->rgb_state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
unsigned int pos = 0;
@@ -383,14 +380,8 @@ static void FNAME_DECL(uncompress_row0_seg)(int i,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &encoder->rgb_state;
- Channel * const channel_r = encoder->channels;
- Channel * const channel_g = channel_r + 1;
- Channel * const channel_b = channel_g + 1;
-
- BYTE * const correlate_row_r = channel_r->correlate_row;
- BYTE * const correlate_row_g = channel_g->correlate_row;
- BYTE * const correlate_row_b = channel_b->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
int stopidx;
spice_assert(end - i > 0);
@@ -436,7 +427,7 @@ static void FNAME_DECL(uncompress_row0)(PIXEL * const cur_row,
unsigned int width)
{
- CommonState *state = &encoder->rgb_state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
unsigned int pos = 0;
@@ -493,14 +484,8 @@ static void FNAME_DECL(uncompress_row_seg)(const PIXEL * const prev_row,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &encoder->rgb_state;
- Channel * const channel_r = encoder->channels;
- Channel * const channel_g = channel_r + 1;
- Channel * const channel_b = channel_g + 1;
-
- BYTE * const correlate_row_r = channel_r->correlate_row;
- BYTE * const correlate_row_g = channel_g->correlate_row;
- BYTE * const correlate_row_b = channel_b->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
const unsigned int waitmask = bppmask[state->wmidx];
int stopidx;
int run_index = 0;
@@ -574,7 +559,7 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row,
unsigned int width)
{
- CommonState *state = &encoder->rgb_state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
unsigned int pos = 0;
@@ -645,3 +630,5 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row,
#undef UNCOMPRESS_PIX_START
#undef UPDATE_MODEL_COMP
#undef APPLY_ALL_COMP
+#undef DECLARE_STATE_VARIABLES
+#undef DECLARE_CHANNEL_VARIABLES
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index 225a292..d21f059 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -43,6 +43,11 @@
#define SAME_PIXEL(p1, p2) \
(GET_a(p1) == GET_a(p2))
+#define DECLARE_STATE_VARIABLES \
+ CommonState *state = &channel_a->state
+#define DECLARE_CHANNEL_VARIABLES \
+ BYTE * const correlate_row_a = channel_a->correlate_row
+
#if BPC == 8
# define golomb_coding golomb_coding_8bpc
# define golomb_decoding golomb_decoding_8bpc
@@ -110,8 +115,8 @@ static void FNAME_DECL(compress_row0_seg)(int i,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &channel_a->state;
- BYTE * const correlate_row_a = channel_a->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
int stopidx;
spice_assert(end - i > 0);
@@ -150,7 +155,7 @@ static void FNAME_DECL(compress_row0_seg)(int i,
static void FNAME_DECL(compress_row0)(const PIXEL *cur_row, unsigned int width)
{
- CommonState *state = &channel_a->state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
int pos = 0;
@@ -200,8 +205,8 @@ static void FNAME_DECL(compress_row_seg)(int i,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &channel_a->state;
- BYTE * const correlate_row_a = channel_a->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
int stopidx;
int run_index = 0;
int run_size;
@@ -262,7 +267,7 @@ static void FNAME_DECL(compress_row)(const PIXEL * const prev_row,
unsigned int width)
{
- CommonState *state = &channel_a->state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
unsigned int pos = 0;
@@ -318,8 +323,8 @@ static void FNAME_DECL(uncompress_row0_seg)(int i,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &channel_a->state;
- BYTE * const correlate_row_a = channel_a->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
int stopidx;
spice_assert(end - i > 0);
@@ -361,10 +366,11 @@ static void FNAME_DECL(uncompress_row0_seg)(int i,
state->waitcnt = stopidx - end;
}
-static void FNAME_DECL(uncompress_row0)(PIXEL * const cur_row, unsigned int width)
+static void FNAME_DECL(uncompress_row0)(PIXEL * const cur_row,
+ unsigned int width)
{
- CommonState *state = &channel_a->state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
unsigned int pos = 0;
@@ -420,8 +426,8 @@ static void FNAME_DECL(uncompress_row_seg)(const PIXEL * const prev_row,
SPICE_GNUC_UNUSED const unsigned int bpc,
const unsigned int bpc_mask)
{
- CommonState *state = &channel_a->state;
- BYTE * const correlate_row_a = channel_a->correlate_row;
+ DECLARE_STATE_VARIABLES;
+ DECLARE_CHANNEL_VARIABLES;
const unsigned int waitmask = bppmask[state->wmidx];
int stopidx;
int run_index = 0;
@@ -493,7 +499,7 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row,
unsigned int width)
{
- CommonState *state = &channel_a->state;
+ DECLARE_STATE_VARIABLES;
const unsigned int bpc = BPC;
const unsigned int bpc_mask = BPC_MASK;
unsigned int pos = 0;
@@ -557,3 +563,5 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row,
#undef SET_a
#undef GET_a
#undef APPLY_ALL_COMP
+#undef DECLARE_STATE_VARIABLES
+#undef DECLARE_CHANNEL_VARIABLES