lzoruby 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.txt → README} +3 -7
- data/ext/extconf.rb +4 -1
- metadata +24 -131
- data/ext/compr1b.h +0 -81
- data/ext/compr1c.h +0 -81
- data/ext/config1.h +0 -61
- data/ext/config1a.h +0 -196
- data/ext/config1b.h +0 -140
- data/ext/config1c.h +0 -145
- data/ext/config1f.h +0 -97
- data/ext/config1x.h +0 -118
- data/ext/config1y.h +0 -66
- data/ext/config1z.h +0 -65
- data/ext/config2a.h +0 -155
- data/ext/lzo/lzo1.h +0 -96
- data/ext/lzo/lzo1a.h +0 -96
- data/ext/lzo/lzo1b.h +0 -160
- data/ext/lzo/lzo1c.h +0 -160
- data/ext/lzo/lzo1f.h +0 -108
- data/ext/lzo/lzo1x.h +0 -177
- data/ext/lzo/lzo1y.h +0 -145
- data/ext/lzo/lzo1z.h +0 -150
- data/ext/lzo/lzo2a.h +0 -92
- data/ext/lzo/lzo_asm.h +0 -139
- data/ext/lzo/lzoconf.h +0 -417
- data/ext/lzo/lzodefs.h +0 -1807
- data/ext/lzo/lzoutil.h +0 -73
- data/ext/lzo1.c +0 -635
- data/ext/lzo1_99.c +0 -130
- data/ext/lzo1_cm.ch +0 -52
- data/ext/lzo1_d.ch +0 -155
- data/ext/lzo1a.c +0 -657
- data/ext/lzo1a_99.c +0 -130
- data/ext/lzo1a_cm.ch +0 -242
- data/ext/lzo1a_cr.ch +0 -128
- data/ext/lzo1a_de.h +0 -158
- data/ext/lzo1b_1.c +0 -46
- data/ext/lzo1b_2.c +0 -46
- data/ext/lzo1b_3.c +0 -46
- data/ext/lzo1b_4.c +0 -46
- data/ext/lzo1b_5.c +0 -46
- data/ext/lzo1b_6.c +0 -46
- data/ext/lzo1b_7.c +0 -46
- data/ext/lzo1b_8.c +0 -46
- data/ext/lzo1b_9.c +0 -46
- data/ext/lzo1b_99.c +0 -49
- data/ext/lzo1b_9x.c +0 -365
- data/ext/lzo1b_c.ch +0 -270
- data/ext/lzo1b_cc.c +0 -167
- data/ext/lzo1b_cc.h +0 -93
- data/ext/lzo1b_cm.ch +0 -294
- data/ext/lzo1b_cr.ch +0 -126
- data/ext/lzo1b_d.ch +0 -282
- data/ext/lzo1b_d1.c +0 -46
- data/ext/lzo1b_d2.c +0 -46
- data/ext/lzo1b_de.h +0 -344
- data/ext/lzo1b_r.ch +0 -117
- data/ext/lzo1b_rr.c +0 -43
- data/ext/lzo1b_sm.ch +0 -210
- data/ext/lzo1b_tm.ch +0 -99
- data/ext/lzo1b_xx.c +0 -98
- data/ext/lzo1c_1.c +0 -46
- data/ext/lzo1c_2.c +0 -46
- data/ext/lzo1c_3.c +0 -46
- data/ext/lzo1c_4.c +0 -46
- data/ext/lzo1c_5.c +0 -46
- data/ext/lzo1c_6.c +0 -46
- data/ext/lzo1c_7.c +0 -46
- data/ext/lzo1c_8.c +0 -46
- data/ext/lzo1c_9.c +0 -46
- data/ext/lzo1c_99.c +0 -49
- data/ext/lzo1c_9x.c +0 -379
- data/ext/lzo1c_cc.c +0 -167
- data/ext/lzo1c_cc.h +0 -93
- data/ext/lzo1c_d1.c +0 -46
- data/ext/lzo1c_d2.c +0 -46
- data/ext/lzo1c_rr.c +0 -43
- data/ext/lzo1c_xx.c +0 -98
- data/ext/lzo1f_1.c +0 -312
- data/ext/lzo1f_9x.c +0 -345
- data/ext/lzo1f_d.ch +0 -223
- data/ext/lzo1f_d1.c +0 -46
- data/ext/lzo1f_d2.c +0 -46
- data/ext/lzo1x_1.c +0 -50
- data/ext/lzo1x_1k.c +0 -50
- data/ext/lzo1x_1l.c +0 -50
- data/ext/lzo1x_1o.c +0 -50
- data/ext/lzo1x_9x.c +0 -881
- data/ext/lzo1x_c.ch +0 -351
- data/ext/lzo1x_d.ch +0 -466
- data/ext/lzo1x_d1.c +0 -46
- data/ext/lzo1x_d2.c +0 -46
- data/ext/lzo1x_d3.c +0 -108
- data/ext/lzo1x_o.c +0 -45
- data/ext/lzo1x_oo.ch +0 -366
- data/ext/lzo1y_1.c +0 -50
- data/ext/lzo1y_9x.c +0 -42
- data/ext/lzo1y_d1.c +0 -46
- data/ext/lzo1y_d2.c +0 -46
- data/ext/lzo1y_d3.c +0 -45
- data/ext/lzo1y_o.c +0 -45
- data/ext/lzo1z_9x.c +0 -42
- data/ext/lzo1z_d1.c +0 -46
- data/ext/lzo1z_d2.c +0 -46
- data/ext/lzo1z_d3.c +0 -45
- data/ext/lzo2a_9x.c +0 -357
- data/ext/lzo2a_d.ch +0 -188
- data/ext/lzo2a_d1.c +0 -46
- data/ext/lzo2a_d2.c +0 -46
- data/ext/lzo_conf.h +0 -323
- data/ext/lzo_crc.c +0 -167
- data/ext/lzo_dict.h +0 -316
- data/ext/lzo_dll.ch +0 -64
- data/ext/lzo_init.c +0 -176
- data/ext/lzo_mchw.ch +0 -242
- data/ext/lzo_ptr.c +0 -92
- data/ext/lzo_ptr.h +0 -154
- data/ext/lzo_str.c +0 -71
- data/ext/lzo_swd.ch +0 -707
- data/ext/lzo_util.c +0 -165
- data/ext/miniacc.h +0 -6553
- data/ext/stats1a.h +0 -137
- data/ext/stats1b.h +0 -142
- data/ext/stats1c.h +0 -61
data/ext/lzo1x_d1.c
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
/* lzo1x_d1.c -- LZO1X 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 "config1x.h"
|
42
|
-
|
43
|
-
#undef LZO_TEST_OVERRUN
|
44
|
-
#define DO_DECOMPRESS lzo1x_decompress
|
45
|
-
|
46
|
-
#include "lzo1x_d.ch"
|
data/ext/lzo1x_d2.c
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
/* lzo1x_d2.c -- LZO1X decompression with overrun testing
|
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 "config1x.h"
|
42
|
-
|
43
|
-
#define LZO_TEST_OVERRUN
|
44
|
-
#define DO_DECOMPRESS lzo1x_decompress_safe
|
45
|
-
|
46
|
-
#include "lzo1x_d.ch"
|
data/ext/lzo1x_d3.c
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
/* lzo1x_d3.c -- LZO1X decompression with preset dictionary
|
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 "config1x.h"
|
42
|
-
|
43
|
-
#define LZO_TEST_OVERRUN
|
44
|
-
|
45
|
-
|
46
|
-
#define SLOW_MEMCPY(a,b,l) { do *a++ = *b++; while (--l > 0); }
|
47
|
-
#define FAST_MEMCPY(a,b,l) { lzo_memcpy(a,b,l); a += l; }
|
48
|
-
|
49
|
-
#if 1 && defined(FAST_MEMCPY)
|
50
|
-
# define DICT_MEMMOVE(op,m_pos,m_len,m_off) \
|
51
|
-
if (m_off >= (m_len)) \
|
52
|
-
FAST_MEMCPY(op,m_pos,m_len) \
|
53
|
-
else \
|
54
|
-
SLOW_MEMCPY(op,m_pos,m_len)
|
55
|
-
#else
|
56
|
-
# define DICT_MEMMOVE(op,m_pos,m_len,m_off) \
|
57
|
-
SLOW_MEMCPY(op,m_pos,m_len)
|
58
|
-
#endif
|
59
|
-
|
60
|
-
#if !defined(FAST_MEMCPY)
|
61
|
-
# define FAST_MEMCPY SLOW_MEMCPY
|
62
|
-
#endif
|
63
|
-
|
64
|
-
|
65
|
-
#define COPY_DICT_DICT(m_len,m_off) \
|
66
|
-
{ \
|
67
|
-
register const lzo_bytep m_pos; \
|
68
|
-
m_off -= pd(op, out); assert(m_off > 0); \
|
69
|
-
if (m_off > dict_len) goto lookbehind_overrun; \
|
70
|
-
m_pos = dict_end - m_off; \
|
71
|
-
if (m_len > m_off) \
|
72
|
-
{ \
|
73
|
-
m_len -= m_off; \
|
74
|
-
FAST_MEMCPY(op,m_pos,m_off) \
|
75
|
-
m_pos = out; \
|
76
|
-
SLOW_MEMCPY(op,m_pos,m_len) \
|
77
|
-
} \
|
78
|
-
else \
|
79
|
-
FAST_MEMCPY(op,m_pos,m_len) \
|
80
|
-
}
|
81
|
-
|
82
|
-
#define COPY_DICT(m_len,m_off) \
|
83
|
-
assert(m_len >= 2); assert(m_off > 0); assert(op > out); \
|
84
|
-
if (m_off <= pd(op, out)) \
|
85
|
-
{ \
|
86
|
-
register const lzo_bytep m_pos = op - m_off; \
|
87
|
-
DICT_MEMMOVE(op,m_pos,m_len,m_off) \
|
88
|
-
} \
|
89
|
-
else \
|
90
|
-
COPY_DICT_DICT(m_len,m_off)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
LZO_PUBLIC(int)
|
96
|
-
lzo1x_decompress_dict_safe ( const lzo_bytep in, lzo_uint in_len,
|
97
|
-
lzo_bytep out, lzo_uintp out_len,
|
98
|
-
lzo_voidp wrkmem /* NOT USED */,
|
99
|
-
const lzo_bytep dict, lzo_uint dict_len)
|
100
|
-
|
101
|
-
|
102
|
-
#include "lzo1x_d.ch"
|
103
|
-
|
104
|
-
|
105
|
-
/*
|
106
|
-
vi:ts=4:et
|
107
|
-
*/
|
108
|
-
|
data/ext/lzo1x_o.c
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
/* lzo1x_o.c -- LZO1X compressed data optimizer
|
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 "config1x.h"
|
42
|
-
|
43
|
-
#define DO_OPTIMIZE lzo1x_optimize
|
44
|
-
|
45
|
-
#include "lzo1x_oo.ch"
|
data/ext/lzo1x_oo.ch
DELETED
@@ -1,366 +0,0 @@
|
|
1
|
-
/* lzo1x_oo.ch -- LZO1X compressed data optimizer
|
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 TEST_IP (ip < ip_end)
|
42
|
-
#define TEST_OP (op <= op_end)
|
43
|
-
|
44
|
-
#define NO_LIT LZO_UINT_MAX
|
45
|
-
|
46
|
-
|
47
|
-
/***********************************************************************
|
48
|
-
//
|
49
|
-
************************************************************************/
|
50
|
-
|
51
|
-
static void copy2(lzo_bytep ip, const lzo_bytep m_pos, lzo_uint off)
|
52
|
-
{
|
53
|
-
assert(off > 0);
|
54
|
-
ip[0] = m_pos[0];
|
55
|
-
if (off == 1)
|
56
|
-
ip[1] = m_pos[0];
|
57
|
-
else
|
58
|
-
ip[1] = m_pos[1];
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
static void copy3(lzo_bytep ip, const lzo_bytep m_pos, lzo_uint off)
|
63
|
-
{
|
64
|
-
assert(off > 0);
|
65
|
-
ip[0] = m_pos[0];
|
66
|
-
if (off == 1)
|
67
|
-
{
|
68
|
-
ip[2] = ip[1] = m_pos[0];
|
69
|
-
}
|
70
|
-
else if (off == 2)
|
71
|
-
{
|
72
|
-
ip[1] = m_pos[1];
|
73
|
-
ip[2] = m_pos[0];
|
74
|
-
}
|
75
|
-
else
|
76
|
-
{
|
77
|
-
ip[1] = m_pos[1];
|
78
|
-
ip[2] = m_pos[2];
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
/***********************************************************************
|
84
|
-
// optimize a block of data.
|
85
|
-
************************************************************************/
|
86
|
-
|
87
|
-
LZO_PUBLIC(int)
|
88
|
-
DO_OPTIMIZE ( lzo_bytep in , lzo_uint in_len,
|
89
|
-
lzo_bytep out, lzo_uintp out_len,
|
90
|
-
lzo_voidp wrkmem )
|
91
|
-
{
|
92
|
-
lzo_bytep op;
|
93
|
-
lzo_bytep ip;
|
94
|
-
lzo_uint t;
|
95
|
-
lzo_bytep m_pos;
|
96
|
-
lzo_bytep const ip_end = in + in_len;
|
97
|
-
lzo_bytep const op_end = out + *out_len;
|
98
|
-
lzo_bytep litp = NULL;
|
99
|
-
lzo_uint lit = 0;
|
100
|
-
lzo_uint next_lit = NO_LIT;
|
101
|
-
lzo_uint nl;
|
102
|
-
unsigned long o_m1_a = 0, o_m1_b = 0, o_m2 = 0, o_m3_a = 0, o_m3_b = 0;
|
103
|
-
|
104
|
-
LZO_UNUSED(wrkmem);
|
105
|
-
|
106
|
-
*out_len = 0;
|
107
|
-
|
108
|
-
op = out;
|
109
|
-
ip = in;
|
110
|
-
|
111
|
-
assert(in_len >= 3);
|
112
|
-
if (*ip > 17)
|
113
|
-
{
|
114
|
-
t = *ip++ - 17;
|
115
|
-
if (t < 4)
|
116
|
-
goto match_next;
|
117
|
-
goto first_literal_run;
|
118
|
-
}
|
119
|
-
assert(*ip < 16 || (*ip == 17 && in_len == 3));
|
120
|
-
|
121
|
-
while (TEST_IP && TEST_OP)
|
122
|
-
{
|
123
|
-
t = *ip++;
|
124
|
-
if (t >= 16)
|
125
|
-
goto match;
|
126
|
-
/* a literal run */
|
127
|
-
litp = ip - 1;
|
128
|
-
if (t == 0)
|
129
|
-
{
|
130
|
-
t = 15;
|
131
|
-
while (*ip == 0)
|
132
|
-
t += 255, ip++;
|
133
|
-
t += *ip++;
|
134
|
-
}
|
135
|
-
lit = t + 3;
|
136
|
-
/* copy literals */
|
137
|
-
copy_literal_run:
|
138
|
-
*op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
|
139
|
-
first_literal_run:
|
140
|
-
do *op++ = *ip++; while (--t > 0);
|
141
|
-
|
142
|
-
|
143
|
-
t = *ip++;
|
144
|
-
|
145
|
-
if (t >= 16)
|
146
|
-
goto match;
|
147
|
-
#if defined(LZO1X)
|
148
|
-
m_pos = op - 1 - 0x800;
|
149
|
-
#elif defined(LZO1Y)
|
150
|
-
m_pos = op - 1 - 0x400;
|
151
|
-
#endif
|
152
|
-
m_pos -= t >> 2;
|
153
|
-
m_pos -= *ip++ << 2;
|
154
|
-
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
|
155
|
-
lit = 0;
|
156
|
-
goto match_done;
|
157
|
-
|
158
|
-
|
159
|
-
/* handle matches */
|
160
|
-
do {
|
161
|
-
if (t < 16) /* a M1 match */
|
162
|
-
{
|
163
|
-
m_pos = op - 1;
|
164
|
-
m_pos -= t >> 2;
|
165
|
-
m_pos -= *ip++ << 2;
|
166
|
-
|
167
|
-
if (litp == NULL)
|
168
|
-
goto copy_m1;
|
169
|
-
|
170
|
-
/* assert that there was a match just before */
|
171
|
-
assert(lit >= 1 && lit <= 3);
|
172
|
-
assert(litp == ip - 2 - lit - 2);
|
173
|
-
assert((lzo_uint)(*litp & 3) == lit);
|
174
|
-
nl = ip[-2] & 3;
|
175
|
-
/* test if a match follows */
|
176
|
-
if (nl == 0 && lit == 1 && ip[0] >= 16)
|
177
|
-
{
|
178
|
-
next_lit = nl;
|
179
|
-
/* adjust length of previous short run */
|
180
|
-
lit += 2;
|
181
|
-
*litp = LZO_BYTE((*litp & ~3) | lit);
|
182
|
-
/* copy over the 2 literals that replace the match */
|
183
|
-
copy2(ip-2,m_pos,pd(op,m_pos));
|
184
|
-
o_m1_a++;
|
185
|
-
}
|
186
|
-
/* test if a literal run follows */
|
187
|
-
else if (nl == 0 && ip[0] < 16 && ip[0] != 0 &&
|
188
|
-
(lit + 2 + ip[0] < 16))
|
189
|
-
{
|
190
|
-
t = *ip++;
|
191
|
-
/* remove short run */
|
192
|
-
*litp &= ~3;
|
193
|
-
/* copy over the 2 literals that replace the match */
|
194
|
-
copy2(ip-3+1,m_pos,pd(op,m_pos));
|
195
|
-
/* move literals 1 byte ahead */
|
196
|
-
litp += 2;
|
197
|
-
if (lit > 0)
|
198
|
-
lzo_memmove(litp+1,litp,lit);
|
199
|
-
/* insert new length of long literal run */
|
200
|
-
lit += 2 + t + 3; assert(lit <= 18);
|
201
|
-
*litp = LZO_BYTE(lit - 3);
|
202
|
-
|
203
|
-
o_m1_b++;
|
204
|
-
*op++ = *m_pos++; *op++ = *m_pos++;
|
205
|
-
goto copy_literal_run;
|
206
|
-
}
|
207
|
-
copy_m1:
|
208
|
-
*op++ = *m_pos++; *op++ = *m_pos++;
|
209
|
-
}
|
210
|
-
else
|
211
|
-
{
|
212
|
-
match:
|
213
|
-
if (t >= 64) /* a M2 match */
|
214
|
-
{
|
215
|
-
m_pos = op - 1;
|
216
|
-
#if defined(LZO1X)
|
217
|
-
m_pos -= (t >> 2) & 7;
|
218
|
-
m_pos -= *ip++ << 3;
|
219
|
-
t = (t >> 5) - 1;
|
220
|
-
#elif defined(LZO1Y)
|
221
|
-
m_pos -= (t >> 2) & 3;
|
222
|
-
m_pos -= *ip++ << 2;
|
223
|
-
t = (t >> 4) - 3;
|
224
|
-
#endif
|
225
|
-
if (litp == NULL)
|
226
|
-
goto copy_m;
|
227
|
-
|
228
|
-
nl = ip[-2] & 3;
|
229
|
-
/* test if in beetween two long literal runs */
|
230
|
-
if (t == 1 && lit > 3 && nl == 0 &&
|
231
|
-
ip[0] < 16 && ip[0] != 0 && (lit + 3 + ip[0] < 16))
|
232
|
-
{
|
233
|
-
assert(*litp == lit - 3);
|
234
|
-
t = *ip++;
|
235
|
-
/* copy over the 3 literals that replace the match */
|
236
|
-
copy3(ip-1-2,m_pos,pd(op,m_pos));
|
237
|
-
/* set new length of previous literal run */
|
238
|
-
lit += 3 + t + 3; assert(lit <= 18);
|
239
|
-
*litp = LZO_BYTE(lit - 3);
|
240
|
-
o_m2++;
|
241
|
-
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
|
242
|
-
goto copy_literal_run;
|
243
|
-
}
|
244
|
-
}
|
245
|
-
else
|
246
|
-
{
|
247
|
-
if (t >= 32) /* a M3 match */
|
248
|
-
{
|
249
|
-
t &= 31;
|
250
|
-
if (t == 0)
|
251
|
-
{
|
252
|
-
t = 31;
|
253
|
-
while (*ip == 0)
|
254
|
-
t += 255, ip++;
|
255
|
-
t += *ip++;
|
256
|
-
}
|
257
|
-
m_pos = op - 1;
|
258
|
-
m_pos -= *ip++ >> 2;
|
259
|
-
m_pos -= *ip++ << 6;
|
260
|
-
}
|
261
|
-
else /* a M4 match */
|
262
|
-
{
|
263
|
-
m_pos = op;
|
264
|
-
m_pos -= (t & 8) << 11;
|
265
|
-
t &= 7;
|
266
|
-
if (t == 0)
|
267
|
-
{
|
268
|
-
t = 7;
|
269
|
-
while (*ip == 0)
|
270
|
-
t += 255, ip++;
|
271
|
-
t += *ip++;
|
272
|
-
}
|
273
|
-
m_pos -= *ip++ >> 2;
|
274
|
-
m_pos -= *ip++ << 6;
|
275
|
-
if (m_pos == op)
|
276
|
-
goto eof_found;
|
277
|
-
m_pos -= 0x4000;
|
278
|
-
}
|
279
|
-
if (litp == NULL)
|
280
|
-
goto copy_m;
|
281
|
-
|
282
|
-
nl = ip[-2] & 3;
|
283
|
-
/* test if in beetween two matches */
|
284
|
-
if (t == 1 && lit == 0 && nl == 0 && ip[0] >= 16)
|
285
|
-
{
|
286
|
-
assert(litp == ip - 3 - lit - 2);
|
287
|
-
assert((lzo_uint)(*litp & 3) == lit);
|
288
|
-
next_lit = nl;
|
289
|
-
/* make a previous short run */
|
290
|
-
lit += 3;
|
291
|
-
*litp = LZO_BYTE((*litp & ~3) | lit);
|
292
|
-
/* copy over the 3 literals that replace the match */
|
293
|
-
copy3(ip-3,m_pos,pd(op,m_pos));
|
294
|
-
o_m3_a++;
|
295
|
-
}
|
296
|
-
/* test if a literal run follows */
|
297
|
-
else if (t == 1 && lit <= 3 && nl == 0 &&
|
298
|
-
ip[0] < 16 && ip[0] != 0 && (lit + 3 + ip[0] < 16))
|
299
|
-
{
|
300
|
-
assert(litp == ip - 3 - lit - 2);
|
301
|
-
assert((lzo_uint)(*litp & 3) == lit);
|
302
|
-
t = *ip++;
|
303
|
-
/* remove short run */
|
304
|
-
*litp &= ~3;
|
305
|
-
/* copy over the 3 literals that replace the match */
|
306
|
-
copy3(ip-4+1,m_pos,pd(op,m_pos));
|
307
|
-
/* move literals 1 byte ahead */
|
308
|
-
litp += 2;
|
309
|
-
if (lit > 0)
|
310
|
-
lzo_memmove(litp+1,litp,lit);
|
311
|
-
/* insert new length of long literal run */
|
312
|
-
lit += 3 + t + 3; assert(lit <= 18);
|
313
|
-
*litp = LZO_BYTE(lit - 3);
|
314
|
-
|
315
|
-
o_m3_b++;
|
316
|
-
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
|
317
|
-
goto copy_literal_run;
|
318
|
-
}
|
319
|
-
}
|
320
|
-
copy_m:
|
321
|
-
*op++ = *m_pos++; *op++ = *m_pos++;
|
322
|
-
do *op++ = *m_pos++; while (--t > 0);
|
323
|
-
}
|
324
|
-
|
325
|
-
match_done:
|
326
|
-
if (next_lit == NO_LIT)
|
327
|
-
{
|
328
|
-
t = ip[-2] & 3;
|
329
|
-
lit = t;
|
330
|
-
litp = ip - 2;
|
331
|
-
}
|
332
|
-
else
|
333
|
-
t = next_lit;
|
334
|
-
assert(t <= 3);
|
335
|
-
next_lit = NO_LIT;
|
336
|
-
if (t == 0)
|
337
|
-
break;
|
338
|
-
/* copy literals */
|
339
|
-
match_next:
|
340
|
-
do *op++ = *ip++; while (--t > 0);
|
341
|
-
t = *ip++;
|
342
|
-
} while (TEST_IP && TEST_OP);
|
343
|
-
}
|
344
|
-
|
345
|
-
/* no EOF code was found */
|
346
|
-
*out_len = pd(op, out);
|
347
|
-
return LZO_E_EOF_NOT_FOUND;
|
348
|
-
|
349
|
-
eof_found:
|
350
|
-
assert(t == 1);
|
351
|
-
#if 0
|
352
|
-
printf("optimize: %5lu %5lu %5lu %5lu %5lu\n",
|
353
|
-
o_m1_a, o_m1_b, o_m2, o_m3_a, o_m3_b);
|
354
|
-
#endif
|
355
|
-
LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
|
356
|
-
LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
|
357
|
-
*out_len = pd(op, out);
|
358
|
-
return (ip == ip_end ? LZO_E_OK :
|
359
|
-
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
|
360
|
-
}
|
361
|
-
|
362
|
-
|
363
|
-
/*
|
364
|
-
vi:ts=4:et
|
365
|
-
*/
|
366
|
-
|