[FFmpeg-cvslog] mandelbrot: support different outer coloring methods.

Michael Niedermayer git at videolan.org
Fri Nov 11 23:34:19 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Nov 11 23:22:04 2011 +0100| [4ccd898af2a5cf86a005c5f9861676c1b63448d4] | committer: Michael Niedermayer

mandelbrot: support different outer coloring methods.

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

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

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

diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 6987501..fef5733 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -30,6 +30,11 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/parseutils.h"
 
+enum Outer{
+    ITERATION_COUNT,
+    NORMALIZED_ITERATION_COUNT,
+};
+
 typedef struct {
     int w, h;
     AVRational time_base;
@@ -39,6 +44,7 @@ typedef struct {
     double start_y;
     double start_scale;
     double bailout;
+    enum Outer outer;
 } MBContext;
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -54,6 +60,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
     mb->start_y=-1.5;
     mb->start_scale=3.0;
     mb->bailout=100;
+    mb->outer= NORMALIZED_ITERATION_COUNT;
     if (args)
         sscanf(args, "%127[^:]:%127[^:]:%d,%lf:%lf:%lf", frame_size, frame_rate, &mb->maxiter, &mb->start_x, &mb->start_y, &mb->start_scale);
 
@@ -123,7 +130,10 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
             for(i=0; i<256; i++){
                 double t;
                 if(zr*zr + zi*zi > mb->bailout){
-                    zr= i + (log(log(mb->bailout)) - log(log(sqrt(zr*zr + zi*zi))))/log(2); break;
+                    switch(mb->outer){
+                    case            ITERATION_COUNT: zr= i; break;
+                    case NORMALIZED_ITERATION_COUNT: zr= i + (log(log(mb->bailout)) - log(log(sqrt(zr*zr + 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;
                 }



More information about the ffmpeg-cvslog mailing list