[FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use): support palettes with alpha"

Soft Works softworkz at hotmail.com
Sun Oct 30 23:19:05 EET 2022



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Clément Bœsch
> Sent: Sunday, October 30, 2022 6:58 PM
> To: ffmpeg-devel at ffmpeg.org
> Cc: softworkz at hotmail.com; Clément Bœsch <u at pkh.me>
> Subject: [FFmpeg-devel] [PATCH] Revert "avfilter/vf_palette(gen|use):
> support palettes with alpha"
> 
> This reverts commit dea673d0d548c864ec85f9260d8900d944ef7a2a.
> 
> This change cannot work for several reasons, the most obvious ones
> are:
> 
> - the alpha is being part of the scoring of the color difference,
> even
>   though we can not interpret the alpha as part of the perception of
> the
>   color (we don't even know if it's premultiplied or postmultiplied)
> - the colors are averaged with their alpha value which simply cannot
>   work
> 
> The command proposed in the original thread of the patch actually
> produces a completely broken file:
> 
>     ffmpeg -y -loglevel verbose -i fate-suite/apng/o_sample.png -
> filter_complex
> "split[split1][split2];[split1]palettegen=max_colors=254:use_alpha=1[
> pal1];[split2][pal1]paletteuse=use_alpha=1" -frames:v 1 out.png
> 
> We can see that many color pixels are off, but more importantly some
> colors have a random alpha value: https://imgur.com/eFQ2UK7
> 
> I don't see any easy fix for this unfortunately, the approach appears
> to
> be flawed by design.
> ---

At the time of submission I did a lot of experiments and the results
seemed to be very useful:

https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f

softworkz


More information about the ffmpeg-devel mailing list