In computing, Deflate (stylized as DEFLATE) is a lossless data compression file format that uses a combination of LZ77 and Huffman coding. It was designed by Phil Katz, for version 2 of his PKZIP archiving tool. Deflate was later specified in RFC 1951 (1996). Katz also designed the original algorithm used to construct Deflate streams. This algorithm was patented as , and assigned to PKWARE, Inc. As stated in the RFC document, an algorithm producing Deflate files was widely thought to be implementable in a manner not covered by patents. This led to its widespread use – for example, in gzip compressed files and PNG image files, in addition to the ZIP file format for which Katz originally designed it. The patent has since expired. Stream format A Deflate stream consists of a series of blocks. Each block is preceded by a 3-bit header: First 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. Second and third bits: Encoding method used for this block type: 00: A stored (a.k.a. raw or literal) section, between 0 and 65,535 bytes in length 01: A static Huffman compressed block, using a pre-agreed Huffman tree defined in the RFC 10: A dynamic Huffman compressed block, complete with the Huffman table supplied 11: Reserved—don't use. The stored block option adds minimal overhead and is used for data that is incompressible. Most compressible data will end up being encoded using method 10, the dynamic Huffman encoding, which produces an optimized Huffman tree customized for each block of data individually. Instructions to generate the necessary Huffman tree immediately follow the block header. The static Huffman option is used for short messages, where the fixed saving gained by omitting the tree outweighs the percentage compression loss due to using a non-optimal (thus, not technically Huffman) code. Compression is achieved through two steps: The matching and replacement of duplicate strings with pointers. Replacing symbols with new, weighted symbols based on the frequency of use. Duplicate string elimination Within compressed blocks, if a duplicate series of bytes is spotted (a repeated string), then a back-reference is inserted, linking to the previous location of that identical string instead. An encoded match to an earlier string consists of an 8-bit length (3–258 bytes) and a 15-bit distance (1–32,768 bytes) to the beginning of the duplicate. Relative back-references can be