Coverage Report

Created: 2026-12-01 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/lzo-2.10/src/lzo1b_c.ch
Line
Count
Source
1
/* lzo1b_c.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) 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
34
#if !defined(LZO_HAVE_R1) && !defined(LZO_NO_R1)
35
#  define LZO_HAVE_R1 1
36
#endif
37
38
#if !defined(LZO_HAVE_M3) && !defined(LZO_NO_M3)
39
#  if (M3O_BITS < 8)
40
#    define LZO_HAVE_M3 1
41
#  endif
42
#endif
43
44
45
#define MI      /*empty*/
46
#define SI      MI
47
#if (DD_BITS > 0)
48
506k
#define DI      ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,drun,dv,ii,in); MI
49
242k
#define XI      assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
50
#else
51
185k
#define DI      ++ii; DINDEX1(dindex,ii); UPDATE_I(dict,0,dindex,ii,in); MI
52
291k
#define XI      assert(ii < ip); ii = ip;
53
#endif
54
55
56
/***********************************************************************
57
// compress a block of data.
58
//
59
// I really apologize for this spaghetti code.
60
************************************************************************/
61
62
#ifdef __cplusplus
63
extern "C" {
64
#endif
65
LZO_PRIVATE(int)
66
do_compress    ( const lzo_bytep in , lzo_uint  in_len,
67
                       lzo_bytep out, lzo_uintp out_len,
68
                       lzo_voidp wrkmem )
69
6.49k
{
70
6.49k
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
4.91k
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
6.49k
    lzo_bytep op;
78
6.49k
    const lzo_bytep const in_end = in + in_len;
79
6.49k
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
6.49k
    const lzo_bytep ii;
81
#if defined(LZO_HAVE_R1)
82
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
#endif
84
#if defined(LZO_HAVE_M3)
85
1.83k
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
6.49k
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
4.66k
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
6.49k
    op = out;
109
6.49k
    ip = in;
110
6.49k
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
4.91k
    DVAL_FIRST(dv,ip);
115
4.91k
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
4.91k
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
6.49k
    assert(ip < ip_end);
123
6.49k
    for (;;)
124
45.5M
    {
125
45.5M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
45.5M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
45.5M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
45.5M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
45.5M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
45.5M
#endif
143
144
45.5M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
405k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
405k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
405k
#endif
150
151
36.4M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
44.4M
literal:
162
#if (DD_BITS == 0)
163
9.07M
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
44.4M
        if (++ip >= ip_end)
166
1.80k
            break;
167
#if (DD_BITS > 0)
168
35.3M
        DVAL_NEXT(dv,ip);
169
35.3M
#endif
170
9.06M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
9.06M
match:
179
#if (DD_BITS == 0)
180
291k
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
1.11M
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
1.11M
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
1.11M
#endif
188
189
1.11M
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
1.11M
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
#endif
203
204
1.11M
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
1.11M
        assert(ii == ip);
209
210
1.11M
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
6.49k
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
6.49k
    if (pd(in_end,ii) > 0)
249
5.76k
    {
250
5.76k
        lzo_uint t = pd(in_end,ii);
251
5.76k
        op = STORE_RUN(op,ii,t);
252
5.76k
    }
253
254
6.49k
    *out_len = pd(op, out);
255
6.49k
    return LZO_E_OK;                /* compression went ok */
256
6.49k
}
lzo1_99.c:do_compress
Line
Count
Source
69
410
{
70
410
    const lzo_bytep ip;
71
410
#if (DD_BITS > 0)
72
410
#if defined(__LZO_HASH_INCREMENTAL)
73
410
    lzo_xint dv;
74
410
#endif
75
410
    unsigned drun = 0;
76
410
#endif
77
410
    lzo_bytep op;
78
410
    const lzo_bytep const in_end = in + in_len;
79
410
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
410
    const lzo_bytep ii;
81
#if defined(LZO_HAVE_R1)
82
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
410
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
410
#if (LZO_DETERMINISTIC)
104
410
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
410
#endif
106
107
108
410
    op = out;
109
410
    ip = in;
110
410
    ii = ip;            /* point to start of current literal run */
111
112
113
410
#if (DD_BITS > 0)
114
410
    DVAL_FIRST(dv,ip);
115
410
    UPDATE_D(dict,drun,dv,ip,in);
116
410
    ip++;
117
410
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
410
    assert(ip < ip_end);
123
410
    for (;;)
124
8.69M
    {
125
8.69M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
8.69M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
8.69M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
8.69M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
8.69M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
8.69M
#endif
143
144
8.69M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
8.69M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
8.69M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
8.69M
#endif
150
151
8.69M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
8.59M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
8.59M
        if (++ip >= ip_end)
166
120
            break;
167
8.59M
#if (DD_BITS > 0)
168
8.59M
        DVAL_NEXT(dv,ip);
169
8.59M
#endif
170
8.59M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
102k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
102k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
102k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
102k
#endif
188
189
102k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
102k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
#endif
203
204
102k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
102k
        assert(ii == ip);
209
210
102k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
410
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
410
    if (pd(in_end,ii) > 0)
249
340
    {
250
340
        lzo_uint t = pd(in_end,ii);
251
340
        op = STORE_RUN(op,ii,t);
252
340
    }
253
254
410
    *out_len = pd(op, out);
255
410
    return LZO_E_OK;                /* compression went ok */
256
410
}
lzo1a_99.c:do_compress
Line
Count
Source
69
421
{
70
421
    const lzo_bytep ip;
71
421
#if (DD_BITS > 0)
72
421
#if defined(__LZO_HASH_INCREMENTAL)
73
421
    lzo_xint dv;
74
421
#endif
75
421
    unsigned drun = 0;
76
421
#endif
77
421
    lzo_bytep op;
78
421
    const lzo_bytep const in_end = in + in_len;
79
421
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
421
    const lzo_bytep ii;
81
421
#if defined(LZO_HAVE_R1)
82
421
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
421
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
421
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
421
#if (LZO_DETERMINISTIC)
104
421
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
421
#endif
106
107
108
421
    op = out;
109
421
    ip = in;
110
421
    ii = ip;            /* point to start of current literal run */
111
112
113
421
#if (DD_BITS > 0)
114
421
    DVAL_FIRST(dv,ip);
115
421
    UPDATE_D(dict,drun,dv,ip,in);
116
421
    ip++;
117
421
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
421
    assert(ip < ip_end);
123
421
    for (;;)
124
11.8M
    {
125
11.8M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
11.8M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
11.8M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
11.8M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
11.8M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
11.8M
#endif
143
144
11.8M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
11.8M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
11.8M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
11.8M
#endif
150
151
11.8M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
11.6M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
11.6M
        if (++ip >= ip_end)
166
117
            break;
167
11.6M
#if (DD_BITS > 0)
168
11.6M
        DVAL_NEXT(dv,ip);
169
11.6M
#endif
170
11.6M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
204k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
204k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
204k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
204k
#endif
188
189
204k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
204k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
#endif
203
204
204k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
203k
        assert(ii == ip);
209
210
203k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
421
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
421
    if (pd(in_end,ii) > 0)
249
349
    {
250
349
        lzo_uint t = pd(in_end,ii);
251
349
        op = STORE_RUN(op,ii,t);
252
349
    }
253
254
421
    *out_len = pd(op, out);
255
421
    return LZO_E_OK;                /* compression went ok */
256
421
}
lzo1b_1.c:do_compress
Line
Count
Source
69
378
{
70
378
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
378
    lzo_bytep op;
78
378
    const lzo_bytep const in_end = in + in_len;
79
378
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
378
    const lzo_bytep ii;
81
378
#if defined(LZO_HAVE_R1)
82
378
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
378
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
378
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
378
#if (LZO_DETERMINISTIC)
104
378
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
378
#endif
106
107
108
378
    op = out;
109
378
    ip = in;
110
378
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
    DVAL_FIRST(dv,ip);
115
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
    DVAL_NEXT(dv,ip);
118
#else
119
378
    ip++;
120
378
#endif
121
122
378
    assert(ip < ip_end);
123
378
    for (;;)
124
2.17M
    {
125
2.17M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.17M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
2.17M
#if (DD_BITS == 0)
131
2.17M
        lzo_uint dindex;
132
2.17M
#endif
133
2.17M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.17M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.17M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.17M
#endif
143
144
2.17M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
74.6k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
74.6k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
74.6k
#endif
150
151
74.6k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.12M
literal:
162
2.12M
#if (DD_BITS == 0)
163
2.12M
        UPDATE_I(dict,0,dindex,ip,in);
164
2.12M
#endif
165
2.12M
        if (++ip >= ip_end)
166
135
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
2.12M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
2.12M
match:
179
49.7k
#if (DD_BITS == 0)
180
49.7k
        UPDATE_I(dict,0,dindex,ip,in);
181
49.7k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
49.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
49.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
49.7k
#endif
188
189
49.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
49.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
49.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
49.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
49.7k
#endif
203
204
49.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
49.4k
        assert(ii == ip);
209
210
49.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
378
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
378
    if (pd(in_end,ii) > 0)
249
343
    {
250
343
        lzo_uint t = pd(in_end,ii);
251
343
        op = STORE_RUN(op,ii,t);
252
343
    }
253
254
378
    *out_len = pd(op, out);
255
378
    return LZO_E_OK;                /* compression went ok */
256
378
}
lzo1b_2.c:do_compress
Line
Count
Source
69
348
{
70
348
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
348
    lzo_bytep op;
78
348
    const lzo_bytep const in_end = in + in_len;
79
348
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
348
    const lzo_bytep ii;
81
348
#if defined(LZO_HAVE_R1)
82
348
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
348
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
348
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
348
#if (LZO_DETERMINISTIC)
104
348
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
348
#endif
106
107
108
348
    op = out;
109
348
    ip = in;
110
348
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
    DVAL_FIRST(dv,ip);
115
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
    DVAL_NEXT(dv,ip);
118
#else
119
348
    ip++;
120
348
#endif
121
122
348
    assert(ip < ip_end);
123
348
    for (;;)
124
2.10M
    {
125
2.10M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.10M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
2.10M
#if (DD_BITS == 0)
131
2.10M
        lzo_uint dindex;
132
2.10M
#endif
133
2.10M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.10M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.10M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.10M
#endif
143
144
2.10M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
150k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
150k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
150k
#endif
150
151
150k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.98M
literal:
162
1.98M
#if (DD_BITS == 0)
163
1.98M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.98M
#endif
165
1.98M
        if (++ip >= ip_end)
166
155
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.98M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.98M
match:
179
113k
#if (DD_BITS == 0)
180
113k
        UPDATE_I(dict,0,dindex,ip,in);
181
113k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
113k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
113k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
113k
#endif
188
189
113k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
113k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
113k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
113k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
113k
#endif
203
204
113k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
113k
        assert(ii == ip);
209
210
113k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
348
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
348
    if (pd(in_end,ii) > 0)
249
325
    {
250
325
        lzo_uint t = pd(in_end,ii);
251
325
        op = STORE_RUN(op,ii,t);
252
325
    }
253
254
348
    *out_len = pd(op, out);
255
348
    return LZO_E_OK;                /* compression went ok */
256
348
}
lzo1b_3.c:do_compress
Line
Count
Source
69
365
{
70
365
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
365
    lzo_bytep op;
78
365
    const lzo_bytep const in_end = in + in_len;
79
365
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
365
    const lzo_bytep ii;
81
365
#if defined(LZO_HAVE_R1)
82
365
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
365
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
365
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
365
#if (LZO_DETERMINISTIC)
104
365
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
365
#endif
106
107
108
365
    op = out;
109
365
    ip = in;
110
365
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
    DVAL_FIRST(dv,ip);
115
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
    DVAL_NEXT(dv,ip);
118
#else
119
365
    ip++;
120
365
#endif
121
122
365
    assert(ip < ip_end);
123
365
    for (;;)
124
1.19M
    {
125
1.19M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.19M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.19M
#if (DD_BITS == 0)
131
1.19M
        lzo_uint dindex;
132
1.19M
#endif
133
1.19M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.19M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.19M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.19M
#endif
143
144
1.19M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
64.5k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
64.5k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
64.5k
#endif
150
151
64.5k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.15M
literal:
162
1.15M
#if (DD_BITS == 0)
163
1.15M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.15M
#endif
165
1.15M
        if (++ip >= ip_end)
166
134
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.15M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.15M
match:
179
36.1k
#if (DD_BITS == 0)
180
36.1k
        UPDATE_I(dict,0,dindex,ip,in);
181
36.1k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
36.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
36.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
36.1k
#endif
188
189
36.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
36.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
36.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
36.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
36.1k
#endif
203
204
36.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
35.9k
        assert(ii == ip);
209
210
35.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
365
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
365
    if (pd(in_end,ii) > 0)
249
339
    {
250
339
        lzo_uint t = pd(in_end,ii);
251
339
        op = STORE_RUN(op,ii,t);
252
339
    }
253
254
365
    *out_len = pd(op, out);
255
365
    return LZO_E_OK;                /* compression went ok */
256
365
}
lzo1b_4.c:do_compress
Line
Count
Source
69
387
{
70
387
    const lzo_bytep ip;
71
387
#if (DD_BITS > 0)
72
387
#if defined(__LZO_HASH_INCREMENTAL)
73
387
    lzo_xint dv;
74
387
#endif
75
387
    unsigned drun = 0;
76
387
#endif
77
387
    lzo_bytep op;
78
387
    const lzo_bytep const in_end = in + in_len;
79
387
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
387
    const lzo_bytep ii;
81
387
#if defined(LZO_HAVE_R1)
82
387
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
387
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
387
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
387
#if (LZO_DETERMINISTIC)
104
387
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
387
#endif
106
107
108
387
    op = out;
109
387
    ip = in;
110
387
    ii = ip;            /* point to start of current literal run */
111
112
113
387
#if (DD_BITS > 0)
114
387
    DVAL_FIRST(dv,ip);
115
387
    UPDATE_D(dict,drun,dv,ip,in);
116
387
    ip++;
117
387
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
387
    assert(ip < ip_end);
123
387
    for (;;)
124
1.02M
    {
125
1.02M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.02M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.02M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.02M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.02M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.02M
#endif
143
144
1.02M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
1.00M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
959k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
959k
        if (++ip >= ip_end)
166
98
            break;
167
959k
#if (DD_BITS > 0)
168
959k
        DVAL_NEXT(dv,ip);
169
959k
#endif
170
959k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
65.1k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
65.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
65.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
65.1k
#endif
188
189
65.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
65.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
65.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
65.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
65.1k
#endif
203
204
65.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
64.8k
        assert(ii == ip);
209
210
64.8k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
387
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
387
    if (pd(in_end,ii) > 0)
249
359
    {
250
359
        lzo_uint t = pd(in_end,ii);
251
359
        op = STORE_RUN(op,ii,t);
252
359
    }
253
254
387
    *out_len = pd(op, out);
255
387
    return LZO_E_OK;                /* compression went ok */
256
387
}
lzo1b_5.c:do_compress
Line
Count
Source
69
345
{
70
345
    const lzo_bytep ip;
71
345
#if (DD_BITS > 0)
72
345
#if defined(__LZO_HASH_INCREMENTAL)
73
345
    lzo_xint dv;
74
345
#endif
75
345
    unsigned drun = 0;
76
345
#endif
77
345
    lzo_bytep op;
78
345
    const lzo_bytep const in_end = in + in_len;
79
345
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
345
    const lzo_bytep ii;
81
345
#if defined(LZO_HAVE_R1)
82
345
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
345
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
345
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
345
#if (LZO_DETERMINISTIC)
104
345
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
345
#endif
106
107
108
345
    op = out;
109
345
    ip = in;
110
345
    ii = ip;            /* point to start of current literal run */
111
112
113
345
#if (DD_BITS > 0)
114
345
    DVAL_FIRST(dv,ip);
115
345
    UPDATE_D(dict,drun,dv,ip,in);
116
345
    ip++;
117
345
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
345
    assert(ip < ip_end);
123
345
    for (;;)
124
517k
    {
125
517k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
517k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
517k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
517k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
517k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
517k
#endif
143
144
517k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
507k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
477k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
477k
        if (++ip >= ip_end)
166
64
            break;
167
477k
#if (DD_BITS > 0)
168
477k
        DVAL_NEXT(dv,ip);
169
477k
#endif
170
477k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
40.4k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
40.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
40.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
40.4k
#endif
188
189
40.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
40.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
40.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
40.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
40.4k
#endif
203
204
40.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
40.1k
        assert(ii == ip);
209
210
40.1k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
345
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
345
    if (pd(in_end,ii) > 0)
249
317
    {
250
317
        lzo_uint t = pd(in_end,ii);
251
317
        op = STORE_RUN(op,ii,t);
252
317
    }
253
254
345
    *out_len = pd(op, out);
255
345
    return LZO_E_OK;                /* compression went ok */
256
345
}
lzo1b_6.c:do_compress
Line
Count
Source
69
377
{
70
377
    const lzo_bytep ip;
71
377
#if (DD_BITS > 0)
72
377
#if defined(__LZO_HASH_INCREMENTAL)
73
377
    lzo_xint dv;
74
377
#endif
75
377
    unsigned drun = 0;
76
377
#endif
77
377
    lzo_bytep op;
78
377
    const lzo_bytep const in_end = in + in_len;
79
377
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
377
    const lzo_bytep ii;
81
377
#if defined(LZO_HAVE_R1)
82
377
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
377
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
377
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
377
#if (LZO_DETERMINISTIC)
104
377
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
377
#endif
106
107
108
377
    op = out;
109
377
    ip = in;
110
377
    ii = ip;            /* point to start of current literal run */
111
112
113
377
#if (DD_BITS > 0)
114
377
    DVAL_FIRST(dv,ip);
115
377
    UPDATE_D(dict,drun,dv,ip,in);
116
377
    ip++;
117
377
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
377
    assert(ip < ip_end);
123
377
    for (;;)
124
2.34M
    {
125
2.34M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.34M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.34M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.34M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.34M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.34M
#endif
143
144
2.34M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
2.33M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.30M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.30M
        if (++ip >= ip_end)
166
92
            break;
167
2.30M
#if (DD_BITS > 0)
168
2.30M
        DVAL_NEXT(dv,ip);
169
2.30M
#endif
170
2.30M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
43.0k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
43.0k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
43.0k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
43.0k
#endif
188
189
43.0k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
43.0k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
43.0k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
43.0k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
43.0k
#endif
203
204
43.0k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
42.7k
        assert(ii == ip);
209
210
42.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
377
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
377
    if (pd(in_end,ii) > 0)
249
336
    {
250
336
        lzo_uint t = pd(in_end,ii);
251
336
        op = STORE_RUN(op,ii,t);
252
336
    }
253
254
377
    *out_len = pd(op, out);
255
377
    return LZO_E_OK;                /* compression went ok */
256
377
}
lzo1b_7.c:do_compress
Line
Count
Source
69
365
{
70
365
    const lzo_bytep ip;
71
365
#if (DD_BITS > 0)
72
365
#if defined(__LZO_HASH_INCREMENTAL)
73
365
    lzo_xint dv;
74
365
#endif
75
365
    unsigned drun = 0;
76
365
#endif
77
365
    lzo_bytep op;
78
365
    const lzo_bytep const in_end = in + in_len;
79
365
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
365
    const lzo_bytep ii;
81
365
#if defined(LZO_HAVE_R1)
82
365
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
365
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
365
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
365
#if (LZO_DETERMINISTIC)
104
365
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
365
#endif
106
107
108
365
    op = out;
109
365
    ip = in;
110
365
    ii = ip;            /* point to start of current literal run */
111
112
113
365
#if (DD_BITS > 0)
114
365
    DVAL_FIRST(dv,ip);
115
365
    UPDATE_D(dict,drun,dv,ip,in);
116
365
    ip++;
117
365
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
365
    assert(ip < ip_end);
123
365
    for (;;)
124
556k
    {
125
556k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
556k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
556k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
556k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
556k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
556k
#endif
143
144
556k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
542k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
489k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
489k
        if (++ip >= ip_end)
166
82
            break;
167
489k
#if (DD_BITS > 0)
168
489k
        DVAL_NEXT(dv,ip);
169
489k
#endif
170
489k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
67.2k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
67.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
67.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
67.2k
#endif
188
189
67.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
67.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
67.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
67.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
67.2k
#endif
203
204
67.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
66.9k
        assert(ii == ip);
209
210
66.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
365
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
365
    if (pd(in_end,ii) > 0)
249
335
    {
250
335
        lzo_uint t = pd(in_end,ii);
251
335
        op = STORE_RUN(op,ii,t);
252
335
    }
253
254
365
    *out_len = pd(op, out);
255
365
    return LZO_E_OK;                /* compression went ok */
256
365
}
lzo1b_8.c:do_compress
Line
Count
Source
69
388
{
70
388
    const lzo_bytep ip;
71
388
#if (DD_BITS > 0)
72
388
#if defined(__LZO_HASH_INCREMENTAL)
73
388
    lzo_xint dv;
74
388
#endif
75
388
    unsigned drun = 0;
76
388
#endif
77
388
    lzo_bytep op;
78
388
    const lzo_bytep const in_end = in + in_len;
79
388
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
388
    const lzo_bytep ii;
81
388
#if defined(LZO_HAVE_R1)
82
388
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
388
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
388
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
388
#if (LZO_DETERMINISTIC)
104
388
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
388
#endif
106
107
108
388
    op = out;
109
388
    ip = in;
110
388
    ii = ip;            /* point to start of current literal run */
111
112
113
388
#if (DD_BITS > 0)
114
388
    DVAL_FIRST(dv,ip);
115
388
    UPDATE_D(dict,drun,dv,ip,in);
116
388
    ip++;
117
388
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
388
    assert(ip < ip_end);
123
388
    for (;;)
124
849k
    {
125
849k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
849k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
849k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
849k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
849k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
849k
#endif
143
144
849k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
839k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
799k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
799k
        if (++ip >= ip_end)
166
91
            break;
167
799k
#if (DD_BITS > 0)
168
799k
        DVAL_NEXT(dv,ip);
169
799k
#endif
170
799k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
50.6k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
50.6k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
50.6k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
50.6k
#endif
188
189
50.6k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
50.6k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
50.6k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
50.6k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
50.6k
#endif
203
204
50.6k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
50.3k
        assert(ii == ip);
209
210
50.3k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
388
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
388
    if (pd(in_end,ii) > 0)
249
352
    {
250
352
        lzo_uint t = pd(in_end,ii);
251
352
        op = STORE_RUN(op,ii,t);
252
352
    }
253
254
388
    *out_len = pd(op, out);
255
388
    return LZO_E_OK;                /* compression went ok */
256
388
}
lzo1b_9.c:do_compress
Line
Count
Source
69
435
{
70
435
    const lzo_bytep ip;
71
435
#if (DD_BITS > 0)
72
435
#if defined(__LZO_HASH_INCREMENTAL)
73
435
    lzo_xint dv;
74
435
#endif
75
435
    unsigned drun = 0;
76
435
#endif
77
435
    lzo_bytep op;
78
435
    const lzo_bytep const in_end = in + in_len;
79
435
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
435
    const lzo_bytep ii;
81
435
#if defined(LZO_HAVE_R1)
82
435
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
435
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
435
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
435
#if (LZO_DETERMINISTIC)
104
435
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
435
#endif
106
107
108
435
    op = out;
109
435
    ip = in;
110
435
    ii = ip;            /* point to start of current literal run */
111
112
113
435
#if (DD_BITS > 0)
114
435
    DVAL_FIRST(dv,ip);
115
435
    UPDATE_D(dict,drun,dv,ip,in);
116
435
    ip++;
117
435
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
435
    assert(ip < ip_end);
123
435
    for (;;)
124
1.54M
    {
125
1.54M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.54M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.54M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.54M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.54M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.54M
#endif
143
144
1.54M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
1.54M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
1.54M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
1.54M
#endif
150
151
1.54M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.49M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.49M
        if (++ip >= ip_end)
166
102
            break;
167
1.49M
#if (DD_BITS > 0)
168
1.49M
        DVAL_NEXT(dv,ip);
169
1.49M
#endif
170
1.49M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
46.9k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
46.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
46.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
46.9k
#endif
188
189
46.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
46.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
46.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
46.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
46.9k
#endif
203
204
46.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
46.5k
        assert(ii == ip);
209
210
46.5k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
435
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
435
    if (pd(in_end,ii) > 0)
249
353
    {
250
353
        lzo_uint t = pd(in_end,ii);
251
353
        op = STORE_RUN(op,ii,t);
252
353
    }
253
254
435
    *out_len = pd(op, out);
255
435
    return LZO_E_OK;                /* compression went ok */
256
435
}
lzo1b_99.c:do_compress
Line
Count
Source
69
442
{
70
442
    const lzo_bytep ip;
71
442
#if (DD_BITS > 0)
72
442
#if defined(__LZO_HASH_INCREMENTAL)
73
442
    lzo_xint dv;
74
442
#endif
75
442
    unsigned drun = 0;
76
442
#endif
77
442
    lzo_bytep op;
78
442
    const lzo_bytep const in_end = in + in_len;
79
442
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
442
    const lzo_bytep ii;
81
442
#if defined(LZO_HAVE_R1)
82
442
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
442
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
442
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
442
#if (LZO_DETERMINISTIC)
104
442
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
442
#endif
106
107
108
442
    op = out;
109
442
    ip = in;
110
442
    ii = ip;            /* point to start of current literal run */
111
112
113
442
#if (DD_BITS > 0)
114
442
    DVAL_FIRST(dv,ip);
115
442
    UPDATE_D(dict,drun,dv,ip,in);
116
442
    ip++;
117
442
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
442
    assert(ip < ip_end);
123
442
    for (;;)
124
594k
    {
125
594k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
594k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
594k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
594k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
594k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
594k
#endif
143
144
594k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
594k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
552k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
552k
        if (++ip >= ip_end)
166
93
            break;
167
552k
#if (DD_BITS > 0)
168
552k
        DVAL_NEXT(dv,ip);
169
552k
#endif
170
552k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
42.3k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
42.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
42.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
42.3k
#endif
188
189
42.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
42.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
42.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
42.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
42.3k
#endif
203
204
42.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
42.0k
        assert(ii == ip);
209
210
42.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
442
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
442
    if (pd(in_end,ii) > 0)
249
388
    {
250
388
        lzo_uint t = pd(in_end,ii);
251
388
        op = STORE_RUN(op,ii,t);
252
388
    }
253
254
442
    *out_len = pd(op, out);
255
442
    return LZO_E_OK;                /* compression went ok */
256
442
}
lzo1c_1.c:do_compress
Line
Count
Source
69
483
{
70
483
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
483
    lzo_bytep op;
78
483
    const lzo_bytep const in_end = in + in_len;
79
483
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
483
    const lzo_bytep ii;
81
483
#if defined(LZO_HAVE_R1)
82
483
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
483
#endif
84
483
#if defined(LZO_HAVE_M3)
85
483
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
483
#endif
87
88
483
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
483
    op = out;
109
483
    ip = in;
110
483
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
    DVAL_FIRST(dv,ip);
115
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
    DVAL_NEXT(dv,ip);
118
#else
119
483
    ip++;
120
483
#endif
121
122
483
    assert(ip < ip_end);
123
483
    for (;;)
124
3.89M
    {
125
3.89M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
3.89M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
3.89M
#if (DD_BITS == 0)
131
3.89M
        lzo_uint dindex;
132
3.89M
#endif
133
3.89M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
3.89M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
3.89M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
3.89M
#endif
143
144
3.89M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
115k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
115k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
115k
#endif
150
151
115k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.80M
literal:
162
3.80M
#if (DD_BITS == 0)
163
3.80M
        UPDATE_I(dict,0,dindex,ip,in);
164
3.80M
#endif
165
3.80M
        if (++ip >= ip_end)
166
182
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
3.80M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
3.80M
match:
179
92.5k
#if (DD_BITS == 0)
180
92.5k
        UPDATE_I(dict,0,dindex,ip,in);
181
92.5k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
92.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
92.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
92.5k
#endif
188
189
92.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
92.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
92.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
92.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
92.5k
#endif
203
204
92.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
92.2k
        assert(ii == ip);
209
210
92.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
483
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
483
    if (pd(in_end,ii) > 0)
249
417
    {
250
417
        lzo_uint t = pd(in_end,ii);
251
417
        op = STORE_RUN(op,ii,t);
252
417
    }
253
254
483
    *out_len = pd(op, out);
255
483
    return LZO_E_OK;                /* compression went ok */
256
483
}
lzo1c_5.c:do_compress
Line
Count
Source
69
413
{
70
413
    const lzo_bytep ip;
71
413
#if (DD_BITS > 0)
72
413
#if defined(__LZO_HASH_INCREMENTAL)
73
413
    lzo_xint dv;
74
413
#endif
75
413
    unsigned drun = 0;
76
413
#endif
77
413
    lzo_bytep op;
78
413
    const lzo_bytep const in_end = in + in_len;
79
413
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
413
    const lzo_bytep ii;
81
413
#if defined(LZO_HAVE_R1)
82
413
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
413
#endif
84
413
#if defined(LZO_HAVE_M3)
85
413
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
413
#endif
87
88
413
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
413
    op = out;
109
413
    ip = in;
110
413
    ii = ip;            /* point to start of current literal run */
111
112
113
413
#if (DD_BITS > 0)
114
413
    DVAL_FIRST(dv,ip);
115
413
    UPDATE_D(dict,drun,dv,ip,in);
116
413
    ip++;
117
413
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
413
    assert(ip < ip_end);
123
413
    for (;;)
124
2.32M
    {
125
2.32M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.32M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.32M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.32M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.32M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.32M
#endif
143
144
2.32M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
2.31M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.27M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.27M
        if (++ip >= ip_end)
166
106
            break;
167
2.27M
#if (DD_BITS > 0)
168
2.27M
        DVAL_NEXT(dv,ip);
169
2.27M
#endif
170
2.27M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
47.6k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
47.6k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
47.6k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
47.6k
#endif
188
189
47.6k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
47.6k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
47.6k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
47.6k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
47.6k
#endif
203
204
47.6k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
47.3k
        assert(ii == ip);
209
210
47.3k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
413
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
413
    if (pd(in_end,ii) > 0)
249
383
    {
250
383
        lzo_uint t = pd(in_end,ii);
251
383
        op = STORE_RUN(op,ii,t);
252
383
    }
253
254
413
    *out_len = pd(op, out);
255
413
    return LZO_E_OK;                /* compression went ok */
256
413
}
lzo1c_9.c:do_compress
Line
Count
Source
69
435
{
70
435
    const lzo_bytep ip;
71
435
#if (DD_BITS > 0)
72
435
#if defined(__LZO_HASH_INCREMENTAL)
73
435
    lzo_xint dv;
74
435
#endif
75
435
    unsigned drun = 0;
76
435
#endif
77
435
    lzo_bytep op;
78
435
    const lzo_bytep const in_end = in + in_len;
79
435
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
435
    const lzo_bytep ii;
81
435
#if defined(LZO_HAVE_R1)
82
435
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
435
#endif
84
435
#if defined(LZO_HAVE_M3)
85
435
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
435
#endif
87
88
435
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
435
    op = out;
109
435
    ip = in;
110
435
    ii = ip;            /* point to start of current literal run */
111
112
113
435
#if (DD_BITS > 0)
114
435
    DVAL_FIRST(dv,ip);
115
435
    UPDATE_D(dict,drun,dv,ip,in);
116
435
    ip++;
117
435
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
435
    assert(ip < ip_end);
123
435
    for (;;)
124
1.41M
    {
125
1.41M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.41M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.41M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.41M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.41M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.41M
#endif
143
144
1.41M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
1.41M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
1.41M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
1.41M
#endif
150
151
1.41M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.39M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.39M
        if (++ip >= ip_end)
166
114
            break;
167
1.39M
#if (DD_BITS > 0)
168
1.39M
        DVAL_NEXT(dv,ip);
169
1.39M
#endif
170
1.39M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
23.7k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
23.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
23.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
23.7k
#endif
188
189
23.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
23.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
23.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
23.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
23.7k
#endif
203
204
23.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
23.4k
        assert(ii == ip);
209
210
23.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
435
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
435
    if (pd(in_end,ii) > 0)
249
377
    {
250
377
        lzo_uint t = pd(in_end,ii);
251
377
        op = STORE_RUN(op,ii,t);
252
377
    }
253
254
435
    *out_len = pd(op, out);
255
435
    return LZO_E_OK;                /* compression went ok */
256
435
}
lzo1c_99.c:do_compress
Line
Count
Source
69
500
{
70
500
    const lzo_bytep ip;
71
500
#if (DD_BITS > 0)
72
500
#if defined(__LZO_HASH_INCREMENTAL)
73
500
    lzo_xint dv;
74
500
#endif
75
500
    unsigned drun = 0;
76
500
#endif
77
500
    lzo_bytep op;
78
500
    const lzo_bytep const in_end = in + in_len;
79
500
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
500
    const lzo_bytep ii;
81
500
#if defined(LZO_HAVE_R1)
82
500
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
500
#endif
84
500
#if defined(LZO_HAVE_M3)
85
500
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
500
#endif
87
88
500
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
500
    op = out;
109
500
    ip = in;
110
500
    ii = ip;            /* point to start of current literal run */
111
112
113
500
#if (DD_BITS > 0)
114
500
    DVAL_FIRST(dv,ip);
115
500
    UPDATE_D(dict,drun,dv,ip,in);
116
500
    ip++;
117
500
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
500
    assert(ip < ip_end);
123
500
    for (;;)
124
4.45M
    {
125
4.45M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
4.45M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
4.45M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
4.45M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
4.45M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
4.45M
#endif
143
144
4.45M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
4.45M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
4.36M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
4.36M
        if (++ip >= ip_end)
166
117
            break;
167
4.36M
#if (DD_BITS > 0)
168
4.36M
        DVAL_NEXT(dv,ip);
169
4.36M
#endif
170
4.36M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
90.1k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
90.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
90.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
90.1k
#endif
188
189
90.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
90.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
90.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
90.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
90.1k
#endif
203
204
90.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
89.7k
        assert(ii == ip);
209
210
89.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
500
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
500
    if (pd(in_end,ii) > 0)
249
453
    {
250
453
        lzo_uint t = pd(in_end,ii);
251
453
        op = STORE_RUN(op,ii,t);
252
453
    }
253
254
500
    *out_len = pd(op, out);
255
500
    return LZO_E_OK;                /* compression went ok */
256
500
}
257
#ifdef __cplusplus
258
} /* extern "C" */
259
#endif
260
261
262
/* vim:set ts=4 sw=4 et: */