Binary run length encoding

Juan Francisco Rodríguez Herrera
Vicente González Ruiz

September 12, 2016

Contents

1 Intro
2 Encoder
3 Decoder

1 Intro

2 Encoder

  1. Let s 0.
  2. While there are bits to encode:
    1. Read the next n consecutive bits equal to s.
    2. Write n.
    3. s (s + 1)modulus2.

3 Decoder

  1. Let s 0.
  2. While there are items n to decode:
    1. Write n bits equal to s.
    2. s (s + 1)modulus2.

Example

The runs:

0000111110000001111111000000

are encoded as::

4 5 6 7 6