From: Frediano Ziglio <fziglio@xxxxxxxxxx> This commit reorders the macro declarations at the beginning of quic_tmpl.c and quic_rgb_tmpl.c so that they follow a similar order. This does the same for the #undef at the end of both file. This commit is only code movement, and should not add/remove anything which was not there before. The next commit will unify the macro declarations and #undef. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx> --- common/quic_rgb_tmpl.c | 53 +++++++++++++++-------------- common/quic_tmpl.c | 75 +++++++++++++++++++++--------------------- 2 files changed, 63 insertions(+), 65 deletions(-) diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c index 2221201..29f1cab 100644 --- a/common/quic_rgb_tmpl.c +++ b/common/quic_rgb_tmpl.c @@ -19,15 +19,36 @@ #include <config.h> #endif +#define COMPRESS_IMP + #define FARGS_DECL(arg1, ...) (Encoder *encoder, arg1, ##__VA_ARGS__) #define FARGS_CALL(arg1, ...) (encoder, arg1, ##__VA_ARGS__) +#define SAME_PIXEL(p1, p2) \ + (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \ + GET_b(p1) == GET_b(p2)) +#define COPY_PIXEL(dest, src) \ + SET_r(dest, GET_r(src)); \ + SET_g(dest, GET_g(src)); \ + SET_b(dest, GET_b(src)) +#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 +#define APPLY_ALL_COMP(macro, ...) \ + macro(r, ## __VA_ARGS__); \ + macro(g, ## __VA_ARGS__); \ + macro(b, ## __VA_ARGS__) #ifdef QUIC_RGB32 #undef QUIC_RGB32 #define PIXEL rgb32_pixel_t #define FNAME(name) quic_rgb32_##name #define BPC 8 -#define COMPRESS_IMP #define SET_r(pix, val) ((pix)->r = val) #define GET_r(pix) ((pix)->r) #define SET_g(pix, val) ((pix)->g = val) @@ -42,7 +63,6 @@ #define PIXEL rgb24_pixel_t #define FNAME(name) quic_rgb24_##name #define BPC 8 -#define COMPRESS_IMP #define SET_r(pix, val) ((pix)->r = val) #define GET_r(pix) ((pix)->r) #define SET_g(pix, val) ((pix)->g = val) @@ -57,7 +77,6 @@ #define PIXEL rgb16_pixel_t #define FNAME(name) quic_rgb16_##name #define BPC 5 -#define COMPRESS_IMP #define SET_r(pix, val) (*(pix) = (*(pix) & ~(0x1f << 10)) | ((val) << 10)) #define GET_r(pix) ((*(pix) >> 10) & 0x1f) #define SET_g(pix, val) (*(pix) = (*(pix) & ~(0x1f << 5)) | ((val) << 5)) @@ -72,6 +91,7 @@ #define PIXEL rgb32_pixel_t #define FNAME(name) quic_rgb16_to_32_##name #define BPC 5 +#define COMPRESS_IMP #define SET_r(pix, val) ((pix)->r = ((val) << 3) | (((val) & 0x1f) >> 2)) #define GET_r(pix) ((pix)->r >> 3) #define SET_g(pix, val) ((pix)->g = ((val) << 3) | (((val) & 0x1f) >> 2)) @@ -84,23 +104,6 @@ #define FNAME_DECL(name) FNAME(name) FARGS_DECL #define FNAME_CALL(name) FNAME(name) FARGS_CALL -#define SAME_PIXEL(p1, p2) \ - (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \ - GET_b(p1) == GET_b(p2)) -#define COPY_PIXEL(dest, src) \ - SET_r(dest, GET_r(src)); \ - SET_g(dest, GET_g(src)); \ - SET_b(dest, GET_b(src)) -#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 # define golomb_decoding golomb_decoding_5bpc @@ -156,11 +159,6 @@ correlate_row_##channel[index]) #define UPDATE_MODEL(index) APPLY_ALL_COMP(UPDATE_MODEL_COMP, index) -#define APPLY_ALL_COMP(macro, ...) \ - macro(r, ## __VA_ARGS__); \ - macro(g, ## __VA_ARGS__); \ - macro(b, ## __VA_ARGS__) - #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])) { \ @@ -212,6 +210,9 @@ static void FNAME_DECL(compress_row0_seg)(int i, state->waitcnt = stopidx - end; } +#undef COMPRESS_ONE_ROW0_0 +#undef COMPRESS_ONE_ROW0 + static void FNAME_DECL(compress_row0)(const PIXEL *cur_row, unsigned int width) { DECLARE_STATE_VARIABLES; @@ -605,8 +606,6 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row, #undef UPDATE_MODEL #undef DECORRELATE_0 #undef DECORRELATE -#undef COMPRESS_ONE_ROW0_0 -#undef COMPRESS_ONE_ROW0 #undef COMPRESS_ONE_0 #undef COMPRESS_ONE #undef CORRELATE_0 diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c index 525eb99..96db766 100644 --- a/common/quic_tmpl.c +++ b/common/quic_tmpl.c @@ -19,28 +19,11 @@ #include <config.h> #endif -#ifdef ONE_BYTE -#undef ONE_BYTE -#define FNAME(name) quic_one_##name -#define PIXEL one_byte_t -#endif - -#ifdef FOUR_BYTE -#undef FOUR_BYTE -#define FNAME(name) quic_four_##name -#define PIXEL four_bytes_t -#endif - #define FARGS_DECL(...) (Encoder *encoder, Channel *channel_a, ##__VA_ARGS__) #define FARGS_CALL(...) (encoder, channel_a, ##__VA_ARGS__) -#define FNAME_DECL(name) FNAME(name) FARGS_DECL -#define FNAME_CALL(name) FNAME(name) FARGS_CALL - -#define BPC 8 - +#define UNCOMPRESS_PIX_START(row) do { } while (0) #define SET_a(pix, val) ((pix)->a = val) #define GET_a(pix) ((pix)->a) - #define SAME_PIXEL(p1, p2) \ (GET_a(p1) == GET_a(p2)) #define COPY_PIXEL(dest, src) \ @@ -49,6 +32,27 @@ CommonState *state = &channel_a->state #define DECLARE_CHANNEL_VARIABLES \ BYTE * const correlate_row_a = channel_a->correlate_row +#define APPLY_ALL_COMP(macro, ...) \ + macro(a, ## __VA_ARGS__) + +#ifdef ONE_BYTE +#undef ONE_BYTE +#define FNAME(name) quic_one_##name +#define PIXEL one_byte_t +#define BPC 8 + +#endif + +#ifdef FOUR_BYTE +#undef FOUR_BYTE +#define FNAME(name) quic_four_##name +#define PIXEL four_bytes_t +#define BPC 8 + +#endif + +#define FNAME_DECL(name) FNAME(name) FARGS_DECL +#define FNAME_CALL(name) FNAME(name) FARGS_CALL #if BPC == 8 # define golomb_coding golomb_coding_8bpc @@ -64,13 +68,6 @@ #define _PIXEL_A(channel, curr) ((unsigned int)GET_##channel((curr) - 1)) #define _PIXEL_B(channel, prev) ((unsigned int)GET_##channel(prev)) -#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; \ - } \ -} - /* a */ #define DECORRELATE_0(channel, curr, bpc_mask)\ @@ -107,8 +104,12 @@ if (SAME_PIXEL(&prev_row[i - 1], &prev_row[i])) { correlate_row_##channel[index]) #define UPDATE_MODEL(index) APPLY_ALL_COMP(UPDATE_MODEL_COMP, index) -#define APPLY_ALL_COMP(macro, ...) \ - macro(a, ## __VA_ARGS__) +#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; \ + } \ +} static void FNAME_DECL(compress_row0_seg)(int i, const PIXEL * const cur_row, @@ -301,8 +302,6 @@ static void FNAME_DECL(compress_row)(const PIXEL * const prev_row, spice_assert(DEFwminext > 0); } -#define UNCOMPRESS_PIX_START(row) do { } while (0) - #define UNCOMPRESS_ONE_ROW0_0(channel) \ correlate_row_##channel[0] = (BYTE)golomb_decoding(find_bucket(channel_##channel, \ correlate_row_##channel[-1])->bestcode, \ @@ -542,10 +541,17 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row, #undef _PIXEL_B #undef SAME_PIXEL #undef RLE_PRED_IMP +#undef UPDATE_MODEL #undef DECORRELATE_0 #undef DECORRELATE +#undef COMPRESS_ONE_0 +#undef COMPRESS_ONE #undef CORRELATE_0 #undef CORRELATE +#undef UNCOMPRESS_ONE_ROW0_0 +#undef UNCOMPRESS_ONE_ROW0 +#undef UNCOMPRESS_ONE_0 +#undef UNCOMPRESS_ONE #undef golomb_coding #undef golomb_decoding #undef update_model @@ -553,17 +559,10 @@ static void FNAME_DECL(uncompress_row)(const PIXEL * const prev_row, #undef family #undef BPC #undef BPC_MASK -#undef UPDATE_MODEL -#undef UNCOMPRESS_PIX_START -#undef UPDATE_MODEL_COMP -#undef COMPRESS_ONE_0 -#undef COMPRESS_ONE -#undef UNCOMPRESS_ONE_ROW0 -#undef UNCOMPRESS_ONE_ROW0_0 -#undef UNCOMPRESS_ONE_0 -#undef UNCOMPRESS_ONE #undef SET_a #undef GET_a +#undef UNCOMPRESS_PIX_START +#undef UPDATE_MODEL_COMP #undef APPLY_ALL_COMP #undef DECLARE_STATE_VARIABLES #undef DECLARE_CHANNEL_VARIABLES -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel