1 /* lzo1a_de.h -- definitions for the the LZO1A algorithm
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
6 Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
7 Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
8 Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
9 Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
10 Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
11 Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
12 Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
13 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
14 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
15 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
16 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
17 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
20 The LZO library is free software; you can redistribute it and/or
21 modify it under the terms of the GNU General Public License as
22 published by the Free Software Foundation; either version 2 of
23 the License, or (at your option) any later version.
25 The LZO library is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
30 You should have received a copy of the GNU General Public License
31 along with the LZO library; see the file COPYING.
32 If not, write to the Free Software Foundation, Inc.,
33 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 Markus F.X.J. Oberhumer
36 <markus@oberhumer.com>
37 http://www.oberhumer.com/opensource/lzo/
41 /* WARNING: this file should *not* be used by applications. It is
42 part of the implementation of the LZO package and is subject
55 /***********************************************************************
57 ************************************************************************/
60 Format of the marker byte
65 00000000 a long literal run ('R0' run) - there are short and long R0 runs
66 000rrrrr a short literal run with len r
67 mmmooooo a short match (len = 2+m, o = offset low bits)
68 111ooooo a long match (o = offset low bits)
72 #define RSIZE (1 << RBITS)
73 #define RMASK (RSIZE - 1)
75 #define MBITS (8 - OBITS)
76 #define MSIZE (1 << MBITS)
77 #define MMASK (MSIZE - 1)
79 #define OBITS RBITS /* offset and run-length use same bits */
80 #define OSIZE (1 << OBITS)
81 #define OMASK (OSIZE - 1)
84 /* additional bits for coding the length in a long match */
86 #define LSIZE (1 << LBITS)
87 #define LMASK (LSIZE - 1)
90 /***********************************************************************
91 // some macros to improve readability
92 ************************************************************************/
94 /* Minimum len of a match */
96 #define THRESHOLD (MIN_MATCH - 1)
98 /* Min-/Maximum len of a match coded in 2 bytes */
99 #define MIN_MATCH_SHORT (MIN_MATCH)
100 #define MAX_MATCH_SHORT (MIN_MATCH_SHORT + (MSIZE - 2) - 1)
101 /* why (MSIZE - 2) ? because 0 is used to mark runs,
102 * and MSIZE-1 is used to mark a long match */
104 /* Min-/Maximum len of a match coded in 3 bytes */
105 #define MIN_MATCH_LONG (MAX_MATCH_SHORT + 1)
106 #define MAX_MATCH_LONG (MIN_MATCH_LONG + LSIZE - 1)
108 /* Min-/Maximum offset of a match */
110 #define MAX_OFFSET (1 << (CHAR_BIT + OBITS))
113 /* R0 literal run (a long run) */
115 #define R0MIN (RSIZE) /* Minimum len of R0 run of literals */
116 #define R0MAX (R0MIN + 255) /* Maximum len of R0 run of literals */
117 #define R0FAST (R0MAX & ~7) /* R0MAX aligned to 8 byte boundary */
119 #if (R0MAX - R0FAST != 7) || ((R0FAST & 7) != 0)
120 # error "something went wrong"
123 /* 7 special codes from R0FAST+1 .. R0MAX
124 * these codes mean long R0 runs with lengths
125 * 512, 1024, 2048, 4096, 8192, 16384, 32768 */
130 RBITS | MBITS MIN THR. MSIZE MAXS MINL MAXL MAXO R0MAX R0FAST
131 ======+===============================================================
132 3 | 5 3 2 32 32 33 288 2048 263 256
133 4 | 4 3 2 16 16 17 272 4096 271 264
134 5 | 3 3 2 8 8 9 264 8192 287 280
139 /***********************************************************************
141 ************************************************************************/
144 #include "lzo_dict.h"
145 #define DVAL_LEN DVAL_LOOKAHEAD
153 #endif /* already included */