Skip to content
io
deflate

deflate

Mojo module 🡭

deflate

DEFLATE (RFC 1951), both directions.

inflate() is a translation of zlib’s puff.c reference decoder (Mark Adler, zlib-licensed), with a first-level lookup table in front of its bit-at-a-time decode() (_decode_fast). deflate() is a from-scratch LZ77 + Huffman encoder built against the RFC: one block, coded with either the fixed tables (RFC 1951 3.2.6, BTYPE=01) or a dynamic code fitted to the data (3.2.7, BTYPE=10), whichever spends fewer bits, over a hash-chain match finder with bounded search depth (_MAX_CHAIN). canvas.io.png’s write_png is the caller.

tests/test_deflate.mojo round-trips both directions against real zlib.compress()/zlib.decompress() output.

Functions