liveBook · Manning

Code table

As explained in How Computers Make Books

A code table is a predefined mapping from encoded symbols or run lengths to their codewords.

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

How How Computers Make Books covers it

How deep it goes
Defines lookup, prefix safety, frequency choice, and tree representation, but does not explain how Huffman tables are constructed.
Examples
Uses Huffman-coded text, black-and-white fax runs, code tables, and corresponding binary trees.
What it assumes
Assumes only basic bits and frequencies, and develops the need for shared tables and unambiguous variable-length codes.
What you can do after
Apply code tables to encode and decode simple text or alternating image runs while checking prefix-free decoding.
How it connects
Connects frequency, prefix property, Huffman coding, tree representations, and image compression.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Computers Make Books. The section links point to the parts of the book it draws on.