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

Gustavo Sverzut Barbieri barbieri
Sat Sep 23 18:24:53 CEST 2006


On 9/12/06, Michael Niedermayer <michaelni at gmx.at> wrote:
> Hi
> On Sun, Sep 10, 2006 at 04:37:41PM -0300, Gustavo Sverzut Barbieri wrote:
> [...]
> > +  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];
> > +
> > +      memset(picture->data[2] + top[2], yuv_color[2], hwidth);
> > +      top[2] += picture->linesize[2];
> > +    }
> >  }
>
> maybe something like the following could be used to simplify this
>
> for (j = 0; j < hheight; j++){
>     for(c=0; c<4; c++){
>         int plane= ((int[]){0,0,1,2})[c];
>         memset(picture->data[plane] + top[plane], yuv_color[plane], width >> !!plane);
>         top[plane] += picture->linesize[plane];
>     }
> }
>
> of course only if its not slower

I don't think it's slower since compilers would do loop unrolling.

However I don't think my version is that bad either, maybe a comment
on why I do twice for Y channel?


-- 
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




More information about the ffmpeg-devel mailing list