summaryrefslogtreecommitdiff
path: root/libavcodec/xan.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-09-05 19:35:59 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-09-05 19:35:59 +0000
commit5333450ce6b2cbe7e45b3e7520656e954dda6e75 (patch)
treedcc4030d1b3d554a0a736669f2e3eee275a284c0 /libavcodec/xan.c
parent7a656933c91809dc8b2ec73bade826a76a58a304 (diff)
Use memcpy to copy till end of line in one go instead of copying pixel by pixel
in xan_wc3_output_pixel_run and xan_wc3_copy_pixel_run Originally committed as revision 19774 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/xan.c')
-rw-r--r--libavcodec/xan.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index c2d4007ccb..83b64ca050 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -181,13 +181,14 @@ static inline void xan_wc3_output_pixel_run(XanContext *s,
line_inc = stride - width;
index = y * stride + x;
current_x = x;
- while((pixel_count--) && (index < s->frame_size)) {
+ while(pixel_count && (index < s->frame_size)) {
+ int count = FFMIN(pixel_count, width - current_x);
+ memcpy(palette_plane + index, pixel_buffer, count);
+ pixel_count -= count;
+ index += count;
+ pixel_buffer += count;
+ current_x += count;
- /* don't do a memcpy() here; keyframes generally copy an entire
- * frame of data and the stride needs to be accounted for */
- palette_plane[index++] = *pixel_buffer++;
-
- current_x++;
if (current_x >= width) {
index += line_inc;
current_x = 0;
@@ -213,18 +214,21 @@ static inline void xan_wc3_copy_pixel_run(XanContext *s,
curframe_x = x;
prevframe_index = (y + motion_y) * stride + x + motion_x;
prevframe_x = x + motion_x;
- while((pixel_count--) && (curframe_index < s->frame_size)) {
+ while(pixel_count && (curframe_index < s->frame_size)) {
+ int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x);
- palette_plane[curframe_index++] =
- prev_palette_plane[prevframe_index++];
+ memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count);
+ pixel_count -= count;
+ curframe_index += count;
+ prevframe_index += count;
+ curframe_x += count;
+ prevframe_x += count;
- curframe_x++;
if (curframe_x >= width) {
curframe_index += line_inc;
curframe_x = 0;
}
- prevframe_x++;
if (prevframe_x >= width) {
prevframe_index += line_inc;
prevframe_x = 0;