[Ffmpeg-devel] [PATCH] drawtext.c: 05 rewrite draw_box using memset()
Måns Rullgård
mru
Sun Sep 10 21:15:21 CEST 2006
"Gustavo Sverzut Barbieri" <barbieri at gmail.com> writes:
> As suggested here before, rewrite draw_box() using memset(), which
> should be faster.
>
> --- drawtext.c-after_patch04 2006-09-10 14:40:02.000000000 -0300
> +++ drawtext.c 2006-09-10 14:40:47.000000000 -0300
> @@ -368,14 +368,28 @@
>
> static inline void draw_box(AVPicture *picture, unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned char yuv_color[3])
> {
> - int i, j;
> + unsigned j, top[3], hx, hy, hwidth, hheight;
>
> - for (j = 0; (j < height); j++)
> - for (i = 0; (i < width); i++)
> - {
> - SET_PIXEL(picture, yuv_color, (i+x), (y+j));
> - }
> + hx = x >> 1;
> + hy = y >> 1;
> + hwidth = width >> 1;
> + hheight = height >> 1;
>
> + top[0] = picture->linesize[0] * y + x;
> + top[1] = picture->linesize[1] * hy + hx;
> + top[2] = picture->linesize[2] * hy + hx;
> +
> + for (j = 0; j < hheight; j++)
> + {
> + memset(picture->data[0] + top[0], yuv_color[0], width);
> + top[0] += picture->linesize[0];
> +
> + memset(picture->data[0] + top[0], yuv_color[0], width);
> + top[0] += picture->linesize[0];
> +
> + memset(picture->data[1] + top[1], yuv_color[1], hwidth);
> + top[1] += picture->linesize[1];
> + }
> }
I think you may have made a copy and paste mistake here. Did you
really mean to set data[0] twice and data[2] not at all?
--
M?ns Rullg?rd
mru at inprovide.com
More information about the ffmpeg-devel
mailing list