lzoruby 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/{README.txt → README} +3 -7
  2. data/ext/extconf.rb +4 -1
  3. metadata +24 -131
  4. data/ext/compr1b.h +0 -81
  5. data/ext/compr1c.h +0 -81
  6. data/ext/config1.h +0 -61
  7. data/ext/config1a.h +0 -196
  8. data/ext/config1b.h +0 -140
  9. data/ext/config1c.h +0 -145
  10. data/ext/config1f.h +0 -97
  11. data/ext/config1x.h +0 -118
  12. data/ext/config1y.h +0 -66
  13. data/ext/config1z.h +0 -65
  14. data/ext/config2a.h +0 -155
  15. data/ext/lzo/lzo1.h +0 -96
  16. data/ext/lzo/lzo1a.h +0 -96
  17. data/ext/lzo/lzo1b.h +0 -160
  18. data/ext/lzo/lzo1c.h +0 -160
  19. data/ext/lzo/lzo1f.h +0 -108
  20. data/ext/lzo/lzo1x.h +0 -177
  21. data/ext/lzo/lzo1y.h +0 -145
  22. data/ext/lzo/lzo1z.h +0 -150
  23. data/ext/lzo/lzo2a.h +0 -92
  24. data/ext/lzo/lzo_asm.h +0 -139
  25. data/ext/lzo/lzoconf.h +0 -417
  26. data/ext/lzo/lzodefs.h +0 -1807
  27. data/ext/lzo/lzoutil.h +0 -73
  28. data/ext/lzo1.c +0 -635
  29. data/ext/lzo1_99.c +0 -130
  30. data/ext/lzo1_cm.ch +0 -52
  31. data/ext/lzo1_d.ch +0 -155
  32. data/ext/lzo1a.c +0 -657
  33. data/ext/lzo1a_99.c +0 -130
  34. data/ext/lzo1a_cm.ch +0 -242
  35. data/ext/lzo1a_cr.ch +0 -128
  36. data/ext/lzo1a_de.h +0 -158
  37. data/ext/lzo1b_1.c +0 -46
  38. data/ext/lzo1b_2.c +0 -46
  39. data/ext/lzo1b_3.c +0 -46
  40. data/ext/lzo1b_4.c +0 -46
  41. data/ext/lzo1b_5.c +0 -46
  42. data/ext/lzo1b_6.c +0 -46
  43. data/ext/lzo1b_7.c +0 -46
  44. data/ext/lzo1b_8.c +0 -46
  45. data/ext/lzo1b_9.c +0 -46
  46. data/ext/lzo1b_99.c +0 -49
  47. data/ext/lzo1b_9x.c +0 -365
  48. data/ext/lzo1b_c.ch +0 -270
  49. data/ext/lzo1b_cc.c +0 -167
  50. data/ext/lzo1b_cc.h +0 -93
  51. data/ext/lzo1b_cm.ch +0 -294
  52. data/ext/lzo1b_cr.ch +0 -126
  53. data/ext/lzo1b_d.ch +0 -282
  54. data/ext/lzo1b_d1.c +0 -46
  55. data/ext/lzo1b_d2.c +0 -46
  56. data/ext/lzo1b_de.h +0 -344
  57. data/ext/lzo1b_r.ch +0 -117
  58. data/ext/lzo1b_rr.c +0 -43
  59. data/ext/lzo1b_sm.ch +0 -210
  60. data/ext/lzo1b_tm.ch +0 -99
  61. data/ext/lzo1b_xx.c +0 -98
  62. data/ext/lzo1c_1.c +0 -46
  63. data/ext/lzo1c_2.c +0 -46
  64. data/ext/lzo1c_3.c +0 -46
  65. data/ext/lzo1c_4.c +0 -46
  66. data/ext/lzo1c_5.c +0 -46
  67. data/ext/lzo1c_6.c +0 -46
  68. data/ext/lzo1c_7.c +0 -46
  69. data/ext/lzo1c_8.c +0 -46
  70. data/ext/lzo1c_9.c +0 -46
  71. data/ext/lzo1c_99.c +0 -49
  72. data/ext/lzo1c_9x.c +0 -379
  73. data/ext/lzo1c_cc.c +0 -167
  74. data/ext/lzo1c_cc.h +0 -93
  75. data/ext/lzo1c_d1.c +0 -46
  76. data/ext/lzo1c_d2.c +0 -46
  77. data/ext/lzo1c_rr.c +0 -43
  78. data/ext/lzo1c_xx.c +0 -98
  79. data/ext/lzo1f_1.c +0 -312
  80. data/ext/lzo1f_9x.c +0 -345
  81. data/ext/lzo1f_d.ch +0 -223
  82. data/ext/lzo1f_d1.c +0 -46
  83. data/ext/lzo1f_d2.c +0 -46
  84. data/ext/lzo1x_1.c +0 -50
  85. data/ext/lzo1x_1k.c +0 -50
  86. data/ext/lzo1x_1l.c +0 -50
  87. data/ext/lzo1x_1o.c +0 -50
  88. data/ext/lzo1x_9x.c +0 -881
  89. data/ext/lzo1x_c.ch +0 -351
  90. data/ext/lzo1x_d.ch +0 -466
  91. data/ext/lzo1x_d1.c +0 -46
  92. data/ext/lzo1x_d2.c +0 -46
  93. data/ext/lzo1x_d3.c +0 -108
  94. data/ext/lzo1x_o.c +0 -45
  95. data/ext/lzo1x_oo.ch +0 -366
  96. data/ext/lzo1y_1.c +0 -50
  97. data/ext/lzo1y_9x.c +0 -42
  98. data/ext/lzo1y_d1.c +0 -46
  99. data/ext/lzo1y_d2.c +0 -46
  100. data/ext/lzo1y_d3.c +0 -45
  101. data/ext/lzo1y_o.c +0 -45
  102. data/ext/lzo1z_9x.c +0 -42
  103. data/ext/lzo1z_d1.c +0 -46
  104. data/ext/lzo1z_d2.c +0 -46
  105. data/ext/lzo1z_d3.c +0 -45
  106. data/ext/lzo2a_9x.c +0 -357
  107. data/ext/lzo2a_d.ch +0 -188
  108. data/ext/lzo2a_d1.c +0 -46
  109. data/ext/lzo2a_d2.c +0 -46
  110. data/ext/lzo_conf.h +0 -323
  111. data/ext/lzo_crc.c +0 -167
  112. data/ext/lzo_dict.h +0 -316
  113. data/ext/lzo_dll.ch +0 -64
  114. data/ext/lzo_init.c +0 -176
  115. data/ext/lzo_mchw.ch +0 -242
  116. data/ext/lzo_ptr.c +0 -92
  117. data/ext/lzo_ptr.h +0 -154
  118. data/ext/lzo_str.c +0 -71
  119. data/ext/lzo_swd.ch +0 -707
  120. data/ext/lzo_util.c +0 -165
  121. data/ext/miniacc.h +0 -6553
  122. data/ext/stats1a.h +0 -137
  123. data/ext/stats1b.h +0 -142
  124. data/ext/stats1c.h +0 -61
@@ -1,294 +0,0 @@
1
- /* lzo1b_cm.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
- // code the match
50
- ************************************************************************/
51
-
52
- #if (DD_BITS == 0)
53
-
54
- /* we already matched M2_MIN_LEN bytes,
55
- * m_pos also already advanced M2_MIN_LEN bytes */
56
- ip += M2_MIN_LEN;
57
- assert(m_pos < ip);
58
-
59
- /* try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes
60
- * to see if we get more than a M2 match */
61
- #define M2_OR_M3 (MATCH_M2)
62
-
63
- #else /* (DD_BITS == 0) */
64
-
65
- /* we already matched m_len bytes */
66
- assert(m_len >= M2_MIN_LEN);
67
- ip += m_len;
68
- assert(ip <= in_end);
69
-
70
- #define M2_OR_M3 (m_len <= M2_MAX_LEN)
71
-
72
- #endif /* (DD_BITS == 0) */
73
-
74
-
75
-
76
- if (M2_OR_M3)
77
- {
78
- /* we've found a M2 or M3 match */
79
- assert(ip <= in_end);
80
-
81
- /* 2a) compute match parameters */
82
- #if (DD_BITS == 0)
83
- assert(pd(ip,m_pos) == m_off);
84
- --ip; /* ran one too far, point back to non-match */
85
- m_len = pd(ip, ii);
86
- #endif
87
-
88
- /* 2a2) verify match parameters */
89
- assert(m_len >= M2_MIN_LEN);
90
- assert(m_len <= M2_MAX_LEN);
91
- assert(m_len <= M3_MAX_LEN);
92
-
93
- assert(m_off >= M2_MIN_OFFSET);
94
- assert(m_off >= M3_MIN_OFFSET);
95
- assert(m_off <= M3_MAX_OFFSET);
96
- assert(ii-m_off == m_pos_sav);
97
- assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
98
-
99
- /* 2b) code the match */
100
- #if (_M2_MAX_OFFSET != _M3_MAX_OFFSET)
101
- if (m_off <= M2_MAX_OFFSET)
102
- {
103
- #else
104
- assert(m_off <= M2_MAX_OFFSET);
105
- #endif
106
- m_off -= M2_MIN_OFFSET;
107
- /* code match len + low offset bits */
108
- *op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) |
109
- (m_off & M2O_MASK));
110
- /* code high offset bits */
111
- *op++ = LZO_BYTE(m_off >> M2O_BITS);
112
- LZO_STATS(lzo_stats->m2_matches++);
113
- LZO_STATS(lzo_stats->m2_match[m_len]++);
114
- #if (_M2_MAX_OFFSET != _M3_MAX_OFFSET)
115
- }
116
- else
117
- {
118
- #if defined(LZO_HAVE_R1)
119
- #if (M3_MIN_LEN == M2_MIN_LEN)
120
- r1 = ip_end; /* invalidate R1 pointer */
121
- #endif
122
- #endif
123
- assert(m_len >= M3_MIN_LEN);
124
- m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
125
- /* code match len */
126
- *op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
127
- /* code low offset bits */
128
- *op++ = LZO_BYTE(m_off & M3O_MASK);
129
- /* code high offset bits */
130
- *op++ = LZO_BYTE(m_off >> M3O_BITS);
131
- LZO_STATS(lzo_stats->m3_matches++);
132
- LZO_STATS(lzo_stats->m3_match[m_len]++);
133
- #if defined(LZO_HAVE_M3)
134
- m3 = op; /* set M3 pointer */
135
- #endif
136
- }
137
- #endif /* (_M2_MAX_OFFSET != _M3_MAX_OFFSET) */
138
-
139
-
140
- if (ip >= ip_end)
141
- {
142
- ii = ip;
143
- break;
144
- }
145
-
146
-
147
- /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
148
-
149
- #if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3)
150
- /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
151
- ++ii;
152
- do {
153
- DVAL_NEXT(dv,ii);
154
- #if 0
155
- UPDATE_D(dict,drun,dv,ii,in);
156
- #else
157
- dict[ DINDEX(dv,ii) ] = DENTRY(ii,in);
158
- #endif
159
- MI
160
- } while (++ii < ip);
161
- DVAL_NEXT(dv,ii);
162
- assert(ii == ip);
163
- DVAL_ASSERT(dv,ip);
164
- #elif (CLEVEL >= 3)
165
- SI DI DI XI
166
- #elif (CLEVEL >= 2)
167
- SI DI XI
168
- #else
169
- XI
170
- #endif
171
- }
172
-
173
- else
174
-
175
- {
176
- /* we've found a M3 or M4 match - see how far we can still go */
177
- assert(ip <= in_end);
178
- assert(lzo_memcmp(m_pos_sav,ii,(lzo_uint)(ip-ii)) == 0);
179
-
180
- /* 2a) compute match parameters */
181
- #if !defined(MATCH_IP_END)
182
- assert(ii == ip - (M2_MAX_LEN + 1));
183
- #if (DD_BITS > 0)
184
- assert(m_len == (lzo_uint)(ip-ii));
185
- m_pos = ip - m_off;
186
- assert(m_pos == m_pos_sav + m_len);
187
- #endif
188
- {
189
- const lzo_bytep end;
190
- end = in_end;
191
- while (ip < end && *m_pos == *ip)
192
- m_pos++, ip++;
193
- assert(ip <= in_end);
194
- m_len = pd(ip, ii);
195
- }
196
- assert(pd(ip,m_pos) == m_off);
197
- #endif
198
-
199
- /* 2a2) verify match parameters */
200
- assert(m_len >= M3_MIN_LEN);
201
-
202
- assert(m_off >= M3_MIN_OFFSET);
203
- assert(m_off >= M4_MIN_OFFSET);
204
- assert(m_off <= M3_MAX_OFFSET);
205
- assert(m_off <= M4_MAX_OFFSET);
206
- assert(ii-m_off == m_pos_sav);
207
- assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
208
-
209
- /* 2b) code the match */
210
- if (m_len <= M3_MAX_LEN)
211
- {
212
- /* code match len */
213
- *op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
214
- LZO_STATS(lzo_stats->m3_matches++);
215
- LZO_STATS(lzo_stats->m3_match[m_len]++);
216
- }
217
- else
218
- {
219
- assert(m_len >= M4_MIN_LEN);
220
- /* code M4 match len flag */
221
- *op++ = M4_MARKER;
222
- /* code match len */
223
- m_len -= M4_MIN_LEN - 1;
224
- while (m_len > 255)
225
- {
226
- m_len -= 255;
227
- *op++ = 0;
228
- }
229
- assert(m_len > 0);
230
- *op++ = LZO_BYTE(m_len);
231
- LZO_STATS(lzo_stats->m4_matches++);
232
- }
233
-
234
- m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
235
- /* code low offset bits */
236
- *op++ = LZO_BYTE(m_off & M3O_MASK);
237
- /* code high offset bits */
238
- *op++ = LZO_BYTE(m_off >> M3O_BITS);
239
-
240
- #if defined(LZO_HAVE_M3)
241
- m3 = op; /* set M3 pointer */
242
- #endif
243
-
244
-
245
- if (ip >= ip_end)
246
- {
247
- ii = ip;
248
- break;
249
- }
250
-
251
-
252
- /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
253
- #if (CLEVEL == 9)
254
- /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
255
- /* This is not recommended because it can be slow. */
256
- ++ii;
257
- do {
258
- DVAL_NEXT(dv,ii);
259
- #if 0
260
- UPDATE_D(dict,drun,dv,ii,in);
261
- #else
262
- dict[ DINDEX(dv,ii) ] = DENTRY(ii,in);
263
- #endif
264
- MI
265
- } while (++ii < ip);
266
- DVAL_NEXT(dv,ii);
267
- assert(ii == ip);
268
- DVAL_ASSERT(dv,ip);
269
- #elif (CLEVEL >= 8)
270
- SI DI DI DI DI DI DI DI DI XI
271
- #elif (CLEVEL >= 7)
272
- SI DI DI DI DI DI DI DI XI
273
- #elif (CLEVEL >= 6)
274
- SI DI DI DI DI DI DI XI
275
- #elif (CLEVEL >= 5)
276
- SI DI DI DI DI XI
277
- #elif (CLEVEL >= 4)
278
- SI DI DI DI XI
279
- #elif (CLEVEL >= 3)
280
- SI DI DI XI
281
- #elif (CLEVEL >= 2)
282
- SI DI XI
283
- #else
284
- XI
285
- #endif
286
- }
287
-
288
- /* ii now points to the start of the next literal run */
289
- assert(ii == ip);
290
-
291
-
292
- /*
293
- vi:ts=4:et
294
- */
@@ -1,126 +0,0 @@
1
- /* lzo1b_cr.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
- // store the current literal run
50
- ************************************************************************/
51
-
52
- assert(ip < ip_end);
53
- if (pd(ip,ii) > 0)
54
- {
55
- lzo_uint t = pd(ip,ii);
56
-
57
- #if defined(LZO_HAVE_R1)
58
- if (ip == r1)
59
- {
60
- /* Code a context sensitive R1 match. */
61
- LZO_STATS(lzo_stats->literals += t);
62
- LZO_STATS(lzo_stats->r1_matches++);
63
- assert(t == 1);
64
- /* modify marker byte */
65
- assert((op[-2] >> M2O_BITS) == (M2_MARKER >> M2O_BITS));
66
- op[-2] &= M2O_MASK;
67
- assert((op[-2] >> M2O_BITS) == 0);
68
- /* copy 1 literal */
69
- *op++ = *ii++;
70
- r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
71
- }
72
- else
73
- #endif
74
- if (t < R0MIN)
75
- {
76
- /* inline the copying of a short run */
77
- LZO_STATS(lzo_stats->literals += t);
78
- LZO_STATS(lzo_stats->lit_runs++);
79
- LZO_STATS(lzo_stats->lit_run[t]++);
80
- #if defined(LZO_HAVE_M3)
81
- if (t < LZO_SIZE(8-M3O_BITS) && op == m3)
82
- {
83
- /* Code a very short literal run into the low offset bits
84
- * of the previous M3/M4 match.
85
- */
86
- LZO_STATS(lzo_stats->lit_runs_after_m3_match++);
87
- LZO_STATS(lzo_stats->lit_run_after_m3_match[t]++);
88
- assert((m3[-2] >> M3O_BITS) == 0);
89
- m3[-2] |= LZO_BYTE(t << M3O_BITS);
90
- }
91
- else
92
- #endif
93
- {
94
- *op++ = LZO_BYTE(t);
95
- }
96
- MEMCPY_DS(op, ii, t);
97
- #if defined(LZO_HAVE_R1)
98
- r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
99
- #endif
100
- }
101
- else if (t < R0FAST)
102
- {
103
- /* inline the copying of a short R0 run */
104
- LZO_STATS(lzo_stats->literals += t);
105
- LZO_STATS(lzo_stats->r0short_runs++);
106
- *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
107
- MEMCPY_DS(op, ii, t);
108
- #if defined(LZO_HAVE_R1)
109
- r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
110
- #endif
111
- }
112
- else
113
- {
114
- op = STORE_RUN(op,ii,t);
115
- ii = ip;
116
- }
117
- }
118
-
119
-
120
- /* ii now points to the start of the current match */
121
- assert(ii == ip);
122
-
123
-
124
- /*
125
- vi:ts=4:et
126
- */
@@ -1,282 +0,0 @@
1
- /* lzo1b_d.ch -- implementation of the LZO1B decompression 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 "lzo1_d.ch"
42
-
43
-
44
- /***********************************************************************
45
- // decompress a block of data.
46
- ************************************************************************/
47
-
48
- LZO_PUBLIC(int)
49
- DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
50
- lzo_bytep out, lzo_uintp out_len,
51
- lzo_voidp wrkmem )
52
- {
53
- register lzo_bytep op;
54
- register const lzo_bytep ip;
55
- register lzo_uint t;
56
- register const lzo_bytep m_pos;
57
-
58
- const lzo_bytep const ip_end = in + in_len;
59
- #if defined(HAVE_ANY_OP)
60
- lzo_bytep const op_end = out + *out_len;
61
- #endif
62
-
63
- LZO_UNUSED(wrkmem);
64
-
65
- op = out;
66
- ip = in;
67
-
68
- while (TEST_IP && TEST_OP)
69
- {
70
- t = *ip++; /* get marker */
71
-
72
- if (t < R0MIN) /* a literal run */
73
- {
74
- if (t == 0) /* a R0 literal run */
75
- {
76
- NEED_IP(1);
77
- t = *ip++;
78
- if (t >= R0FAST - R0MIN) /* a long R0 run */
79
- {
80
- t -= R0FAST - R0MIN;
81
- if (t == 0)
82
- t = R0FAST;
83
- else
84
- {
85
- #if 0
86
- t = 256u << ((unsigned) t);
87
- #else
88
- /* help the optimizer */
89
- lzo_uint tt = 256;
90
- do tt <<= 1; while (--t > 0);
91
- t = tt;
92
- #endif
93
- }
94
-
95
- NEED_IP(t); NEED_OP(t);
96
- #if 1 && defined(LZO_UNALIGNED_OK_4)
97
- do {
98
- * (lzo_uint32p) (op+0) = * (const lzo_uint32p) (ip+0);
99
- * (lzo_uint32p) (op+4) = * (const lzo_uint32p) (ip+4);
100
- op += 8; ip += 8;
101
- t -= 8;
102
- } while (t > 0);
103
- #else
104
- MEMCPY8_DS(op,ip,t);
105
- #endif
106
- continue;
107
- }
108
- t += R0MIN; /* a short R0 run */
109
- }
110
-
111
- NEED_IP(t); NEED_OP(t);
112
- /* copy literal run */
113
- #if 1 && defined(LZO_UNALIGNED_OK_4)
114
- if (t >= 4)
115
- {
116
- do {
117
- * (lzo_uint32p) op = * (const lzo_uint32p) ip;
118
- op += 4; ip += 4; t -= 4;
119
- } while (t >= 4);
120
- if (t > 0) do *op++ = *ip++; while (--t > 0);
121
- }
122
- else
123
- #endif
124
- {
125
- #if (M3O_BITS < 7)
126
- literal1:
127
- #endif
128
- do *op++ = *ip++; while (--t > 0);
129
- }
130
-
131
- #if (M3O_BITS == 7)
132
- literal2:
133
- #endif
134
-
135
- /* after a literal a match must follow */
136
- while (TEST_IP && TEST_OP)
137
- {
138
- t = *ip++; /* get R1 marker */
139
- if (t >= R0MIN)
140
- goto match;
141
-
142
- NEED_IP(2); NEED_OP(M2_MIN_LEN + 1);
143
-
144
- /* R1 match - a M2_MIN_LEN match + 1 byte literal */
145
- assert((t & M2O_MASK) == t);
146
- m_pos = op - M2_MIN_OFFSET;
147
- m_pos -= t | (((lzo_uint) *ip++) << M2O_BITS);
148
- assert(m_pos >= out); assert(m_pos < op);
149
- TEST_LB(m_pos);
150
- COPY_M2;
151
- *op++ = *ip++;
152
- }
153
-
154
- #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
155
- break;
156
- #endif
157
- }
158
-
159
- match:
160
-
161
- if (t >= M2_MARKER) /* a M2 match */
162
- {
163
- /* get match offset */
164
- NEED_IP(1);
165
- m_pos = op - M2_MIN_OFFSET;
166
- m_pos -= (t & M2O_MASK) | (((lzo_uint) *ip++) << M2O_BITS);
167
- assert(m_pos >= out); assert(m_pos < op);
168
- TEST_LB(m_pos);
169
-
170
- /* get match len */
171
- t = (t >> M2O_BITS) - 1;
172
- NEED_OP(t + M2_MIN_LEN - 1);
173
- COPY_M2X;
174
- MEMCPY_DS(op,m_pos,t);
175
- }
176
- else /* a M3 or M4 match */
177
- {
178
- /* get match len */
179
- t &= M3L_MASK;
180
- if (t == 0) /* a M4 match */
181
- {
182
- NEED_IP(1);
183
- while (*ip == 0)
184
- {
185
- t += 255;
186
- ip++;
187
- NEED_IP(1);
188
- }
189
- t += (M4_MIN_LEN - M3_MIN_LEN) + *ip++;
190
- }
191
-
192
- /* get match offset */
193
- NEED_IP(2);
194
- m_pos = op - (M3_MIN_OFFSET - M3_EOF_OFFSET);
195
- m_pos -= *ip++ & M3O_MASK;
196
- m_pos -= (lzo_uint)(*ip++) << M3O_BITS;
197
- #if defined(LZO_EOF_CODE)
198
- if (m_pos == op)
199
- goto eof_found;
200
- #endif
201
-
202
- /* copy match */
203
- assert(m_pos >= out); assert(m_pos < op);
204
- TEST_LB(m_pos); NEED_OP(t + M3_MIN_LEN - 1);
205
- #if defined(LZO_UNALIGNED_OK_4)
206
- if (t >= 2 * 4 - (M3_MIN_LEN - 1) && (op - m_pos) >= 4)
207
- {
208
- * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
209
- op += 4; m_pos += 4; t -= 4 - (M3_MIN_LEN - 1);
210
- do {
211
- * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
212
- op += 4; m_pos += 4; t -= 4;
213
- } while (t >= 4);
214
- if (t > 0) do *op++ = *m_pos++; while (--t > 0);
215
- }
216
- else
217
- #endif
218
- {
219
- COPY_M3X;
220
- MEMCPY_DS(op,m_pos,t);
221
- }
222
-
223
-
224
- #if (M3O_BITS < 7)
225
- t = ip[-2] >> M3O_BITS;
226
- if (t)
227
- {
228
- NEED_IP(t); NEED_OP(t);
229
- goto literal1;
230
- }
231
- #elif (M3O_BITS == 7)
232
- /* optimized version */
233
- if (ip[-2] & (1 << M3O_BITS))
234
- {
235
- NEED_IP(1); NEED_OP(1);
236
- *op++ = *ip++;
237
- goto literal2;
238
- }
239
- #endif
240
- }
241
- }
242
-
243
-
244
- #if defined(LZO_EOF_CODE)
245
- #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
246
- /* no EOF code was found */
247
- *out_len = pd(op, out);
248
- return LZO_E_EOF_NOT_FOUND;
249
- #endif
250
-
251
- eof_found:
252
- assert(t == 1);
253
- #endif
254
- *out_len = pd(op, out);
255
- return (ip == ip_end ? LZO_E_OK :
256
- (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
257
-
258
-
259
- #if defined(HAVE_NEED_IP)
260
- input_overrun:
261
- *out_len = pd(op, out);
262
- return LZO_E_INPUT_OVERRUN;
263
- #endif
264
-
265
- #if defined(HAVE_NEED_OP)
266
- output_overrun:
267
- *out_len = pd(op, out);
268
- return LZO_E_OUTPUT_OVERRUN;
269
- #endif
270
-
271
- #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
272
- lookbehind_overrun:
273
- *out_len = pd(op, out);
274
- return LZO_E_LOOKBEHIND_OVERRUN;
275
- #endif
276
- }
277
-
278
-
279
- /*
280
- vi:ts=4:et
281
- */
282
-