[FFmpeg-cvslog] mandelbrot: correct and simplify the formula used in NORMALIZED_ITERATION_COUNT

Giorgio Vazzana git at videolan.org
Sun Nov 13 17:36:02 CET 2011


ffmpeg | branch: master | Giorgio Vazzana <mywing81 at gmail.com> | Sun Nov 13 16:09:58 2011 +0100| [e555119c739fb35e3bdd8905050104ae0a4692e2] | committer: Michael Niedermayer

mandelbrot: correct and simplify the formula used in NORMALIZED_ITERATION_COUNT

Use log(sqrt(mb->bailout)) instead of log(mb->bailout) because mb->bailout represent
the bailout radius squared, and then simplify the two sqrt().
This is also slightly faster.

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

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

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

diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 719e169..7a1a864 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -185,7 +185,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
                 if(zr*zr + 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(zr*zr + zi*zi))))/log(2); break;
+                    case NORMALIZED_ITERATION_COUNT: zr= i + log2(log(mb->bailout) / log(zr*zr + zi*zi)); break;
                     }
                     c= lrintf((sin(zr)+1)*127) + lrintf((sin(zr/1.234)+1)*127)*256*256 + lrintf((sin(zr/100)+1)*127)*256;
                     break;
@@ -200,7 +200,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
                 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;
+                    case NORMALIZED_ITERATION_COUNT: zr= i + log2(log(mb->bailout) / log(t*t + zi*zi)); 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