aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-13 16:55:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-13 17:01:56 +0100
commit88166fc579772c881c21fa6f63faa2ad49ce38e8 (patch)
treedf233bfc10444a3a5c5f328eef1e547434616624
parent1d066087327ef3eb496ad5d78b4ccc0d40c5c9d6 (diff)
downloadffmpeg-88166fc579772c881c21fa6f63faa2ad49ce38e8.tar.gz
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>
-rw-r--r--libavfilter/vsrc_mandelbrot.c20
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;