[FFmpeg-devel] [PATCH 1/4] lavfi/delogo: don't recompute the same difference again and again

Michael Niedermayer michaelni at gmx.at
Fri Jul 5 14:02:58 CEST 2013


On Fri, Jul 05, 2013 at 11:17:31AM +0200, Stefano Sabatini wrote:
> On date Friday 2013-07-05 10:23:18 +0200, Jean Delvare encoded:
> > The top left hand corner pixel coordinates are already stored in
> > logo_x1 and logo_y1 so don't recompute each of them 6 times for every
> > iteration.
> > 
> > This is a simple code optimization, result is obviously the same. The
> > performance gain is small (about 2% in my tests) but still good to
> > have, and the new code is clearer.
> > 
> > Signed-off-by: Jean Delvare <khali at linux-fr.org>
> > ---
> >  libavfilter/vf_delogo.c |   24 ++++++++++++------------
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> > 
> > --- ffmpeg.orig/libavfilter/vf_delogo.c	2013-06-28 10:46:25.562635244 +0200
> > +++ ffmpeg/libavfilter/vf_delogo.c	2013-06-28 10:46:46.316635552 +0200
> > @@ -100,21 +100,21 @@ static void apply_delogo(uint8_t *dst, i
> >              weightb = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (y-logo_y1)                 * sar.num;
> >  
> >              interp =
> > -                (topleft[src_linesize*(y-logo_y  -yclipt)]   +
> > -                 topleft[src_linesize*(y-logo_y-1-yclipt)]   +
> > -                 topleft[src_linesize*(y-logo_y+1-yclipt)])  * weightl
> > +                (topleft[src_linesize*(y-logo_y1)]    +
> > +                 topleft[src_linesize*(y-logo_y1-1)]  +
> > +                 topleft[src_linesize*(y-logo_y1+1)]) * weightl
> >                  +
> > -                (topright[src_linesize*(y-logo_y-yclipt)]    +
> > -                 topright[src_linesize*(y-logo_y-1-yclipt)]  +
> > -                 topright[src_linesize*(y-logo_y+1-yclipt)]) * weightr
> > +                (topright[src_linesize*(y-logo_y1)]    +
> > +                 topright[src_linesize*(y-logo_y1-1)]  +
> > +                 topright[src_linesize*(y-logo_y1+1)]) * weightr
> >                  +
> > -                (topleft[x-logo_x-xclipl]    +
> > -                 topleft[x-logo_x-1-xclipl]  +
> > -                 topleft[x-logo_x+1-xclipl]) * weightt
> > +                (topleft[x-logo_x1]    +
> > +                 topleft[x-logo_x1-1]  +
> > +                 topleft[x-logo_x1+1]) * weightt
> >                  +
> > -                (botleft[x-logo_x-xclipl]    +
> > -                 botleft[x-logo_x-1-xclipl]  +
> > -                 botleft[x-logo_x+1-xclipl]) * weightb;
> > +                (botleft[x-logo_x1]    +
> > +                 botleft[x-logo_x1-1]  +
> > +                 botleft[x-logo_x1+1]) * weightb;
> >              interp /= (weightl + weightr + weightt + weightb) * 3U;
> 
> LGTM, thanks.

applied

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130705/ede4b6c7/attachment.asc>


More information about the ffmpeg-devel mailing list