fdeflate

Fast deflate implementation specialized for PNG image data

Latest version: 0.3.7 registry icon
Maintenance score
88
Safety score
100
Popularity score
71
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.3.7 0 0 0 0 0
0.3.6 0 0 0 0 0
0.3.5 0 0 0 0 0
0.3.4 0 0 0 0 0
0.3.3 0 0 0 0 0
0.3.2 0 0 0 0 0
0.3.1 0 0 0 0 0
0.3.0 0 0 0 0 0
0.2.1 0 0 0 0 0
0.2.0 0 0 0 0 0
0.1.1 0 0 0 0 0
0.1.0 0 0 0 0 0

Stability
Latest release:

0.3.7 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Apache-2.0   -   Apache License 2.0

Not a wildcard

Not proprietary

OSI Compliant


MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



fdeflate

crates.io Documentation Build Status

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.