[Ffmpeg-devel] [PATCH] drawtext.c: 05 rewrite draw_box using memset()

Gustavo Sverzut Barbieri barbieri
Sun Sep 10 21:37:41 CEST 2006


On 9/10/06, M?ns Rullg?rd <mru at inprovide.com> wrote:
> "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?

Ouch!!!! Sorry, splitting up the patches led me to an error.

Yes, there are 2 uses of data[0] since Y channel is twice U and V.
but I really miss data[2] line.

-- 
Gustavo Sverzut Barbieri
--------------------------------------
Jabber: barbieri at gmail.com
   MSN: barbieri at gmail.com
  ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010
 Phone:  +1 (347) 624 6296; 08122692 at sip.stanaphone.com
   GPG: 0xB640E1A2 @ wwwkeys.pgp.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: drawtext_05-rewrite_draw_box-try2.patch
Type: text/x-patch
Size: 1182 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060910/100793ab/attachment.bin>



More information about the ffmpeg-devel mailing list