QOI image compression format introduced

A new, lightweight, lossless image compression format, QOI (Quite OK Image), is introduced, which allows very fast image compression in RGB and RGBA color spaces. When comparing performance with the PNG format, a single-threaded reference implementation of the QOI format in the C language, which does not use SIMD instructions and assembler optimizations, is 20-50 times faster than the libpng and stb_image libraries in encoding speed, and 3-4 times in decoding speed. In terms of compression efficiency, QOI in most tests is close to libpng (in some tests it is slightly ahead, and in others it loses), but in general it is noticeably ahead of stb_image (up to 20% gain).

The QOI reference implementation in C has only 300 lines of code. The source code is distributed under the MIT license. Additionally, enthusiasts have prepared implementations of encoders and decoders in Go, Zig and Rust. The project is being developed by Dominic Szablewski, a game developer with experience in creating a library for MPEG1 video decoding. Using the QOI format, the author wanted to show that it is possible to create an effective and simple alternative to overcomplicated modern image encoding formats.

QOI performance does not depend on the resolution and nature of the encoded image (O(n)). Encoding and decoding is performed in one pass - each pixel is processed only once and can be encoded in one of 4 ways, selected depending on the values ​​of past pixels. If the next pixel coincides with the previous one, then the repetition counter only increases. If a pixel matches one of the values ​​in the past pixel buffer 64, then a 6-bit offset to the past pixel is indicated instead of the value. If the color of the last pixel differs slightly, the difference is indicated in the short form (abbreviated encoding of the differences in color components that fit into 2,4 and 5 bits). If no optimization is applicable, the full rgba value is specified.

Source: opennet.ru

Add a comment