diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-11-13 19:55:28 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-11-13 20:01:56 +0400 |
commit | 88166fc579772c881c21fa6f63faa2ad49ce38e8 (patch) | |
tree | df233bfc10444a3a5c5f328eef1e547434616624 /libavfilter/vsrc_mandelbrot.c | |
parent | 1d066087327ef3eb496ad5d78b4ccc0d40c5c9d6 (diff) |
mandelbrot: unroll the innermost loop once.
This allows us to remove a if() and a variable assignment.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vsrc_mandelbrot.c')
-rw-r--r-- | libavfilter/vsrc_mandelbrot.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c index 6f9644d198..719e169928 100644 --- a/libavfilter/vsrc_mandelbrot.c +++ b/libavfilter/vsrc_mandelbrot.c @@ -190,11 +190,25 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize, c= lrintf((sin(zr)+1)*127) + lrintf((sin(zr/1.234)+1)*127)*256*256 + lrintf((sin(zr/100)+1)*127)*256; break; } - t= zr*zr - zi*zi; + t= zr*zr - zi*zi + cr; zi= 2*zr*zi + ci; - zr= t + cr; if(use_zyklus){ - if((i&1) && mb->zyklus[i>>1][0]==zr && mb->zyklus[i>>1][1]==zi) + mb->zyklus[i][0]= t; + mb->zyklus[i][1]= zi; + } + i++; + if(t*t + zi*zi > mb->bailout){ + switch(mb->outer){ + case ITERATION_COUNT: zr= i; break; + case NORMALIZED_ITERATION_COUNT: zr= i + (log(log(mb->bailout)) - log(log(sqrt(t*t + zi*zi))))/log(2); break; + } + c= lrintf((sin(zr)+1)*127) + lrintf((sin(zr/1.234)+1)*127)*256*256 + lrintf((sin(zr/100)+1)*127)*256; + break; + } + zr= t*t - zi*zi+cr; + zi= 2*t*zi + ci; + if(use_zyklus){ + if(mb->zyklus[i>>1][0]==zr && mb->zyklus[i>>1][1]==zi) break; mb->zyklus[i][0]= zr; mb->zyklus[i][1]= zi; |