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/lzo1a_99.c
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* lzo1a_99.c -- implementation of the LZO1A-99 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
|
+
#define COMPRESS_ID 99
|
|
43
|
+
|
|
44
|
+
#define DDBITS 3
|
|
45
|
+
#define CLEVEL 9
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/***********************************************************************
|
|
49
|
+
//
|
|
50
|
+
************************************************************************/
|
|
51
|
+
|
|
52
|
+
#define LZO_NEED_DICT_H
|
|
53
|
+
#include "config1a.h"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/***********************************************************************
|
|
57
|
+
// compression internal entry point.
|
|
58
|
+
************************************************************************/
|
|
59
|
+
|
|
60
|
+
static int
|
|
61
|
+
_lzo1a_do_compress ( const lzo_bytep in, lzo_uint in_len,
|
|
62
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
63
|
+
lzo_voidp wrkmem,
|
|
64
|
+
lzo_compress_t func )
|
|
65
|
+
{
|
|
66
|
+
int r;
|
|
67
|
+
|
|
68
|
+
/* don't try to compress a block that's too short */
|
|
69
|
+
if (in_len <= 0)
|
|
70
|
+
{
|
|
71
|
+
*out_len = 0;
|
|
72
|
+
r = LZO_E_OK;
|
|
73
|
+
}
|
|
74
|
+
else if (in_len <= MIN_LOOKAHEAD + 1)
|
|
75
|
+
{
|
|
76
|
+
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
|
|
77
|
+
*out_len = 0;
|
|
78
|
+
r = LZO_E_NOT_COMPRESSIBLE;
|
|
79
|
+
#else
|
|
80
|
+
*out_len = pd(STORE_RUN(out,in,in_len), out);
|
|
81
|
+
r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
|
|
82
|
+
#endif
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
r = func(in,in_len,out,out_len,wrkmem);
|
|
86
|
+
|
|
87
|
+
return r;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/***********************************************************************
|
|
92
|
+
//
|
|
93
|
+
************************************************************************/
|
|
94
|
+
|
|
95
|
+
#if !defined(COMPRESS_ID)
|
|
96
|
+
#define COMPRESS_ID _LZO_ECONCAT2(DD_BITS,CLEVEL)
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
#define LZO_CODE_MATCH_INCLUDE_FILE "lzo1a_cm.ch"
|
|
101
|
+
#include "lzo1b_c.ch"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/***********************************************************************
|
|
105
|
+
//
|
|
106
|
+
************************************************************************/
|
|
107
|
+
|
|
108
|
+
#define LZO_COMPRESS \
|
|
109
|
+
LZO_CPP_ECONCAT3(lzo1a_,COMPRESS_ID,_compress)
|
|
110
|
+
|
|
111
|
+
#define LZO_COMPRESS_FUNC \
|
|
112
|
+
LZO_CPP_ECONCAT3(_lzo1a_,COMPRESS_ID,_compress_func)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
/***********************************************************************
|
|
116
|
+
//
|
|
117
|
+
************************************************************************/
|
|
118
|
+
|
|
119
|
+
LZO_PUBLIC(int)
|
|
120
|
+
LZO_COMPRESS ( const lzo_bytep in, lzo_uint in_len,
|
|
121
|
+
lzo_bytep out, lzo_uintp out_len,
|
|
122
|
+
lzo_voidp wrkmem )
|
|
123
|
+
{
|
|
124
|
+
return _lzo1a_do_compress(in,in_len,out,out_len,wrkmem,do_compress);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
vi:ts=4:et
|
|
130
|
+
*/
|
data/ext/lzo1a_cm.ch
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/* lzo1a_cm.ch -- implementation of the LZO1A 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
|
+
// code the match in LZO1 compatible format
|
|
50
|
+
************************************************************************/
|
|
51
|
+
|
|
52
|
+
#define THRESHOLD (M2_MIN_LEN - 1)
|
|
53
|
+
#define MSIZE LZO_SIZE(M2L_BITS)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/***********************************************************************
|
|
57
|
+
//
|
|
58
|
+
************************************************************************/
|
|
59
|
+
|
|
60
|
+
#if (DD_BITS == 0)
|
|
61
|
+
|
|
62
|
+
/* we already matched M2_MIN_LEN bytes,
|
|
63
|
+
* m_pos also already advanced M2_MIN_LEN bytes */
|
|
64
|
+
ip += M2_MIN_LEN;
|
|
65
|
+
assert(m_pos < ip);
|
|
66
|
+
|
|
67
|
+
/* try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes
|
|
68
|
+
* to see if we get more than a M2 match */
|
|
69
|
+
#define M2_OR_M3 (MATCH_M2)
|
|
70
|
+
|
|
71
|
+
#else /* (DD_BITS == 0) */
|
|
72
|
+
|
|
73
|
+
/* we already matched m_len bytes */
|
|
74
|
+
assert(m_len >= M2_MIN_LEN);
|
|
75
|
+
ip += m_len;
|
|
76
|
+
assert(ip <= in_end);
|
|
77
|
+
|
|
78
|
+
#define M2_OR_M3 (m_len <= M2_MAX_LEN)
|
|
79
|
+
|
|
80
|
+
#endif /* (DD_BITS == 0) */
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if (M2_OR_M3)
|
|
84
|
+
{
|
|
85
|
+
/* we've found a short match */
|
|
86
|
+
assert(ip <= in_end);
|
|
87
|
+
|
|
88
|
+
/* 2a) compute match parameters */
|
|
89
|
+
#if (DD_BITS == 0)
|
|
90
|
+
assert(pd(ip,m_pos) == m_off);
|
|
91
|
+
--ip; /* ran one too far, point back to non-match */
|
|
92
|
+
m_len = ip - ii;
|
|
93
|
+
#endif
|
|
94
|
+
assert(m_len >= M2_MIN_LEN);
|
|
95
|
+
assert(m_len <= M2_MAX_LEN);
|
|
96
|
+
|
|
97
|
+
assert(m_off >= M2_MIN_OFFSET);
|
|
98
|
+
assert(m_off <= M2_MAX_OFFSET);
|
|
99
|
+
assert(ii-m_off == m_pos_sav);
|
|
100
|
+
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
|
|
101
|
+
|
|
102
|
+
/* 2b) code the match */
|
|
103
|
+
m_off -= M2_MIN_OFFSET;
|
|
104
|
+
/* code short match len + low offset bits */
|
|
105
|
+
*op++ = LZO_BYTE(((m_len - THRESHOLD) << M2O_BITS) |
|
|
106
|
+
(m_off & M2O_MASK));
|
|
107
|
+
/* code high offset bits */
|
|
108
|
+
*op++ = LZO_BYTE(m_off >> M2O_BITS);
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if (ip >= ip_end)
|
|
112
|
+
{
|
|
113
|
+
ii = ip;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
|
|
119
|
+
|
|
120
|
+
#if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3)
|
|
121
|
+
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */
|
|
122
|
+
++ii;
|
|
123
|
+
do {
|
|
124
|
+
DVAL_NEXT(dv,ii);
|
|
125
|
+
#if 0
|
|
126
|
+
UPDATE_D(dict,drun,dv,ii,in);
|
|
127
|
+
#else
|
|
128
|
+
dict[ DINDEX(dv,ii) ] = DENTRY(ii,in);
|
|
129
|
+
#endif
|
|
130
|
+
MI
|
|
131
|
+
} while (++ii < ip);
|
|
132
|
+
DVAL_NEXT(dv,ii);
|
|
133
|
+
assert(ii == ip);
|
|
134
|
+
DVAL_ASSERT(dv,ip);
|
|
135
|
+
#elif (CLEVEL >= 3)
|
|
136
|
+
SI DI DI XI
|
|
137
|
+
#elif (CLEVEL >= 2)
|
|
138
|
+
SI DI XI
|
|
139
|
+
#else
|
|
140
|
+
XI
|
|
141
|
+
#endif
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
else
|
|
145
|
+
|
|
146
|
+
{
|
|
147
|
+
/* we've found a long match - see how far we can still go */
|
|
148
|
+
const lzo_bytep end;
|
|
149
|
+
|
|
150
|
+
assert(ip <= in_end);
|
|
151
|
+
assert(ii == ip - (M2_MAX_LEN + 1));
|
|
152
|
+
assert(lzo_memcmp(m_pos_sav,ii,(lzo_uint)(ip-ii)) == 0);
|
|
153
|
+
|
|
154
|
+
#if (DD_BITS > 0)
|
|
155
|
+
assert(m_len == (lzo_uint)(ip-ii));
|
|
156
|
+
m_pos = ip - m_off;
|
|
157
|
+
assert(m_pos == m_pos_sav + m_len);
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
if (pd(in_end,ip) <= (M3_MAX_LEN - M3_MIN_LEN))
|
|
161
|
+
end = in_end;
|
|
162
|
+
else
|
|
163
|
+
{
|
|
164
|
+
end = ip + (M3_MAX_LEN - M3_MIN_LEN);
|
|
165
|
+
assert(end < in_end);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
while (ip < end && *m_pos == *ip)
|
|
169
|
+
m_pos++, ip++;
|
|
170
|
+
assert(ip <= in_end);
|
|
171
|
+
|
|
172
|
+
/* 2a) compute match parameters */
|
|
173
|
+
m_len = pd(ip, ii);
|
|
174
|
+
assert(m_len >= M3_MIN_LEN);
|
|
175
|
+
assert(m_len <= M3_MAX_LEN);
|
|
176
|
+
|
|
177
|
+
assert(m_off >= M3_MIN_OFFSET);
|
|
178
|
+
assert(m_off <= M3_MAX_OFFSET);
|
|
179
|
+
assert(ii-m_off == m_pos_sav);
|
|
180
|
+
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
|
|
181
|
+
assert(pd(ip,m_pos) == m_off);
|
|
182
|
+
|
|
183
|
+
/* 2b) code the match */
|
|
184
|
+
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
|
|
185
|
+
/* code long match flag + low offset bits */
|
|
186
|
+
*op++ = LZO_BYTE(((MSIZE - 1) << M3O_BITS) | (m_off & M3O_MASK));
|
|
187
|
+
/* code high offset bits */
|
|
188
|
+
*op++ = LZO_BYTE(m_off >> M3O_BITS);
|
|
189
|
+
/* code match len */
|
|
190
|
+
*op++ = LZO_BYTE(m_len - M3_MIN_LEN);
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
if (ip >= ip_end)
|
|
194
|
+
{
|
|
195
|
+
ii = ip;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
|
|
201
|
+
#if (CLEVEL == 9)
|
|
202
|
+
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */
|
|
203
|
+
/* This is not recommended because it can be slow. */
|
|
204
|
+
++ii;
|
|
205
|
+
do {
|
|
206
|
+
DVAL_NEXT(dv,ii);
|
|
207
|
+
#if 0
|
|
208
|
+
UPDATE_D(dict,drun,dv,ii,in);
|
|
209
|
+
#else
|
|
210
|
+
dict[ DINDEX(dv,ii) ] = DENTRY(ii,in);
|
|
211
|
+
#endif
|
|
212
|
+
MI
|
|
213
|
+
} while (++ii < ip);
|
|
214
|
+
DVAL_NEXT(dv,ii);
|
|
215
|
+
assert(ii == ip);
|
|
216
|
+
DVAL_ASSERT(dv,ip);
|
|
217
|
+
#elif (CLEVEL >= 8)
|
|
218
|
+
SI DI DI DI DI DI DI DI DI XI
|
|
219
|
+
#elif (CLEVEL >= 7)
|
|
220
|
+
SI DI DI DI DI DI DI DI XI
|
|
221
|
+
#elif (CLEVEL >= 6)
|
|
222
|
+
SI DI DI DI DI DI DI XI
|
|
223
|
+
#elif (CLEVEL >= 5)
|
|
224
|
+
SI DI DI DI DI XI
|
|
225
|
+
#elif (CLEVEL >= 4)
|
|
226
|
+
SI DI DI DI XI
|
|
227
|
+
#elif (CLEVEL >= 3)
|
|
228
|
+
SI DI DI XI
|
|
229
|
+
#elif (CLEVEL >= 2)
|
|
230
|
+
SI DI XI
|
|
231
|
+
#else
|
|
232
|
+
XI
|
|
233
|
+
#endif
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* ii now points to the start of the next literal run */
|
|
237
|
+
assert(ii == ip);
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
/*
|
|
241
|
+
vi:ts=4:et
|
|
242
|
+
*/
|
data/ext/lzo1a_cr.ch
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* lzo1a_cr.ch -- literal run handling 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 __LZO1A_CR_H
|
|
48
|
+
#define __LZO1A_CR_H
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/***********************************************************************
|
|
52
|
+
// code a literal run
|
|
53
|
+
************************************************************************/
|
|
54
|
+
|
|
55
|
+
static lzo_bytep
|
|
56
|
+
store_run(lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
|
|
57
|
+
{
|
|
58
|
+
register lzo_bytep op;
|
|
59
|
+
register const lzo_bytep ip;
|
|
60
|
+
register lzo_uint t;
|
|
61
|
+
|
|
62
|
+
op = oo;
|
|
63
|
+
ip = ii;
|
|
64
|
+
assert(r_len > 0);
|
|
65
|
+
|
|
66
|
+
/* code a long R0 run */
|
|
67
|
+
if (r_len >= 512)
|
|
68
|
+
{
|
|
69
|
+
unsigned r_bits = 6; /* 256 << 6 == 16384 */
|
|
70
|
+
lzo_uint tt = 32768u;
|
|
71
|
+
|
|
72
|
+
while (r_len >= (t = tt))
|
|
73
|
+
{
|
|
74
|
+
r_len -= t;
|
|
75
|
+
*op++ = 0; *op++ = (R0MAX - R0MIN);
|
|
76
|
+
MEMCPY8_DS(op, ip, t);
|
|
77
|
+
LZO_STATS(lzo_stats->r0long_runs++);
|
|
78
|
+
}
|
|
79
|
+
tt >>= 1;
|
|
80
|
+
do {
|
|
81
|
+
if (r_len >= (t = tt))
|
|
82
|
+
{
|
|
83
|
+
r_len -= t;
|
|
84
|
+
*op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
|
|
85
|
+
MEMCPY8_DS(op, ip, t);
|
|
86
|
+
LZO_STATS(lzo_stats->r0long_runs++);
|
|
87
|
+
}
|
|
88
|
+
tt >>= 1;
|
|
89
|
+
} while (--r_bits > 0);
|
|
90
|
+
}
|
|
91
|
+
assert(r_len < 512);
|
|
92
|
+
|
|
93
|
+
while (r_len >= (t = R0FAST))
|
|
94
|
+
{
|
|
95
|
+
r_len -= t;
|
|
96
|
+
*op++ = 0; *op++ = (R0FAST - R0MIN);
|
|
97
|
+
MEMCPY8_DS(op, ip, t);
|
|
98
|
+
LZO_STATS(lzo_stats->r0fast_runs++);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
t = r_len;
|
|
102
|
+
if (t >= R0MIN)
|
|
103
|
+
{
|
|
104
|
+
/* code a short R0 run */
|
|
105
|
+
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
|
|
106
|
+
MEMCPY_DS(op, ip, t);
|
|
107
|
+
LZO_STATS(lzo_stats->r0short_runs++);
|
|
108
|
+
}
|
|
109
|
+
else if (t > 0)
|
|
110
|
+
{
|
|
111
|
+
/* code a short literal run */
|
|
112
|
+
LZO_STATS(lzo_stats->lit_runs++);
|
|
113
|
+
LZO_STATS(lzo_stats->lit_run[t]++);
|
|
114
|
+
*op++ = LZO_BYTE(t);
|
|
115
|
+
MEMCPY_DS(op, ip, t);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return op;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
#endif /* already included */
|
|
124
|
+
|
|
125
|
+
/*
|
|
126
|
+
vi:ts=4:et
|
|
127
|
+
*/
|
|
128
|
+
|
data/ext/lzo1a_de.h
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
|
data/ext/lzo1b_1.c
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* lzo1b_1.c -- main internal configuration file for the the LZO library
|
|
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 COMPRESS_ID 1
|
|
42
|
+
|
|
43
|
+
#define DDBITS 0
|
|
44
|
+
#define CLEVEL 1
|
|
45
|
+
#include "compr1b.h"
|
|
46
|
+
|