Golomb-Rice coding

Vicente González Ruiz

December 31, 2019

Contents

1 Basics
2 Golomb Encoder
 2.1 Example (m = 7 and s = 8)
3 Golomb Decoder
 3.1 Example (decode 10010 for m = 7)
 3.2 Lab
4 Rice Encoder
 4.1 Example (k = 1 and s = 7)
5 Rice Decoder
  5.0.1 Example (decode 11101 for k = 1)
 5.1 Lab
References

1 Basics

2 Golomb Encoder

  1. k log2(m).
  2. r smodm.
  3. t 2k m.
  4. Output sm using an unary code. /* Most significant bits */
  5. If r < t:
    1. Output the integer encoded in the k 1 least significant bits of r using a binary code. /* Least significant bits */
  6. Else:
    1. r r + t.
    2. Output the integer encoded in the k least significant bits of r using a binary code.

2.1 Example (m = 7 and s = 8)

  1. [1] k log2(8) = 3.
  2. [2] r 8mod7 = 1.
  3. [3] t 23 7 = 8 7 = 1.
  4. [4] Output 87 = 1 as an unary code (2 bits). Therefore, output 10.
  5. [5] r = 1 t = 1.
  6. [6.A] r 1 + 1 = 2.
  7. [6.B] Output r = 2 using a binary code of k = 3 bits. Therefore, c(8) = 10010.

3 Golomb Decoder

  1. k log2(m).
  2. t 2k m.
  3. Let s the number of consecutive ones in the input (we stop when we read a 0).
  4. Let x the next k 1 bits in the input.
  5. If x < t:
    1. s s × m + x.
  6. Else:
    1. x x × 2+ next input bit.
    2. s s × m + x t.

3.1 Example (decode 10010 for m = 7)

  1. [1] k 3.
  2. [2] t 2k m = 23 7 = 1).
  3. [3] s 1 because we found only one 1 in the input.
  4. [4] x inputk1 = input2 = 01.
  5. [5] x = 1 t = 1.
  6. [6.A] x x × x × 2 + next input bit = x × 1 × 2 + 0 = 2.
  7. [6.B] s s × m + x t = 1 × 7 + 2 1 = 8.

3.2 Lab

TO-DO

4 Rice Encoder

  1. m 2k.
  2. Output sm using an unary code (sm + 1 bits).
  3. Output the k least significant bits of s.

4.1 Example (k = 1 and s = 7)

  1. [1] m 2k = 21 = 2.
  2. [2] Output sm = 72 = 3 using an unary code of 4 bits. Therefore, output 1110.
  3. Output the k = 1 least significant bits of s = 7. So, output 1. Total output c(7) = 11101.

5 Rice Decoder

  1. Let s the number of consecutive ones in the input (we stop when we read a 0).
  2. Let x the next k input bits.
  3. s s × 2k + x.

5.0.1 Example (decode 11101 for k = 1)

  1. [1] s 3 because we found 3 consecutive ones in the input.
  2. [2] x next input k = 1 input bits. Therefore x 1.
  3. [3] s s × 2k + x = 3 × 21 + 1 = 6 + 1 = 7.

5.1 Lab

TO-DO

References

[1]   Solomon Golomb. Run-length encodings (Corresp.). IEEE transactions on information theory, 12(3):399–401, 1966.

[2]   Robert Rice and James Plaunt. Adaptive variable-length coding for efficient compression of spacecraft television data. IEEE Transactions on Communication Technology, 19(6):889–897, 1971.