[FFmpeg-devel] swscale dither

Ronald S. Bultje rsbultje at gmail.com
Fri Jul 15 19:19:04 CEST 2011


Hi Michael,

always great to hear from you, thank you for your kind words.

On Fri, Jul 15, 2011 at 8:33 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> you got the scaling totally wrong and now you add with
> 55eda370cb6fe9e4c21539f3f90fd940fcf7a103 completely incorrect cliping
> because you have the scaling wrong. And the 2 bugs dont cancel each
> other you introduce a significant and wrong bias here.

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. As an example, let's take a max
pixel value of 0x3ff, and add 1 dither of 1, which gives us (0x3ff +
1) >> 2 = 0x100. How would you do this without clipping?

> Also you still use 32bit buffers all over the place for handling 10bit
> data. ffmpegs code uses 32bit buffers only when needed to maintain
> precission and 16bit otherwise. Which should make ffmpegs swscale
> twice as fast on 10bit data once its all done with SIMD :)
> I dont mind at all if it stays that way :))))
> nor do i if you reimplement or take my code as its then less work for
> me to maintain the 16/32bit buffer feature :)))))

I'd be really happy for you if your SIMD was twice as fast as mine. I
accept your challenge. Good luck!

Ronald


More information about the ffmpeg-devel mailing list