- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
Rust CI / Run tests and doctests on ubuntu-1 (push) Has been cancelled
Rust CI / Run tests and doctests on ubuntu (push) Has been cancelled
Rust CI / Verify Minimum Supported Rust Version in Cargo.toml (push) Has been cancelled
Rust CI / Run tests and doctests on ubuntu-2 (push) Has been cancelled
Rust CI / Run tests and doctests on ubuntu-3 (push) Has been cancelled
Rust CI / Run tests on big endian architecture (push) Has been cancelled
Rust CI / clippy (push) Has been cancelled
Rust CI / Fuzz targets (cargo-fuzz) (push) Has been cancelled
Rust CI / rustfmt (push) Has been cancelled
Rust CI / cargo-deny (push) Has been cancelled
|
||
| .github/workflows | ||
| benches | ||
| fuzz | ||
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.toml | ||
| CHANGES.md | ||
| deny.toml | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
fdeflate
A fast, safe, and modern zlib implementation for PNG.
Overview
This crate contains an optimized implementation of the deflate algorithm tuned for PNG images, but capable of handling arbitrary data. It was created to serve as the compression backend for the png crate and can also be used as a standalone library. The upcoming 0.4.x series will feature a fully compatible streaming encoder supporting uncompressed output, traditional levels 1-9, and two specialized compression levels designed for PNG images.
Decompression
The decoder employs several modern features than help it achieve exceptional performance that rivals or exceeds the performance of zlib-ng and zlib-rs without using any unsafe code:
- It uses larger Huffman tables with up to 4096 entries, to better make use of the larger L1 caches available on modern processors.
- Multi-byte literal decoding enables decoding two literals with a single table lookup. Since PNG files often have a higher percentage of literals, this is particularly helpful for them.
- Optimized Huffman table construction which requires fewer random writes.
Compression
The compressor is still under active development, with the current status tracked on the main branch.
Preliminary benchmark data shows that fdeflate meaningfully outperforms zlib-rs for levels 1-3 and is slightly better for levels 4-7. Levels 8 and 9 aren't yet implemented.
Ultra-fast compression
The "ultra-fast" compression level is a specialized compression mode that is several times faster than other modes while still providing some amount of compression. It is designed to be performance-competitive with QOI while still being compatible with zlib. It does so by making a bunch of simplifying assumptions:
- Exactly one block per deflate stream.
- No distance codes except for run length encoding of zeros.
- A single fixed Huffman tree trained on a large corpus of PNG images.
- All Huffman codes are <= 12 bits.
In the 0.3.x series, the ultra-fast mode is the only supported compression mode.
Inspiration
The algorithms in this crate take inspiration many other compression libraries including: fpnge, lz4, xz-utils zlib-ng, zlib-rs, ZStandard, and zune-inflate.