Exponential-Golomb code (or Exp-Golomb) is a universal code encoding the positive integers. To code a number:
- Write the number plus 1 in binary.
- Count the bits, subtract one, and write that number of starting zero bits preceding the previous bit string.
The code begins:
0 => 1 => 1 1 => 10 => 010 2 => 11 => 011 3 => 100 => 00100 4 => 101 => 00101 5 => 110 => 00110 6 => 111 => 00111 7 => 1000 => 0001000 8 => 1001 => 0001001 ...
Exp-Golomb coding is used in the MPEG-4 video compression standard, as well as in the Dirac video codec.
Exp-Golomb is identical to the Elias gamma code of the same number plus one. Thus it can encode zero, whereas Elias gamma can only encode numbers greater than zero.
See also: Elias gamma coding, Elias delta coding, Elias omega coding