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

Soft Works softworkz at hotmail.com
Mon Oct 31 22:41:30 EET 2022



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Clément Bœsch
> Sent: Monday, October 31, 2022 7:51 PM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] Revert
> "avfilter/vf_palette(gen|use): support palettes with alpha"
> 
> On Mon, Oct 31, 2022 at 03:11:13PM +0000, Soft Works wrote:
> [...]
> > And pngquant doing the impossible as well:
> >
> > > Interestingly, pngquant which is supposed to have the best open
> source
> > > quantization algorithms
> 
> Says who?

That's the result of my research I did at that time. 
Feel free to do your own research.

> https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da
> 02d86925cc0167831205/pam.h#L163-L182
> >
> https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da
> 02d86925cc0167831205/mediancut.c#L29-L49
> >
> https://github.com/ImageOptim/libimagequant/blob/a16c9ca66a24158496da
> 02d86925cc0167831205/mediancut.c#L449-L476
> >
> 
> I'd rather not look too much into that code. Do they mess up the
> alpha
> channel as well? 

When working on this, you should at least be familiar with the quality
of results it provides, even when you don't want to look at the code.


> > 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

I'll take that as a joke..

> properly, but I'll ask for it to be reliable enough so that it's
> enabled
> by default.

That's not acceptable either, because the filter may also be
used to create animated GIFs where only a single palette entry
may exist which indicates full transparency and all others are
fully opaque.


I don't want to be just negative and rejective and I'm really 
welcoming patches that provide improvement. But I think that 
a prerequisite for working on this subject is to be familiar
with state-of-the art implementations of image color quantization.

The best implementations I'm aware of can be found in PhotoShop
(closed source) and pngquant (open source).

The quantization that vf_elbg (with use_alpha) does get very
close to the aforementioned, but it comes at the price of 
relatively high computational cost.

If you would come up with an implementation for palettegen/-use
that provides comparable results in an efficient way like
pngquant, that would be really awesome!

> but I'll ask for it to be reliable enough so that it's

I'll ask for your patch to support alpha in the same 
optional way like it is supported right now.
(actually something that should go without saying)

Best regards,
softworkz








More information about the ffmpeg-devel mailing list