openage
openage copied to clipboard
Speed up PNG compression trials with in-memory files
The converter has support for optimizing PNG compression like OptiPNG by trying to compress a file several times (each with different compression parameters) and choosing the result with the smallest file size. Currently, we initialize each trial by getting a file pointer from libc.stdio.tmpfile
and writing to that file. libpng
's standard output path asks for a FILE * stream. However, using a temporary file is slower than doing everything in-memory.
One solution would be the usage of the more advanced libpng
API. We can pass libpng
a custom write function png_set_write_fn()
(described here) that writes to a buffer. This would have to be done in pure C++ which is then called by Cython code in the converter.
I can implement this
@MavethGH Great :)
https://github.com/SFTtech/openage/pull/1495 resolved this issue.