[FFmpeg-devel] swscale dither
Ronald S. Bultje
rsbultje at gmail.com
Fri Jul 15 21:58:16 CEST 2011
On Fri, Jul 15, 2011 at 11:07 AM, madshi <madshi at gmail.com> wrote:
> 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
That doesn't overcome the problem. 0x3ff+3-0+2 still needs to be clipped.
> 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
Don't get me wrong, I believe dithering can be done better. I'm
working on some experiments. I hope they'll work.
More information about the ffmpeg-devel