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) 2011 Markus Franz Xaver Johannes Oberhumer
6   Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
7   Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
8   Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
9   Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
10   Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
11   Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
12   Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
13   Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
14   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
15   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
16   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
17   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
18   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
19   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
20   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
21   All Rights Reserved.
22
23   The LZO library is free software; you can redistribute it and/or
24   modify it under the terms of the GNU General Public License as
25   published by the Free Software Foundation; either version 2 of
26   the License, or (at your option) any later version.
27
28   The LZO library is distributed in the hope that it will be useful,
29   but WITHOUT ANY WARRANTY; without even the implied warranty of
30   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31   GNU General Public License for more details.
32
33   You should have received a copy of the GNU General Public License
34   along with the LZO library; see the file COPYING.
35   If not, write to the Free Software Foundation, Inc.,
36   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37
38   Markus F.X.J. Oberhumer
39   <markus@oberhumer.com>
40   http://www.oberhumer.com/opensource/lzo/
41 */
42
43
44/* WARNING: this file should *not* be used by applications. It is
45   part of the implementation of the LZO package and is subject
46   to change.
47 */
48
49
50#ifndef __LZO_DEFS_H
51#define __LZO_DEFS_H 1
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57
58/***********************************************************************
59//
60************************************************************************/
61
62/*
63     Format of the marker byte
64
65
66     76543210
67     --------
68     00000000   a long literal run ('R0' run) - there are short and long R0 runs
69     000rrrrr   a short literal run with len r
70     mmmooooo   a short match (len = 2+m, o = offset low bits)
71     111ooooo   a long match (o = offset low bits)
72*/
73
74
75#define RSIZE   (1 << RBITS)
76#define RMASK   (RSIZE - 1)
77
78#define MBITS   (8 - OBITS)
79#define MSIZE   (1 << MBITS)
80#define MMASK   (MSIZE - 1)
81
82#define OBITS   RBITS               /* offset and run-length use same bits */
83#define OSIZE   (1 << OBITS)
84#define OMASK   (OSIZE - 1)
85
86
87/* additional bits for coding the length in a long match */
88#define LBITS   8
89#define LSIZE   (1 << LBITS)
90#define LMASK   (LSIZE - 1)
91
92
93/***********************************************************************
94// some macros to improve readability
95************************************************************************/
96
97/* Minimum len of a match */
98#define MIN_MATCH           3
99#define THRESHOLD           (MIN_MATCH - 1)
100
101/* Min-/Maximum len of a match coded in 2 bytes */
102#define MIN_MATCH_SHORT     (MIN_MATCH)
103#define MAX_MATCH_SHORT     (MIN_MATCH_SHORT + (MSIZE - 2) - 1)
104/* why (MSIZE - 2) ? because 0 is used to mark runs,
105 *                   and MSIZE-1 is used to mark a long match */
106
107/* Min-/Maximum len of a match coded in 3 bytes */
108#define MIN_MATCH_LONG      (MAX_MATCH_SHORT + 1)
109#define MAX_MATCH_LONG      (MIN_MATCH_LONG + LSIZE - 1)
110
111/* Min-/Maximum offset of a match */
112#define MIN_OFFSET          1
113#define MAX_OFFSET          (1 << (CHAR_BIT + OBITS))
114
115
116/* R0 literal run (a long run) */
117
118#define R0MIN   (RSIZE)             /* Minimum len of R0 run of literals */
119#define R0MAX   (R0MIN + 255)       /* Maximum len of R0 run of literals */
120#define R0FAST  (R0MAX & ~7)        /* R0MAX aligned to 8 byte boundary */
121
122#if (R0MAX - R0FAST != 7) || ((R0FAST & 7) != 0)
123#  error "something went wrong"
124#endif
125
126/* 7 special codes from R0FAST+1 .. R0MAX
127 * these codes mean long R0 runs with lengths
128 * 512, 1024, 2048, 4096, 8192, 16384, 32768 */
129
130
131/*
132
133RBITS | MBITS  MIN  THR.  MSIZE  MAXS  MINL  MAXL   MAXO  R0MAX R0FAST
134======+===============================================================
135  3   |   5      3    2     32    32    33    288   2048    263   256
136  4   |   4      3    2     16    16    17    272   4096    271   264
137  5   |   3      3    2      8     8     9    264   8192    287   280
138
139 */
140
141
142/***********************************************************************
143//
144************************************************************************/
145
146#define DBITS       13
147#include "lzo_dict.h"
148#define DVAL_LEN    DVAL_LOOKAHEAD
149
150
151
152#ifdef __cplusplus
153} /* extern "C" */
154#endif
155
156#endif /* already included */
157
158/*
159vi:ts=4:et
160*/
161
162