lzoruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +339 -0
- data/README.txt +57 -0
- data/ext/compr1b.h +81 -0
- data/ext/compr1c.h +81 -0
- data/ext/config1.h +61 -0
- data/ext/config1a.h +196 -0
- data/ext/config1b.h +140 -0
- data/ext/config1c.h +145 -0
- data/ext/config1f.h +97 -0
- data/ext/config1x.h +118 -0
- data/ext/config1y.h +66 -0
- data/ext/config1z.h +65 -0
- data/ext/config2a.h +155 -0
- data/ext/extconf.rb +2 -0
- data/ext/lzo/lzo1.h +96 -0
- data/ext/lzo/lzo1a.h +96 -0
- data/ext/lzo/lzo1b.h +160 -0
- data/ext/lzo/lzo1c.h +160 -0
- data/ext/lzo/lzo1f.h +108 -0
- data/ext/lzo/lzo1x.h +177 -0
- data/ext/lzo/lzo1y.h +145 -0
- data/ext/lzo/lzo1z.h +150 -0
- data/ext/lzo/lzo2a.h +92 -0
- data/ext/lzo/lzo_asm.h +139 -0
- data/ext/lzo/lzoconf.h +417 -0
- data/ext/lzo/lzodefs.h +1807 -0
- data/ext/lzo/lzoutil.h +73 -0
- data/ext/lzo1.c +635 -0
- data/ext/lzo1_99.c +130 -0
- data/ext/lzo1_cm.ch +52 -0
- data/ext/lzo1_d.ch +155 -0
- data/ext/lzo1a.c +657 -0
- data/ext/lzo1a_99.c +130 -0
- data/ext/lzo1a_cm.ch +242 -0
- data/ext/lzo1a_cr.ch +128 -0
- data/ext/lzo1a_de.h +158 -0
- data/ext/lzo1b_1.c +46 -0
- data/ext/lzo1b_2.c +46 -0
- data/ext/lzo1b_3.c +46 -0
- data/ext/lzo1b_4.c +46 -0
- data/ext/lzo1b_5.c +46 -0
- data/ext/lzo1b_6.c +46 -0
- data/ext/lzo1b_7.c +46 -0
- data/ext/lzo1b_8.c +46 -0
- data/ext/lzo1b_9.c +46 -0
- data/ext/lzo1b_99.c +49 -0
- data/ext/lzo1b_9x.c +365 -0
- data/ext/lzo1b_c.ch +270 -0
- data/ext/lzo1b_cc.c +167 -0
- data/ext/lzo1b_cc.h +93 -0
- data/ext/lzo1b_cm.ch +294 -0
- data/ext/lzo1b_cr.ch +126 -0
- data/ext/lzo1b_d.ch +282 -0
- data/ext/lzo1b_d1.c +46 -0
- data/ext/lzo1b_d2.c +46 -0
- data/ext/lzo1b_de.h +344 -0
- data/ext/lzo1b_r.ch +117 -0
- data/ext/lzo1b_rr.c +43 -0
- data/ext/lzo1b_sm.ch +210 -0
- data/ext/lzo1b_tm.ch +99 -0
- data/ext/lzo1b_xx.c +98 -0
- data/ext/lzo1c_1.c +46 -0
- data/ext/lzo1c_2.c +46 -0
- data/ext/lzo1c_3.c +46 -0
- data/ext/lzo1c_4.c +46 -0
- data/ext/lzo1c_5.c +46 -0
- data/ext/lzo1c_6.c +46 -0
- data/ext/lzo1c_7.c +46 -0
- data/ext/lzo1c_8.c +46 -0
- data/ext/lzo1c_9.c +46 -0
- data/ext/lzo1c_99.c +49 -0
- data/ext/lzo1c_9x.c +379 -0
- data/ext/lzo1c_cc.c +167 -0
- data/ext/lzo1c_cc.h +93 -0
- data/ext/lzo1c_d1.c +46 -0
- data/ext/lzo1c_d2.c +46 -0
- data/ext/lzo1c_rr.c +43 -0
- data/ext/lzo1c_xx.c +98 -0
- data/ext/lzo1f_1.c +312 -0
- data/ext/lzo1f_9x.c +345 -0
- data/ext/lzo1f_d.ch +223 -0
- data/ext/lzo1f_d1.c +46 -0
- data/ext/lzo1f_d2.c +46 -0
- data/ext/lzo1x_1.c +50 -0
- data/ext/lzo1x_1k.c +50 -0
- data/ext/lzo1x_1l.c +50 -0
- data/ext/lzo1x_1o.c +50 -0
- data/ext/lzo1x_9x.c +881 -0
- data/ext/lzo1x_c.ch +351 -0
- data/ext/lzo1x_d.ch +466 -0
- data/ext/lzo1x_d1.c +46 -0
- data/ext/lzo1x_d2.c +46 -0
- data/ext/lzo1x_d3.c +108 -0
- data/ext/lzo1x_o.c +45 -0
- data/ext/lzo1x_oo.ch +366 -0
- data/ext/lzo1y_1.c +50 -0
- data/ext/lzo1y_9x.c +42 -0
- data/ext/lzo1y_d1.c +46 -0
- data/ext/lzo1y_d2.c +46 -0
- data/ext/lzo1y_d3.c +45 -0
- data/ext/lzo1y_o.c +45 -0
- data/ext/lzo1z_9x.c +42 -0
- data/ext/lzo1z_d1.c +46 -0
- data/ext/lzo1z_d2.c +46 -0
- data/ext/lzo1z_d3.c +45 -0
- data/ext/lzo2a_9x.c +357 -0
- data/ext/lzo2a_d.ch +188 -0
- data/ext/lzo2a_d1.c +46 -0
- data/ext/lzo2a_d2.c +46 -0
- data/ext/lzo_conf.h +323 -0
- data/ext/lzo_crc.c +167 -0
- data/ext/lzo_dict.h +316 -0
- data/ext/lzo_dll.ch +64 -0
- data/ext/lzo_init.c +176 -0
- data/ext/lzo_mchw.ch +242 -0
- data/ext/lzo_ptr.c +92 -0
- data/ext/lzo_ptr.h +154 -0
- data/ext/lzo_str.c +71 -0
- data/ext/lzo_swd.ch +707 -0
- data/ext/lzo_util.c +165 -0
- data/ext/lzoruby.c +149 -0
- data/ext/miniacc.h +6553 -0
- data/ext/stats1a.h +137 -0
- data/ext/stats1b.h +142 -0
- data/ext/stats1c.h +61 -0
- metadata +180 -0
data/ext/lzo1b_de.h
ADDED
@@ -0,0 +1,344 @@
|
|
1
|
+
/* lzo1b_de.h -- definitions for the the LZO1B/LZO1C 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 library 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
|
+
76543210
|
63
|
+
--------
|
64
|
+
00000000 R0 - a long literal run ('R0' run)
|
65
|
+
000rrrrr R - a short literal run with len r
|
66
|
+
00100000 M4 - a very long match
|
67
|
+
001mmmmm M3 - a long match (len = m+M3_MIN_LEN)
|
68
|
+
mmmooooo M2 - a short match (len = m+M2_MIN_LEN, o = offset low bits)
|
69
|
+
|
70
|
+
M1 is not used !
|
71
|
+
*/
|
72
|
+
|
73
|
+
|
74
|
+
#ifndef R_BITS
|
75
|
+
#define R_BITS (5)
|
76
|
+
#endif
|
77
|
+
|
78
|
+
|
79
|
+
#ifndef M1L_BITS
|
80
|
+
#define M1L_BITS (0)
|
81
|
+
#endif
|
82
|
+
#ifndef M2L_BITS
|
83
|
+
#define M2L_BITS (CHAR_BIT - M2O_BITS)
|
84
|
+
#endif
|
85
|
+
#ifndef M3L_BITS
|
86
|
+
#define M3L_BITS (R_BITS)
|
87
|
+
#endif
|
88
|
+
#ifndef M4L_BITS
|
89
|
+
#define M4L_BITS (CHAR_BIT)
|
90
|
+
#endif
|
91
|
+
|
92
|
+
#ifndef M1O_BITS
|
93
|
+
#define M1O_BITS (6)
|
94
|
+
#endif
|
95
|
+
#ifndef M2O_BITS
|
96
|
+
#define M2O_BITS (R_BITS)
|
97
|
+
#endif
|
98
|
+
#ifndef M3O_BITS
|
99
|
+
#define M3O_BITS (CHAR_BIT)
|
100
|
+
#endif
|
101
|
+
#ifndef M4O_BITS
|
102
|
+
#define M4O_BITS (M3O_BITS) /* must be the same */
|
103
|
+
#endif
|
104
|
+
|
105
|
+
#ifndef M1X_BITS
|
106
|
+
#define M1X_BITS (M1O_BITS)
|
107
|
+
#endif
|
108
|
+
#ifndef M2X_BITS
|
109
|
+
#define M2X_BITS (M2O_BITS + CHAR_BIT)
|
110
|
+
#endif
|
111
|
+
#ifndef M3X_BITS
|
112
|
+
#define M3X_BITS (M3O_BITS + CHAR_BIT)
|
113
|
+
#endif
|
114
|
+
#ifndef M4X_BITS
|
115
|
+
#define M4X_BITS M3X_BITS
|
116
|
+
#endif
|
117
|
+
|
118
|
+
|
119
|
+
#define __MIN_OFFSET(bits) 1
|
120
|
+
#define __MAX_OFFSET(bits) LZO_LSIZE(bits)
|
121
|
+
|
122
|
+
#define M1_MIN_OFFSET __MIN_OFFSET(M1X_BITS)
|
123
|
+
#define M2_MIN_OFFSET __MIN_OFFSET(M2X_BITS)
|
124
|
+
#define M3_MIN_OFFSET __MIN_OFFSET(M3X_BITS)
|
125
|
+
#define M4_MIN_OFFSET M3_MIN_OFFSET
|
126
|
+
|
127
|
+
#if defined(LZO_EOF_CODE) && !defined(M3_EOF_OFFSET)
|
128
|
+
#define M3_EOF_OFFSET 1
|
129
|
+
#else
|
130
|
+
#define M3_EOF_OFFSET 0
|
131
|
+
#endif
|
132
|
+
|
133
|
+
#ifndef _M1_MAX_OFFSET
|
134
|
+
#define _M1_MAX_OFFSET __MAX_OFFSET(M1X_BITS)
|
135
|
+
#endif
|
136
|
+
#ifndef _M2_MAX_OFFSET
|
137
|
+
#define _M2_MAX_OFFSET __MAX_OFFSET(M2X_BITS)
|
138
|
+
#endif
|
139
|
+
#ifndef _M3_MAX_OFFSET
|
140
|
+
#define _M3_MAX_OFFSET (__MAX_OFFSET(M3X_BITS) - M3_EOF_OFFSET)
|
141
|
+
#endif
|
142
|
+
#ifndef _M4_MAX_OFFSET
|
143
|
+
#define _M4_MAX_OFFSET _M3_MAX_OFFSET
|
144
|
+
#endif
|
145
|
+
#ifndef _MAX_OFFSET
|
146
|
+
#define _MAX_OFFSET _M4_MAX_OFFSET
|
147
|
+
#endif
|
148
|
+
|
149
|
+
#if (M3_EOF_OFFSET > 0) && (_M2_MAX_OFFSET == _M3_MAX_OFFSET + M3_EOF_OFFSET)
|
150
|
+
# undef _M2_MAX_OFFSET
|
151
|
+
# define _M2_MAX_OFFSET _M3_MAX_OFFSET
|
152
|
+
#endif
|
153
|
+
#if (_M2_MAX_OFFSET > _M3_MAX_OFFSET)
|
154
|
+
# error
|
155
|
+
#endif
|
156
|
+
|
157
|
+
#define M1_MAX_OFFSET ((lzo_uint) _M1_MAX_OFFSET)
|
158
|
+
#define M2_MAX_OFFSET ((lzo_uint) _M2_MAX_OFFSET)
|
159
|
+
#define M3_MAX_OFFSET ((lzo_uint) _M3_MAX_OFFSET)
|
160
|
+
#define M4_MAX_OFFSET ((lzo_uint) _M4_MAX_OFFSET)
|
161
|
+
#define MAX_OFFSET ((lzo_uint) _MAX_OFFSET)
|
162
|
+
|
163
|
+
|
164
|
+
#ifndef M1_MIN_LEN
|
165
|
+
#define M1_MIN_LEN (2)
|
166
|
+
#endif
|
167
|
+
#ifndef M2_MIN_LEN
|
168
|
+
#define M2_MIN_LEN (3)
|
169
|
+
#endif
|
170
|
+
#ifndef M3_MIN_LEN
|
171
|
+
#if (M3X_BITS == M2X_BITS)
|
172
|
+
#define M3_MIN_LEN (M2_MAX_LEN + 1)
|
173
|
+
#else
|
174
|
+
#define M3_MIN_LEN (4)
|
175
|
+
#endif
|
176
|
+
#endif
|
177
|
+
#ifndef M4_MIN_LEN
|
178
|
+
#define M4_MIN_LEN (M3_MAX_LEN + 1)
|
179
|
+
#endif
|
180
|
+
|
181
|
+
#ifndef M1_MAX_LEN
|
182
|
+
#define M1_MAX_LEN (M1_MIN_LEN + LZO_SIZE(M1L_BITS) - 1)
|
183
|
+
#endif
|
184
|
+
#ifndef M2_MAX_LEN
|
185
|
+
#define M2_MAX_LEN (M2_MIN_LEN + LZO_SIZE(M2L_BITS) - 3)
|
186
|
+
#endif
|
187
|
+
#ifndef M3_MAX_LEN
|
188
|
+
#define M3_MAX_LEN (M3_MIN_LEN + LZO_SIZE(M3L_BITS) - 2)
|
189
|
+
#endif
|
190
|
+
#ifndef M4_MAX_LEN
|
191
|
+
#define M4_MAX_LEN (ULONG_MAX)
|
192
|
+
#endif
|
193
|
+
|
194
|
+
|
195
|
+
#define M1O_MASK LZO_MASK(M1O_BITS)
|
196
|
+
#define M1L_MASK LZO_MASK(M1L_BITS)
|
197
|
+
#define M2O_MASK LZO_MASK(M2O_BITS)
|
198
|
+
#define M2L_MASK LZO_MASK(M2L_BITS)
|
199
|
+
#define M3O_MASK LZO_MASK(M3O_BITS)
|
200
|
+
#define M3L_MASK LZO_MASK(M3L_BITS)
|
201
|
+
#define M4O_MASK LZO_MASK(M4O_BITS)
|
202
|
+
#define M4L_MASK LZO_MASK(M4L_BITS)
|
203
|
+
|
204
|
+
|
205
|
+
#define M1_MARKER (1 << M1O_BITS)
|
206
|
+
#define M2_MARKER (2 << M2O_BITS)
|
207
|
+
#define M3_MARKER (1 << M3L_BITS)
|
208
|
+
#define M4_MARKER M3_MARKER
|
209
|
+
|
210
|
+
|
211
|
+
/***********************************************************************
|
212
|
+
// R0 literal run (a long run)
|
213
|
+
************************************************************************/
|
214
|
+
|
215
|
+
#ifndef R0MIN
|
216
|
+
#define R0MIN (LZO_SIZE(R_BITS)) /* Minimum len of R0 run of literals */
|
217
|
+
#endif
|
218
|
+
#define R0MAX (R0MIN + 256 - 1) /* Maximum len of R0 run of literals */
|
219
|
+
|
220
|
+
#if (R0MAX - (R0MAX & ~7u) >= 7)
|
221
|
+
#define R0FAST (R0MAX & ~7u) /* R0MAX aligned to 8 byte boundary */
|
222
|
+
#else
|
223
|
+
#define R0FAST (R0MAX & ~15u) /* R0MAX aligned to 8 byte boundary */
|
224
|
+
#endif
|
225
|
+
|
226
|
+
#if (R0MAX - R0FAST < 7) || ((R0FAST & 7) != 0)
|
227
|
+
# error "something went wrong"
|
228
|
+
#endif
|
229
|
+
#if (R0FAST * 2 < 512)
|
230
|
+
# error "R0FAST is not big enough"
|
231
|
+
#endif
|
232
|
+
|
233
|
+
/* 7 special codes from R0FAST+1 .. R0MAX
|
234
|
+
* these codes mean long R0 runs with lengths
|
235
|
+
* 512, 1024, 2048, 4096, 8192, 16384, 32768
|
236
|
+
*/
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
/***********************************************************************
|
241
|
+
// matching
|
242
|
+
************************************************************************/
|
243
|
+
|
244
|
+
#define PS *m_pos++ != *ip++
|
245
|
+
|
246
|
+
|
247
|
+
/* We already matched M2_MIN_LEN bytes.
|
248
|
+
* Try to match another M2_MAX_LEN - M2_MIN_LEN bytes. */
|
249
|
+
|
250
|
+
#if (M2_MAX_LEN - M2_MIN_LEN == 4)
|
251
|
+
# define MATCH_M2X (PS || PS || PS || PS)
|
252
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 5)
|
253
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS)
|
254
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 6)
|
255
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS || PS)
|
256
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 7)
|
257
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS || PS || PS)
|
258
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 13)
|
259
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS || PS || PS || PS || \
|
260
|
+
PS || PS || PS || PS || PS)
|
261
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 14)
|
262
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS || PS || PS || PS || \
|
263
|
+
PS || PS || PS || PS || PS || PS)
|
264
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 16)
|
265
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS || PS || PS || PS || \
|
266
|
+
PS || PS || PS || PS || PS || PS || PS || PS)
|
267
|
+
#elif (M2_MAX_LEN - M2_MIN_LEN == 29)
|
268
|
+
# define MATCH_M2X (PS || PS || PS || PS || PS || PS || PS || PS || \
|
269
|
+
PS || PS || PS || PS || PS || PS || PS || PS || \
|
270
|
+
PS || PS || PS || PS || PS || PS || PS || PS || \
|
271
|
+
PS || PS || PS || PS || PS)
|
272
|
+
#else
|
273
|
+
# error "MATCH_M2X not yet implemented"
|
274
|
+
#endif
|
275
|
+
|
276
|
+
|
277
|
+
/* We already matched M2_MIN_LEN bytes.
|
278
|
+
* Try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes
|
279
|
+
* to see if we get more than a M2 match */
|
280
|
+
|
281
|
+
#define MATCH_M2 (MATCH_M2X || PS)
|
282
|
+
|
283
|
+
|
284
|
+
/***********************************************************************
|
285
|
+
// copying
|
286
|
+
************************************************************************/
|
287
|
+
|
288
|
+
#define _CP *op++ = *m_pos++
|
289
|
+
|
290
|
+
#if (M2_MIN_LEN == 2)
|
291
|
+
# define COPY_M2X _CP
|
292
|
+
#elif (M2_MIN_LEN == 3)
|
293
|
+
# define COPY_M2X _CP; _CP
|
294
|
+
#elif (M2_MIN_LEN == 4)
|
295
|
+
# define COPY_M2X _CP; _CP; _CP
|
296
|
+
#else
|
297
|
+
# error "COPY_M2X not yet implemented"
|
298
|
+
#endif
|
299
|
+
|
300
|
+
#if (M3_MIN_LEN == 3)
|
301
|
+
# define COPY_M3X _CP; _CP
|
302
|
+
#elif (M3_MIN_LEN == 4)
|
303
|
+
# define COPY_M3X _CP; _CP; _CP
|
304
|
+
#elif (M3_MIN_LEN == 9)
|
305
|
+
# define COPY_M3X _CP; _CP; _CP; _CP; _CP; _CP; _CP; _CP
|
306
|
+
#else
|
307
|
+
# error "COPY_M3X not yet implemented"
|
308
|
+
#endif
|
309
|
+
|
310
|
+
#define COPY_M2 COPY_M2X; *op++ = *m_pos++
|
311
|
+
#define COPY_M3 COPY_M3X; *op++ = *m_pos++
|
312
|
+
|
313
|
+
|
314
|
+
/***********************************************************************
|
315
|
+
//
|
316
|
+
************************************************************************/
|
317
|
+
|
318
|
+
#if defined(LZO_NEED_DICT_H)
|
319
|
+
|
320
|
+
#define DL_MIN_LEN M2_MIN_LEN
|
321
|
+
#define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
|
322
|
+
#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
|
323
|
+
#include "lzo_dict.h"
|
324
|
+
|
325
|
+
#ifndef MIN_LOOKAHEAD
|
326
|
+
#define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
|
327
|
+
#endif
|
328
|
+
#ifndef MAX_LOOKBEHIND
|
329
|
+
#define MAX_LOOKBEHIND (MAX_OFFSET)
|
330
|
+
#endif
|
331
|
+
|
332
|
+
#endif /* defined(LZO_NEED_DICT_H) */
|
333
|
+
|
334
|
+
|
335
|
+
#ifdef __cplusplus
|
336
|
+
} /* extern "C" */
|
337
|
+
#endif
|
338
|
+
|
339
|
+
#endif /* already included */
|
340
|
+
|
341
|
+
/*
|
342
|
+
vi:ts=4:et
|
343
|
+
*/
|
344
|
+
|
data/ext/lzo1b_r.ch
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
/* lzo1b_r.ch -- literal run handling for the the LZO1B/LZO1C 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
|
+
/***********************************************************************
|
42
|
+
// store a literal run (internal)
|
43
|
+
************************************************************************/
|
44
|
+
|
45
|
+
LZO_PUBLIC(lzo_bytep )
|
46
|
+
STORE_RUN ( lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
|
47
|
+
{
|
48
|
+
register lzo_bytep op;
|
49
|
+
register const lzo_bytep ip;
|
50
|
+
register lzo_uint t;
|
51
|
+
|
52
|
+
LZO_STATS(lzo_stats->literals += r_len);
|
53
|
+
|
54
|
+
op = oo;
|
55
|
+
ip = ii;
|
56
|
+
assert(r_len > 0);
|
57
|
+
|
58
|
+
/* code a long R0 run */
|
59
|
+
if (r_len >= 512)
|
60
|
+
{
|
61
|
+
unsigned r_bits = 6; /* 256 << 6 == 16384 */
|
62
|
+
lzo_uint tt = 32768u;
|
63
|
+
|
64
|
+
while (r_len >= (t = tt))
|
65
|
+
{
|
66
|
+
r_len -= t;
|
67
|
+
*op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
|
68
|
+
MEMCPY8_DS(op, ip, t);
|
69
|
+
LZO_STATS(lzo_stats->r0long_runs++);
|
70
|
+
}
|
71
|
+
tt >>= 1;
|
72
|
+
do {
|
73
|
+
if (r_len >= (t = tt))
|
74
|
+
{
|
75
|
+
r_len -= t;
|
76
|
+
*op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
|
77
|
+
MEMCPY8_DS(op, ip, t);
|
78
|
+
LZO_STATS(lzo_stats->r0long_runs++);
|
79
|
+
}
|
80
|
+
tt >>= 1;
|
81
|
+
} while (--r_bits > 0);
|
82
|
+
}
|
83
|
+
assert(r_len < 512);
|
84
|
+
|
85
|
+
while (r_len >= (t = R0FAST))
|
86
|
+
{
|
87
|
+
r_len -= t;
|
88
|
+
*op++ = 0; *op++ = (R0FAST - R0MIN);
|
89
|
+
MEMCPY8_DS(op, ip, t);
|
90
|
+
LZO_STATS(lzo_stats->r0fast_runs++);
|
91
|
+
}
|
92
|
+
|
93
|
+
t = r_len;
|
94
|
+
if (t >= R0MIN)
|
95
|
+
{
|
96
|
+
/* code a short R0 run */
|
97
|
+
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
|
98
|
+
MEMCPY_DS(op, ip, t);
|
99
|
+
LZO_STATS(lzo_stats->r0short_runs++);
|
100
|
+
}
|
101
|
+
else if (t > 0)
|
102
|
+
{
|
103
|
+
/* code a short literal run */
|
104
|
+
LZO_STATS(lzo_stats->lit_runs++);
|
105
|
+
LZO_STATS(lzo_stats->lit_run[t]++);
|
106
|
+
*op++ = LZO_BYTE(t);
|
107
|
+
MEMCPY_DS(op, ip, t);
|
108
|
+
}
|
109
|
+
|
110
|
+
return op;
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
/*
|
115
|
+
vi:ts=4:et
|
116
|
+
*/
|
117
|
+
|
data/ext/lzo1b_rr.c
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
/* lzo1b_rr.c -- literal run handling
|
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
|
+
#include "config1b.h"
|
42
|
+
|
43
|
+
#include "lzo1b_r.ch"
|
data/ext/lzo1b_sm.ch
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
/* lzo1b_sm.ch -- implementation of the LZO1B compression 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 library and is subject
|
43
|
+
to change.
|
44
|
+
*/
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
/***********************************************************************
|
49
|
+
// search for a match
|
50
|
+
************************************************************************/
|
51
|
+
|
52
|
+
#if (DD_BITS == 0)
|
53
|
+
|
54
|
+
/* search ip in the dictionary */
|
55
|
+
DINDEX1(dindex,ip);
|
56
|
+
GINDEX(m_pos,m_off,dict,dindex,in);
|
57
|
+
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M3_MAX_OFFSET))
|
58
|
+
goto literal;
|
59
|
+
#if 1
|
60
|
+
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
|
61
|
+
goto try_match;
|
62
|
+
DINDEX2(dindex,ip);
|
63
|
+
#endif
|
64
|
+
GINDEX(m_pos,m_off,dict,dindex,in);
|
65
|
+
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M3_MAX_OFFSET))
|
66
|
+
goto literal;
|
67
|
+
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
|
68
|
+
goto try_match;
|
69
|
+
goto literal;
|
70
|
+
|
71
|
+
|
72
|
+
#else /* (DD_BITS == 0) */
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
/* search ip in the deepened dictionary */
|
77
|
+
{
|
78
|
+
lzo_dict_p d = &dict [ DINDEX(dv,ip) ];
|
79
|
+
const lzo_bytep ip_sav;
|
80
|
+
unsigned j = DD_SIZE;
|
81
|
+
lzo_uint x_len;
|
82
|
+
lzo_uint x_off;
|
83
|
+
|
84
|
+
DVAL_ASSERT(dv,ip);
|
85
|
+
|
86
|
+
ip_sav = ip;
|
87
|
+
m_len = 0;
|
88
|
+
do {
|
89
|
+
#if !defined(NDEBUG)
|
90
|
+
const lzo_bytep z_pos = NULL;
|
91
|
+
#endif
|
92
|
+
#if defined(LZO_DICT_USE_PTR)
|
93
|
+
m_pos = *d;
|
94
|
+
assert((z_pos = m_pos) == *d);
|
95
|
+
#if defined(LZO_DETERMINISTIC)
|
96
|
+
assert(m_pos == NULL || m_pos >= in);
|
97
|
+
assert(m_pos == NULL || m_pos < ip);
|
98
|
+
#endif
|
99
|
+
#else
|
100
|
+
x_off = *d;
|
101
|
+
#endif
|
102
|
+
assert(ip == ip_sav);
|
103
|
+
|
104
|
+
if (LZO_CHECK_MPOS(m_pos,x_off,in,ip,MAX_OFFSET))
|
105
|
+
#if (CLEVEL == 9)
|
106
|
+
*d = DENTRY(ip,in);
|
107
|
+
#else
|
108
|
+
((void)(0));
|
109
|
+
#endif
|
110
|
+
else if (m_pos[m_len] != ip[m_len])
|
111
|
+
((void)(0));
|
112
|
+
else if (*m_pos++ == *ip++ && *m_pos++ == *ip++ && *m_pos++ == *ip++)
|
113
|
+
{
|
114
|
+
#if !defined(LZO_DICT_USE_PTR)
|
115
|
+
assert((z_pos = ip - 3 - x_off) == (m_pos - 3));
|
116
|
+
#endif
|
117
|
+
/* a match */
|
118
|
+
if (MATCH_M2)
|
119
|
+
{
|
120
|
+
x_len = pd((ip - 1), ip_sav);
|
121
|
+
if (x_len > m_len)
|
122
|
+
{
|
123
|
+
m_len = x_len;
|
124
|
+
m_off = x_off;
|
125
|
+
assert((m_pos_sav = z_pos) != NULL);
|
126
|
+
}
|
127
|
+
#if (CLEVEL == 9)
|
128
|
+
/* try to find a closer match */
|
129
|
+
else if (x_len == m_len && x_off < m_off)
|
130
|
+
{
|
131
|
+
m_off = x_off;
|
132
|
+
assert((m_pos_sav = z_pos) != NULL);
|
133
|
+
}
|
134
|
+
#endif
|
135
|
+
}
|
136
|
+
else
|
137
|
+
{
|
138
|
+
assert((ip - ip_sav) == M2_MAX_LEN + 1);
|
139
|
+
#if (CLEVEL == 9)
|
140
|
+
#if defined(MATCH_IP_END)
|
141
|
+
{
|
142
|
+
const lzo_bytep end;
|
143
|
+
end = MATCH_IP_END;
|
144
|
+
while (ip < end && *m_pos == *ip)
|
145
|
+
m_pos++, ip++;
|
146
|
+
assert(ip <= in_end);
|
147
|
+
x_len = pd(ip, ip_sav);
|
148
|
+
}
|
149
|
+
if (x_len > m_len)
|
150
|
+
{
|
151
|
+
m_len = x_len;
|
152
|
+
m_off = x_off;
|
153
|
+
assert((m_pos_sav = z_pos) != NULL);
|
154
|
+
if (ip >= MATCH_IP_END)
|
155
|
+
{
|
156
|
+
ip = ip_sav;
|
157
|
+
#if 0
|
158
|
+
/* not needed - we are at the end */
|
159
|
+
d -= DD_SIZE - j;
|
160
|
+
assert(d == &dict [ DINDEX(dv,ip) ]);
|
161
|
+
UPDATE_P(d,drun,ip,in);
|
162
|
+
#endif
|
163
|
+
goto match;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
else if (x_len == m_len && x_off < m_off)
|
167
|
+
{
|
168
|
+
m_off = x_off;
|
169
|
+
assert((m_pos_sav = z_pos) != NULL);
|
170
|
+
}
|
171
|
+
#else
|
172
|
+
/* try to find a closer match */
|
173
|
+
if (m_len < M2_MAX_LEN + 1 || x_off < m_off)
|
174
|
+
{
|
175
|
+
m_len = M2_MAX_LEN + 1;
|
176
|
+
m_off = x_off;
|
177
|
+
assert((m_pos_sav = z_pos) != NULL);
|
178
|
+
}
|
179
|
+
#endif
|
180
|
+
#else
|
181
|
+
/* don't search for a longer/closer match */
|
182
|
+
m_len = M2_MAX_LEN + 1;
|
183
|
+
m_off = x_off;
|
184
|
+
assert((m_pos_sav = z_pos) != NULL);
|
185
|
+
ip = ip_sav;
|
186
|
+
d -= DD_SIZE - j;
|
187
|
+
assert(d == &dict [ DINDEX(dv,ip) ]);
|
188
|
+
UPDATE_P(d,drun,ip,in);
|
189
|
+
goto match;
|
190
|
+
#endif
|
191
|
+
}
|
192
|
+
ip = ip_sav;
|
193
|
+
}
|
194
|
+
else
|
195
|
+
ip = ip_sav;
|
196
|
+
d++;
|
197
|
+
} while (--j > 0);
|
198
|
+
assert(ip == ip_sav);
|
199
|
+
|
200
|
+
d -= DD_SIZE;
|
201
|
+
assert(d == &dict [ DINDEX(dv,ip) ]);
|
202
|
+
UPDATE_P(d,drun,ip,in);
|
203
|
+
}
|
204
|
+
|
205
|
+
#endif /* (DD_BITS == 0) */
|
206
|
+
|
207
|
+
|
208
|
+
/*
|
209
|
+
vi:ts=4:et
|
210
|
+
*/
|