On Sat, Sep 25, 2021 at 5:00 AM Soft Works <softwo...@hotmail.com> wrote:
> > > > -----Original Message----- > > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of > > Soft Works > > Sent: Friday, 24 September 2021 19:03 > > To: FFmpeg development discussions and patches <ffmpeg- > > de...@ffmpeg.org> > > Subject: Re: [FFmpeg-devel] Scaling PAL8 images with alpha > > > > > > > > > -----Original Message----- > > > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of > > Michael > > > Niedermayer > > > Sent: Friday, 24 September 2021 17:40 > > > To: FFmpeg development discussions and patches <ffmpeg- > > de...@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. > > I've put a few thing together to illustrate what I'm talking about: > > https://gist.github.com/softworkz/deef5c2a43d3d629c3e17f9e21544a8f > > > Meanwhile I found what I need: https://github.com/ImageOptim/libimagequant > > Interestingly, they are comparing their lib specifically to the > Photoshop feature that I mentioned: https://pngquant.org/vsphotoshop.html > In the 2000's, the PS implementation for image quantization, optimization > and compression (profanely named "Save for Web") had remained > unparalleled for years, that's why it was one of my first thoughts. > > I hadn't heard about libimagequant before, but it seems to do exactly > what is needed for rescaling PAL8 to PAL8 at a high quality. > > Before spending any time on it, I wanted ask whether that library > would be acceptable for adding it as a (GPLv3) reference to the > project and as a dependency to my filter? > > I'm against more GPLv3 dependency in lavfi. > Kind regards, > softworkz > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".