[FFmpeg-devel] [PATCH] memcpy-less expand
Vitor Sessak
vitor1001
Fri Sep 18 08:41:26 CEST 2009
Michael Tison wrote:
> Here's an attempt at the memcpy-less expand. I implemented a
> get_video_buffer for the input pad that'll hand a correctly sized
> buffer to the previous filter.
Thanks for the patch, but I think there is a little misunderstanding
about memcpy-less expand. When we refer to it, we are actually talking
about a O(1) expand. In your code, there is this loop:
> +static void draw_expanded_pic(AVFilterPicRef *pic, ExpContext *exp) {
> + uint8_t *row;
> + int i, j, plane, vsub, hsub, max_h, max_w, c;
> + int xoff, yoff; //< (x,y)offset
> +
> + xoff = exp->x;
> + yoff = exp->y;
> +
> + for(i=0; i<4; i++)
> + pic->data[i] = pic->pic->data[i];
> + for(i=0; i<4; i++)
> + pic->linesize[i] = pic->pic->linesize[i];
> +
> + for(plane = 0; plane < 3; plane++) {
> + c = (plane == 0) ? 0 : 128;
> + hsub = (plane == 0) ? 0 : exp->hsub;
> + vsub = (plane == 0) ? 0 : exp->vsub;
> + max_h = exp->h0 + exp->dh - 1;
> + max_w = exp->w0 + exp->dw;
> +
> + row = pic->data[plane] + (max_h >> vsub)*pic->linesize[plane];
> + for(j = max_h >> vsub; j >= 0; j--) {
> + for(i = max_w >> hsub; i >= 0; i--) {
> + if(in_region(i<<hsub, j<<vsub, hsub, vsub, exp))
> + row[i] = *(pic->data[plane] + i + j*pic->linesize[plane]
> + - (xoff >> hsub) - (yoff >> vsub)*pic->linesize[plane]);
> + else
> + row[i] = c;
> + }
Where one could replace the inner loop by a memcpy and two memset if
they inlined the in_region() function. What we would want is a expand
filter that would just change the pic->data[] pointers and not touch the
data inside it, but it would need the data[] buffer to be already
alloc'ed with the right size someway, that's the tricky part.
-Vitor
More information about the ffmpeg-devel
mailing list