[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DEFLATE, ZLIB and RFC1951



At 18:13 23.07.01 +0100, Paul Onions wrote:
>In the description of DEFLATE in RFC1951 it states that the compressed data
>is in the form of a sequence of blocks, where each block has a 3-bit header
>consisting of a BFINAL bit and a BTYPE bit-pair.  The BFINAL bit identifies
>the last block of the sequence and the BTYPE pair indicates whether the
>block is either non-compressed, compressed with fixed huffman codes, or
>compressed with dynamic huffman codes.
>
>My question is how these bits should be handled when using ZLIB?
>
>I can't find any explicit mention of these bits in the ZLIB documentation
>and, after playing around with ZLIB (using the python module), it seems that
>it does not produce/understand these bits.
>
>Is this correct (and they have to be handled external to ZLIB), or am I
>misunderstanding something here?
>
>Any help would be appreciated,
>Paul(o)
>

ZLIB _does_ produce these. And when single stepping through the 
inflate_blocks() routine, it certainly interprets them
correcty.

      NEEDBITS(3)
      t = (uInt)b & 7;
      s->last = t & 1;
      switch (t >> 1)
      {
        case 0:                         /* stored */
          [cut]
        case 1:                         /* fixed */
          [cut]
        case 2:                         /* dynamic */
          [cut]
        case 3:                         /* illegal */
          [cut]
	}

s->last is your BFINAL and t >> 1 is BTYPE.

J–rn


Follow-Ups: References: