3 ms·
Wuffs is great. I use it in Substrata (https://substrata.info/ https://substrata.info/) for loading PNGs. It is both faster and safer than LibPNG. It's someth
by Ono-Sendai 2y ago
Wuffs is great. I use it in Substrata (https://substrata.info/ https://substrata.info/) for loading PNGs. It is both faster and safer than LibPNG.
It's something around 2x faster than LibPNG in my tests (depending on the PNG file), see timings here: https://github.com/google/wuffs/issues/13#issuecomment-1732575707 https://github.com/google/wuffs/issues/13#issuecomment-17325...
So generally Wuffs is great and you should use it to decode your PNGs. There are some downsides: not all of the obscure bit depths and formats that PNG supports are loaded as-is, some are converted to more standard formats.
Also the Wuffs documentation is a bit hard to understand. It's a litle bit of a mission getting PNG decoding working. You can see my code for that here though:
https://github.com/glaretechnologies/glare-core/blob/2c7174ca95c68bfc4cea982ec12ac60db0bfd61d/graphics/PNGDecoder.cpp#L175 https://github.com/glaretechnologies/glare-core/blob/2c7174c...
- repsilat 2y agoThe "mango" lib [1] claims to be even faster for PNGs. Actively maintained but doesn't have as much buzz, I think the devs haven't advertised it as much on places like this. Also, it has the funniest testimonials. 1: https://github.com/t0rakka/mango https://github.com/t0rakka/mango
- yjftsjthsd-h 2y agoSpeed isn't the only thing that matters; is mango as safe as wuffs in the face of untrusted input?
- edflsafoiewq 2y agoWhere does the extra speed come from?
- nicoburns 2y agoMy understanding is that libpng is unoptimised and 5-10x faster is possible.
- pornel 2y agolibpng is reasonably fast, and has SIMD optimizations. Make sure to compile it with a modern CPU target. The biggest bottleneck in PNG decoding is zlib, which is not part of libpng. There are faster inflate implementations, but nowhere near 5x. The second slowest thing is unfiltering, but it takes only 10-20% of the decoding time, so even lightspeed implementation would make little difference. There is possibility of a 10x difference when encoding, but that's not due to libpng being slow, but because it's possible to apply worse compression and there are dedicated crappy-but-veryfast encoders.