/src/lzo-2.10/src/lzo_mchw.ch
Line | Count | Source |
1 | | /* lzo_mchw.ch -- matching functions using a window |
2 | | |
3 | | This file is part of the LZO real-time data compression library. |
4 | | |
5 | | Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer |
6 | | All Rights Reserved. |
7 | | |
8 | | The LZO library is free software; you can redistribute it and/or |
9 | | modify it under the terms of the GNU General Public License as |
10 | | published by the Free Software Foundation; either version 2 of |
11 | | the License, or (at your option) any later version. |
12 | | |
13 | | The LZO library is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with the LZO library; see the file COPYING. |
20 | | If not, write to the Free Software Foundation, Inc., |
21 | | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | |
23 | | Markus F.X.J. Oberhumer |
24 | | <markus@oberhumer.com> |
25 | | http://www.oberhumer.com/opensource/lzo/ |
26 | | */ |
27 | | |
28 | | |
29 | | /*********************************************************************** |
30 | | // |
31 | | ************************************************************************/ |
32 | | |
33 | | typedef struct |
34 | | { |
35 | | unsigned init; |
36 | | |
37 | | lzo_uint look; /* bytes in lookahead buffer */ |
38 | | |
39 | | lzo_uint m_len; |
40 | | lzo_uint m_off; |
41 | | |
42 | | lzo_uint last_m_len; |
43 | | lzo_uint last_m_off; |
44 | | |
45 | | const lzo_bytep bp; |
46 | | const lzo_bytep ip; |
47 | | const lzo_bytep in; |
48 | | const lzo_bytep in_end; |
49 | | lzo_bytep out; |
50 | | |
51 | | lzo_callback_p cb; |
52 | | |
53 | | lzo_uint textsize; /* text size counter */ |
54 | | lzo_uint codesize; /* code size counter */ |
55 | | lzo_uint printcount; /* counter for reporting progress every 1K bytes */ |
56 | | |
57 | | /* some stats */ |
58 | | lzo_uint lit_bytes; |
59 | | lzo_uint match_bytes; |
60 | | lzo_uint rep_bytes; |
61 | | lzo_uint lazy; |
62 | | |
63 | | #if defined(LZO1B) |
64 | | lzo_uint r1_m_len; |
65 | | |
66 | | /* some stats */ |
67 | | lzo_uint r1_r, m3_r, m2_m, m3_m; |
68 | | #endif |
69 | | |
70 | | #if defined(LZO1C) |
71 | | lzo_uint r1_m_len; |
72 | | lzo_bytep m3; |
73 | | |
74 | | /* some stats */ |
75 | | lzo_uint r1_r, m3_r, m2_m, m3_m; |
76 | | #endif |
77 | | |
78 | | #if defined(LZO1F) |
79 | | lzo_uint r1_lit; |
80 | | lzo_uint r1_m_len; |
81 | | |
82 | | /* some stats */ |
83 | | lzo_uint r1_r, m2_m, m3_m; |
84 | | #endif |
85 | | |
86 | | #if defined(LZO1X) || defined(LZO1Y) || defined(LZO1Z) |
87 | | lzo_uint r1_lit; |
88 | | lzo_uint r1_m_len; |
89 | | |
90 | | /* some stats */ |
91 | | lzo_uint m1a_m, m1b_m, m2_m, m3_m, m4_m; |
92 | | lzo_uint lit1_r, lit2_r, lit3_r; |
93 | | #endif |
94 | | |
95 | | #if defined(LZO2A) |
96 | | /* some stats */ |
97 | | lzo_uint m1, m2, m3, m4; |
98 | | #endif |
99 | | } |
100 | | LZO_COMPRESS_T; |
101 | | |
102 | | |
103 | 135M | #define getbyte(c) ((c).ip < (c).in_end ? *((c).ip)++ : (-1)) |
104 | | |
105 | | #include "lzo_swd.ch" |
106 | | |
107 | | |
108 | | /*********************************************************************** |
109 | | // |
110 | | ************************************************************************/ |
111 | | |
112 | | static int |
113 | | init_match ( LZO_COMPRESS_T *c, lzo_swd_p s, |
114 | | const lzo_bytep dict, lzo_uint dict_len, |
115 | | lzo_uint32_t flags ) |
116 | 5.83k | { |
117 | 5.83k | int r; |
118 | | |
119 | 5.83k | assert(!c->init); |
120 | 5.83k | c->init = 1; |
121 | | |
122 | 5.83k | s->c = c; |
123 | | |
124 | 5.83k | c->last_m_len = c->last_m_off = 0; |
125 | | |
126 | 5.83k | c->textsize = c->codesize = c->printcount = 0; |
127 | 5.83k | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; |
128 | 5.83k | c->lazy = 0; |
129 | | |
130 | 5.83k | r = swd_init(s,dict,dict_len); |
131 | 5.83k | if (r != LZO_E_OK) |
132 | 0 | { |
133 | 0 | swd_exit(s); |
134 | 0 | return r; |
135 | 0 | } |
136 | | |
137 | 5.83k | s->use_best_off = (flags & 1) ? 1 : 0; |
138 | 5.83k | return LZO_E_OK; |
139 | 5.83k | } Line | Count | Source | 116 | 521 | { | 117 | 521 | int r; | 118 | | | 119 | 521 | assert(!c->init); | 120 | 521 | c->init = 1; | 121 | | | 122 | 521 | s->c = c; | 123 | | | 124 | 521 | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 521 | c->textsize = c->codesize = c->printcount = 0; | 127 | 521 | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 521 | c->lazy = 0; | 129 | | | 130 | 521 | r = swd_init(s,dict,dict_len); | 131 | 521 | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 521 | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 521 | return LZO_E_OK; | 139 | 521 | } |
Line | Count | Source | 116 | 588 | { | 117 | 588 | int r; | 118 | | | 119 | 588 | assert(!c->init); | 120 | 588 | c->init = 1; | 121 | | | 122 | 588 | s->c = c; | 123 | | | 124 | 588 | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 588 | c->textsize = c->codesize = c->printcount = 0; | 127 | 588 | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 588 | c->lazy = 0; | 129 | | | 130 | 588 | r = swd_init(s,dict,dict_len); | 131 | 588 | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 588 | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 588 | return LZO_E_OK; | 139 | 588 | } |
Line | Count | Source | 116 | 648 | { | 117 | 648 | int r; | 118 | | | 119 | 648 | assert(!c->init); | 120 | 648 | c->init = 1; | 121 | | | 122 | 648 | s->c = c; | 123 | | | 124 | 648 | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 648 | c->textsize = c->codesize = c->printcount = 0; | 127 | 648 | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 648 | c->lazy = 0; | 129 | | | 130 | 648 | r = swd_init(s,dict,dict_len); | 131 | 648 | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 648 | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 648 | return LZO_E_OK; | 139 | 648 | } |
Line | Count | Source | 116 | 1.06k | { | 117 | 1.06k | int r; | 118 | | | 119 | 1.06k | assert(!c->init); | 120 | 1.06k | c->init = 1; | 121 | | | 122 | 1.06k | s->c = c; | 123 | | | 124 | 1.06k | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 1.06k | c->textsize = c->codesize = c->printcount = 0; | 127 | 1.06k | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 1.06k | c->lazy = 0; | 129 | | | 130 | 1.06k | r = swd_init(s,dict,dict_len); | 131 | 1.06k | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 1.06k | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 1.06k | return LZO_E_OK; | 139 | 1.06k | } |
Line | Count | Source | 116 | 1.05k | { | 117 | 1.05k | int r; | 118 | | | 119 | 1.05k | assert(!c->init); | 120 | 1.05k | c->init = 1; | 121 | | | 122 | 1.05k | s->c = c; | 123 | | | 124 | 1.05k | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 1.05k | c->textsize = c->codesize = c->printcount = 0; | 127 | 1.05k | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 1.05k | c->lazy = 0; | 129 | | | 130 | 1.05k | r = swd_init(s,dict,dict_len); | 131 | 1.05k | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 1.05k | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 1.05k | return LZO_E_OK; | 139 | 1.05k | } |
Line | Count | Source | 116 | 1.32k | { | 117 | 1.32k | int r; | 118 | | | 119 | 1.32k | assert(!c->init); | 120 | 1.32k | c->init = 1; | 121 | | | 122 | 1.32k | s->c = c; | 123 | | | 124 | 1.32k | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 1.32k | c->textsize = c->codesize = c->printcount = 0; | 127 | 1.32k | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 1.32k | c->lazy = 0; | 129 | | | 130 | 1.32k | r = swd_init(s,dict,dict_len); | 131 | 1.32k | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 1.32k | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 1.32k | return LZO_E_OK; | 139 | 1.32k | } |
Line | Count | Source | 116 | 646 | { | 117 | 646 | int r; | 118 | | | 119 | 646 | assert(!c->init); | 120 | 646 | c->init = 1; | 121 | | | 122 | 646 | s->c = c; | 123 | | | 124 | 646 | c->last_m_len = c->last_m_off = 0; | 125 | | | 126 | 646 | c->textsize = c->codesize = c->printcount = 0; | 127 | 646 | c->lit_bytes = c->match_bytes = c->rep_bytes = 0; | 128 | 646 | c->lazy = 0; | 129 | | | 130 | 646 | r = swd_init(s,dict,dict_len); | 131 | 646 | if (r != LZO_E_OK) | 132 | 0 | { | 133 | 0 | swd_exit(s); | 134 | 0 | return r; | 135 | 0 | } | 136 | | | 137 | 646 | s->use_best_off = (flags & 1) ? 1 : 0; | 138 | 646 | return LZO_E_OK; | 139 | 646 | } |
|
140 | | |
141 | | |
142 | | /*********************************************************************** |
143 | | // |
144 | | ************************************************************************/ |
145 | | |
146 | | static int |
147 | | find_match ( LZO_COMPRESS_T *c, lzo_swd_p s, |
148 | | lzo_uint this_len, lzo_uint skip ) |
149 | 49.1M | { |
150 | 49.1M | assert(c->init); |
151 | | |
152 | 49.1M | if (skip > 0) |
153 | 2.73M | { |
154 | 2.73M | assert(this_len >= skip); |
155 | 2.73M | swd_accept(s, this_len - skip); |
156 | 2.73M | c->textsize += this_len - skip + 1; |
157 | 2.73M | } |
158 | 46.4M | else |
159 | 46.4M | { |
160 | 46.4M | assert(this_len <= 1); |
161 | 46.4M | c->textsize += this_len - skip; |
162 | 46.4M | } |
163 | | |
164 | 49.1M | s->m_len = SWD_THRESHOLD; |
165 | 49.1M | s->m_off = 0; |
166 | | #ifdef SWD_BEST_OFF |
167 | 31.8M | if (s->use_best_off) |
168 | 31.8M | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); |
169 | | #endif |
170 | 49.1M | swd_findbest(s); |
171 | 49.1M | c->m_len = s->m_len; |
172 | 49.1M | c->m_off = s->m_off; |
173 | | |
174 | 49.1M | swd_getbyte(s); |
175 | | |
176 | 49.1M | if (s->b_char < 0) |
177 | 5.83k | { |
178 | 5.83k | c->look = 0; |
179 | 5.83k | c->m_len = 0; |
180 | 5.83k | swd_exit(s); |
181 | 5.83k | } |
182 | 49.1M | else |
183 | 49.1M | { |
184 | 49.1M | c->look = s->look + 1; |
185 | 49.1M | } |
186 | 49.1M | c->bp = c->ip - c->look; |
187 | | |
188 | | #if 0 |
189 | | /* brute force match search */ |
190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) |
191 | | { |
192 | | const lzo_bytep ip = c->bp; |
193 | | const lzo_bytep m = c->bp - c->m_off; |
194 | | const lzo_bytep in = c->in; |
195 | | |
196 | | if (ip - in > s->swd_n) |
197 | | in = ip - s->swd_n; |
198 | | for (;;) |
199 | | { |
200 | | while (*in != *ip) |
201 | | in++; |
202 | | if (in == ip) |
203 | | break; |
204 | | if (in != m) |
205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) |
206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); |
207 | | in++; |
208 | | } |
209 | | } |
210 | | #endif |
211 | | |
212 | 49.1M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) |
213 | 0 | { |
214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); |
215 | 0 | c->printcount += 1024; |
216 | 0 | } |
217 | | |
218 | 49.1M | return LZO_E_OK; |
219 | 49.1M | } Line | Count | Source | 149 | 3.16M | { | 150 | 3.16M | assert(c->init); | 151 | | | 152 | 3.16M | if (skip > 0) | 153 | 126k | { | 154 | 126k | assert(this_len >= skip); | 155 | 126k | swd_accept(s, this_len - skip); | 156 | 126k | c->textsize += this_len - skip + 1; | 157 | 126k | } | 158 | 3.03M | else | 159 | 3.03M | { | 160 | 3.03M | assert(this_len <= 1); | 161 | 3.03M | c->textsize += this_len - skip; | 162 | 3.03M | } | 163 | | | 164 | 3.16M | s->m_len = SWD_THRESHOLD; | 165 | 3.16M | s->m_off = 0; | 166 | | #ifdef SWD_BEST_OFF | 167 | | if (s->use_best_off) | 168 | | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | | #endif | 170 | 3.16M | swd_findbest(s); | 171 | 3.16M | c->m_len = s->m_len; | 172 | 3.16M | c->m_off = s->m_off; | 173 | | | 174 | 3.16M | swd_getbyte(s); | 175 | | | 176 | 3.16M | if (s->b_char < 0) | 177 | 521 | { | 178 | 521 | c->look = 0; | 179 | 521 | c->m_len = 0; | 180 | 521 | swd_exit(s); | 181 | 521 | } | 182 | 3.16M | else | 183 | 3.16M | { | 184 | 3.16M | c->look = s->look + 1; | 185 | 3.16M | } | 186 | 3.16M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 3.16M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 3.16M | return LZO_E_OK; | 219 | 3.16M | } |
Line | Count | Source | 149 | 5.70M | { | 150 | 5.70M | assert(c->init); | 151 | | | 152 | 5.70M | if (skip > 0) | 153 | 151k | { | 154 | 151k | assert(this_len >= skip); | 155 | 151k | swd_accept(s, this_len - skip); | 156 | 151k | c->textsize += this_len - skip + 1; | 157 | 151k | } | 158 | 5.55M | else | 159 | 5.55M | { | 160 | 5.55M | assert(this_len <= 1); | 161 | 5.55M | c->textsize += this_len - skip; | 162 | 5.55M | } | 163 | | | 164 | 5.70M | s->m_len = SWD_THRESHOLD; | 165 | 5.70M | s->m_off = 0; | 166 | | #ifdef SWD_BEST_OFF | 167 | | if (s->use_best_off) | 168 | | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | | #endif | 170 | 5.70M | swd_findbest(s); | 171 | 5.70M | c->m_len = s->m_len; | 172 | 5.70M | c->m_off = s->m_off; | 173 | | | 174 | 5.70M | swd_getbyte(s); | 175 | | | 176 | 5.70M | if (s->b_char < 0) | 177 | 588 | { | 178 | 588 | c->look = 0; | 179 | 588 | c->m_len = 0; | 180 | 588 | swd_exit(s); | 181 | 588 | } | 182 | 5.70M | else | 183 | 5.70M | { | 184 | 5.70M | c->look = s->look + 1; | 185 | 5.70M | } | 186 | 5.70M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 5.70M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 5.70M | return LZO_E_OK; | 219 | 5.70M | } |
Line | Count | Source | 149 | 6.00M | { | 150 | 6.00M | assert(c->init); | 151 | | | 152 | 6.00M | if (skip > 0) | 153 | 337k | { | 154 | 337k | assert(this_len >= skip); | 155 | 337k | swd_accept(s, this_len - skip); | 156 | 337k | c->textsize += this_len - skip + 1; | 157 | 337k | } | 158 | 5.66M | else | 159 | 5.66M | { | 160 | 5.66M | assert(this_len <= 1); | 161 | 5.66M | c->textsize += this_len - skip; | 162 | 5.66M | } | 163 | | | 164 | 6.00M | s->m_len = SWD_THRESHOLD; | 165 | 6.00M | s->m_off = 0; | 166 | | #ifdef SWD_BEST_OFF | 167 | | if (s->use_best_off) | 168 | | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | | #endif | 170 | 6.00M | swd_findbest(s); | 171 | 6.00M | c->m_len = s->m_len; | 172 | 6.00M | c->m_off = s->m_off; | 173 | | | 174 | 6.00M | swd_getbyte(s); | 175 | | | 176 | 6.00M | if (s->b_char < 0) | 177 | 648 | { | 178 | 648 | c->look = 0; | 179 | 648 | c->m_len = 0; | 180 | 648 | swd_exit(s); | 181 | 648 | } | 182 | 6.00M | else | 183 | 6.00M | { | 184 | 6.00M | c->look = s->look + 1; | 185 | 6.00M | } | 186 | 6.00M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 6.00M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 6.00M | return LZO_E_OK; | 219 | 6.00M | } |
Line | Count | Source | 149 | 7.37M | { | 150 | 7.37M | assert(c->init); | 151 | | | 152 | 7.37M | if (skip > 0) | 153 | 633k | { | 154 | 633k | assert(this_len >= skip); | 155 | 633k | swd_accept(s, this_len - skip); | 156 | 633k | c->textsize += this_len - skip + 1; | 157 | 633k | } | 158 | 6.74M | else | 159 | 6.74M | { | 160 | 6.74M | assert(this_len <= 1); | 161 | 6.74M | c->textsize += this_len - skip; | 162 | 6.74M | } | 163 | | | 164 | 7.37M | s->m_len = SWD_THRESHOLD; | 165 | 7.37M | s->m_off = 0; | 166 | 7.37M | #ifdef SWD_BEST_OFF | 167 | 7.37M | if (s->use_best_off) | 168 | 7.37M | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | 7.37M | #endif | 170 | 7.37M | swd_findbest(s); | 171 | 7.37M | c->m_len = s->m_len; | 172 | 7.37M | c->m_off = s->m_off; | 173 | | | 174 | 7.37M | swd_getbyte(s); | 175 | | | 176 | 7.37M | if (s->b_char < 0) | 177 | 1.06k | { | 178 | 1.06k | c->look = 0; | 179 | 1.06k | c->m_len = 0; | 180 | 1.06k | swd_exit(s); | 181 | 1.06k | } | 182 | 7.37M | else | 183 | 7.37M | { | 184 | 7.37M | c->look = s->look + 1; | 185 | 7.37M | } | 186 | 7.37M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 7.37M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 7.37M | return LZO_E_OK; | 219 | 7.37M | } |
Line | Count | Source | 149 | 12.3M | { | 150 | 12.3M | assert(c->init); | 151 | | | 152 | 12.3M | if (skip > 0) | 153 | 599k | { | 154 | 599k | assert(this_len >= skip); | 155 | 599k | swd_accept(s, this_len - skip); | 156 | 599k | c->textsize += this_len - skip + 1; | 157 | 599k | } | 158 | 11.7M | else | 159 | 11.7M | { | 160 | 11.7M | assert(this_len <= 1); | 161 | 11.7M | c->textsize += this_len - skip; | 162 | 11.7M | } | 163 | | | 164 | 12.3M | s->m_len = SWD_THRESHOLD; | 165 | 12.3M | s->m_off = 0; | 166 | 12.3M | #ifdef SWD_BEST_OFF | 167 | 12.3M | if (s->use_best_off) | 168 | 12.3M | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | 12.3M | #endif | 170 | 12.3M | swd_findbest(s); | 171 | 12.3M | c->m_len = s->m_len; | 172 | 12.3M | c->m_off = s->m_off; | 173 | | | 174 | 12.3M | swd_getbyte(s); | 175 | | | 176 | 12.3M | if (s->b_char < 0) | 177 | 1.05k | { | 178 | 1.05k | c->look = 0; | 179 | 1.05k | c->m_len = 0; | 180 | 1.05k | swd_exit(s); | 181 | 1.05k | } | 182 | 12.3M | else | 183 | 12.3M | { | 184 | 12.3M | c->look = s->look + 1; | 185 | 12.3M | } | 186 | 12.3M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 12.3M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 12.3M | return LZO_E_OK; | 219 | 12.3M | } |
Line | Count | Source | 149 | 12.0M | { | 150 | 12.0M | assert(c->init); | 151 | | | 152 | 12.0M | if (skip > 0) | 153 | 737k | { | 154 | 737k | assert(this_len >= skip); | 155 | 737k | swd_accept(s, this_len - skip); | 156 | 737k | c->textsize += this_len - skip + 1; | 157 | 737k | } | 158 | 11.3M | else | 159 | 11.3M | { | 160 | 11.3M | assert(this_len <= 1); | 161 | 11.3M | c->textsize += this_len - skip; | 162 | 11.3M | } | 163 | | | 164 | 12.0M | s->m_len = SWD_THRESHOLD; | 165 | 12.0M | s->m_off = 0; | 166 | 12.0M | #ifdef SWD_BEST_OFF | 167 | 12.0M | if (s->use_best_off) | 168 | 12.0M | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | 12.0M | #endif | 170 | 12.0M | swd_findbest(s); | 171 | 12.0M | c->m_len = s->m_len; | 172 | 12.0M | c->m_off = s->m_off; | 173 | | | 174 | 12.0M | swd_getbyte(s); | 175 | | | 176 | 12.0M | if (s->b_char < 0) | 177 | 1.32k | { | 178 | 1.32k | c->look = 0; | 179 | 1.32k | c->m_len = 0; | 180 | 1.32k | swd_exit(s); | 181 | 1.32k | } | 182 | 12.0M | else | 183 | 12.0M | { | 184 | 12.0M | c->look = s->look + 1; | 185 | 12.0M | } | 186 | 12.0M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 12.0M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 12.0M | return LZO_E_OK; | 219 | 12.0M | } |
Line | Count | Source | 149 | 2.43M | { | 150 | 2.43M | assert(c->init); | 151 | | | 152 | 2.43M | if (skip > 0) | 153 | 145k | { | 154 | 145k | assert(this_len >= skip); | 155 | 145k | swd_accept(s, this_len - skip); | 156 | 145k | c->textsize += this_len - skip + 1; | 157 | 145k | } | 158 | 2.28M | else | 159 | 2.28M | { | 160 | 2.28M | assert(this_len <= 1); | 161 | 2.28M | c->textsize += this_len - skip; | 162 | 2.28M | } | 163 | | | 164 | 2.43M | s->m_len = SWD_THRESHOLD; | 165 | 2.43M | s->m_off = 0; | 166 | | #ifdef SWD_BEST_OFF | 167 | | if (s->use_best_off) | 168 | | lzo_memset(s->best_pos,0,sizeof(s->best_pos)); | 169 | | #endif | 170 | 2.43M | swd_findbest(s); | 171 | 2.43M | c->m_len = s->m_len; | 172 | 2.43M | c->m_off = s->m_off; | 173 | | | 174 | 2.43M | swd_getbyte(s); | 175 | | | 176 | 2.43M | if (s->b_char < 0) | 177 | 646 | { | 178 | 646 | c->look = 0; | 179 | 646 | c->m_len = 0; | 180 | 646 | swd_exit(s); | 181 | 646 | } | 182 | 2.43M | else | 183 | 2.43M | { | 184 | 2.43M | c->look = s->look + 1; | 185 | 2.43M | } | 186 | 2.43M | c->bp = c->ip - c->look; | 187 | | | 188 | | #if 0 | 189 | | /* brute force match search */ | 190 | | if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) | 191 | | { | 192 | | const lzo_bytep ip = c->bp; | 193 | | const lzo_bytep m = c->bp - c->m_off; | 194 | | const lzo_bytep in = c->in; | 195 | | | 196 | | if (ip - in > s->swd_n) | 197 | | in = ip - s->swd_n; | 198 | | for (;;) | 199 | | { | 200 | | while (*in != *ip) | 201 | | in++; | 202 | | if (in == ip) | 203 | | break; | 204 | | if (in != m) | 205 | | if (lzo_memcmp(in,ip,c->m_len+1) == 0) | 206 | | printf("%p %p %p %5d\n",in,ip,m,c->m_len); | 207 | | in++; | 208 | | } | 209 | | } | 210 | | #endif | 211 | | | 212 | 2.43M | if (c->cb && c->cb->nprogress && c->textsize > c->printcount) | 213 | 0 | { | 214 | 0 | (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0); | 215 | 0 | c->printcount += 1024; | 216 | 0 | } | 217 | | | 218 | 2.43M | return LZO_E_OK; | 219 | 2.43M | } |
|
220 | | |
221 | | |
222 | | /* vim:set ts=4 sw=4 et: */ |