by rsp1984 · 3y ago · 0 comments
This summer I spent a lot of time researching lossless compression formats as a streaming format for our 3D capture and reconstruction engine. QOI was on our list too.
My biggest criticism about QOI is that in many cases it doesn't compress at all, or even increases size. It works well on the demo images that come with the package but these are carefully selected. It also works well on high-res, high-quality images with lots of single-color background and/or smooth gradients. But give it grainy, noisy, smaller-format images and it completely breaks down.
We ended up sticking with PNG, which btw. has fast open source implementations too [1][2].
[1] https://libspng.org/ [2] https://github.com/richgel999/fpng
In QOIP, opcodes themselves are stored in the format, LZ4 or zstd compression
https://github.com/chocolate42/qoipond
QOIR adds: color profile, EXIF, premultiplied alpha, lossy mode, tile support, LZ4 compression, AFAIK it does this while beating the original QOI in terms of speed AND efficiency.
Lots of benchmarks in: https://github.com/nigeltao/qoir
QOIX is my very own version that adds: Greyscale [+alpha] 8-bit image support, lossy 10-bit support (16-bit encoded as 10-bit, intended for elevation maps), so it's really 3 codecs , optional LZ4. https://github.com/AuburnSounds/gamut
The benchmark suite[1] I compiled contains many different types of images. The "industry standard" sets like the Kodak and Tecnick Photos, texture packs and icons are complete. No images have been removed from these sets. Some of the other collections (photos and game screenshots from Wikipedia and those from pngimg.com) are a random sample. I did not remove any images just because they compressed badly.
Also, the fact that some images compress badly is a non issue, if the whole set of assets that you need for your game/app combined have an acceptable compression ratio. If that's not the case, by all means, chose another image format.
On average, for a lot of assets types, QOI usually performs quite ok.
Lossless compression of random noise isn't possible and lossy compression of it requires content aware algorithms (e.g. AI) to get results.
Even if you don't readily see the random noise, it's there. Subtly changing the hues of pixels just slightly enough to be incompressible.
Imagine an image with large blocks of constant colour in 8-bit colour depth has 2 bits of random noise on every pixel. We indeed can't ever compress to less than 2 bits per pixel, but we can still get down to that.
I am imagining something like a "base layer" with averaged brightness + arithmetic coding for differences might do it.
Nice :-)