Tizen 2.1 base
[external/lzo2.git] / src / lzo1a_de.h
1 /* lzo1a_de.h -- definitions for the the LZO1A algorithm
2
3    This file is part of the LZO real-time data compression library.
4
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
18    All Rights Reserved.
19
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.
24
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.
29
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.
34
35    Markus F.X.J. Oberhumer
36    <markus@oberhumer.com>
37    http://www.oberhumer.com/opensource/lzo/
38  */
39
40
41 /* WARNING: this file should *not* be used by applications. It is
42    part of the implementation of the LZO package and is subject
43    to change.
44  */
45
46
47 #ifndef __LZO_DEFS_H
48 #define __LZO_DEFS_H
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54
55 /***********************************************************************
56 //
57 ************************************************************************/
58
59 /*
60      Format of the marker byte
61
62
63      76543210
64      --------
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)
69 */
70
71
72 #define RSIZE   (1 << RBITS)
73 #define RMASK   (RSIZE - 1)
74
75 #define MBITS   (8 - OBITS)
76 #define MSIZE   (1 << MBITS)
77 #define MMASK   (MSIZE - 1)
78
79 #define OBITS   RBITS               /* offset and run-length use same bits */
80 #define OSIZE   (1 << OBITS)
81 #define OMASK   (OSIZE - 1)
82
83
84 /* additional bits for coding the length in a long match */
85 #define LBITS   8
86 #define LSIZE   (1 << LBITS)
87 #define LMASK   (LSIZE - 1)
88
89
90 /***********************************************************************
91 // some macros to improve readability
92 ************************************************************************/
93
94 /* Minimum len of a match */
95 #define MIN_MATCH           3
96 #define THRESHOLD           (MIN_MATCH - 1)
97
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 */
103
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)
107
108 /* Min-/Maximum offset of a match */
109 #define MIN_OFFSET          1
110 #define MAX_OFFSET          (1 << (CHAR_BIT + OBITS))
111
112
113 /* R0 literal run (a long run) */
114
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 */
118
119 #if (R0MAX - R0FAST != 7) || ((R0FAST & 7) != 0)
120 #  error "something went wrong"
121 #endif
122
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 */
126
127
128 /*
129
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
135
136  */
137
138
139 /***********************************************************************
140 //
141 ************************************************************************/
142
143 #define DBITS       13
144 #include "lzo_dict.h"
145 #define DVAL_LEN    DVAL_LOOKAHEAD
146
147
148
149 #ifdef __cplusplus
150 } /* extern "C" */
151 #endif
152
153 #endif /* already included */
154
155 /*
156 vi:ts=4:et
157 */
158