1 ## Copyright (C) 2007 Gorka Lertxundi
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {@var{m} =} lz77deco (@var{c}, @var{alph}, @var{la}, @var{n})
18 ## Lempel-Ziv 77 source algorithm decoding implementation. Where
22 ## message decoded (1xN).
24 ## encoded message (Mx3).
28 ## lookahead buffer size.
30 ## sliding window buffer size.
35 function m = lz77deco(c, alph, la, n)
36 if (la <= 0 || n <= 0)
37 error("lz77deco: Lookahead buffer size and window size must be higher than 0.");
40 error("lz77deco: Unreachable configuration: n - la >= la.");
43 error("lz77deco: Alphabet size within less than 2 symbols? Is that possible?.");
46 error("lz77deco: Encoded message must be a Nx3 matrix.");
55 temp = n-la+c(x,2)-c(x,1);
57 window(n-la+y) = window(c(x,1)+y);
59 window(n-la+c(x,2)+1) = c(x,3);
62 m_deco = window(n-la+1:n-la+c(x,2)+1);
71 window(1:n-la) = window(temp+1:n-la+temp);
77 %! lz77deco([8 2 1 ; 7 3 2 ; 6 7 2 ; 2 8 0],3,9,18)