[FFmpeg-cvslog] vsrc_mandelbrot: Use threshold to detect cycles.

Michael Niedermayer git at videolan.org
Sun Nov 20 00:07:22 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Nov 19 23:28:56 2011 +0100| [690860d0d55be4af0242a7664fb78b471e391c9b] | committer: Michael Niedermayer

vsrc_mandelbrot: Use threshold to detect cycles.
This way cycles are detected much earlier.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=690860d0d55be4af0242a7664fb78b471e391c9b
---

 libavfilter/vsrc_mandelbrot.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 629fae1..3a9f961 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;\



More information about the ffmpeg-cvslog mailing list