aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-19 23:28:56 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-19 23:28:56 +0100
commit690860d0d55be4af0242a7664fb78b471e391c9b (patch)
treecc2217cb105481bd191ca6aee06e1142df159a64
parenta5dfedd3814f742a0e7f0bf3112f664f3c5649bd (diff)
downloadffmpeg-690860d0d55be4af0242a7664fb78b471e391c9b.tar.gz
vsrc_mandelbrot: Use threshold to detect cycles.
This way cycles are detected much earlier. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavfilter/vsrc_mandelbrot.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 629fae1b69..3a9f9619e6 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -279,6 +279,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
}
for(x=0; x<mb->w; x++){
+ float epsilon;
const double cr=mb->start_x+scale*(x-mb->w/2);
double zr=cr;
double zi=ci;
@@ -298,6 +299,8 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
}
use_zyklus= (x==0 || mb->inner!=BLACK ||color[x-1 + y*linesize] == 0xFF000000);
+ if(use_zyklus)
+ epsilon= scale*1*sqrt(SQR(x-mb->w/2) + SQR(y-mb->h/2))/mb->w;
#define Z_Z2_C(outr,outi,inr,ini)\
outr= inr*inr - ini*ini + cr;\
@@ -306,7 +309,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
#define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\
Z_Z2_C(outr,outi,inr,ini)\
if(use_zyklus){\
- if(Z && mb->zyklus[i>>1][0]==outr && mb->zyklus[i>>1][1]==outi)\
+ if(Z && fabs(mb->zyklus[i>>1][0]-outr)+fabs(mb->zyklus[i>>1][1]-outi) <= epsilon)\
break;\
}\
mb->zyklus[i][0]= outr;\