On Mon, Nov 23, 2015 at 05:19:52PM -0500, Ganesh Ajjanagadde wrote: > This rewrites into the mathematically equivalent expression avoiding sqrt, > and results in a very minor speedup. > > Tested on x86-64, Haswell, GNU/Linux. > Command: > ffmpeg -v error -f lavfi -i mandelbrot -f null - > > old (draw_mandelbrot): > 3982389425 decicycles in draw_mandelbrot, 256 runs, 0 skips > 7634221782 decicycles in draw_mandelbrot, 512 runs, 0 skips > 20576449397 decicycles in draw_mandelbrot, 1024 runs, 0 skips > 12949998655 decicycles in draw_mandelbrot, 2048 runs, 0 skips > > new (draw_mandelbrot): > 3966406060 decicycles in draw_mandelbrot, 256 runs, 0 skips > 7553322112 decicycles in draw_mandelbrot, 512 runs, 0 skips > 20454169970 decicycles in draw_mandelbrot, 1024 runs, 0 skips > 12822228615 decicycles in draw_mandelbrot, 2048 runs, 0 skips > > Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> > --- > libavfilter/vsrc_mandelbrot.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c > index 950c5c8..20da8ae 100644 > --- a/libavfilter/vsrc_mandelbrot.c > +++ b/libavfilter/vsrc_mandelbrot.c > @@ -291,7 +291,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, > uint32_t *color, int linesize, > > use_zyklus= (x==0 || s->inner!=BLACK ||color[x-1 + y*linesize] > == 0xFF000000); > if(use_zyklus) > - epsilon= scale*1*sqrt(SQR(x-s->w/2) + SQR(y-s->h/2))/s->w; > + epsilon= SQR(scale/s->w)*(SQR(x-s->w/2) + SQR(y-s->h/2));
if the sqrt is a speed problem, (i had originally thougt it would not be) you can probably replace this by an approximation like: epsilon= scale*CONSTANT*(FFABS(x-s->w/2) + FFABS(y-s->h/2))/s->w; [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel