Coverage Report

Created: 2026-07-25 06:22

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
701k
#define DI      ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,drun,dv,ii,in); MI
49
329k
#define XI      assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
50
#else
51
201k
#define DI      ++ii; DINDEX1(dindex,ii); UPDATE_I(dict,0,dindex,ii,in); MI
52
330k
#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.00k
{
70
6.00k
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
4.52k
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
6.00k
    lzo_bytep op;
78
6.00k
    const lzo_bytep const in_end = in + in_len;
79
6.00k
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
6.00k
    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.70k
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
6.00k
    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.30k
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
6.00k
    op = out;
109
6.00k
    ip = in;
110
6.00k
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
4.52k
    DVAL_FIRST(dv,ip);
115
4.52k
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
4.52k
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
6.00k
    assert(ip < ip_end);
123
6.00k
    for (;;)
124
42.3M
    {
125
42.3M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
42.3M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
42.3M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
42.3M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
42.3M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
42.3M
#endif
143
144
42.3M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
432k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
432k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
432k
#endif
150
151
31.7M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
41.1M
literal:
162
#if (DD_BITS == 0)
163
10.6M
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
41.1M
        if (++ip >= ip_end)
166
1.73k
            break;
167
#if (DD_BITS > 0)
168
30.5M
        DVAL_NEXT(dv,ip);
169
30.5M
#endif
170
10.6M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
10.6M
match:
179
#if (DD_BITS == 0)
180
331k
        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.22M
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
1.22M
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
1.22M
#endif
188
189
1.22M
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
1.22M
        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.22M
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
1.21M
        assert(ii == ip);
209
210
1.21M
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
6.00k
    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.00k
    if (pd(in_end,ii) > 0)
249
5.41k
    {
250
5.41k
        lzo_uint t = pd(in_end,ii);
251
5.41k
        op = STORE_RUN(op,ii,t);
252
5.41k
    }
253
254
6.00k
    *out_len = pd(op, out);
255
6.00k
    return LZO_E_OK;                /* compression went ok */
256
6.00k
}
lzo1_99.c:do_compress
Line
Count
Source
69
372
{
70
372
    const lzo_bytep ip;
71
372
#if (DD_BITS > 0)
72
372
#if defined(__LZO_HASH_INCREMENTAL)
73
372
    lzo_xint dv;
74
372
#endif
75
372
    unsigned drun = 0;
76
372
#endif
77
372
    lzo_bytep op;
78
372
    const lzo_bytep const in_end = in + in_len;
79
372
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
372
    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
372
    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
372
#if (LZO_DETERMINISTIC)
104
372
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
372
#endif
106
107
108
372
    op = out;
109
372
    ip = in;
110
372
    ii = ip;            /* point to start of current literal run */
111
112
113
372
#if (DD_BITS > 0)
114
372
    DVAL_FIRST(dv,ip);
115
372
    UPDATE_D(dict,drun,dv,ip,in);
116
372
    ip++;
117
372
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
372
    assert(ip < ip_end);
123
372
    for (;;)
124
8.72M
    {
125
8.72M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
8.72M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
8.72M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
8.72M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
8.72M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
8.72M
#endif
143
144
8.72M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
8.72M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
8.72M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
8.72M
#endif
150
151
8.72M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
8.56M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
8.56M
        if (++ip >= ip_end)
166
105
            break;
167
8.56M
#if (DD_BITS > 0)
168
8.56M
        DVAL_NEXT(dv,ip);
169
8.56M
#endif
170
8.56M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
159k
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
159k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
159k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
159k
#endif
188
189
159k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
159k
        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
159k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
158k
        assert(ii == ip);
209
210
158k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
372
    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
372
    if (pd(in_end,ii) > 0)
249
308
    {
250
308
        lzo_uint t = pd(in_end,ii);
251
308
        op = STORE_RUN(op,ii,t);
252
308
    }
253
254
372
    *out_len = pd(op, out);
255
372
    return LZO_E_OK;                /* compression went ok */
256
372
}
lzo1a_99.c:do_compress
Line
Count
Source
69
374
{
70
374
    const lzo_bytep ip;
71
374
#if (DD_BITS > 0)
72
374
#if defined(__LZO_HASH_INCREMENTAL)
73
374
    lzo_xint dv;
74
374
#endif
75
374
    unsigned drun = 0;
76
374
#endif
77
374
    lzo_bytep op;
78
374
    const lzo_bytep const in_end = in + in_len;
79
374
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
374
    const lzo_bytep ii;
81
374
#if defined(LZO_HAVE_R1)
82
374
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
374
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
374
    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
374
#if (LZO_DETERMINISTIC)
104
374
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
374
#endif
106
107
108
374
    op = out;
109
374
    ip = in;
110
374
    ii = ip;            /* point to start of current literal run */
111
112
113
374
#if (DD_BITS > 0)
114
374
    DVAL_FIRST(dv,ip);
115
374
    UPDATE_D(dict,drun,dv,ip,in);
116
374
    ip++;
117
374
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
374
    assert(ip < ip_end);
123
374
    for (;;)
124
8.55M
    {
125
8.55M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
8.55M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
8.55M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
8.55M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
8.55M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
8.55M
#endif
143
144
8.55M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
8.55M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
8.55M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
8.55M
#endif
150
151
8.55M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
8.43M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
8.43M
        if (++ip >= ip_end)
166
100
            break;
167
8.43M
#if (DD_BITS > 0)
168
8.43M
        DVAL_NEXT(dv,ip);
169
8.43M
#endif
170
8.43M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
125k
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
125k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
125k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
125k
#endif
188
189
125k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
125k
        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
125k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
124k
        assert(ii == ip);
209
210
124k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
374
    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
374
    if (pd(in_end,ii) > 0)
249
320
    {
250
320
        lzo_uint t = pd(in_end,ii);
251
320
        op = STORE_RUN(op,ii,t);
252
320
    }
253
254
374
    *out_len = pd(op, out);
255
374
    return LZO_E_OK;                /* compression went ok */
256
374
}
lzo1b_1.c:do_compress
Line
Count
Source
69
362
{
70
362
    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
362
    lzo_bytep op;
78
362
    const lzo_bytep const in_end = in + in_len;
79
362
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
362
    const lzo_bytep ii;
81
362
#if defined(LZO_HAVE_R1)
82
362
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
362
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
362
    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
362
#if (LZO_DETERMINISTIC)
104
362
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
362
#endif
106
107
108
362
    op = out;
109
362
    ip = in;
110
362
    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
362
    ip++;
120
362
#endif
121
122
362
    assert(ip < ip_end);
123
362
    for (;;)
124
2.70M
    {
125
2.70M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.70M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
2.70M
#if (DD_BITS == 0)
131
2.70M
        lzo_uint dindex;
132
2.70M
#endif
133
2.70M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.70M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.70M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.70M
#endif
143
144
2.70M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
135k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
135k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
135k
#endif
150
151
135k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.54M
literal:
162
2.54M
#if (DD_BITS == 0)
163
2.54M
        UPDATE_I(dict,0,dindex,ip,in);
164
2.54M
#endif
165
2.54M
        if (++ip >= ip_end)
166
159
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
2.54M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
2.54M
match:
179
155k
#if (DD_BITS == 0)
180
155k
        UPDATE_I(dict,0,dindex,ip,in);
181
155k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
155k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
155k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
155k
#endif
188
189
155k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
155k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
155k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
155k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
155k
#endif
203
204
155k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
155k
        assert(ii == ip);
209
210
155k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
362
    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
362
    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
362
    *out_len = pd(op, out);
255
362
    return LZO_E_OK;                /* compression went ok */
256
362
}
lzo1b_2.c:do_compress
Line
Count
Source
69
328
{
70
328
    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
328
    lzo_bytep op;
78
328
    const lzo_bytep const in_end = in + in_len;
79
328
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
328
    const lzo_bytep ii;
81
328
#if defined(LZO_HAVE_R1)
82
328
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
328
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
328
    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
328
#if (LZO_DETERMINISTIC)
104
328
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
328
#endif
106
107
108
328
    op = out;
109
328
    ip = in;
110
328
    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
328
    ip++;
120
328
#endif
121
122
328
    assert(ip < ip_end);
123
328
    for (;;)
124
1.37M
    {
125
1.37M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.37M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.37M
#if (DD_BITS == 0)
131
1.37M
        lzo_uint dindex;
132
1.37M
#endif
133
1.37M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.37M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.37M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.37M
#endif
143
144
1.37M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
47.4k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
47.4k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
47.4k
#endif
150
151
47.4k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.32M
literal:
162
1.32M
#if (DD_BITS == 0)
163
1.32M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.32M
#endif
165
1.32M
        if (++ip >= ip_end)
166
140
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.32M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.32M
match:
179
51.9k
#if (DD_BITS == 0)
180
51.9k
        UPDATE_I(dict,0,dindex,ip,in);
181
51.9k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
51.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
51.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
51.9k
#endif
188
189
51.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
51.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
51.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
51.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
51.9k
#endif
203
204
51.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
51.7k
        assert(ii == ip);
209
210
51.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
328
    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
328
    if (pd(in_end,ii) > 0)
249
313
    {
250
313
        lzo_uint t = pd(in_end,ii);
251
313
        op = STORE_RUN(op,ii,t);
252
313
    }
253
254
328
    *out_len = pd(op, out);
255
328
    return LZO_E_OK;                /* compression went ok */
256
328
}
lzo1b_3.c:do_compress
Line
Count
Source
69
332
{
70
332
    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
332
    lzo_bytep op;
78
332
    const lzo_bytep const in_end = in + in_len;
79
332
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
332
    const lzo_bytep ii;
81
332
#if defined(LZO_HAVE_R1)
82
332
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
332
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
332
    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
332
#if (LZO_DETERMINISTIC)
104
332
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
332
#endif
106
107
108
332
    op = out;
109
332
    ip = in;
110
332
    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
332
    ip++;
120
332
#endif
121
122
332
    assert(ip < ip_end);
123
332
    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
1.02M
#if (DD_BITS == 0)
131
1.02M
        lzo_uint dindex;
132
1.02M
#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
42.6k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
42.6k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
42.6k
#endif
150
151
42.6k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
946k
literal:
162
946k
#if (DD_BITS == 0)
163
946k
        UPDATE_I(dict,0,dindex,ip,in);
164
946k
#endif
165
946k
        if (++ip >= ip_end)
166
123
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
945k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
945k
match:
179
75.1k
#if (DD_BITS == 0)
180
75.1k
        UPDATE_I(dict,0,dindex,ip,in);
181
75.1k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
75.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
75.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
75.1k
#endif
188
189
75.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
75.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
75.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
75.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
75.1k
#endif
203
204
75.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
74.8k
        assert(ii == ip);
209
210
74.8k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
332
    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
332
    if (pd(in_end,ii) > 0)
249
314
    {
250
314
        lzo_uint t = pd(in_end,ii);
251
314
        op = STORE_RUN(op,ii,t);
252
314
    }
253
254
332
    *out_len = pd(op, out);
255
332
    return LZO_E_OK;                /* compression went ok */
256
332
}
lzo1b_4.c:do_compress
Line
Count
Source
69
362
{
70
362
    const lzo_bytep ip;
71
362
#if (DD_BITS > 0)
72
362
#if defined(__LZO_HASH_INCREMENTAL)
73
362
    lzo_xint dv;
74
362
#endif
75
362
    unsigned drun = 0;
76
362
#endif
77
362
    lzo_bytep op;
78
362
    const lzo_bytep const in_end = in + in_len;
79
362
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
362
    const lzo_bytep ii;
81
362
#if defined(LZO_HAVE_R1)
82
362
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
362
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
362
    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
362
#if (LZO_DETERMINISTIC)
104
362
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
362
#endif
106
107
108
362
    op = out;
109
362
    ip = in;
110
362
    ii = ip;            /* point to start of current literal run */
111
112
113
362
#if (DD_BITS > 0)
114
362
    DVAL_FIRST(dv,ip);
115
362
    UPDATE_D(dict,drun,dv,ip,in);
116
362
    ip++;
117
362
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
362
    assert(ip < ip_end);
123
362
    for (;;)
124
1.80M
    {
125
1.80M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.80M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.80M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.80M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.80M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.80M
#endif
143
144
1.80M
#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.78M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.65M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.65M
        if (++ip >= ip_end)
166
109
            break;
167
1.65M
#if (DD_BITS > 0)
168
1.65M
        DVAL_NEXT(dv,ip);
169
1.65M
#endif
170
1.65M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
144k
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
144k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
144k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
144k
#endif
188
189
144k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
144k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
144k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
144k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
144k
#endif
203
204
144k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
144k
        assert(ii == ip);
209
210
144k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
362
    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
362
    if (pd(in_end,ii) > 0)
249
338
    {
250
338
        lzo_uint t = pd(in_end,ii);
251
338
        op = STORE_RUN(op,ii,t);
252
338
    }
253
254
362
    *out_len = pd(op, out);
255
362
    return LZO_E_OK;                /* compression went ok */
256
362
}
lzo1b_5.c:do_compress
Line
Count
Source
69
314
{
70
314
    const lzo_bytep ip;
71
314
#if (DD_BITS > 0)
72
314
#if defined(__LZO_HASH_INCREMENTAL)
73
314
    lzo_xint dv;
74
314
#endif
75
314
    unsigned drun = 0;
76
314
#endif
77
314
    lzo_bytep op;
78
314
    const lzo_bytep const in_end = in + in_len;
79
314
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
314
    const lzo_bytep ii;
81
314
#if defined(LZO_HAVE_R1)
82
314
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
314
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
314
    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
314
#if (LZO_DETERMINISTIC)
104
314
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
314
#endif
106
107
108
314
    op = out;
109
314
    ip = in;
110
314
    ii = ip;            /* point to start of current literal run */
111
112
113
314
#if (DD_BITS > 0)
114
314
    DVAL_FIRST(dv,ip);
115
314
    UPDATE_D(dict,drun,dv,ip,in);
116
314
    ip++;
117
314
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
314
    assert(ip < ip_end);
123
314
    for (;;)
124
676k
    {
125
676k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
676k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
676k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
676k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
676k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
676k
#endif
143
144
676k
#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
666k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
630k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
630k
        if (++ip >= ip_end)
166
74
            break;
167
630k
#if (DD_BITS > 0)
168
630k
        DVAL_NEXT(dv,ip);
169
630k
#endif
170
630k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
45.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
45.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
45.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
45.3k
#endif
188
189
45.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
45.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
45.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
45.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
45.3k
#endif
203
204
45.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
45.0k
        assert(ii == ip);
209
210
45.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
314
    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
314
    if (pd(in_end,ii) > 0)
249
292
    {
250
292
        lzo_uint t = pd(in_end,ii);
251
292
        op = STORE_RUN(op,ii,t);
252
292
    }
253
254
314
    *out_len = pd(op, out);
255
314
    return LZO_E_OK;                /* compression went ok */
256
314
}
lzo1b_6.c:do_compress
Line
Count
Source
69
346
{
70
346
    const lzo_bytep ip;
71
346
#if (DD_BITS > 0)
72
346
#if defined(__LZO_HASH_INCREMENTAL)
73
346
    lzo_xint dv;
74
346
#endif
75
346
    unsigned drun = 0;
76
346
#endif
77
346
    lzo_bytep op;
78
346
    const lzo_bytep const in_end = in + in_len;
79
346
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
346
    const lzo_bytep ii;
81
346
#if defined(LZO_HAVE_R1)
82
346
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
346
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
346
    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
346
#if (LZO_DETERMINISTIC)
104
346
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
346
#endif
106
107
108
346
    op = out;
109
346
    ip = in;
110
346
    ii = ip;            /* point to start of current literal run */
111
112
113
346
#if (DD_BITS > 0)
114
346
    DVAL_FIRST(dv,ip);
115
346
    UPDATE_D(dict,drun,dv,ip,in);
116
346
    ip++;
117
346
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
346
    assert(ip < ip_end);
123
346
    for (;;)
124
1.14M
    {
125
1.14M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.14M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.14M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.14M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.14M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.14M
#endif
143
144
1.14M
#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.13M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.09M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.09M
        if (++ip >= ip_end)
166
79
            break;
167
1.09M
#if (DD_BITS > 0)
168
1.09M
        DVAL_NEXT(dv,ip);
169
1.09M
#endif
170
1.09M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
49.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
49.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
49.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
49.4k
#endif
188
189
49.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
49.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
49.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
49.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
49.4k
#endif
203
204
49.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
49.2k
        assert(ii == ip);
209
210
49.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
346
    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
346
    if (pd(in_end,ii) > 0)
249
311
    {
250
311
        lzo_uint t = pd(in_end,ii);
251
311
        op = STORE_RUN(op,ii,t);
252
311
    }
253
254
346
    *out_len = pd(op, out);
255
346
    return LZO_E_OK;                /* compression went ok */
256
346
}
lzo1b_7.c:do_compress
Line
Count
Source
69
348
{
70
348
    const lzo_bytep ip;
71
348
#if (DD_BITS > 0)
72
348
#if defined(__LZO_HASH_INCREMENTAL)
73
348
    lzo_xint dv;
74
348
#endif
75
348
    unsigned drun = 0;
76
348
#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
348
#if (DD_BITS > 0)
114
348
    DVAL_FIRST(dv,ip);
115
348
    UPDATE_D(dict,drun,dv,ip,in);
116
348
    ip++;
117
348
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
348
    assert(ip < ip_end);
123
348
    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
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#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
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.18M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.14M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.14M
        if (++ip >= ip_end)
166
89
            break;
167
1.14M
#if (DD_BITS > 0)
168
1.14M
        DVAL_NEXT(dv,ip);
169
1.14M
#endif
170
1.14M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
51.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
51.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
51.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
51.2k
#endif
188
189
51.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
51.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
51.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
51.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
51.2k
#endif
203
204
51.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
50.9k
        assert(ii == ip);
209
210
50.9k
    }
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
322
    {
250
322
        lzo_uint t = pd(in_end,ii);
251
322
        op = STORE_RUN(op,ii,t);
252
322
    }
253
254
348
    *out_len = pd(op, out);
255
348
    return LZO_E_OK;                /* compression went ok */
256
348
}
lzo1b_8.c:do_compress
Line
Count
Source
69
366
{
70
366
    const lzo_bytep ip;
71
366
#if (DD_BITS > 0)
72
366
#if defined(__LZO_HASH_INCREMENTAL)
73
366
    lzo_xint dv;
74
366
#endif
75
366
    unsigned drun = 0;
76
366
#endif
77
366
    lzo_bytep op;
78
366
    const lzo_bytep const in_end = in + in_len;
79
366
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
366
    const lzo_bytep ii;
81
366
#if defined(LZO_HAVE_R1)
82
366
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
366
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
366
    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
366
#if (LZO_DETERMINISTIC)
104
366
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
366
#endif
106
107
108
366
    op = out;
109
366
    ip = in;
110
366
    ii = ip;            /* point to start of current literal run */
111
112
113
366
#if (DD_BITS > 0)
114
366
    DVAL_FIRST(dv,ip);
115
366
    UPDATE_D(dict,drun,dv,ip,in);
116
366
    ip++;
117
366
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
366
    assert(ip < ip_end);
123
366
    for (;;)
124
1.43M
    {
125
1.43M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.43M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.43M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.43M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.43M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.43M
#endif
143
144
1.43M
#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.41M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.37M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.37M
        if (++ip >= ip_end)
166
94
            break;
167
1.37M
#if (DD_BITS > 0)
168
1.37M
        DVAL_NEXT(dv,ip);
169
1.37M
#endif
170
1.37M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
69.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
69.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
69.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
69.3k
#endif
188
189
69.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
69.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
69.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
69.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
69.3k
#endif
203
204
69.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
69.0k
        assert(ii == ip);
209
210
69.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
366
    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
366
    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
366
    *out_len = pd(op, out);
255
366
    return LZO_E_OK;                /* compression went ok */
256
366
}
lzo1b_9.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
788k
    {
125
788k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
788k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
788k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
788k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
788k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
788k
#endif
143
144
788k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
788k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
788k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
788k
#endif
150
151
788k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
738k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
738k
        if (++ip >= ip_end)
166
84
            break;
167
738k
#if (DD_BITS > 0)
168
738k
        DVAL_NEXT(dv,ip);
169
738k
#endif
170
738k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
49.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
49.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
49.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
49.9k
#endif
188
189
49.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
49.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
49.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
49.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
49.9k
#endif
203
204
49.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
49.6k
        assert(ii == ip);
209
210
49.6k
    }
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
321
    {
250
321
        lzo_uint t = pd(in_end,ii);
251
321
        op = STORE_RUN(op,ii,t);
252
321
    }
253
254
388
    *out_len = pd(op, out);
255
388
    return LZO_E_OK;                /* compression went ok */
256
388
}
lzo1b_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
410
#if defined(LZO_HAVE_R1)
82
410
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
410
#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
1.00M
    {
125
1.00M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.00M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.00M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.00M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.00M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.00M
#endif
143
144
1.00M
#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
945k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
945k
        if (++ip >= ip_end)
166
99
            break;
167
945k
#if (DD_BITS > 0)
168
945k
        DVAL_NEXT(dv,ip);
169
945k
#endif
170
945k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
61.5k
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
61.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
61.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
61.5k
#endif
188
189
61.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
61.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
61.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
61.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
61.5k
#endif
203
204
61.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
61.2k
        assert(ii == ip);
209
210
61.2k
    }
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
371
    {
250
371
        lzo_uint t = pd(in_end,ii);
251
371
        op = STORE_RUN(op,ii,t);
252
371
    }
253
254
410
    *out_len = pd(op, out);
255
410
    return LZO_E_OK;                /* compression went ok */
256
410
}
lzo1c_1.c:do_compress
Line
Count
Source
69
462
{
70
462
    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
462
    lzo_bytep op;
78
462
    const lzo_bytep const in_end = in + in_len;
79
462
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
462
    const lzo_bytep ii;
81
462
#if defined(LZO_HAVE_R1)
82
462
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
462
#endif
84
462
#if defined(LZO_HAVE_M3)
85
462
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
462
#endif
87
88
462
    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
462
    op = out;
109
462
    ip = in;
110
462
    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
462
    ip++;
120
462
#endif
121
122
462
    assert(ip < ip_end);
123
462
    for (;;)
124
5.89M
    {
125
5.89M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
5.89M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
5.89M
#if (DD_BITS == 0)
131
5.89M
        lzo_uint dindex;
132
5.89M
#endif
133
5.89M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
5.89M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
5.89M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
5.89M
#endif
143
144
5.89M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
207k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
207k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
207k
#endif
150
151
207k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
5.84M
literal:
162
5.84M
#if (DD_BITS == 0)
163
5.84M
        UPDATE_I(dict,0,dindex,ip,in);
164
5.84M
#endif
165
5.84M
        if (++ip >= ip_end)
166
183
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
5.84M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
5.84M
match:
179
48.4k
#if (DD_BITS == 0)
180
48.4k
        UPDATE_I(dict,0,dindex,ip,in);
181
48.4k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
48.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
48.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
48.4k
#endif
188
189
48.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
48.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
48.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
48.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
48.4k
#endif
203
204
48.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
48.2k
        assert(ii == ip);
209
210
48.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
462
    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
462
    if (pd(in_end,ii) > 0)
249
409
    {
250
409
        lzo_uint t = pd(in_end,ii);
251
409
        op = STORE_RUN(op,ii,t);
252
409
    }
253
254
462
    *out_len = pd(op, out);
255
462
    return LZO_E_OK;                /* compression went ok */
256
462
}
lzo1c_5.c:do_compress
Line
Count
Source
69
369
{
70
369
    const lzo_bytep ip;
71
369
#if (DD_BITS > 0)
72
369
#if defined(__LZO_HASH_INCREMENTAL)
73
369
    lzo_xint dv;
74
369
#endif
75
369
    unsigned drun = 0;
76
369
#endif
77
369
    lzo_bytep op;
78
369
    const lzo_bytep const in_end = in + in_len;
79
369
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
369
    const lzo_bytep ii;
81
369
#if defined(LZO_HAVE_R1)
82
369
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
369
#endif
84
369
#if defined(LZO_HAVE_M3)
85
369
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
369
#endif
87
88
369
    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
369
    op = out;
109
369
    ip = in;
110
369
    ii = ip;            /* point to start of current literal run */
111
112
113
369
#if (DD_BITS > 0)
114
369
    DVAL_FIRST(dv,ip);
115
369
    UPDATE_D(dict,drun,dv,ip,in);
116
369
    ip++;
117
369
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
369
    assert(ip < ip_end);
123
369
    for (;;)
124
2.35M
    {
125
2.35M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.35M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.35M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.35M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.35M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.35M
#endif
143
144
2.35M
#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.29M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.29M
        if (++ip >= ip_end)
166
92
            break;
167
2.29M
#if (DD_BITS > 0)
168
2.29M
        DVAL_NEXT(dv,ip);
169
2.29M
#endif
170
2.29M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
53.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
53.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
53.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
53.2k
#endif
188
189
53.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
53.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
53.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
53.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
53.2k
#endif
203
204
53.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
52.9k
        assert(ii == ip);
209
210
52.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
369
    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
369
    if (pd(in_end,ii) > 0)
249
347
    {
250
347
        lzo_uint t = pd(in_end,ii);
251
347
        op = STORE_RUN(op,ii,t);
252
347
    }
253
254
369
    *out_len = pd(op, out);
255
369
    return LZO_E_OK;                /* compression went ok */
256
369
}
lzo1c_9.c:do_compress
Line
Count
Source
69
411
{
70
411
    const lzo_bytep ip;
71
411
#if (DD_BITS > 0)
72
411
#if defined(__LZO_HASH_INCREMENTAL)
73
411
    lzo_xint dv;
74
411
#endif
75
411
    unsigned drun = 0;
76
411
#endif
77
411
    lzo_bytep op;
78
411
    const lzo_bytep const in_end = in + in_len;
79
411
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
411
    const lzo_bytep ii;
81
411
#if defined(LZO_HAVE_R1)
82
411
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
411
#endif
84
411
#if defined(LZO_HAVE_M3)
85
411
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
411
#endif
87
88
411
    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
411
    op = out;
109
411
    ip = in;
110
411
    ii = ip;            /* point to start of current literal run */
111
112
113
411
#if (DD_BITS > 0)
114
411
    DVAL_FIRST(dv,ip);
115
411
    UPDATE_D(dict,drun,dv,ip,in);
116
411
    ip++;
117
411
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
411
    assert(ip < ip_end);
123
411
    for (;;)
124
954k
    {
125
954k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
954k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
954k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
954k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
954k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
954k
#endif
143
144
954k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
954k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
954k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
954k
#endif
150
151
954k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
922k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
922k
        if (++ip >= ip_end)
166
106
            break;
167
922k
#if (DD_BITS > 0)
168
922k
        DVAL_NEXT(dv,ip);
169
922k
#endif
170
922k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
32.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
32.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
32.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
32.1k
#endif
188
189
32.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
32.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
32.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
32.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
32.1k
#endif
203
204
32.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
31.8k
        assert(ii == ip);
209
210
31.8k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
411
    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
411
    if (pd(in_end,ii) > 0)
249
365
    {
250
365
        lzo_uint t = pd(in_end,ii);
251
365
        op = STORE_RUN(op,ii,t);
252
365
    }
253
254
411
    *out_len = pd(op, out);
255
411
    return LZO_E_OK;                /* compression went ok */
256
411
}
lzo1c_99.c:do_compress
Line
Count
Source
69
462
{
70
462
    const lzo_bytep ip;
71
462
#if (DD_BITS > 0)
72
462
#if defined(__LZO_HASH_INCREMENTAL)
73
462
    lzo_xint dv;
74
462
#endif
75
462
    unsigned drun = 0;
76
462
#endif
77
462
    lzo_bytep op;
78
462
    const lzo_bytep const in_end = in + in_len;
79
462
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
462
    const lzo_bytep ii;
81
462
#if defined(LZO_HAVE_R1)
82
462
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
462
#endif
84
462
#if defined(LZO_HAVE_M3)
85
462
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
462
#endif
87
88
462
    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
462
    op = out;
109
462
    ip = in;
110
462
    ii = ip;            /* point to start of current literal run */
111
112
113
462
#if (DD_BITS > 0)
114
462
    DVAL_FIRST(dv,ip);
115
462
    UPDATE_D(dict,drun,dv,ip,in);
116
462
    ip++;
117
462
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
462
    assert(ip < ip_end);
123
462
    for (;;)
124
2.76M
    {
125
2.76M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.76M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.76M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.76M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.76M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.76M
#endif
143
144
2.76M
#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.76M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.71M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.71M
        if (++ip >= ip_end)
166
102
            break;
167
2.71M
#if (DD_BITS > 0)
168
2.71M
        DVAL_NEXT(dv,ip);
169
2.71M
#endif
170
2.71M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
51.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
51.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
51.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
51.4k
#endif
188
189
51.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
51.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
51.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
51.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
51.4k
#endif
203
204
51.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
51.0k
        assert(ii == ip);
209
210
51.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
462
    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
462
    if (pd(in_end,ii) > 0)
249
412
    {
250
412
        lzo_uint t = pd(in_end,ii);
251
412
        op = STORE_RUN(op,ii,t);
252
412
    }
253
254
462
    *out_len = pd(op, out);
255
462
    return LZO_E_OK;                /* compression went ok */
256
462
}
257
#ifdef __cplusplus
258
} /* extern "C" */
259
#endif
260
261
262
/* vim:set ts=4 sw=4 et: */