[FFmpeg-devel] [PATCH] libswscale/swscale_unscaled: fix DITHER_COPY macro

Michael Niedermayer michael at niedermayer.cc
Thu Mar 16 20:17:38 EET 2017


On Wed, Mar 15, 2017 at 10:52:29PM +0100, Mateusz Brzostek wrote:
> Hello!
> 
> There are 3 problems with DITHER_COPY macro in libswscale/swscale_unscaled.c:
> 1) there is overflow in dithering from 12-bit to 10-bit (output value > 1023);
> 2) for limit range the lower limit is not respected, for example from 10-bit to 8-bit value 64 is converted to 15;
> 3) for many iteration of downscale/upscale of the same image the 200th iteration is significantly darker.
> 
> The first bug is due to wrong dithers table (now it is OK only for 8-bit destination), fix is:
> -        const uint8_t *dither= dithers[src_depth-9][i&7];\
> +        const uint8_t *dither= dithers[src_depth-dst_depth-1][i&7];\
> 
> For bugs 2) and 3) it is needed formula that do not make images darker (in attachment). So please review.

does your code maintain white and black levels ?
with 4 bits white is 15, with 7 bits white is 127 for example
white should stay white
black should stay black
in both directions

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170316/df199a8d/attachment.sig>


More information about the ffmpeg-devel mailing list