Deflate Format: differences between type blocks

Viewed 205

I am currently trying to write a compressor and decompressor with the same purpose as the RFC Deflate specification.

I'm not able to understand the difference between how blocks are composed in the compression with fixed tables and dynamic tables. The file is processed by LZ77 generating (distance, length) + literal.

  • How do I know the type of block?
  • Do I have to compress this data?
  • Given that I use a fixed compression and don't have to send the tables, how would the encoder know how to encode data?
  • Moreover, do I have to send data before the actual compression executes?

I am confused on the difference between fixed tables and the table we send in the dynamic mode, and how the two blocks use them to encode data.

I'm currently reading Data Compression: The Complete Reference. Any advice will be helpful.

1 Answers

Since you are trying to compress, you would pick the smaller of the two. zlib's deflate computes what the size of a fixed block, a dynamic block, and a stored block would be, and emits the smallest of the three.

If you are encoding a fixed block, you encode using the fixed code for literal/lengths and distances. This code is provided in the RFC.

Related