Commit 42e96409 authored by Mike Melanson's avatar Mike Melanson

MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's

RGB not RGG)

Originally committed as revision 2293 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent bf649a9d
...@@ -274,7 +274,7 @@ static void inline xan_wc3_build_palette(XanContext *s, ...@@ -274,7 +274,7 @@ static void inline xan_wc3_build_palette(XanContext *s,
palette16[i] = palette16[i] =
((r >> 3) << 10) | ((r >> 3) << 10) |
((g >> 3) << 5) | ((g >> 3) << 5) |
((g >> 3) << 0); ((b >> 3) << 0);
} }
break; break;
...@@ -287,7 +287,7 @@ static void inline xan_wc3_build_palette(XanContext *s, ...@@ -287,7 +287,7 @@ static void inline xan_wc3_build_palette(XanContext *s,
palette16[i] = palette16[i] =
((r >> 3) << 11) | ((r >> 3) << 11) |
((g >> 2) << 5) | ((g >> 2) << 5) |
((g >> 3) << 0); ((b >> 3) << 0);
} }
break; break;
...@@ -338,6 +338,15 @@ static void inline xan_wc3_build_palette(XanContext *s, ...@@ -338,6 +338,15 @@ static void inline xan_wc3_build_palette(XanContext *s,
} }
} }
/* 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, static void inline xan_wc3_output_pixel_run(XanContext *s,
unsigned char *pixel_buffer, int x, int y, int pixel_count) unsigned char *pixel_buffer, int x, int y, int pixel_count)
{ {
...@@ -371,12 +380,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s, ...@@ -371,12 +380,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s,
* frame of data and the stride needs to be accounted for */ * frame of data and the stride needs to be accounted for */
palette_plane[index++] = *pixel_buffer++; palette_plane[index++] = *pixel_buffer++;
current_x++; ADVANCE_CURRENT_X();
if (current_x >= width) {
/* reset accounting variables */
index += line_inc;
current_x = 0;
}
} }
break; break;
...@@ -392,12 +396,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s, ...@@ -392,12 +396,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s,
rgb16_plane[index++] = palette16[*pixel_buffer++]; rgb16_plane[index++] = palette16[*pixel_buffer++];
current_x++; ADVANCE_CURRENT_X();
if (current_x >= width) {
/* reset accounting variables */
index += line_inc;
current_x = 0;
}
} }
break; break;
...@@ -415,12 +414,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s, ...@@ -415,12 +414,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s,
rgb_plane[index++] = s->palette[pix * 4 + 1]; rgb_plane[index++] = s->palette[pix * 4 + 1];
rgb_plane[index++] = s->palette[pix * 4 + 2]; rgb_plane[index++] = s->palette[pix * 4 + 2];
current_x++; ADVANCE_CURRENT_X();
if (current_x >= width) {
/* reset accounting variables */
index += line_inc;
current_x = 0;
}
} }
break; break;
...@@ -435,12 +429,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s, ...@@ -435,12 +429,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s,
rgb32_plane[index++] = palette32[*pixel_buffer++]; rgb32_plane[index++] = palette32[*pixel_buffer++];
current_x++; ADVANCE_CURRENT_X();
if (current_x >= width) {
/* reset accounting variables */
index += line_inc;
current_x = 0;
}
} }
break; break;
...@@ -460,12 +449,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s, ...@@ -460,12 +449,7 @@ static void inline xan_wc3_output_pixel_run(XanContext *s,
v_plane[index] = s->palette[pix * 4 + 2]; v_plane[index] = s->palette[pix * 4 + 2];
index++; index++;
current_x++; ADVANCE_CURRENT_X();
if (current_x >= width) {
/* reset accounting variables */
index += line_inc;
current_x = 0;
}
} }
break; break;
...@@ -475,6 +459,20 @@ static void inline xan_wc3_output_pixel_run(XanContext *s, ...@@ -475,6 +459,20 @@ static void inline xan_wc3_output_pixel_run(XanContext *s,
} }
} }
#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, static void inline xan_wc3_copy_pixel_run(XanContext *s,
int x, int y, int pixel_count, int motion_x, int motion_y) int x, int y, int pixel_count, int motion_x, int motion_y)
{ {
...@@ -506,19 +504,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s, ...@@ -506,19 +504,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s,
palette_plane[curframe_index++] = palette_plane[curframe_index++] =
prev_palette_plane[prevframe_index++]; prev_palette_plane[prevframe_index++];
curframe_x++; ADVANCE_CURFRAME_X();
if (curframe_x >= width) { ADVANCE_PREVFRAME_X();
/* 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;
}
} }
break; break;
...@@ -537,19 +524,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s, ...@@ -537,19 +524,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s,
rgb16_plane[curframe_index++] = rgb16_plane[curframe_index++] =
prev_rgb16_plane[prevframe_index++]; prev_rgb16_plane[prevframe_index++];
curframe_x++; ADVANCE_CURFRAME_X();
if (curframe_x >= width) { ADVANCE_PREVFRAME_X();
/* 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;
}
} }
break; break;
...@@ -570,19 +546,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s, ...@@ -570,19 +546,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s,
rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++];
rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++];
curframe_x++; ADVANCE_CURFRAME_X();
if (curframe_x >= width) { ADVANCE_PREVFRAME_X();
/* 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;
}
} }
break; break;
...@@ -600,19 +565,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s, ...@@ -600,19 +565,8 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s,
rgb32_plane[curframe_index++] = rgb32_plane[curframe_index++] =
prev_rgb32_plane[prevframe_index++]; prev_rgb32_plane[prevframe_index++];
curframe_x++; ADVANCE_CURFRAME_X();
if (curframe_x >= width) { ADVANCE_PREVFRAME_X();
/* 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;
}
} }
break; break;
...@@ -636,20 +590,9 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s, ...@@ -636,20 +590,9 @@ static void inline xan_wc3_copy_pixel_run(XanContext *s,
v_plane[curframe_index] = prev_v_plane[prevframe_index]; v_plane[curframe_index] = prev_v_plane[prevframe_index];
curframe_index++; curframe_index++;
curframe_x++; ADVANCE_CURFRAME_X();
if (curframe_x >= width) {
/* reset accounting variables */
curframe_index += line_inc;
curframe_x = 0;
}
prevframe_index++; prevframe_index++;
prevframe_x++; ADVANCE_PREVFRAME_X();
if (prevframe_x >= width) {
/* reset accounting variables */
prevframe_index += line_inc;
prevframe_x = 0;
}
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment