[FFmpeg-cvslog] mandelbrot: unroll the innermost loop once.

Michael Niedermayer git at videolan.org
Sun Nov 13 17:05:38 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Nov 13 16:55:28 2011 +0100| [88166fc579772c881c21fa6f63faa2ad49ce38e8] | committer: Michael Niedermayer

mandelbrot: unroll the innermost loop once.
This allows us to remove a if() and a variable assignment.

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

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

 libavfilter/vsrc_mandelbrot.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 6f9644d..719e169 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -190,11 +190,25 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
                     c= lrintf((sin(zr)+1)*127) + lrintf((sin(zr/1.234)+1)*127)*256*256 + lrintf((sin(zr/100)+1)*127)*256;
                     break;
                 }
-                t= zr*zr - zi*zi;
+                t= zr*zr - zi*zi + cr;
                 zi= 2*zr*zi + ci;
-                zr=       t + cr;
                 if(use_zyklus){
-                    if((i&1) && mb->zyklus[i>>1][0]==zr && mb->zyklus[i>>1][1]==zi)
+                    mb->zyklus[i][0]= t;
+                    mb->zyklus[i][1]= zi;
+                }
+                i++;
+                if(t*t + zi*zi > mb->bailout){
+                    switch(mb->outer){
+                    case            ITERATION_COUNT: zr= i; break;
+                    case NORMALIZED_ITERATION_COUNT: zr= i + (log(log(mb->bailout)) - log(log(sqrt(t*t + 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;
+                }
+                zr= t*t - zi*zi+cr;
+                zi= 2*t*zi + ci;
+                if(use_zyklus){
+                    if(mb->zyklus[i>>1][0]==zr && mb->zyklus[i>>1][1]==zi)
                         break;
                     mb->zyklus[i][0]= zr;
                     mb->zyklus[i][1]= zi;



More information about the ffmpeg-cvslog mailing list