openage icon indicating copy to clipboard operation
openage copied to clipboard

Speed up PNG compression trials with in-memory files

Open heinezen opened this issue 3 years ago • 2 comments

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.

heinezen avatar Mar 20 '21 20:03 heinezen

I can implement this

MavethGH avatar Oct 27 '21 16:10 MavethGH

@MavethGH Great :)

heinezen avatar Oct 27 '21 18:10 heinezen

https://github.com/SFTtech/openage/pull/1495 resolved this issue.

heinezen avatar Sep 10 '23 11:09 heinezen