Browse code

mandelbrot: add a end_scale and pts so we can zoom in.

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

Michael Niedermayer authored on 2011/11/12 07:58:08
Showing 1 changed files
... ...
@@ -43,6 +43,8 @@ typedef struct {
43 43
     double start_x;
44 44
     double start_y;
45 45
     double start_scale;
46
+    double end_scale;
47
+    double end_pts;
46 48
     double bailout;
47 49
     enum Outer outer;
48 50
 } MBContext;
... ...
@@ -57,8 +59,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
57 57
 
58 58
     mb->maxiter=256;
59 59
     mb->start_x=0;
60
-    mb->start_y=0;
60
+    mb->start_y=1;
61 61
     mb->start_scale=3.0;
62
+    mb->end_scale=0.3;
63
+    mb->end_pts=200;
62 64
     mb->bailout=100;
63 65
     mb->outer= NORMALIZED_ITERATION_COUNT;
64 66
     if (args)
... ...
@@ -69,6 +73,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
69 69
         return AVERROR(EINVAL);
70 70
     }
71 71
     mb->start_scale /=mb->h;
72
+    mb->end_scale /=mb->h;
72 73
 
73 74
     if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 ||
74 75
         frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
... ...
@@ -119,10 +124,12 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
119 119
     MBContext *mb = ctx->priv;
120 120
     int x,y,i;
121 121
 
122
+    double scale= mb->start_scale*pow(mb->end_scale/mb->start_scale, pts/mb->end_pts);
123
+
122 124
     for(y=0; y<mb->h; y++){
123 125
         for(x=0; x<mb->w; x++){
124
-            const double cr=mb->start_x+mb->start_scale*(x-mb->w/2);
125
-            const double ci=mb->start_y+mb->start_scale*(y-mb->h/2);
126
+            const double cr=mb->start_x+scale*(x-mb->w/2);
127
+            const double ci=mb->start_y+scale*(y-mb->h/2);
126 128
             double zr=cr;
127 129
             double zi=ci;
128 130
             uint32_t c=0;