Deflate

object Deflate

Pure-Kotlin RFC 1951 DEFLATE deflater, the inverse of Inflate.

Pipeline: greedy hash-chained LZ77 over a 32 KiB window → one final block, emitted with whichever of fixed (BTYPE=01) or dynamic (BTYPE=10) Huffman codes is smaller for this input. The dynamic code lengths follow zlib's length-limited Huffman (trees.c build_tree + gen_bitlen): a min-heap Huffman tree, then the overflow-redistribution that caps lengths at 15 bits (7 for the code-length code) while preserving the Kraft equality.

This encoder never emits stored (BTYPE=00) blocks and never splits its output into several blocks. One dynamic or fixed block encodes an input of any size.

Output is bare DEFLATE; the gzip/zlib framers wrap it. It decodes byte-for-byte through Inflate and through stock zlib.

Functions

Link copied to clipboard

Compress data to a bare DEFLATE stream (no zlib/gzip wrapper).