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:

    Married love is a stream that, after a certain length of time, sinks into the earth and flows underground. Something is there, but one does not know what. Only the vegetation shows that there is still water.
    Gerald Branan (1894–1987)