Commit e555119c authored by Giorgio Vazzana's avatar Giorgio Vazzana Committed by 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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ad0bdd2f
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment