[FFmpeg-cvslog] mandelbrot: add dither to convergence & mincol colorings.

Michael Niedermayer git at videolan.org
Tue Nov 15 23:01:05 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Nov 15 21:33:11 2011 +0100| [04bb26e3ee50a3506af924ff83bf83e13ebef9b0] | committer: Michael Niedermayer

mandelbrot: add dither to convergence & mincol colorings.
This avoids banding artifacts.
Note, low end TFTs still show some banding.

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

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

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

diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index f575fb1..194d866 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -72,6 +72,7 @@ typedef struct {
     Point *point_cache;
     Point *next_cache;
     double (*zyklus)[2];
+    uint32_t dither;
 } MBContext;
 
 #define OFFSET(x) offsetof(MBContext, x)
@@ -224,6 +225,8 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
             double zr=cr;
             double zi=ci;
             uint32_t c=0;
+            double dv= mb->dither / (double)(1LL<<32);
+            mb->dither= mb->dither*1664525+1013904223;
 
             if(color[x + y*linesize] & 0xFF000000)
                 continue;
@@ -267,7 +270,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
                     c= ((c<<5)&0xE0) + ((c<<16)&0xE000) + ((c<<27)&0xE00000);
                 }
                 }else if(mb->inner==CONVTIME){
-                    c= (i*255/mb->maxiter)*0x010101;
+                    c= floor(i*255.0/mb->maxiter+dv)*0x010101;
                 } else if(mb->inner==MINCOL){
                     int j;
                     double closest=9999;
@@ -278,7 +281,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
                             closest_index= j;
                         }
                     closest = sqrt(closest);
-                    c= lrintf((mb->zyklus[closest_index][0]/closest+1)*127) + lrintf((mb->zyklus[closest_index][1]/closest+1)*127)*256;
+                    c= lrintf((mb->zyklus[closest_index][0]/closest+1)*127+dv) + lrintf((mb->zyklus[closest_index][1]/closest+1)*127+dv)*256;
                 }
             }
             c |= 0xFF000000;



More information about the ffmpeg-cvslog mailing list