[FFmpeg-devel] swscale dither

madshi madshi at gmail.com
Fri Jul 15 20:07:04 CEST 2011


2011/7/15 Ronald S. Bultje <rsbultje at gmail.com>
> So what your scaled-dither code does is to have a
> start value, add a random number to it in the subpixel-
> range of the destination pixel, and then shift. In this
> example, 10bit -> 8bit has two bits of pixel clipping
> and thus we add a 2bit random number [0,1,2,3] to it,
> as in (10bit + rand[0,1,2,3]) >> 2 = 8bit.

I don't think that's a good dither. I'd suggest using TPDF dithering:

(10bit + rand[0..3] - rand[0..3] + 2) >> 2 = 8bit

Actually it would be better to increase the bitdepth of the whole
calculation to achieve a better triangular distribution of the dithering
noise. E.g.:

((10bit << 14) + rand[0..65535] - rand[0..65535] + 32768) >> 16 = 8bit

Best regards, Mathias.


More information about the ffmpeg-devel mailing list