DEFLATE - Stream Format

Stream Format

A Deflate stream consists of a series of blocks. Each block is preceded by a 3-bit header:

  • 1 bit: Last-block-in-stream marker:
    • 1: this is the last block in the stream.
    • 0: there are more blocks to process after this one.
  • 2 bits: Encoding method used for this block type:
    • 00: a stored/raw/literal section, between 0 and 65,535 bytes in length.
    • 01: a static Huffman compressed block, using a pre-agreed Huffman tree.
    • 10: a compressed block complete with the Huffman table supplied.
    • 11: reserved, don't use.

Most blocks will end up being encoded using method 10, the dynamic Huffman encoding, which produces an optimised Huffman tree customised for each block of data individually. Instructions to generate the necessary Huffman tree immediately follow the block header.

Compression is achieved through two steps

  • The matching and replacement of duplicate strings with pointers.
  • Replacing symbols with new, weighted symbols based on frequency of use.

Read more about this topic:  DEFLATE

Famous quotes containing the word stream:

    In contrast to the flux and muddle of life, art is clarity and enduring presence. In the stream of life, few things are perceived clearly because few things stay put. Every mood or emotion is mixed or diluted by contrary and extraneous elements. The clarity of art—the precise evocation of mood in the novel, or of summer twilight in a painting—is like waking to a bright landscape after a long fitful slumber, or the fragrance of chicken soup after a week of head cold.
    Yi-Fu Tuan (b. 1930)