Skip to main content

Module deflate

Module deflate 

Source
Expand description

DEFLATE (RFC 1951) and zlib (RFC 1950) compression, as used by PNG.

The decoder handles all three block types (stored, fixed and dynamic Huffman). The encoder finds matches with a hash-chain LZ77 search over the 32 KiB window and emits them with the fixed Huffman code, or uses stored blocks at level 0.

See the book entry Image files.

Functionsยง

adler32
The Adler-32 checksum used by zlib.
deflate
Compresses to a raw DEFLATE stream. level 0 stores the data; any other level runs the LZ77 search, with longer hash chains (more compression, more time) for higher levels up to 9, and falls back to stored blocks if the fixed Huffman code would make the data larger (as it does for random bytes).
inflate
Decompresses a raw DEFLATE stream.
inflate_limited
Decompresses a raw DEFLATE stream, failing if the output would exceed max_output bytes (a guard against decompression bombs, which expand up to about 1000 to 1).
zlib_compress
Compresses to a zlib stream (see deflate for level).
zlib_decompress
Decompresses a zlib stream (header, DEFLATE data, Adler-32 trailer), verifying the checksum.