summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-12 16:33:12 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-12 16:46:16 +0100
commit50b8f9388adfc09283a8f1990d91a2acc24dadb7 (patch)
treedf7b2bc3a922cd8af3dd5aaf57c80d7942c0e1fb /libavfilter
parent3de934c8735449482a8d04cac02fa0060bffa3c8 (diff)
mandelbrot: detect cycles to speed up interior rendering.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vsrc_mandelbrot.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 2ea080ec06..67b289340d 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -56,6 +56,7 @@ typedef struct {
int cache_used;
Point *point_cache;
Point *next_cache;
+ double (*zyklus)[2];
} MBContext;
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -96,6 +97,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
mb->cache_used = 0;
mb->point_cache= av_malloc(sizeof(*mb->point_cache)*mb->cache_allocated);
mb-> next_cache= av_malloc(sizeof(*mb-> next_cache)*mb->cache_allocated);
+ mb-> zyklus = av_malloc(sizeof(*mb->zyklus) * mb->maxiter);
return 0;
}
@@ -107,6 +109,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_freep(&mb->point_cache);
av_freep(&mb-> next_cache);
+ av_freep(&mb->zyklus);
}
static int query_formats(AVFilterContext *ctx)
@@ -187,6 +190,10 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
t= zr*zr - zi*zi;
zi= 2*zr*zi + ci;
zr= t + cr;
+ if(i && mb->zyklus[i>>1][0]==zr && mb->zyklus[i>>1][1]==zi)
+ break;
+ mb->zyklus[i][0]= zr;
+ mb->zyklus[i][1]= zi;
}
c |= 0xFF000000;
color[x + y*linesize]= c;