Mercurial > libavcodec.hg
changeset 1476:72e115e94673 libavcodec
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
RGB not RGG)
author | tmmm |
---|---|
date | Fri, 19 Sep 2003 04:00:32 +0000 |
parents | 26eb7678cb46 |
children | afc7baa19b62 |
files | xan.c |
diffstat | 1 files changed, 40 insertions(+), 97 deletions(-) [+] |
line wrap: on
line diff
--- a/xan.c Fri Sep 19 01:13:53 2003 +0000 +++ b/xan.c Fri Sep 19 04:00:32 2003 +0000 @@ -274,7 +274,7 @@ palette16[i] = ((r >> 3) << 10) | ((g >> 3) << 5) | - ((g >> 3) << 0); + ((b >> 3) << 0); } break; @@ -287,7 +287,7 @@ palette16[i] = ((r >> 3) << 11) | ((g >> 2) << 5) | - ((g >> 3) << 0); + ((b >> 3) << 0); } break; @@ -338,6 +338,15 @@ } } +/* advance current_x variable; reset accounting variables if current_x + * moves beyond width */ +#define ADVANCE_CURRENT_X() \ + current_x++; \ + if (current_x >= width) { \ + index += line_inc; \ + current_x = 0; \ + } + static void inline xan_wc3_output_pixel_run(XanContext *s, unsigned char *pixel_buffer, int x, int y, int pixel_count) { @@ -371,12 +380,7 @@ * frame of data and the stride needs to be accounted for */ palette_plane[index++] = *pixel_buffer++; - current_x++; - if (current_x >= width) { - /* reset accounting variables */ - index += line_inc; - current_x = 0; - } + ADVANCE_CURRENT_X(); } break; @@ -392,12 +396,7 @@ rgb16_plane[index++] = palette16[*pixel_buffer++]; - current_x++; - if (current_x >= width) { - /* reset accounting variables */ - index += line_inc; - current_x = 0; - } + ADVANCE_CURRENT_X(); } break; @@ -415,12 +414,7 @@ rgb_plane[index++] = s->palette[pix * 4 + 1]; rgb_plane[index++] = s->palette[pix * 4 + 2]; - current_x++; - if (current_x >= width) { - /* reset accounting variables */ - index += line_inc; - current_x = 0; - } + ADVANCE_CURRENT_X(); } break; @@ -435,12 +429,7 @@ rgb32_plane[index++] = palette32[*pixel_buffer++]; - current_x++; - if (current_x >= width) { - /* reset accounting variables */ - index += line_inc; - current_x = 0; - } + ADVANCE_CURRENT_X(); } break; @@ -460,12 +449,7 @@ v_plane[index] = s->palette[pix * 4 + 2]; index++; - current_x++; - if (current_x >= width) { - /* reset accounting variables */ - index += line_inc; - current_x = 0; - } + ADVANCE_CURRENT_X(); } break; @@ -475,6 +459,20 @@ } } +#define ADVANCE_CURFRAME_X() \ + curframe_x++; \ + if (curframe_x >= width) { \ + curframe_index += line_inc; \ + curframe_x = 0; \ + } + +#define ADVANCE_PREVFRAME_X() \ + prevframe_x++; \ + if (prevframe_x >= width) { \ + prevframe_index += line_inc; \ + prevframe_x = 0; \ + } + static void inline xan_wc3_copy_pixel_run(XanContext *s, int x, int y, int pixel_count, int motion_x, int motion_y) { @@ -506,19 +504,8 @@ palette_plane[curframe_index++] = prev_palette_plane[prevframe_index++]; - curframe_x++; - if (curframe_x >= width) { - /* reset accounting variables */ - curframe_index += line_inc; - curframe_x = 0; - } - - prevframe_x++; - if (prevframe_x >= width) { - /* reset accounting variables */ - prevframe_index += line_inc; - prevframe_x = 0; - } + ADVANCE_CURFRAME_X(); + ADVANCE_PREVFRAME_X(); } break; @@ -537,19 +524,8 @@ rgb16_plane[curframe_index++] = prev_rgb16_plane[prevframe_index++]; - curframe_x++; - if (curframe_x >= width) { - /* reset accounting variables */ - curframe_index += line_inc; - curframe_x = 0; - } - - prevframe_x++; - if (prevframe_x >= width) { - /* reset accounting variables */ - prevframe_index += line_inc; - prevframe_x = 0; - } + ADVANCE_CURFRAME_X(); + ADVANCE_PREVFRAME_X(); } break; @@ -570,19 +546,8 @@ rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; - curframe_x++; - if (curframe_x >= width) { - /* reset accounting variables */ - curframe_index += line_inc; - curframe_x = 0; - } - - prevframe_x++; - if (prevframe_x >= width) { - /* reset accounting variables */ - prevframe_index += line_inc; - prevframe_x = 0; - } + ADVANCE_CURFRAME_X(); + ADVANCE_PREVFRAME_X(); } break; @@ -600,19 +565,8 @@ rgb32_plane[curframe_index++] = prev_rgb32_plane[prevframe_index++]; - curframe_x++; - if (curframe_x >= width) { - /* reset accounting variables */ - curframe_index += line_inc; - curframe_x = 0; - } - - prevframe_x++; - if (prevframe_x >= width) { - /* reset accounting variables */ - prevframe_index += line_inc; - prevframe_x = 0; - } + ADVANCE_CURFRAME_X(); + ADVANCE_PREVFRAME_X(); } break; @@ -636,20 +590,9 @@ v_plane[curframe_index] = prev_v_plane[prevframe_index]; curframe_index++; - curframe_x++; - if (curframe_x >= width) { - /* reset accounting variables */ - curframe_index += line_inc; - curframe_x = 0; - } - + ADVANCE_CURFRAME_X(); prevframe_index++; - prevframe_x++; - if (prevframe_x >= width) { - /* reset accounting variables */ - prevframe_index += line_inc; - prevframe_x = 0; - } + ADVANCE_PREVFRAME_X(); } break;