[FFmpeg-devel] Scaling PAL8 images with alpha

Soft Works softworkz at hotmail.com
Fri Sep 24 20:03:17 EEST 2021



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Michael
> Niedermayer
> Sent: Friday, 24 September 2021 17:40
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] Scaling PAL8 images with alpha
> 
> On Fri, Sep 24, 2021 at 10:30:31AM +0000, Soft Works wrote:
> > Hi,
> >
> > for a new filter, I want to rescale PAL8 subtitle bitmaps where the palette
> includes
> > colors with alpha.
> >
> > From what I’ve seen, swscale doesn’t support PAL8-to-PAL8, only PAL8-to-
> BGR8
> > which doesn’t support alpha and the palette is fixed with 256 entries
> defined by
> > convention, while I would ideally like to be able to allow the following:
> >
> > - constrain the output to use the same palette as the input
> > - adaptively quantize it to a palette with a configurable number of colors
> >
> > Thus it's about the palette quantization (with or without dithering) after
> > scaling in RGBA. (or some cool algorithmic trick I'm not aware of)
> >
> > Is there any existing code that I could reuse? The closest I could find
> > is pngenc, but I'm wondering whether there's something else/better
> > somewhere in the ffmpeg libs that I haven't seen?
> 
> There are some non linear scaling filters which may make sense when you do
> not have the full linear space available see:
> hqx, epx, xbr
> you could also try some neural net stuff

Photoshop can perfectly do what is needed, but their algorithms are not
public.


> or the insane solution, OCR, scale text, render font into RGBA and then back
> to PAL8

LOL, for a moment I had thought the same after the great OCR results I had 
seen recently...


softworkz


More information about the ffmpeg-devel mailing list