Releases: muhammad-fiaz/brotli.zig
Release list
v0.0.3
This release includes:
- Bumped
brotli.zigfrom v0.0.2 to v0.0.3. - Added RFC 7932 second-order literal context modeling with up to 64 contexts and context-tree clustering.
- Added literal block switching for improved compression of heterogeneous data.
- Added static dictionary references using the embedded RFC 7932 dictionary and transform table.
- Added dictionary transforms including identity, suffix, omit-last-N, uppercase-first, and uppercase-all.
- Added large-window encoding support for LGWIN 25–30.
- Added complete
NPOSTFIX/NDIRECTdistance coding support. - Added metadata metablock emission through
.emit_metadataandStreamingCompressor.emitMetadata(). - Reworked streaming decompression to correctly preserve bit-level state across input boundaries.
- Added support for arbitrary streaming chunk sizes, including one-byte-at-a-time input.
- Added
endInput()for explicit end-of-stream handling. - Fixed multiple 32-bit portability issues across encoder and decoder paths.
- Improved compression efficiency on heterogeneous workloads, with reductions of 10.5% and 6.1% on the tested mixed and hetero2 corpora compared with v0.0.2.
- Added extensive tests for context modeling, block switching, static dictionaries, large windows, distance coding, metadata, streaming, and edge cases.
- Verified interoperability with Brotli 1.1 with 55/55 differential cases passing.
- Verified 132/132 quality combinations across 11 corpora.
- Verified cross-target compilation across 8 targets, including real 32-bit x86 Windows.
- Updated all documentation, API references, installation instructions, feature information, and version references for v0.0.3.
v0.0.2
This release introduces a complete native Zig reimplementation of Brotli, replacing the previous C-based implementation with a self-contained, dependency-free codec targeting Zig 0.16.0.
Highlights
- Full native Brotli encoder and decoder based on RFC 7932
- Large Window Brotli decoding support up to 30-bit windows
- No C bindings, libc, or external dependencies
- Native streaming compression and decompression
- Static RFC 7932 dictionary embedded in Zig
- Custom dictionary support
- Quality levels
0–11 - Window bits
10–24 - Generic, text, and font compression modes
- Typed decoder error codes
- Fuzz-tested decoder
- Comprehensive round-trip and streaming tests
Encoder
- Hash-chain match finding
- Greedy and lazy matching
- Recent-distance shortcuts
- Native Huffman table construction
- Simple and complex Huffman trees
- Length-limited Huffman coding
- Compressed and stored metablocks
- Insert-and-copy command generation
- Explicit and implicit distance forms
- Streaming progress callbacks
Decoder
- Full streaming state machine
- Metablocks and metadata blocks
- Uncompressed metablocks
- Context maps with RLE and inverse move-to-front transforms
- Block type and length switching
- Distance ring buffer
- Compound dictionaries
- Static dictionary transforms
- Incremental input/output resumption
- Robust malformed-stream handling
API
New native APIs include:
compress/compressWithOptionsdecompress/decompressWithOptionsdecompressIntomaxCompressedSizeEncoderandDecoderStreamingCompressorStreamingDecompressor- Encoder parameter configuration
- Dictionary attachment
- Output draining and completion queries
Documentation & Examples
Added a complete VitePress documentation site and standalone examples covering compression, decompression, streaming, dictionaries, progress callbacks, error handling, format introspection, and low-level bit operations.
Testing & CI
- Comprehensive compression/decompression round trips
- Multiple qualities, window sizes, and data patterns
- Streaming and flush validation
- Dictionary round-trip tests
- Reference-stream verification
- Malformed input testing
- Decoder fuzzing
- Linux, Windows, and macOS CI
x86,x86_64, andaarch64cross-compilation
Requires Zig 0.16.0 or newer.
v0.0.1
brotli.zig 0.0.1
Initial release of high-level Zig bindings for Google's Brotli compression library (RFC 7932).
Overview
Complete Zig 0.16.0+ bindings for the Brotli C library with 100% public C API coverage, providing idiomatic Zig types, error handling, allocator support, and memory management.
What's New
- Complete Zig 0.16.0+ bindings for Brotli
- 100% public C API coverage (30/30 functions)
- High-level, allocator-friendly Zig API
- One-shot and streaming compression/decompression
- Shared and prepared dictionary support
- Metadata block support
- Full encoder and decoder parameter coverage
- Strongly typed enums and comprehensive error handling
Features
| Feature | Description |
|---|---|
| One-shot API | compress, decompress, compressWithOptions, decompressWithOptions, decompressSimple |
| Streaming Encoder | Encoder.compressStream with process, flush, finish, and emit_metadata |
| Streaming Decoder | Decoder.decompressStream with byte tracking and automatic buffer management |
| Dictionaries | PreparedDictionary, SharedDictionary, encoder/decoder dictionary attachment |
| Metadata | Metadata emission and callback support |
| Custom Allocators | Works with any std.mem.Allocator |
| Large Window | Supports Brotli large window mode |
| Error Handling | Zig-native error mapping for all decoder error codes |
API Coverage
| Category | Coverage |
|---|---|
| Encoder | 15 functions |
| Decoder | 14 functions |
| Shared Dictionary | 3 functions |
| Total | 30/30 public C API functions |
Quality
- 124 automated tests
- 10 runnable examples
- Continuous Integration on Linux, macOS, and Windows
Quick Start
const brotli = @import("brotli");
// Simple compression
const compressed = try brotli.compress(allocator, input);
defer allocator.free(compressed);
const decompressed = try brotli.decompress(allocator, compressed);
defer allocator.free(decompressed);
// Compression with options
const custom = try brotli.compressWithOptions(allocator, input, .{
.quality = 6,
.lgwin = 18,
.mode = .text,
});
defer allocator.free(custom);Installation
zig fetch --save git+https://github.com/muhammad-fiaz/brotli.zig.git#0.0.1Compatibility
- Zig 0.16.0+
- Linux
- macOS
- Windows
Upstream
- Brotli C library (RFC 7932)
- Bundled Brotli source compiled directly via
build.zig
Authors
- Muhammad Fiaz — Zig bindings, build system, and API design
- Google Brotli Authors — Original Brotli compression library
License
MIT