[FFmpeg-devel] [PATCH 1/2] avfilter/paletteuse: fix error dithering accuracy
Clément Bœsch
u at pkh.me
Mon Feb 23 10:17:54 CET 2015
On Wed, Feb 18, 2015 at 03:46:23PM +0100, Clément Bœsch wrote:
> From: Clément Bœsch <clement at stupeflix.com>
>
> ---
> libavfilter/vf_paletteuse.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
> index a8defc7..87a90d0 100644
> --- a/libavfilter/vf_paletteuse.c
> +++ b/libavfilter/vf_paletteuse.c
> @@ -133,9 +133,9 @@ static int query_formats(AVFilterContext *ctx)
>
> static av_always_inline int dither_color(uint32_t px, int er, int eg, int eb, int scale, int shift)
> {
> - return av_clip_uint8((px >> 16 & 0xff) + ((er * scale) >> shift)) << 16
> - | av_clip_uint8((px >> 8 & 0xff) + ((eg * scale) >> shift)) << 8
> - | av_clip_uint8((px & 0xff) + ((eb * scale) >> shift));
> + return av_clip_uint8((px >> 16 & 0xff) + ((er * scale) / (1<<shift))) << 16
> + | av_clip_uint8((px >> 8 & 0xff) + ((eg * scale) / (1<<shift))) << 8
> + | av_clip_uint8((px & 0xff) + ((eb * scale) / (1<<shift)));
> }
>
> static av_always_inline int diff(const uint8_t *c1, const uint8_t *c2)
Applied.
If anyone wants to make this faster, patch very welcome
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150223/84a77ba6/attachment.asc>
More information about the ffmpeg-devel
mailing list