-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Much faster standard PNG writing #55
Comments
Additionally, it's also possible using multiple IDAT's to parallelize PNG encoding across multiple threads. Combining both techniques would result in enormous reductions in wall-block time for writing PNG. The time it takes to read & write PNG is becoming a significant bottleneck in modern commercial environments that use 8K-16K or larger images/textures. |
Given that it results in fully standard PNGs, using this technique doesn't require any changes to the spec, right? |
Correct. No spec changes. There's already a Rust implementation of the threaded writing idea: |
I modified miniz (a zlib alternative) to implement pixel-wise LZ compression: All LZ matches are aligned to 4 byte boundaries, and literals are always output in groups of 4. Compression is ~16% faster, or 8.6x faster than stbi_write_png: miniz.h lvl1g+pixelwise LZ: .145 10.38 |
Which tool was used to generate the graphic? I have cleaned up and published the spec I had for parallel encoding/decoding, it's fairly flexible: https://github.com/libspng/png-restart-marker |
I finally got around to setting up a framework for benchmarking lossless codecs, including JPEG 2000 Part 15 (HTJ2K) and JPEG XL. Initial results at: https://www.lossless-benchmarks.com/ It is possible to achieve throughput comparable to QOI at lower file sizes. |
Using more modern zlib compression libs, it's possible to greatly speed up PNG writing while still writing fully standard PNG's that are reasonably compressed. The possible speed gains are large, I estimate around 2-15x vs. stb_image/lodepng/libpng. (Possibly even faster using libdeflate, a modern Deflate compressor, which I didn't have time to hook up.)
https://twitter.com/richgel999/status/1470696769470271493
Quick PNG writing bench, 2k 32bpp, ~7x faster vs. stbi_write_png:
miniz.h lv1g: .173 secs 9.99MB
lodepng+miniz f0: .256 9.99
miniz lvl3g: .498 8.91
miniz lvl5: .596 8.86
stbi f0 lvl 5: .895 11.41
stbi f0: .944 11.39
lodepng+miniz: .985 5.96
stbi: 1.247 8.15
lodepng: 2.311 5.89
The text was updated successfully, but these errors were encountered: