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
RLE for bin-ary alphabets.
In this case, it is not necessary to indicate the next symbol (only the length) because if a run ends, the other (possible) symbol start with the next run.
2
Encoder
Let
s
←
0
.
While there are bits to encode:
Read the next
n
consecutive bits equal to
s
.
Write
n
.
s
←
(
s
+
1
)
modulus
2
.
3
Decoder
Let
s
←
0
.
While there are items
n
to decode:
Write
n
bits equal to
s
.
s
←
(
s
+
1
)
modulus
2
.
Example
The runs:
0000111110000001111111000000
are encoded as::
4 5 6 7 6