ZLIB Spec Correction Proposal

The current ZLIB Data Format Specification version 3.3, as presented in RFC1950, defines the CINFO (Compression Info) field in Section 2.2. Data Format:

For CM = 8, CINFO is the base-2 logarithm of the LZ77 window size, minus eight (CINFO=7 indicates a 32K window size). Values of CINFO above 7 are not allowed in this version of the specification.  CINFO is not defined in this specification for CM not equal to 8.

For the reasons presented below, this text should be changed to:

For CM = 8, CINFO is an upper bound of the base-2 logarithm of the biggest distance code, minus eight. CINFO = 7 indicates that the distance codes can be at most 32768, and values of CINFO above 7 are not allowed in this version of the specification.  CINFO is not defined in this specification for CM not equal to 8.

Also, in Section 2.3. Compliance, the following text should be added:
A compliant compressor must not output distance codes bigger than 2^(CINFO+8).
...
A compliant decompressor must give an error indication if it detects distance codes bigger than 2^(CINFO+8) in the compressed stream.


The term "the LZ77 window size" is defined by the LZ77 algorithm, but there are some unadressed issues, such as whether to allow matches longer than the window size, or whether to allow matches in the immediate neighborhood of the window margins. These issues are defined by applications, based mainly on the compression ratio vs. execution speed tradeoff. ZLIB is an LZ77 application, but it doesn't specifically define these issues. This may cause unwanted events, such as the events presented here.

- The following encoder optimizations should be correct, but they are not allowed by the current wording of the ZLIB spec:

- The following decoder optimizations should be incorrect, but they are allowed by the current wording of the ZLIB spec:
Back to PNG-Tech Home