summaryrefslogtreecommitdiff
path: root/main/lzo/src/lzo1a_de.h
blob: 3e4b05a0dc624ca988ed9f41a7d8b21e51bec02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* lzo1a_de.h -- definitions for the the LZO1A algorithm

   This file is part of the LZO real-time data compression library.

   Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
   All Rights Reserved.

   The LZO library is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of
   the License, or (at your option) any later version.

   The LZO library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with the LZO library; see the file COPYING.
   If not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

   Markus F.X.J. Oberhumer
   <markus@oberhumer.com>
   http://www.oberhumer.com/opensource/lzo/
 */


/* WARNING: this file should *not* be used by applications. It is
   part of the implementation of the LZO package and is subject
   to change.
 */


#ifndef __LZO_DEFS_H
#define __LZO_DEFS_H 1

#ifdef __cplusplus
extern "C" {
#endif


/***********************************************************************
//
************************************************************************/

/*
     Format of the marker byte


     76543210
     --------
     00000000   a long literal run ('R0' run) - there are short and long R0 runs
     000rrrrr   a short literal run with len r
     mmmooooo   a short match (len = 2+m, o = offset low bits)
     111ooooo   a long match (o = offset low bits)
*/


#define RSIZE   (1 << RBITS)
#define RMASK   (RSIZE - 1)

#define MBITS   (8 - OBITS)
#define MSIZE   (1 << MBITS)
#define MMASK   (MSIZE - 1)

#define OBITS   RBITS               /* offset and run-length use same bits */
#define OSIZE   (1 << OBITS)
#define OMASK   (OSIZE - 1)


/* additional bits for coding the length in a long match */
#define LBITS   8
#define LSIZE   (1 << LBITS)
#define LMASK   (LSIZE - 1)


/***********************************************************************
// some macros to improve readability
************************************************************************/

/* Minimum len of a match */
#define MIN_MATCH           3
#define THRESHOLD           (MIN_MATCH - 1)

/* Min-/Maximum len of a match coded in 2 bytes */
#define MIN_MATCH_SHORT     (MIN_MATCH)
#define MAX_MATCH_SHORT     (MIN_MATCH_SHORT + (MSIZE - 2) - 1)
/* why (MSIZE - 2) ? because 0 is used to mark runs,
 *                   and MSIZE-1 is used to mark a long match */

/* Min-/Maximum len of a match coded in 3 bytes */
#define MIN_MATCH_LONG      (MAX_MATCH_SHORT + 1)
#define MAX_MATCH_LONG      (MIN_MATCH_LONG + LSIZE - 1)

/* Min-/Maximum offset of a match */
#define MIN_OFFSET          1
#define MAX_OFFSET          (1 << (CHAR_BIT + OBITS))


/* R0 literal run (a long run) */

#define R0MIN   (RSIZE)             /* Minimum len of R0 run of literals */
#define R0MAX   (R0MIN + 255)       /* Maximum len of R0 run of literals */
#define R0FAST  (R0MAX & ~7)        /* R0MAX aligned to 8 byte boundary */

#if (R0MAX - R0FAST != 7) || ((R0FAST & 7) != 0)
#  error "something went wrong"
#endif

/* 7 special codes from R0FAST+1 .. R0MAX
 * these codes mean long R0 runs with lengths
 * 512, 1024, 2048, 4096, 8192, 16384, 32768 */


/*

RBITS | MBITS  MIN  THR.  MSIZE  MAXS  MINL  MAXL   MAXO  R0MAX R0FAST
======+===============================================================
  3   |   5      3    2     32    32    33    288   2048    263   256
  4   |   4      3    2     16    16    17    272   4096    271   264
  5   |   3      3    2      8     8     9    264   8192    287   280

 */


/***********************************************************************
//
************************************************************************/

#define DBITS       13
#include "lzo_dict.h"
#define DVAL_LEN    DVAL_LOOKAHEAD



#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* already included */

/*
vi:ts=4:et
*/