A Back Reference to Earlier Output

A back-reference codec can describe a repeated fragment by where it begins in already reconstructed output and how much to copy.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a toy example
  2. Check format-specific cases
  3. Decode a copy instruction from already available output
  4. Specify overlapping copies when the format permits them

Trace a toy example

If output currently ends with ABC and a reference requests the previous three positions for length three, it can append ABC. The decoder interprets distance using its current write position. See index bounds.

Check format-specific cases

Some formats allow a reference to overlap with the portion being written, so reading behavior must follow their rules. Complete input and structural checks help reject unsupported references.[1][2]

Decode a copy instruction from already available output

After emitting literal ABC, a toy decoder can apply distance three and length three to emit another ABC. The distance is relative to output position, not to the encoded input cursor. Check it refers to available data under the format. See replacing repeated fragments.

Output before copy: ABC
Distance 3 points to initial A
Copy 3 symbols: ABC
Final output: ABCABC

Specify overlapping copies when the format permits them

Some formats allow newly produced symbols to become reference sources within the same command. A naive fixed slice can behave differently. Test an invalid distance and the smallest allowed overlap.

References

  1. Claude E. Shannon, A Mathematical Theory of Communication ↩
  2. David J. C. MacKay, Information Theory, Inference, and Learning Algorithms ↩