// Exponential-Golomb - Standard variable-length code in video compression
Used in H.264/AVC and H.265/HEVC codecs.
Different k values for different distributions.
Built-in mapping for signed integers.
Exponential-Golomb codes of order k encode non-negative integer n as: 1) Add 1 to n to get codeNum, 2) Divide by 2^k to get quotient q and remainder r, 3) Write q zeros, then 1, then r in k bits. For k=0, this equals Elias Gamma. Signed integers map: positive n โ 2n-1, non-positive n โ -2n.
Order k=0 (standard): 0 โ 1 1 โ 010 2 โ 011 3 โ 00100 Order k=1: 0 โ 10 1 โ 11 2 โ 010 3 โ 011 Signed mode (k=0): 0 โ 1 (maps to 0) 1 โ 010 (maps to 1) -1 โ 011 (maps to 2) 2 โ 00100 (maps to 3)
Exponential-Golomb coding is a universal variable-length code used extensively in video compression standards like H.264 and H.265. It generalizes Elias Gamma coding with a parameter k that allows adaptation to different data distributions.
k=0 (standard Exp-Golomb) works well for small integers with exponential distribution. Higher k values are better for larger integers or more uniform distributions. Video codecs often use k=0 for syntax elements and adaptive k for residuals.
Exp-Golomb is ideal for video because: 1) Simple to implement in hardware, 2) No lookup tables needed, 3) Good for the statistical distribution of video data, 4) Provides good compression for motion vectors and transform coefficients.
Compared to Huffman: simpler, no tables, but less optimal. Compared to arithmetic coding: much simpler, lower compression. Exp-Golomb strikes a balance between simplicity and efficiency, perfect for real-time video encoding.