1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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@gmx.at>
This commit is contained in:
Giorgio Vazzana 2011-11-13 16:09:58 +01:00 committed by Michael Niedermayer
parent ad0bdd2fd2
commit e555119c73

View File

@ -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;