Parallelization of PNG file creation with C++, libpng and OpenMP

后端 未结 2 773
南旧
南旧 2021-02-08 19:33

I am currently trying to implement a PNG encoder in C++ based on libpng that uses OpenMP to speed up the compression process. The tool is already able to generate PNG files from

2条回答
  •  误落风尘
    2021-02-08 19:54

    I finally got it to parallelize the compression process. As mentioned by Cameron in the comment to his answer I had to strip the zlib header from the zstreams to combine them. Stripping the footer was not required as zlib offers an option called Z_SYNC_FLUSH which can be used for all chunks (except the last one which has to be written with Z_FINISH) to write to a byte boundary. So you can simply concatenate the stream outputs afterwards. Eventually, the adler32 checksum has to be calculated over all threads and copied to the end of the combined zstreams.

    If you are interested in the result you can find the complete proof of concept at https://github.com/anvio/png-parallel

提交回复
热议问题