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.
Files changed (126) hide show
  1. data/LICENSE.txt +339 -0
  2. data/README.txt +57 -0
  3. data/ext/compr1b.h +81 -0
  4. data/ext/compr1c.h +81 -0
  5. data/ext/config1.h +61 -0
  6. data/ext/config1a.h +196 -0
  7. data/ext/config1b.h +140 -0
  8. data/ext/config1c.h +145 -0
  9. data/ext/config1f.h +97 -0
  10. data/ext/config1x.h +118 -0
  11. data/ext/config1y.h +66 -0
  12. data/ext/config1z.h +65 -0
  13. data/ext/config2a.h +155 -0
  14. data/ext/extconf.rb +2 -0
  15. data/ext/lzo/lzo1.h +96 -0
  16. data/ext/lzo/lzo1a.h +96 -0
  17. data/ext/lzo/lzo1b.h +160 -0
  18. data/ext/lzo/lzo1c.h +160 -0
  19. data/ext/lzo/lzo1f.h +108 -0
  20. data/ext/lzo/lzo1x.h +177 -0
  21. data/ext/lzo/lzo1y.h +145 -0
  22. data/ext/lzo/lzo1z.h +150 -0
  23. data/ext/lzo/lzo2a.h +92 -0
  24. data/ext/lzo/lzo_asm.h +139 -0
  25. data/ext/lzo/lzoconf.h +417 -0
  26. data/ext/lzo/lzodefs.h +1807 -0
  27. data/ext/lzo/lzoutil.h +73 -0
  28. data/ext/lzo1.c +635 -0
  29. data/ext/lzo1_99.c +130 -0
  30. data/ext/lzo1_cm.ch +52 -0
  31. data/ext/lzo1_d.ch +155 -0
  32. data/ext/lzo1a.c +657 -0
  33. data/ext/lzo1a_99.c +130 -0
  34. data/ext/lzo1a_cm.ch +242 -0
  35. data/ext/lzo1a_cr.ch +128 -0
  36. data/ext/lzo1a_de.h +158 -0
  37. data/ext/lzo1b_1.c +46 -0
  38. data/ext/lzo1b_2.c +46 -0
  39. data/ext/lzo1b_3.c +46 -0
  40. data/ext/lzo1b_4.c +46 -0
  41. data/ext/lzo1b_5.c +46 -0
  42. data/ext/lzo1b_6.c +46 -0
  43. data/ext/lzo1b_7.c +46 -0
  44. data/ext/lzo1b_8.c +46 -0
  45. data/ext/lzo1b_9.c +46 -0
  46. data/ext/lzo1b_99.c +49 -0
  47. data/ext/lzo1b_9x.c +365 -0
  48. data/ext/lzo1b_c.ch +270 -0
  49. data/ext/lzo1b_cc.c +167 -0
  50. data/ext/lzo1b_cc.h +93 -0
  51. data/ext/lzo1b_cm.ch +294 -0
  52. data/ext/lzo1b_cr.ch +126 -0
  53. data/ext/lzo1b_d.ch +282 -0
  54. data/ext/lzo1b_d1.c +46 -0
  55. data/ext/lzo1b_d2.c +46 -0
  56. data/ext/lzo1b_de.h +344 -0
  57. data/ext/lzo1b_r.ch +117 -0
  58. data/ext/lzo1b_rr.c +43 -0
  59. data/ext/lzo1b_sm.ch +210 -0
  60. data/ext/lzo1b_tm.ch +99 -0
  61. data/ext/lzo1b_xx.c +98 -0
  62. data/ext/lzo1c_1.c +46 -0
  63. data/ext/lzo1c_2.c +46 -0
  64. data/ext/lzo1c_3.c +46 -0
  65. data/ext/lzo1c_4.c +46 -0
  66. data/ext/lzo1c_5.c +46 -0
  67. data/ext/lzo1c_6.c +46 -0
  68. data/ext/lzo1c_7.c +46 -0
  69. data/ext/lzo1c_8.c +46 -0
  70. data/ext/lzo1c_9.c +46 -0
  71. data/ext/lzo1c_99.c +49 -0
  72. data/ext/lzo1c_9x.c +379 -0
  73. data/ext/lzo1c_cc.c +167 -0
  74. data/ext/lzo1c_cc.h +93 -0
  75. data/ext/lzo1c_d1.c +46 -0
  76. data/ext/lzo1c_d2.c +46 -0
  77. data/ext/lzo1c_rr.c +43 -0
  78. data/ext/lzo1c_xx.c +98 -0
  79. data/ext/lzo1f_1.c +312 -0
  80. data/ext/lzo1f_9x.c +345 -0
  81. data/ext/lzo1f_d.ch +223 -0
  82. data/ext/lzo1f_d1.c +46 -0
  83. data/ext/lzo1f_d2.c +46 -0
  84. data/ext/lzo1x_1.c +50 -0
  85. data/ext/lzo1x_1k.c +50 -0
  86. data/ext/lzo1x_1l.c +50 -0
  87. data/ext/lzo1x_1o.c +50 -0
  88. data/ext/lzo1x_9x.c +881 -0
  89. data/ext/lzo1x_c.ch +351 -0
  90. data/ext/lzo1x_d.ch +466 -0
  91. data/ext/lzo1x_d1.c +46 -0
  92. data/ext/lzo1x_d2.c +46 -0
  93. data/ext/lzo1x_d3.c +108 -0
  94. data/ext/lzo1x_o.c +45 -0
  95. data/ext/lzo1x_oo.ch +366 -0
  96. data/ext/lzo1y_1.c +50 -0
  97. data/ext/lzo1y_9x.c +42 -0
  98. data/ext/lzo1y_d1.c +46 -0
  99. data/ext/lzo1y_d2.c +46 -0
  100. data/ext/lzo1y_d3.c +45 -0
  101. data/ext/lzo1y_o.c +45 -0
  102. data/ext/lzo1z_9x.c +42 -0
  103. data/ext/lzo1z_d1.c +46 -0
  104. data/ext/lzo1z_d2.c +46 -0
  105. data/ext/lzo1z_d3.c +45 -0
  106. data/ext/lzo2a_9x.c +357 -0
  107. data/ext/lzo2a_d.ch +188 -0
  108. data/ext/lzo2a_d1.c +46 -0
  109. data/ext/lzo2a_d2.c +46 -0
  110. data/ext/lzo_conf.h +323 -0
  111. data/ext/lzo_crc.c +167 -0
  112. data/ext/lzo_dict.h +316 -0
  113. data/ext/lzo_dll.ch +64 -0
  114. data/ext/lzo_init.c +176 -0
  115. data/ext/lzo_mchw.ch +242 -0
  116. data/ext/lzo_ptr.c +92 -0
  117. data/ext/lzo_ptr.h +154 -0
  118. data/ext/lzo_str.c +71 -0
  119. data/ext/lzo_swd.ch +707 -0
  120. data/ext/lzo_util.c +165 -0
  121. data/ext/lzoruby.c +149 -0
  122. data/ext/miniacc.h +6553 -0
  123. data/ext/stats1a.h +137 -0
  124. data/ext/stats1b.h +142 -0
  125. data/ext/stats1c.h +61 -0
  126. metadata +180 -0
data/ext/lzo1b_cc.c ADDED
@@ -0,0 +1,167 @@
1
+ /* lzo1b_cc.c -- LZO1B 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 "config1b.h"
43
+
44
+
45
+ /***********************************************************************
46
+ // compression internal entry point.
47
+ ************************************************************************/
48
+
49
+ int _lzo1b_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
+ _lzo1b_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
+ _lzo1b_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 lzo1b_stats = &lzo_statistics;
127
+
128
+
129
+ void _lzo1b_stats_init(lzo_stats_t *lzo_stats)
130
+ {
131
+ lzo_memset(lzo_stats,0,sizeof(*lzo_stats));
132
+ }
133
+
134
+
135
+ void _lzo1b_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/lzo1b_cc.h ADDED
@@ -0,0 +1,93 @@
1
+ /* lzo1b_cc.h -- definitions for the the LZO1B 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 __LZO1B_CC_H
48
+ #define __LZO1B_CC_H
49
+
50
+
51
+ /***********************************************************************
52
+ //
53
+ ************************************************************************/
54
+
55
+ extern const lzo_compress_t _lzo1b_1_compress_func;
56
+ extern const lzo_compress_t _lzo1b_2_compress_func;
57
+ extern const lzo_compress_t _lzo1b_3_compress_func;
58
+ extern const lzo_compress_t _lzo1b_4_compress_func;
59
+ extern const lzo_compress_t _lzo1b_5_compress_func;
60
+ extern const lzo_compress_t _lzo1b_6_compress_func;
61
+ extern const lzo_compress_t _lzo1b_7_compress_func;
62
+ extern const lzo_compress_t _lzo1b_8_compress_func;
63
+ extern const lzo_compress_t _lzo1b_9_compress_func;
64
+
65
+ extern const lzo_compress_t _lzo1b_99_compress_func;
66
+
67
+
68
+ /***********************************************************************
69
+ //
70
+ ************************************************************************/
71
+
72
+ LZO_EXTERN(lzo_bytep )
73
+ _lzo1b_store_run ( lzo_bytep const oo, const lzo_bytep const ii,
74
+ lzo_uint r_len);
75
+
76
+ #define STORE_RUN _lzo1b_store_run
77
+
78
+
79
+ lzo_compress_t _lzo1b_get_compress_func(int clevel);
80
+
81
+ int _lzo1b_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/lzo1b_cm.ch ADDED
@@ -0,0 +1,294 @@
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
+ */
data/ext/lzo1b_cr.ch ADDED
@@ -0,0 +1,126 @@
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
+ */