lzoruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/lzo1c_9x.c
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/* lzo1c_9x.c -- implementation of the LZO1C-999 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
|
+
#include "config1c.h"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/***********************************************************************
|
|
45
|
+
//
|
|
46
|
+
************************************************************************/
|
|
47
|
+
|
|
48
|
+
#define N 16383 /* size of ring buffer */
|
|
49
|
+
#define THRESHOLD 2 /* lower limit for match length */
|
|
50
|
+
#define F 2048 /* upper limit for match length */
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
#define LZO1C
|
|
54
|
+
#define LZO_COMPRESS_T lzo1c_999_t
|
|
55
|
+
#define lzo_swd_t lzo1c_999_swd_t
|
|
56
|
+
#include "lzo_mchw.ch"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/***********************************************************************
|
|
61
|
+
//
|
|
62
|
+
************************************************************************/
|
|
63
|
+
|
|
64
|
+
static lzo_bytep
|
|
65
|
+
code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
|
|
66
|
+
{
|
|
67
|
+
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
|
|
68
|
+
{
|
|
69
|
+
assert(m_len >= M2_MIN_LEN);
|
|
70
|
+
assert(m_off >= M2_MIN_OFFSET);
|
|
71
|
+
|
|
72
|
+
m_off -= M2_MIN_OFFSET;
|
|
73
|
+
/* code match len + low offset bits */
|
|
74
|
+
*op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) |
|
|
75
|
+
(m_off & M2O_MASK));
|
|
76
|
+
/* code high offset bits */
|
|
77
|
+
*op++ = LZO_BYTE(m_off >> M2O_BITS);
|
|
78
|
+
c->m2_m++;
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
{
|
|
82
|
+
assert(m_len >= M3_MIN_LEN);
|
|
83
|
+
assert(m_off <= M3_MAX_OFFSET);
|
|
84
|
+
|
|
85
|
+
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
|
|
86
|
+
/* code match len */
|
|
87
|
+
if (m_len <= M3_MAX_LEN)
|
|
88
|
+
*op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
|
|
89
|
+
else
|
|
90
|
+
{
|
|
91
|
+
assert(m_len >= M4_MIN_LEN);
|
|
92
|
+
/* code M4 match len flag */
|
|
93
|
+
*op++ = M4_MARKER;
|
|
94
|
+
/* code match len */
|
|
95
|
+
m_len -= M4_MIN_LEN - 1;
|
|
96
|
+
while (m_len > 255)
|
|
97
|
+
{
|
|
98
|
+
m_len -= 255;
|
|
99
|
+
*op++ = 0;
|
|
100
|
+
}
|
|
101
|
+
assert(m_len > 0);
|
|
102
|
+
*op++ = LZO_BYTE(m_len);
|
|
103
|
+
}
|
|
104
|
+
/* code low offset bits */
|
|
105
|
+
*op++ = LZO_BYTE(m_off & M3O_MASK);
|
|
106
|
+
/* code high offset bits */
|
|
107
|
+
*op++ = LZO_BYTE(m_off >> M3O_BITS);
|
|
108
|
+
|
|
109
|
+
c->r1_m_len = 0;
|
|
110
|
+
c->m3 = op;
|
|
111
|
+
c->m3_m++;
|
|
112
|
+
}
|
|
113
|
+
return op;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
/***********************************************************************
|
|
118
|
+
// this is a public function, but there is no prototype in a header file
|
|
119
|
+
************************************************************************/
|
|
120
|
+
|
|
121
|
+
LZO_EXTERN(int)
|
|
122
|
+
lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
|
|
123
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
124
|
+
lzo_voidp wrkmem,
|
|
125
|
+
lzo_callback_p cb,
|
|
126
|
+
lzo_uint max_chain );
|
|
127
|
+
|
|
128
|
+
LZO_PUBLIC(int)
|
|
129
|
+
lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
|
|
130
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
131
|
+
lzo_voidp wrkmem,
|
|
132
|
+
lzo_callback_p cb,
|
|
133
|
+
lzo_uint max_chain )
|
|
134
|
+
{
|
|
135
|
+
lzo_bytep op;
|
|
136
|
+
const lzo_bytep ii;
|
|
137
|
+
lzo_uint lit;
|
|
138
|
+
lzo_uint m_len, m_off;
|
|
139
|
+
LZO_COMPRESS_T cc;
|
|
140
|
+
LZO_COMPRESS_T * const c = &cc;
|
|
141
|
+
lzo_swd_p const swd = (lzo_swd_p) wrkmem;
|
|
142
|
+
int r;
|
|
143
|
+
|
|
144
|
+
/* sanity check */
|
|
145
|
+
LZO_COMPILE_TIME_ASSERT(LZO1C_999_MEM_COMPRESS >= SIZEOF_LZO_SWD_T)
|
|
146
|
+
|
|
147
|
+
c->init = 0;
|
|
148
|
+
c->ip = c->in = in;
|
|
149
|
+
c->in_end = in + in_len;
|
|
150
|
+
c->cb = cb;
|
|
151
|
+
c->r1_r = c->m3_r = c->m2_m = c->m3_m = 0;
|
|
152
|
+
|
|
153
|
+
op = out;
|
|
154
|
+
ii = c->ip; /* point to start of literal run */
|
|
155
|
+
lit = 0;
|
|
156
|
+
c->r1_m_len = 0;
|
|
157
|
+
c->m3 = out + 1; /* pointer after last m3/m4 match */
|
|
158
|
+
|
|
159
|
+
r = init_match(c,swd,NULL,0,0);
|
|
160
|
+
if (r != 0)
|
|
161
|
+
return r;
|
|
162
|
+
if (max_chain > 0)
|
|
163
|
+
swd->max_chain = max_chain;
|
|
164
|
+
|
|
165
|
+
r = find_match(c,swd,0,0);
|
|
166
|
+
if (r != 0)
|
|
167
|
+
return r;
|
|
168
|
+
while (c->look > 0)
|
|
169
|
+
{
|
|
170
|
+
int lazy_match_min_gain = -1;
|
|
171
|
+
lzo_uint ahead = 0;
|
|
172
|
+
|
|
173
|
+
m_len = c->m_len;
|
|
174
|
+
m_off = c->m_off;
|
|
175
|
+
|
|
176
|
+
#if 0
|
|
177
|
+
printf("%5ld: %5d len:%3d off:%5d\n", (c->ip-c->look)-in, c->look,
|
|
178
|
+
m_len, m_off);
|
|
179
|
+
#endif
|
|
180
|
+
|
|
181
|
+
assert(c->ip - c->look >= in);
|
|
182
|
+
if (lit == 0)
|
|
183
|
+
ii = c->ip - c->look;
|
|
184
|
+
assert(ii + lit == c->ip - c->look);
|
|
185
|
+
assert(swd->b_char == *(c->ip - c->look));
|
|
186
|
+
|
|
187
|
+
if ((m_len < M2_MIN_LEN) ||
|
|
188
|
+
(m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET))
|
|
189
|
+
{
|
|
190
|
+
m_len = 0;
|
|
191
|
+
}
|
|
192
|
+
else
|
|
193
|
+
{
|
|
194
|
+
assert(c->ip - c->look - m_off >= in);
|
|
195
|
+
assert(c->ip - c->look - m_off + m_len < c->ip);
|
|
196
|
+
assert(lzo_memcmp(c->ip - c->look, c->ip - c->look - m_off,
|
|
197
|
+
m_len) == 0);
|
|
198
|
+
|
|
199
|
+
if (lit > 0)
|
|
200
|
+
{
|
|
201
|
+
/* we have a current literal run: do not try a lazy match,
|
|
202
|
+
if the literal could be coded into a r1 or m3 match */
|
|
203
|
+
if (lit == 1 && c->r1_m_len == M2_MIN_LEN)
|
|
204
|
+
lazy_match_min_gain = -1;
|
|
205
|
+
else if (lit == 3 && op == c->m3)
|
|
206
|
+
lazy_match_min_gain = -1;
|
|
207
|
+
else if (lit < 3 && op == c->m3)
|
|
208
|
+
lazy_match_min_gain = 0;
|
|
209
|
+
else
|
|
210
|
+
lazy_match_min_gain = 1;
|
|
211
|
+
|
|
212
|
+
#if (M2_MIN_LEN == 2)
|
|
213
|
+
if (m_len == 2)
|
|
214
|
+
{
|
|
215
|
+
/* don't code a match of len 2 if we have to
|
|
216
|
+
code a literal run. Code a literal instead. */
|
|
217
|
+
m_len = 0;
|
|
218
|
+
}
|
|
219
|
+
#endif
|
|
220
|
+
#if (M2_MIN_LEN == M3_MIN_LEN)
|
|
221
|
+
if (m_len == M2_MIN_LEN && m_off > M2_MAX_OFFSET)
|
|
222
|
+
{
|
|
223
|
+
/* don't code a M3 match of len 3 if we have to
|
|
224
|
+
code a literal run. Code a literal instead. */
|
|
225
|
+
m_len = 0;
|
|
226
|
+
}
|
|
227
|
+
#endif
|
|
228
|
+
}
|
|
229
|
+
else
|
|
230
|
+
{
|
|
231
|
+
/* no current literal run: only try a lazy match,
|
|
232
|
+
if the literal could be coded into a r1 or m3 match */
|
|
233
|
+
if (c->r1_m_len == M2_MIN_LEN || op == c->m3)
|
|
234
|
+
lazy_match_min_gain = 0;
|
|
235
|
+
else
|
|
236
|
+
lazy_match_min_gain = -1;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
/* try a lazy match */
|
|
242
|
+
if (m_len == 0)
|
|
243
|
+
lazy_match_min_gain = -1;
|
|
244
|
+
if (lazy_match_min_gain >= 0 && c->look > m_len)
|
|
245
|
+
{
|
|
246
|
+
assert(m_len > 0);
|
|
247
|
+
|
|
248
|
+
r = find_match(c,swd,1,0);
|
|
249
|
+
assert(r == 0);
|
|
250
|
+
assert(c->look > 0);
|
|
251
|
+
|
|
252
|
+
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET &&
|
|
253
|
+
c->m_off > M2_MAX_OFFSET)
|
|
254
|
+
lazy_match_min_gain += 1;
|
|
255
|
+
|
|
256
|
+
if (c->m_len >= m_len + lazy_match_min_gain)
|
|
257
|
+
{
|
|
258
|
+
c->lazy++;
|
|
259
|
+
#if !defined(NDEBUG)
|
|
260
|
+
m_len = c->m_len;
|
|
261
|
+
m_off = c->m_off;
|
|
262
|
+
assert(lzo_memcmp(c->ip - c->look, c->ip - c->look - m_off,
|
|
263
|
+
m_len) == 0);
|
|
264
|
+
#endif
|
|
265
|
+
lit++;
|
|
266
|
+
assert(ii + lit == c->ip - c->look);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
else
|
|
270
|
+
{
|
|
271
|
+
ahead = 1;
|
|
272
|
+
assert(ii + lit + 1 == c->ip - c->look);
|
|
273
|
+
}
|
|
274
|
+
assert(m_len > 0);
|
|
275
|
+
}
|
|
276
|
+
assert(ii + lit + ahead == c->ip - c->look);
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
if (m_len == 0)
|
|
280
|
+
{
|
|
281
|
+
/* a literal */
|
|
282
|
+
lit++;
|
|
283
|
+
r = find_match(c,swd,1,0);
|
|
284
|
+
assert(r == 0);
|
|
285
|
+
}
|
|
286
|
+
else
|
|
287
|
+
{
|
|
288
|
+
/* 1 - store run */
|
|
289
|
+
if (lit > 0)
|
|
290
|
+
{
|
|
291
|
+
/* code current literal run */
|
|
292
|
+
if (lit == 1 && c->r1_m_len == M2_MIN_LEN)
|
|
293
|
+
{
|
|
294
|
+
/* Code a context sensitive R1 match. */
|
|
295
|
+
assert((op[-2] >> M2O_BITS) == (M2_MARKER >> M2O_BITS));
|
|
296
|
+
op[-2] &= M2O_MASK;
|
|
297
|
+
assert((op[-2] >> M2O_BITS) == 0);
|
|
298
|
+
/* copy 1 literal */
|
|
299
|
+
*op++ = *ii++;
|
|
300
|
+
assert(ii + ahead == c->ip - c->look);
|
|
301
|
+
c->r1_r++;
|
|
302
|
+
}
|
|
303
|
+
else if (lit < 4 && op == c->m3)
|
|
304
|
+
{
|
|
305
|
+
assert((c->m3[-2] >> M3O_BITS) == 0);
|
|
306
|
+
c->m3[-2] |= LZO_BYTE(lit << M3O_BITS);
|
|
307
|
+
MEMCPY_DS(op, ii, lit);
|
|
308
|
+
assert(ii + ahead == c->ip - c->look);
|
|
309
|
+
c->m3_r++;
|
|
310
|
+
}
|
|
311
|
+
else
|
|
312
|
+
{
|
|
313
|
+
op = STORE_RUN(op,ii,lit);
|
|
314
|
+
}
|
|
315
|
+
if (lit < R0FAST)
|
|
316
|
+
c->r1_m_len = m_len;
|
|
317
|
+
else
|
|
318
|
+
c->r1_m_len = 0;
|
|
319
|
+
lit = 0;
|
|
320
|
+
}
|
|
321
|
+
else
|
|
322
|
+
c->r1_m_len = 0;
|
|
323
|
+
|
|
324
|
+
/* 2 - code match */
|
|
325
|
+
op = code_match(c,op,m_len,m_off);
|
|
326
|
+
r = find_match(c,swd,m_len,1+ahead);
|
|
327
|
+
assert(r == 0);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
c->codesize = pd(op, out);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
/* store final run */
|
|
335
|
+
if (lit > 0)
|
|
336
|
+
op = STORE_RUN(op,ii,lit);
|
|
337
|
+
|
|
338
|
+
#if defined(LZO_EOF_CODE)
|
|
339
|
+
*op++ = M3_MARKER | 1;
|
|
340
|
+
*op++ = 0;
|
|
341
|
+
*op++ = 0;
|
|
342
|
+
#endif
|
|
343
|
+
|
|
344
|
+
c->codesize = pd(op, out);
|
|
345
|
+
assert(c->textsize == in_len);
|
|
346
|
+
|
|
347
|
+
*out_len = pd(op, out);
|
|
348
|
+
|
|
349
|
+
if (c->cb && c->cb->nprogress)
|
|
350
|
+
(*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
|
|
351
|
+
|
|
352
|
+
#if 0
|
|
353
|
+
printf("%ld %ld -> %ld: %ld %ld %ld %ld %ld\n",
|
|
354
|
+
(long) c->textsize, (long)in_len, (long) c->codesize,
|
|
355
|
+
c->r1_r, c->m3_r, c->m2_m, c->m3_m, c->lazy);
|
|
356
|
+
#endif
|
|
357
|
+
return LZO_E_OK;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
/***********************************************************************
|
|
363
|
+
//
|
|
364
|
+
************************************************************************/
|
|
365
|
+
|
|
366
|
+
LZO_PUBLIC(int)
|
|
367
|
+
lzo1c_999_compress ( const lzo_bytep in , lzo_uint in_len,
|
|
368
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
369
|
+
lzo_voidp wrkmem )
|
|
370
|
+
{
|
|
371
|
+
return lzo1c_999_compress_callback(in,in_len,out,out_len,wrkmem,
|
|
372
|
+
(lzo_callback_p) 0, 0);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
/*
|
|
377
|
+
vi:ts=4:et
|
|
378
|
+
*/
|
|
379
|
+
|
data/ext/lzo1c_cc.c
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* lzo1c_cc.c -- LZO1C compression internal entry point
|
|
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
|
+
#define LZO_NEED_DICT_H
|
|
42
|
+
#include "config1c.h"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/***********************************************************************
|
|
46
|
+
// compression internal entry point.
|
|
47
|
+
************************************************************************/
|
|
48
|
+
|
|
49
|
+
int _lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len,
|
|
50
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
51
|
+
lzo_voidp wrkmem,
|
|
52
|
+
lzo_compress_t func )
|
|
53
|
+
{
|
|
54
|
+
int r;
|
|
55
|
+
#if defined(LZO_TEST_COMPRESS_OVERRUN)
|
|
56
|
+
lzo_uint avail_out = *out_len;
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#if defined(LZO_COLLECT_STATS)
|
|
61
|
+
_lzo1c_stats_init(lzo_stats);
|
|
62
|
+
lzo_stats->in_len = in_len;
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/* don't try to compress a block that's too short */
|
|
67
|
+
if (in_len <= 0)
|
|
68
|
+
{
|
|
69
|
+
*out_len = 0;
|
|
70
|
+
r = LZO_E_OK;
|
|
71
|
+
}
|
|
72
|
+
else if (in_len <= MIN_LOOKAHEAD + 1)
|
|
73
|
+
{
|
|
74
|
+
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
|
|
75
|
+
*out_len = 0;
|
|
76
|
+
r = LZO_E_NOT_COMPRESSIBLE;
|
|
77
|
+
#else
|
|
78
|
+
*out_len = pd(STORE_RUN(out,in,in_len), out);
|
|
79
|
+
r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
|
|
80
|
+
#endif
|
|
81
|
+
}
|
|
82
|
+
else
|
|
83
|
+
r = func(in,in_len,out,out_len,wrkmem);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
#if defined(LZO_EOF_CODE)
|
|
87
|
+
#if defined(LZO_TEST_COMPRESS_OVERRUN)
|
|
88
|
+
if (r == LZO_E_OK && avail_out - *out_len < 3)
|
|
89
|
+
r = LZO_E_COMPRESS_OVERRUN;
|
|
90
|
+
#endif
|
|
91
|
+
if (r == LZO_E_OK)
|
|
92
|
+
{
|
|
93
|
+
lzo_bytep op = out + *out_len;
|
|
94
|
+
*op++ = M3_MARKER | 1;
|
|
95
|
+
*op++ = 0;
|
|
96
|
+
*op++ = 0;
|
|
97
|
+
*out_len += 3;
|
|
98
|
+
}
|
|
99
|
+
#endif
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
#if defined(LZO_COLLECT_STATS)
|
|
103
|
+
lzo_stats->out_len = *out_len;
|
|
104
|
+
lzo_stats->match_bytes =
|
|
105
|
+
1 * lzo_stats->m1_matches + 2 * lzo_stats->m2_matches +
|
|
106
|
+
3 * lzo_stats->m3_matches + 4 * lzo_stats->m4_matches;
|
|
107
|
+
_lzo1c_stats_calc(lzo_stats);
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
return r;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/***********************************************************************
|
|
115
|
+
// note: this is not thread safe, but as it is used for finetuning only
|
|
116
|
+
// we don't care
|
|
117
|
+
************************************************************************/
|
|
118
|
+
|
|
119
|
+
#undef lzo_stats
|
|
120
|
+
/* lzo_stats_t is still defined */
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
#if defined(LZO_COLLECT_STATS)
|
|
124
|
+
|
|
125
|
+
static lzo_stats_t lzo_statistics;
|
|
126
|
+
lzo_stats_t * const lzo1c_stats = &lzo_statistics;
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
void _lzo1c_stats_init(lzo_stats_t *lzo_stats)
|
|
130
|
+
{
|
|
131
|
+
lzo_memset(lzo_stats,0,sizeof(*lzo_stats));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
void _lzo1c_stats_calc(lzo_stats_t *lzo_stats)
|
|
136
|
+
{
|
|
137
|
+
lzo_stats->matches =
|
|
138
|
+
lzo_stats->m1_matches + lzo_stats->m2_matches +
|
|
139
|
+
lzo_stats->m3_matches + lzo_stats->m4_matches;
|
|
140
|
+
|
|
141
|
+
lzo_stats->literal_overhead = lzo_stats->lit_runs +
|
|
142
|
+
2 * (lzo_stats->r0short_runs + lzo_stats->r0fast_runs +
|
|
143
|
+
lzo_stats->r0long_runs);
|
|
144
|
+
lzo_stats->literal_bytes = lzo_stats->literals +
|
|
145
|
+
lzo_stats->literal_overhead;
|
|
146
|
+
|
|
147
|
+
#if 0
|
|
148
|
+
assert(lzo_stats->match_bytes + lzo_stats->literal_bytes ==
|
|
149
|
+
lzo_stats->out_len);
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
lzo_stats->m2_matches -= lzo_stats->r1_matches;
|
|
153
|
+
lzo_stats->m2_match[M2_MIN_LEN] -= lzo_stats->r1_matches;
|
|
154
|
+
|
|
155
|
+
if (lzo_stats->literals > 0)
|
|
156
|
+
lzo_stats->literal_overhead_percent =
|
|
157
|
+
100.0 * lzo_stats->literal_overhead / lzo_stats->literals;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
#endif
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/*
|
|
165
|
+
vi:ts=4:et
|
|
166
|
+
*/
|
|
167
|
+
|
data/ext/lzo1c_cc.h
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* lzo1c_cc.h -- definitions for the the LZO1C compression driver
|
|
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 __LZO1C_CC_H
|
|
48
|
+
#define __LZO1C_CC_H
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/***********************************************************************
|
|
52
|
+
//
|
|
53
|
+
************************************************************************/
|
|
54
|
+
|
|
55
|
+
extern const lzo_compress_t _lzo1c_1_compress_func;
|
|
56
|
+
extern const lzo_compress_t _lzo1c_2_compress_func;
|
|
57
|
+
extern const lzo_compress_t _lzo1c_3_compress_func;
|
|
58
|
+
extern const lzo_compress_t _lzo1c_4_compress_func;
|
|
59
|
+
extern const lzo_compress_t _lzo1c_5_compress_func;
|
|
60
|
+
extern const lzo_compress_t _lzo1c_6_compress_func;
|
|
61
|
+
extern const lzo_compress_t _lzo1c_7_compress_func;
|
|
62
|
+
extern const lzo_compress_t _lzo1c_8_compress_func;
|
|
63
|
+
extern const lzo_compress_t _lzo1c_9_compress_func;
|
|
64
|
+
|
|
65
|
+
extern const lzo_compress_t _lzo1c_99_compress_func;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
/***********************************************************************
|
|
69
|
+
//
|
|
70
|
+
************************************************************************/
|
|
71
|
+
|
|
72
|
+
LZO_EXTERN(lzo_bytep )
|
|
73
|
+
_lzo1c_store_run ( lzo_bytep const oo, const lzo_bytep const ii,
|
|
74
|
+
lzo_uint r_len);
|
|
75
|
+
|
|
76
|
+
#define STORE_RUN _lzo1c_store_run
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
lzo_compress_t _lzo1c_get_compress_func(int clevel);
|
|
80
|
+
|
|
81
|
+
int _lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len,
|
|
82
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
83
|
+
lzo_voidp wrkmem,
|
|
84
|
+
lzo_compress_t func );
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#endif /* already included */
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
vi:ts=4:et
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
|
data/ext/lzo1c_d1.c
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* lzo1c_d1.c -- LZO1C decompression
|
|
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 "config1c.h"
|
|
42
|
+
|
|
43
|
+
#undef LZO_TEST_OVERRUN
|
|
44
|
+
#define DO_DECOMPRESS lzo1c_decompress
|
|
45
|
+
|
|
46
|
+
#include "lzo1b_d.ch"
|