fhanau / Efficient-Compression-Tool

Fast and effective C++ file optimizer
Apache License 2.0
596 stars 41 forks source link

Optimize LodePNG #106

Open woot000 opened 2 years ago

woot000 commented 2 years ago

Refactor and optimize existing LodePNG functions

These changes decrease the size of the compiled LodePNG code and speed up optimizing PNGs using the --allfilters switch

On MSYS2 MINGW64 gcc 12.2.0, LodePNG code is

On MSYS2 CLANG64 clang 15.0.0, LodePNG code is

There's a ~0.5% speed increase for the --allfilters-b switch, otherwise there is no measurable speed difference optimizing PNGs not using --allfilters or --allfilters-b

fhanau commented 2 years ago

Most other changes look fine, I'll try to go through them in the coming days, might take longer though due to other obligations

fhanau commented 1 year ago

Worked on this a while ago but only recently managed to clean it up given the large scale of changes within one pull request: With the latest commit, many of the changes are integrated. This includes all changes I find useful outside of small cosmetic changes and changes to filter() and optimize_palette(). While there are several changes in these functions that may be useful, reviewing them would be lengthy and complex work while only promising to gain small code size improvements and a tiny speedup in some scenarios. For now, I will leave this pull request open and might integrate filter/palette changes later on, but it is not a priority.