A library 'QOI' that can encode PNG images up to 50 times faster has appeared, so I tried using it
Software engineer
Lossless Image Compression in O (n) Time
https://phoboslab.org/log/2021/11/qoi-fast-lossless-image-compression
In order to implement the image display function in the application, a library corresponding to the encoding / decoding of each image format is required, and as the encoding / decoding library of the PNG image format, ' libpng ' which is a reference implementation of PNG and many others. There is a 'stb ' that corresponds to the image format. The QOI developed this time is a library that emphasizes the speed of encoding and decoding, and when compressing the same PNG format image without deterioration, decoding is 3 to 4 times faster and encoding is 20 to 50 times faster than the existing library. It is possible to execute with.
The source code of QOI and the benchmark application for performance evaluation of QOI is released under the MIT license at the following link. This time, I will actually build and run the benchmark application and check the performance of QOI.
GitHub --phoboslab / qoi: The “Quite OK Image” format for fast, lossless image compression
https://github.com/phoboslab/qoi
This time, we will build the benchmark app on Ubuntu installed on the laptop. First, install Git and then execute the following command to clone the QOI Git repository locally.
git clone https://github.com/phoboslab/qoi.git
Next, install 'build-essential ', which contains the packages required for compiling the source code, and 'libpng-dev' and 'libstb-dev', which are required for building the benchmark application, with the following commands.
sudo apt install build-essential libpng-dev libstb-dev
After that, execute the following command to compile 'qoibench.c', and the build work of the QOI benchmark application is completed.
gcc qoibench.c -std = gnu99 -lpng -I / usr / include / stb -O3 -o qoibench
In the benchmark app, you can compress the specified image with libpng, stb, and QOI without deterioration, and compare the time required for decoding and encoding and the size after compression. When you run the benchmark app, you can execute the following command. Enter the number of benchmark attempts in <iterations>, and enter the directory containing the PNG image files in <directory>.
qoibench <iterations> <directory>
This time, I placed a test PNG format image in the directory 'images / textures /' and ran the benchmark with the following command.
./qoibench 5 images / textures /
For the benchmark test image, I used the following 'Screenshot of the top page of GIGAZINE'. The image below is a resized image, the resolution of the original file used for the benchmark is 1903 x 3334 pixels, and the file size is 6948KB.
Benchmark results are as follows. It took 69.3 ms for libpng, 83.7 ms for stb (stbi), and 28.0 ms for QOI. The time it took to encode was 1106.7 ms for libpng, 929.7 ms for stb (stbi) and 43.0 ms for QOI (qoi). It was confirmed that QOI has a decoding speed of about 2.5 times and an encoding speed of about 25.7 times that of libpng. The compressed file size is 5158KB for libpng, 6883KB for stb, and 5796KB for QOI.
According to Szablewski, QOI uses an intermediate algorithm between run-length compression and lexicographic compression. Due to this mechanism, QOI can obtain a higher compression effect for images with more solid painting elements such as anime-style illustrations. Szablewski said that it may be possible to apply it to video codecs by advancing the development of QOI, and if QOI development progresses and it is adopted in many software, the image display speed and movie display speed will be large. There is a possibility of improvement.
You can check the QOI benchmark results conducted by Szablewski on website screenshots and textures on the following page.
QOI Benchmark Results
https://phoboslab.org/files/qoibench/
Related Posts: