A code table is a shared lookup chart: each encoded symbol or run length points to a codeword. A sender replaces items with these codewords, and a receiver uses the same table to decode them. section 6.4 section 6.3
The table must support unambiguous reading. With the prefix property, no codeword begins another codeword, so a stream of bits can be decoded without guessing where one code ends. section 6.3
A code table can be designed or chosen in different ways:
- A frequency-aware table gives short codewords to common items, reducing the total number of transmitted bits. section 6.3
- A pre-prepared table lets communicating systems agree in advance, avoiding the need to collect statistics from each complete message. section 6.4
- The entries may also be represented as a tree: move left for 0 and right for 1 until reaching the desired symbol. section 6.3
A fax line
Instead of sending every pixel, a fax counts alternating white and black runs and looks up each run length. A 39-pixel line might become runs of 12 white, 4 black, 2 white, 18 black, and 3 white; their codewords are transmitted in order. The example falls from 74 individual pixel bits to 46 coded bits. section 6.4
Figure 6.12 Codes for black-and-white runs
Compare the codewords assigned to black-and-white run lengths, including short codes for common runs. section 6.4
