Skip to content
uencoder

Golomb Coding

Golomb coding is the optimal prefix code for geometric distributions (small values are most likely); a parameter m determines the combination of unary and truncated binary coding.

Purpose

It efficiently encodes geometrically distributed integer sequences such as run lengths, prediction residuals (JPEG-LS), and inverted-index gaps.

Mechanism

For an integer n, compute q = floor((n-1)/m) and r = (n-1) mod m; q is coded in unary and r in truncated binary. With m = 2^k it degenerates to Rice coding.

Use cases

  • JPEG-LS residual coding
  • Run-length coding
  • Compression of geometrically distributed data

Related tools

References