Description
Every part of the decoding process for PNGs is inherently sequential, but there is some performance to be gained by parallelizing the encoding process.
Zlib compression
We have two Zlib compressors that can be used: fdeflate
and flate2
.
#478 implemented this for the fdeflate
mode.
https://github.com/sstadick/crabz/ provides a parallelizing wrapper around flate2
.
Filtering
Filtering can be parallelized fairly easily, since it operates on each row individually. However, for up
and paeth
filters each operation needs not one but two rows - the previous row and the current one.
If we had the entire image in memory at the same time this would be trivial, but implementing this in a streaming fashion may require more somewhat more complex logic.
I don't expect huge gains here because filtering is extremely fast already, but it might become relevant once the rest of the process is parallelized.