comparison xan.c @ 10135:a3abf068e05e libavcodec

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
author reimar
date Sat, 05 Sep 2009 19:35:59 +0000
parents 1d71688b4549
children d7ed9dcc78e3
comparison
equal deleted inserted replaced
10134:1d71688b4549 10135:a3abf068e05e
179 palette_plane = s->current_frame.data[0]; 179 palette_plane = s->current_frame.data[0];
180 stride = s->current_frame.linesize[0]; 180 stride = s->current_frame.linesize[0];
181 line_inc = stride - width; 181 line_inc = stride - width;
182 index = y * stride + x; 182 index = y * stride + x;
183 current_x = x; 183 current_x = x;
184 while((pixel_count--) && (index < s->frame_size)) { 184 while(pixel_count && (index < s->frame_size)) {
185 185 int count = FFMIN(pixel_count, width - current_x);
186 /* don't do a memcpy() here; keyframes generally copy an entire 186 memcpy(palette_plane + index, pixel_buffer, count);
187 * frame of data and the stride needs to be accounted for */ 187 pixel_count -= count;
188 palette_plane[index++] = *pixel_buffer++; 188 index += count;
189 189 pixel_buffer += count;
190 current_x++; 190 current_x += count;
191
191 if (current_x >= width) { 192 if (current_x >= width) {
192 index += line_inc; 193 index += line_inc;
193 current_x = 0; 194 current_x = 0;
194 } 195 }
195 } 196 }
211 line_inc = stride - width; 212 line_inc = stride - width;
212 curframe_index = y * stride + x; 213 curframe_index = y * stride + x;
213 curframe_x = x; 214 curframe_x = x;
214 prevframe_index = (y + motion_y) * stride + x + motion_x; 215 prevframe_index = (y + motion_y) * stride + x + motion_x;
215 prevframe_x = x + motion_x; 216 prevframe_x = x + motion_x;
216 while((pixel_count--) && (curframe_index < s->frame_size)) { 217 while(pixel_count && (curframe_index < s->frame_size)) {
217 218 int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x);
218 palette_plane[curframe_index++] = 219
219 prev_palette_plane[prevframe_index++]; 220 memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count);
220 221 pixel_count -= count;
221 curframe_x++; 222 curframe_index += count;
223 prevframe_index += count;
224 curframe_x += count;
225 prevframe_x += count;
226
222 if (curframe_x >= width) { 227 if (curframe_x >= width) {
223 curframe_index += line_inc; 228 curframe_index += line_inc;
224 curframe_x = 0; 229 curframe_x = 0;
225 } 230 }
226 231
227 prevframe_x++;
228 if (prevframe_x >= width) { 232 if (prevframe_x >= width) {
229 prevframe_index += line_inc; 233 prevframe_index += line_inc;
230 prevframe_x = 0; 234 prevframe_x = 0;
231 } 235 }
232 } 236 }