[FFmpeg-devel] [PATCH v2] avcodec/pngenc: support writing iCCP chunks

Niklas Haas ffmpeg at haasn.xyz
Fri Mar 11 15:37:20 EET 2022


On Fri, 11 Mar 2022 12:18:13 +0100 Andreas Rheinhardt <andreas.rheinhardt at outlook.com> wrote:
> 1. This is not how should work with an AVBPrint -- you are throwing the
> small-string optimization away here.

Noted, though consider: many ICC profiles used in practice are small
enough to fit inside the 1000 byte buffer. Especially the (absurdly
common) case of an embedded sRGB profile.

As an example, exporting a blank image in GIMP to PNG using the default
settings produces a file with a 388-byte deflate compressed iCCP chunk.

But I don't think this is performance critical enough to warrant
skipping the `malloc` call, and it's definitely to allocate once than
re-allocate in a loop.

> 2. Using an AVBPrint with its dynamic reallocations is probably not good
> here at all: It is easy to get a good upper bound via deflateBound()
> which allows to omit the reallocations/the loop. (I should probably have
> applied

This is a good idea. I didn't realize this existed. I'll switch to using
this function.


More information about the ffmpeg-devel mailing list