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

Clément Bœsch u at pkh.me
Mon Oct 31 20:51:28 EET 2022


On Mon, Oct 31, 2022 at 03:11:13PM +0000, Soft Works wrote:
[...]
> > > Photoshop has these different modes as well and it would
> > > surely be useful, but I don't think it should be replacing the
> > > existing behavior.
> > >
> > 
> > There is no point in keeping a ton of complexity exposed as user
> > options
> > for something implementation specific. We offer no guarantee over how
> > the
> > quantization is expected to run.
> 
> Says who?

The API contract with the user is that we propose a quantization, the
implementation details do not matter, we do not document that so we take
no engagement whatsoever in that regards.

Also, users are not looking for many options about how it works under the
hood, they just want the best they can get out of the box, that's a basic
UX rule.

[...]
> And pngquant doing the impossible as well:
> 
> > Interestingly, pngquant which is supposed to have the best open source
> > quantization algorithms

Says who?

> > seems to be using weights (albeit in a more 
> > sophisticated way) and does not handle alpha separately for calculating 
> > color distance, variance and averaging:
> 
> https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da02d86925cc0167831205/pam.h#L163-L182 
> https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da02d86925cc0167831205/mediancut.c#L29-L49 
> https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da02d86925cc0167831205/mediancut.c#L449-L476
> 

I'd rather not look too much into that code. Do they mess up the alpha
channel as well? If not, feel free to investigate how they achieve that.

> > That's not how it's going to work, sorry; I'm not going to increase
> > complexity and maintenance effort for no gain. Implementing a correct
> > support for the alpha will likely involve a revert of that commit
> > anyway.
> 
> If you want to improve the way it works that's another story.
> 
> But at this point, we're talking about removal. And I disagree to that.

You may disagree but:
- the option causes many transparency artifacts
- the option is fundamentally flawed and need to be rewritten differently
- handling the alpha should be by default if such a feature was existing
- the option is preventing improvements to the code

I will send a patchset in the coming days, which depends on its removal.
You'll be free to propose again a patch to support alpha quantization
properly, but I'll ask for it to be reliable enough so that it's enabled
by default.

Regards,

-- 
Clément B.


More information about the ffmpeg-devel mailing list