LZ77

Juan Francisco Rodríguez Herrera
Vicente González Ruiz

September 12, 2016

Contents

1 History
2 Fundamentals of LZ77
3 The LZ77 encoder
4 The LZ77 decoder
5 Decoding example

1 History

2 Fundamentals of LZ77

3 The LZ77 encoder

  1. Let I the length of the dictionary and J the length of the buffer.
  2. Input the first J symbols in the buffer.
  3. While the input is not exhausted:
    1. Let i the position in the dictionary of the first j symbols of the buffer and k the symbol that makes that j can not be larger.
    2. Output ijk.
    3. Input the next j + 1 in the buffer.

4 The LZ77 decoder

  1. While the code-words ijk are not exhausted:
    1. Output the j symbols extracted from the position i in the dictionary.
    2. Output k.
    3. Introduce all the decoded symbols into the buffer.

Encoding example

Dict. Buffer Output Comment




abab
cbababaaaaaa 0 0 a Empty dictionary
a
babc
bababaaaaaa 0 0 b b Not found
ab
abcb
ababaaaaaa 2 2 c ab found
a
babc
baba
baaaaaa 0 3 a bab found
ababc
baba
baaa
aaa 0 2 a ba found
ababcbab
abaa
aaaa
2 3 a aaa found


0123

5 Decoding example

Input Output Dict. Buffer




0 0 a a
a
0 0 b b
a
b
2 2 c abc
ab
abc
0 3 a baba a
babc
baba
0 2 a baa ababc
baba
baa
2 3 a aaaa ababcbabab
abaa
aaaa


0123