QOI: Lossless Image Compression in O(n) Time
Out of curiosity, I modified the benchmark program to simply toss the pixel data into lz4&#x2F;lz4hc for comparison (patch file: <a href="https:&#x2F;&#x2F;paste.debian.net&#x2F;1220663&#x2F;" rel="nofollow">https:&#x2F;&#x2F;paste.debian.net&#x2F;1220663&#x2F;</a>).<p>I&#x27;m actually quite impressed how the resulting size is a little bit smaller than lz4hc (actually not even that far away from libpng), while the encoding speed is quite close to lz4, despite seemingly not having as many hacks and tweaks under the hood to get there. So the encoder is IMO doing amazingly well actually.<p>However, the <i>decoding</i> speed of liblz4 is off by roughly an order of magnitude. But again, liblz4 probably benefits from decades of tweaking &amp; tuning to get there. It would be interesting how much performance could be gotten out of the qoi decoder.<p>Here are the <i>totals</i> I get for the &quot;textures&quot; benchmark samples:<p><pre><code>          decode ms   encode ms   decode mpps   encode mpps   size kb
  libpng:       2.2        32.4         58.67          3.94       160
  stbi:         2.1        17.0         61.50          7.49       228
  qoi:          0.7         0.7        191.50        170.54       181
  lz4:          0.1         0.6       1226.06        206.40       258
  lz4hc:        0.1        70.9       1029.26          1.80       200
</code></pre>
And for the &quot;wallpaper&quot; samples. The spreads seem to be a bit more in favor of qoi here:<p><pre><code>          decode ms   encode ms   decode mpps   encode mpps   size kb
  libpng:     131.9      2287.1         66.63          3.84      8648
  stbi:       147.5      1177.1         59.55          7.46     12468
  qoi:         56.3        56.5        156.13        155.60      9981
  lz4:         14.3        53.1        614.53        165.50     18019
  lz4hc:       13.9      1901.7        630.94          4.62     12699</code></pre>