Previous Next


                                        73
SECTION 3.3                                                                 Filters




                     TABLE 3.6 Typical LZW encoding sequence
INPUT              OUTPUT                CODE ADDED       SEQUENCE REPRESENTED
SEQUENCE           CODE                  TO TABLE         BY NEW CODE

–                  256 (clear-table)     –                –

45                 45                    258              45 45

45 45              258                   259              45 45 45

45 45              258                   260              45 45 65

65                 65                    261              65 45

45 45 45           259                   262              45 45 45 66

66                 66                    –                –

–                  257 (EOD)             –                –

Codes are packed into a continuous bit stream, high-order bit first. This stream is
then divided into 8-bit bytes, high-order bit first. Thus, codes can straddle byte
boundaries arbitrarily. After the EOD marker (code value 257), any leftover bits
in the final byte are set to 0.

In the example above, all the output codes are 9 bits long; they would pack into
bytes as follows (represented in hexadecimal):

     80 0B 60 50 22 0C 0C 85 01

To adapt to changing input sequences, the encoder may at any point issue a clear-
table code, which causes both the encoder and the decoder to restart with initial
tables and a 9-bit code length. By convention, the encoder begins by issuing a
clear-table code. It must issue a clear-table code when the table becomes full; it
may do so sooner.


LZWDecode and FlateDecode Parameters

The LZWDecode and FlateDecode filters accept optional parameters to control
the decoding process. Most of these parameters are related to techniques that
reduce the size of compressed sampled images (rectangular arrays of color values,
described in Section 4.8, “Images”). For example, image data typically changes
very little from sample to sample. Therefore, subtracting the values of adjacent

Previous Next