phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression
MIT License
6.92k stars 330 forks source link

Add `qoi` Rust crate reference (aldanor/qoi-rust) #164

Closed aldanor closed 2 years ago

aldanor commented 2 years ago

Hi all, I finally got to finishing the main work on the Rust crate: https://github.com/aldanor/qoi-rust

@steven-joruk has kindly agreed to hand over the qoi crate name, so the Rust crate is available at https://crates.io/crates/qoi (and docs at https://docs.rs/qoi).

Here's preliminary benchmarks on the reference image suite:

Overall results: (2846 images, 4567.43 MB raw, 1320.95 MP):
---
             decode:Mp/s  encode:Mp/s  decode:MB/s  encode:MB/s
qoi.h              282.9        225.3        978.3        778.9
rapid-qoi          402.3        257.5       1390.9        890.2
qoi-rust           427.4        290.0       1477.7       1002.9

It could be made a bit faster, but that would require delving into unsafe Rust which people tend to dislike. With no-unsafe / no-simd / portable restrictions, I think it's pretty close to how fast it can get.

A few ideas were borrowed from @zakarumych's implementation (namely, hashing and run-length-1 encoding) and credited accordingly in the source code (however, some adjustments needed to be made to avoid bugs that were uncovered during testing).