Define and reuse a COPY_PIXEL macro to copy a pixel. After this commit the 2 template files are exactly the same. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- common/quic_rgb_tmpl.c | 11 ++++++++--- common/quic_tmpl.c | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c index ca735c1..b300836 100644 --- a/common/quic_rgb_tmpl.c +++ b/common/quic_rgb_tmpl.c @@ -28,6 +28,8 @@ # 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) \ + SET_a(dest, GET_a(src)); # define DECLARE_STATE_VARIABLES \ CommonState *state = &channel_a->state # define DECLARE_CHANNEL_VARIABLES \ @@ -40,6 +42,10 @@ # 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 \ @@ -572,9 +578,7 @@ do_run: for (; i < run_end; i++) { UNCOMPRESS_PIX_START(&cur_row[i]); - SET_r(&cur_row[i], GET_r(&cur_row[i - 1])); - SET_g(&cur_row[i], GET_g(&cur_row[i - 1])); - SET_b(&cur_row[i], GET_b(&cur_row[i - 1])); + COPY_PIXEL(&cur_row[i], &cur_row[i - 1]); } if (i == end) { @@ -662,3 +666,4 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_ #undef APPLY_ALL_COMP #undef DECLARE_STATE_VARIABLES #undef DECLARE_CHANNEL_VARIABLES +#undef COPY_PIXEL diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c index 513a0c6..6945912 100644 --- a/common/quic_tmpl.c +++ b/common/quic_tmpl.c @@ -28,6 +28,8 @@ # 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) \ + SET_a(dest, GET_a(src)); # define DECLARE_STATE_VARIABLES \ CommonState *state = &channel_a->state # define DECLARE_CHANNEL_VARIABLES \ @@ -40,6 +42,10 @@ # 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 \ @@ -572,7 +578,7 @@ do_run: for (; i < run_end; i++) { UNCOMPRESS_PIX_START(&cur_row[i]); - SET_a(&cur_row[i], GET_a(&cur_row[i - 1])); + COPY_PIXEL(&cur_row[i], &cur_row[i - 1]); } if (i == end) { @@ -660,3 +666,4 @@ static void FNAME(uncompress_row)(Encoder *encoder, CHANNEL_ARG_ #undef APPLY_ALL_COMP #undef DECLARE_STATE_VARIABLES #undef DECLARE_CHANNEL_VARIABLES +#undef COPY_PIXEL -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel