Coverage Report

Created: 2025-10-28 06:47

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
706k
#define DI      ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,drun,dv,ii,in); MI
49
338k
#define XI      assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
50
#else
51
378k
#define DI      ++ii; DINDEX1(dindex,ii); UPDATE_I(dict,0,dindex,ii,in); MI
52
463k
#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
4.95k
{
70
4.95k
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
3.74k
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
4.95k
    lzo_bytep op;
78
4.95k
    const lzo_bytep const in_end = in + in_len;
79
4.95k
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
4.95k
    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.39k
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
4.95k
    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
3.56k
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
4.95k
    op = out;
109
4.95k
    ip = in;
110
4.95k
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
3.74k
    DVAL_FIRST(dv,ip);
115
3.74k
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
3.74k
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
4.95k
    assert(ip < ip_end);
123
4.95k
    for (;;)
124
31.6M
    {
125
31.6M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
31.6M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
31.6M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
31.6M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
31.6M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
31.6M
#endif
143
144
31.6M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
527k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
527k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
527k
#endif
150
151
20.0M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
29.9M
literal:
162
#if (DD_BITS == 0)
163
11.4M
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
29.9M
        if (++ip >= ip_end)
166
1.18k
            break;
167
#if (DD_BITS > 0)
168
18.4M
        DVAL_NEXT(dv,ip);
169
18.4M
#endif
170
11.4M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
11.4M
match:
179
#if (DD_BITS == 0)
180
464k
        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.65M
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
1.65M
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
1.65M
#endif
188
189
1.65M
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
1.65M
        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.65M
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
1.65M
        assert(ii == ip);
209
210
1.65M
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
4.95k
    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
4.95k
    if (pd(in_end,ii) > 0)
249
4.36k
    {
250
4.36k
        lzo_uint t = pd(in_end,ii);
251
4.36k
        op = STORE_RUN(op,ii,t);
252
4.36k
    }
253
254
4.95k
    *out_len = pd(op, out);
255
4.95k
    return LZO_E_OK;                /* compression went ok */
256
4.95k
}
lzo1_99.c:do_compress
Line
Count
Source
69
325
{
70
325
    const lzo_bytep ip;
71
325
#if (DD_BITS > 0)
72
325
#if defined(__LZO_HASH_INCREMENTAL)
73
325
    lzo_xint dv;
74
325
#endif
75
325
    unsigned drun = 0;
76
325
#endif
77
325
    lzo_bytep op;
78
325
    const lzo_bytep const in_end = in + in_len;
79
325
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
325
    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
325
    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
325
#if (LZO_DETERMINISTIC)
104
325
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
325
#endif
106
107
108
325
    op = out;
109
325
    ip = in;
110
325
    ii = ip;            /* point to start of current literal run */
111
112
113
325
#if (DD_BITS > 0)
114
325
    DVAL_FIRST(dv,ip);
115
325
    UPDATE_D(dict,drun,dv,ip,in);
116
325
    ip++;
117
325
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
325
    assert(ip < ip_end);
123
325
    for (;;)
124
4.07M
    {
125
4.07M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
4.07M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
4.07M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
4.07M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
4.07M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
4.07M
#endif
143
144
4.07M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
4.07M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
4.07M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
4.07M
#endif
150
151
4.07M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.73M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
3.73M
        if (++ip >= ip_end)
166
65
            break;
167
3.73M
#if (DD_BITS > 0)
168
3.73M
        DVAL_NEXT(dv,ip);
169
3.73M
#endif
170
3.73M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
337k
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
337k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
337k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
337k
#endif
188
189
337k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
337k
        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
337k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
337k
        assert(ii == ip);
209
210
337k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
325
    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
325
    if (pd(in_end,ii) > 0)
249
267
    {
250
267
        lzo_uint t = pd(in_end,ii);
251
267
        op = STORE_RUN(op,ii,t);
252
267
    }
253
254
325
    *out_len = pd(op, out);
255
325
    return LZO_E_OK;                /* compression went ok */
256
325
}
lzo1a_99.c:do_compress
Line
Count
Source
69
303
{
70
303
    const lzo_bytep ip;
71
303
#if (DD_BITS > 0)
72
303
#if defined(__LZO_HASH_INCREMENTAL)
73
303
    lzo_xint dv;
74
303
#endif
75
303
    unsigned drun = 0;
76
303
#endif
77
303
    lzo_bytep op;
78
303
    const lzo_bytep const in_end = in + in_len;
79
303
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
303
    const lzo_bytep ii;
81
303
#if defined(LZO_HAVE_R1)
82
303
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
303
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
303
    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
303
#if (LZO_DETERMINISTIC)
104
303
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
303
#endif
106
107
108
303
    op = out;
109
303
    ip = in;
110
303
    ii = ip;            /* point to start of current literal run */
111
112
113
303
#if (DD_BITS > 0)
114
303
    DVAL_FIRST(dv,ip);
115
303
    UPDATE_D(dict,drun,dv,ip,in);
116
303
    ip++;
117
303
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
303
    assert(ip < ip_end);
123
303
    for (;;)
124
3.37M
    {
125
3.37M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
3.37M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
3.37M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
3.37M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
3.37M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
3.37M
#endif
143
144
3.37M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
3.37M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
3.37M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
3.37M
#endif
150
151
3.37M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.24M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
3.24M
        if (++ip >= ip_end)
166
65
            break;
167
3.24M
#if (DD_BITS > 0)
168
3.24M
        DVAL_NEXT(dv,ip);
169
3.24M
#endif
170
3.24M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
129k
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
129k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
129k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
129k
#endif
188
189
129k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
129k
        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
129k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
128k
        assert(ii == ip);
209
210
128k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
303
    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
303
    if (pd(in_end,ii) > 0)
249
241
    {
250
241
        lzo_uint t = pd(in_end,ii);
251
241
        op = STORE_RUN(op,ii,t);
252
241
    }
253
254
303
    *out_len = pd(op, out);
255
303
    return LZO_E_OK;                /* compression went ok */
256
303
}
lzo1b_1.c:do_compress
Line
Count
Source
69
308
{
70
308
    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
308
    lzo_bytep op;
78
308
    const lzo_bytep const in_end = in + in_len;
79
308
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
308
    const lzo_bytep ii;
81
308
#if defined(LZO_HAVE_R1)
82
308
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
308
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
308
    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
308
#if (LZO_DETERMINISTIC)
104
308
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
308
#endif
106
107
108
308
    op = out;
109
308
    ip = in;
110
308
    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
308
    ip++;
120
308
#endif
121
122
308
    assert(ip < ip_end);
123
308
    for (;;)
124
2.04M
    {
125
2.04M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.04M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
2.04M
#if (DD_BITS == 0)
131
2.04M
        lzo_uint dindex;
132
2.04M
#endif
133
2.04M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.04M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.04M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.04M
#endif
143
144
2.04M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
90.6k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
90.6k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
90.6k
#endif
150
151
90.6k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.92M
literal:
162
1.92M
#if (DD_BITS == 0)
163
1.92M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.92M
#endif
165
1.92M
        if (++ip >= ip_end)
166
92
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.92M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.92M
match:
179
115k
#if (DD_BITS == 0)
180
115k
        UPDATE_I(dict,0,dindex,ip,in);
181
115k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
115k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
115k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
115k
#endif
188
189
115k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
115k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
115k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
115k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
115k
#endif
203
204
115k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
115k
        assert(ii == ip);
209
210
115k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
308
    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
308
    if (pd(in_end,ii) > 0)
249
267
    {
250
267
        lzo_uint t = pd(in_end,ii);
251
267
        op = STORE_RUN(op,ii,t);
252
267
    }
253
254
308
    *out_len = pd(op, out);
255
308
    return LZO_E_OK;                /* compression went ok */
256
308
}
lzo1b_2.c:do_compress
Line
Count
Source
69
257
{
70
257
    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
257
    lzo_bytep op;
78
257
    const lzo_bytep const in_end = in + in_len;
79
257
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
257
    const lzo_bytep ii;
81
257
#if defined(LZO_HAVE_R1)
82
257
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
257
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
257
    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
257
#if (LZO_DETERMINISTIC)
104
257
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
257
#endif
106
107
108
257
    op = out;
109
257
    ip = in;
110
257
    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
257
    ip++;
120
257
#endif
121
122
257
    assert(ip < ip_end);
123
257
    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
93.7k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
93.7k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
93.7k
#endif
150
151
93.7k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.27M
literal:
162
1.27M
#if (DD_BITS == 0)
163
1.27M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.27M
#endif
165
1.27M
        if (++ip >= ip_end)
166
85
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.27M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.27M
match:
179
98.3k
#if (DD_BITS == 0)
180
98.3k
        UPDATE_I(dict,0,dindex,ip,in);
181
98.3k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
98.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
98.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
98.3k
#endif
188
189
98.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
98.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
98.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
98.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
98.3k
#endif
203
204
98.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
98.2k
        assert(ii == ip);
209
210
98.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
257
    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
257
    if (pd(in_end,ii) > 0)
249
234
    {
250
234
        lzo_uint t = pd(in_end,ii);
251
234
        op = STORE_RUN(op,ii,t);
252
234
    }
253
254
257
    *out_len = pd(op, out);
255
257
    return LZO_E_OK;                /* compression went ok */
256
257
}
lzo1b_3.c:do_compress
Line
Count
Source
69
282
{
70
282
    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
282
    lzo_bytep op;
78
282
    const lzo_bytep const in_end = in + in_len;
79
282
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
282
    const lzo_bytep ii;
81
282
#if defined(LZO_HAVE_R1)
82
282
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
282
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
282
    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
282
#if (LZO_DETERMINISTIC)
104
282
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
282
#endif
106
107
108
282
    op = out;
109
282
    ip = in;
110
282
    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
282
    ip++;
120
282
#endif
121
122
282
    assert(ip < ip_end);
123
282
    for (;;)
124
3.31M
    {
125
3.31M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
3.31M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
3.31M
#if (DD_BITS == 0)
131
3.31M
        lzo_uint dindex;
132
3.31M
#endif
133
3.31M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
3.31M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
3.31M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
3.31M
#endif
143
144
3.31M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
163k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
163k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
163k
#endif
150
151
163k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.17M
literal:
162
3.17M
#if (DD_BITS == 0)
163
3.17M
        UPDATE_I(dict,0,dindex,ip,in);
164
3.17M
#endif
165
3.17M
        if (++ip >= ip_end)
166
106
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
3.17M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
3.17M
match:
179
140k
#if (DD_BITS == 0)
180
140k
        UPDATE_I(dict,0,dindex,ip,in);
181
140k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
140k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
140k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
140k
#endif
188
189
140k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
140k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
140k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
140k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
140k
#endif
203
204
140k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
140k
        assert(ii == ip);
209
210
140k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
282
    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
282
    if (pd(in_end,ii) > 0)
249
260
    {
250
260
        lzo_uint t = pd(in_end,ii);
251
260
        op = STORE_RUN(op,ii,t);
252
260
    }
253
254
282
    *out_len = pd(op, out);
255
282
    return LZO_E_OK;                /* compression went ok */
256
282
}
lzo1b_4.c:do_compress
Line
Count
Source
69
289
{
70
289
    const lzo_bytep ip;
71
289
#if (DD_BITS > 0)
72
289
#if defined(__LZO_HASH_INCREMENTAL)
73
289
    lzo_xint dv;
74
289
#endif
75
289
    unsigned drun = 0;
76
289
#endif
77
289
    lzo_bytep op;
78
289
    const lzo_bytep const in_end = in + in_len;
79
289
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
289
    const lzo_bytep ii;
81
289
#if defined(LZO_HAVE_R1)
82
289
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
289
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
289
    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
289
#if (LZO_DETERMINISTIC)
104
289
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
289
#endif
106
107
108
289
    op = out;
109
289
    ip = in;
110
289
    ii = ip;            /* point to start of current literal run */
111
112
113
289
#if (DD_BITS > 0)
114
289
    DVAL_FIRST(dv,ip);
115
289
    UPDATE_D(dict,drun,dv,ip,in);
116
289
    ip++;
117
289
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
289
    assert(ip < ip_end);
123
289
    for (;;)
124
826k
    {
125
826k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
826k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
826k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
826k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
826k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
826k
#endif
143
144
826k
#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
803k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
720k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
720k
        if (++ip >= ip_end)
166
65
            break;
167
720k
#if (DD_BITS > 0)
168
720k
        DVAL_NEXT(dv,ip);
169
720k
#endif
170
720k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
105k
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
105k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
105k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
105k
#endif
188
189
105k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
105k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
105k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
105k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
105k
#endif
203
204
105k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
105k
        assert(ii == ip);
209
210
105k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
289
    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
289
    if (pd(in_end,ii) > 0)
249
262
    {
250
262
        lzo_uint t = pd(in_end,ii);
251
262
        op = STORE_RUN(op,ii,t);
252
262
    }
253
254
289
    *out_len = pd(op, out);
255
289
    return LZO_E_OK;                /* compression went ok */
256
289
}
lzo1b_5.c:do_compress
Line
Count
Source
69
285
{
70
285
    const lzo_bytep ip;
71
285
#if (DD_BITS > 0)
72
285
#if defined(__LZO_HASH_INCREMENTAL)
73
285
    lzo_xint dv;
74
285
#endif
75
285
    unsigned drun = 0;
76
285
#endif
77
285
    lzo_bytep op;
78
285
    const lzo_bytep const in_end = in + in_len;
79
285
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
285
    const lzo_bytep ii;
81
285
#if defined(LZO_HAVE_R1)
82
285
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
285
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
285
    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
285
#if (LZO_DETERMINISTIC)
104
285
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
285
#endif
106
107
108
285
    op = out;
109
285
    ip = in;
110
285
    ii = ip;            /* point to start of current literal run */
111
112
113
285
#if (DD_BITS > 0)
114
285
    DVAL_FIRST(dv,ip);
115
285
    UPDATE_D(dict,drun,dv,ip,in);
116
285
    ip++;
117
285
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
285
    assert(ip < ip_end);
123
285
    for (;;)
124
731k
    {
125
731k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
731k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
731k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
731k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
731k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
731k
#endif
143
144
731k
#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
716k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
654k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
654k
        if (++ip >= ip_end)
166
61
            break;
167
654k
#if (DD_BITS > 0)
168
654k
        DVAL_NEXT(dv,ip);
169
654k
#endif
170
654k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
77.0k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
77.0k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
77.0k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
77.0k
#endif
188
189
77.0k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
77.0k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
77.0k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
77.0k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
77.0k
#endif
203
204
77.0k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
76.7k
        assert(ii == ip);
209
210
76.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
285
    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
285
    if (pd(in_end,ii) > 0)
249
255
    {
250
255
        lzo_uint t = pd(in_end,ii);
251
255
        op = STORE_RUN(op,ii,t);
252
255
    }
253
254
285
    *out_len = pd(op, out);
255
285
    return LZO_E_OK;                /* compression went ok */
256
285
}
lzo1b_6.c:do_compress
Line
Count
Source
69
284
{
70
284
    const lzo_bytep ip;
71
284
#if (DD_BITS > 0)
72
284
#if defined(__LZO_HASH_INCREMENTAL)
73
284
    lzo_xint dv;
74
284
#endif
75
284
    unsigned drun = 0;
76
284
#endif
77
284
    lzo_bytep op;
78
284
    const lzo_bytep const in_end = in + in_len;
79
284
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
284
    const lzo_bytep ii;
81
284
#if defined(LZO_HAVE_R1)
82
284
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
284
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
284
    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
284
#if (LZO_DETERMINISTIC)
104
284
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
284
#endif
106
107
108
284
    op = out;
109
284
    ip = in;
110
284
    ii = ip;            /* point to start of current literal run */
111
112
113
284
#if (DD_BITS > 0)
114
284
    DVAL_FIRST(dv,ip);
115
284
    UPDATE_D(dict,drun,dv,ip,in);
116
284
    ip++;
117
284
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
284
    assert(ip < ip_end);
123
284
    for (;;)
124
1.83M
    {
125
1.83M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.83M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.83M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.83M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.83M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.83M
#endif
143
144
1.83M
#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.82M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.75M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.75M
        if (++ip >= ip_end)
166
56
            break;
167
1.75M
#if (DD_BITS > 0)
168
1.75M
        DVAL_NEXT(dv,ip);
169
1.75M
#endif
170
1.75M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
75.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
75.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
75.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
75.4k
#endif
188
189
75.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
75.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
75.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
75.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
75.4k
#endif
203
204
75.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
75.2k
        assert(ii == ip);
209
210
75.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
284
    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
284
    if (pd(in_end,ii) > 0)
249
263
    {
250
263
        lzo_uint t = pd(in_end,ii);
251
263
        op = STORE_RUN(op,ii,t);
252
263
    }
253
254
284
    *out_len = pd(op, out);
255
284
    return LZO_E_OK;                /* compression went ok */
256
284
}
lzo1b_7.c:do_compress
Line
Count
Source
69
271
{
70
271
    const lzo_bytep ip;
71
271
#if (DD_BITS > 0)
72
271
#if defined(__LZO_HASH_INCREMENTAL)
73
271
    lzo_xint dv;
74
271
#endif
75
271
    unsigned drun = 0;
76
271
#endif
77
271
    lzo_bytep op;
78
271
    const lzo_bytep const in_end = in + in_len;
79
271
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
271
    const lzo_bytep ii;
81
271
#if defined(LZO_HAVE_R1)
82
271
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
271
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
271
    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
271
#if (LZO_DETERMINISTIC)
104
271
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
271
#endif
106
107
108
271
    op = out;
109
271
    ip = in;
110
271
    ii = ip;            /* point to start of current literal run */
111
112
113
271
#if (DD_BITS > 0)
114
271
    DVAL_FIRST(dv,ip);
115
271
    UPDATE_D(dict,drun,dv,ip,in);
116
271
    ip++;
117
271
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
271
    assert(ip < ip_end);
123
271
    for (;;)
124
704k
    {
125
704k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
704k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
704k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
704k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
704k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
704k
#endif
143
144
704k
#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
686k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
641k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
641k
        if (++ip >= ip_end)
166
56
            break;
167
641k
#if (DD_BITS > 0)
168
641k
        DVAL_NEXT(dv,ip);
169
641k
#endif
170
641k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
62.8k
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
62.8k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
62.8k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
62.8k
#endif
188
189
62.8k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
62.8k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
62.8k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
62.8k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
62.8k
#endif
203
204
62.8k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
62.6k
        assert(ii == ip);
209
210
62.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
271
    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
271
    if (pd(in_end,ii) > 0)
249
246
    {
250
246
        lzo_uint t = pd(in_end,ii);
251
246
        op = STORE_RUN(op,ii,t);
252
246
    }
253
254
271
    *out_len = pd(op, out);
255
271
    return LZO_E_OK;                /* compression went ok */
256
271
}
lzo1b_8.c:do_compress
Line
Count
Source
69
297
{
70
297
    const lzo_bytep ip;
71
297
#if (DD_BITS > 0)
72
297
#if defined(__LZO_HASH_INCREMENTAL)
73
297
    lzo_xint dv;
74
297
#endif
75
297
    unsigned drun = 0;
76
297
#endif
77
297
    lzo_bytep op;
78
297
    const lzo_bytep const in_end = in + in_len;
79
297
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
297
    const lzo_bytep ii;
81
297
#if defined(LZO_HAVE_R1)
82
297
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
297
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
297
    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
297
#if (LZO_DETERMINISTIC)
104
297
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
297
#endif
106
107
108
297
    op = out;
109
297
    ip = in;
110
297
    ii = ip;            /* point to start of current literal run */
111
112
113
297
#if (DD_BITS > 0)
114
297
    DVAL_FIRST(dv,ip);
115
297
    UPDATE_D(dict,drun,dv,ip,in);
116
297
    ip++;
117
297
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
297
    assert(ip < ip_end);
123
297
    for (;;)
124
1.44M
    {
125
1.44M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.44M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.44M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.44M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.44M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.44M
#endif
143
144
1.44M
#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.42M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.36M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.36M
        if (++ip >= ip_end)
166
66
            break;
167
1.36M
#if (DD_BITS > 0)
168
1.36M
        DVAL_NEXT(dv,ip);
169
1.36M
#endif
170
1.36M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
82.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
82.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
82.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
82.4k
#endif
188
189
82.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
82.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
82.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
82.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
82.4k
#endif
203
204
82.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
82.1k
        assert(ii == ip);
209
210
82.1k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
297
    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
297
    if (pd(in_end,ii) > 0)
249
266
    {
250
266
        lzo_uint t = pd(in_end,ii);
251
266
        op = STORE_RUN(op,ii,t);
252
266
    }
253
254
297
    *out_len = pd(op, out);
255
297
    return LZO_E_OK;                /* compression went ok */
256
297
}
lzo1b_9.c:do_compress
Line
Count
Source
69
327
{
70
327
    const lzo_bytep ip;
71
327
#if (DD_BITS > 0)
72
327
#if defined(__LZO_HASH_INCREMENTAL)
73
327
    lzo_xint dv;
74
327
#endif
75
327
    unsigned drun = 0;
76
327
#endif
77
327
    lzo_bytep op;
78
327
    const lzo_bytep const in_end = in + in_len;
79
327
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
327
    const lzo_bytep ii;
81
327
#if defined(LZO_HAVE_R1)
82
327
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
327
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
327
    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
327
#if (LZO_DETERMINISTIC)
104
327
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
327
#endif
106
107
108
327
    op = out;
109
327
    ip = in;
110
327
    ii = ip;            /* point to start of current literal run */
111
112
113
327
#if (DD_BITS > 0)
114
327
    DVAL_FIRST(dv,ip);
115
327
    UPDATE_D(dict,drun,dv,ip,in);
116
327
    ip++;
117
327
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
327
    assert(ip < ip_end);
123
327
    for (;;)
124
1.63M
    {
125
1.63M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.63M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.63M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.63M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.63M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.63M
#endif
143
144
1.63M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
1.63M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
1.63M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
1.63M
#endif
150
151
1.63M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.55M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.55M
        if (++ip >= ip_end)
166
72
            break;
167
1.55M
#if (DD_BITS > 0)
168
1.55M
        DVAL_NEXT(dv,ip);
169
1.55M
#endif
170
1.55M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
80.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
80.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
80.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
80.5k
#endif
188
189
80.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
80.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
80.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
80.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
80.5k
#endif
203
204
80.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
80.2k
        assert(ii == ip);
209
210
80.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
327
    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
327
    if (pd(in_end,ii) > 0)
249
288
    {
250
288
        lzo_uint t = pd(in_end,ii);
251
288
        op = STORE_RUN(op,ii,t);
252
288
    }
253
254
327
    *out_len = pd(op, out);
255
327
    return LZO_E_OK;                /* compression went ok */
256
327
}
lzo1b_99.c:do_compress
Line
Count
Source
69
333
{
70
333
    const lzo_bytep ip;
71
333
#if (DD_BITS > 0)
72
333
#if defined(__LZO_HASH_INCREMENTAL)
73
333
    lzo_xint dv;
74
333
#endif
75
333
    unsigned drun = 0;
76
333
#endif
77
333
    lzo_bytep op;
78
333
    const lzo_bytep const in_end = in + in_len;
79
333
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
333
    const lzo_bytep ii;
81
333
#if defined(LZO_HAVE_R1)
82
333
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
333
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
333
    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
333
#if (LZO_DETERMINISTIC)
104
333
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
333
#endif
106
107
108
333
    op = out;
109
333
    ip = in;
110
333
    ii = ip;            /* point to start of current literal run */
111
112
113
333
#if (DD_BITS > 0)
114
333
    DVAL_FIRST(dv,ip);
115
333
    UPDATE_D(dict,drun,dv,ip,in);
116
333
    ip++;
117
333
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
333
    assert(ip < ip_end);
123
333
    for (;;)
124
1.74M
    {
125
1.74M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.74M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.74M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.74M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.74M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.74M
#endif
143
144
1.74M
#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.74M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.68M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.68M
        if (++ip >= ip_end)
166
62
            break;
167
1.68M
#if (DD_BITS > 0)
168
1.68M
        DVAL_NEXT(dv,ip);
169
1.68M
#endif
170
1.68M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
65.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
65.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
65.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
65.2k
#endif
188
189
65.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
65.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
65.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
65.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
65.2k
#endif
203
204
65.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
64.9k
        assert(ii == ip);
209
210
64.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
333
    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
333
    if (pd(in_end,ii) > 0)
249
296
    {
250
296
        lzo_uint t = pd(in_end,ii);
251
296
        op = STORE_RUN(op,ii,t);
252
296
    }
253
254
333
    *out_len = pd(op, out);
255
333
    return LZO_E_OK;                /* compression went ok */
256
333
}
lzo1c_1.c:do_compress
Line
Count
Source
69
366
{
70
366
    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
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
366
#if defined(LZO_HAVE_M3)
85
366
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
366
#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
#if (LZO_DETERMINISTIC)
104
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#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
#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
366
    ip++;
120
366
#endif
121
122
366
    assert(ip < ip_end);
123
366
    for (;;)
124
5.22M
    {
125
5.22M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
5.22M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
5.22M
#if (DD_BITS == 0)
131
5.22M
        lzo_uint dindex;
132
5.22M
#endif
133
5.22M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
5.22M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
5.22M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
5.22M
#endif
143
144
5.22M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
180k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
180k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
180k
#endif
150
151
180k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
5.11M
literal:
162
5.11M
#if (DD_BITS == 0)
163
5.11M
        UPDATE_I(dict,0,dindex,ip,in);
164
5.11M
#endif
165
5.11M
        if (++ip >= ip_end)
166
112
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
5.11M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
5.11M
match:
179
110k
#if (DD_BITS == 0)
180
110k
        UPDATE_I(dict,0,dindex,ip,in);
181
110k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
110k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
110k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
110k
#endif
188
189
110k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
110k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
110k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
110k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
110k
#endif
203
204
110k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
109k
        assert(ii == ip);
209
210
109k
    }
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
310
    {
250
310
        lzo_uint t = pd(in_end,ii);
251
310
        op = STORE_RUN(op,ii,t);
252
310
    }
253
254
366
    *out_len = pd(op, out);
255
366
    return LZO_E_OK;                /* compression went ok */
256
366
}
lzo1c_5.c:do_compress
Line
Count
Source
69
311
{
70
311
    const lzo_bytep ip;
71
311
#if (DD_BITS > 0)
72
311
#if defined(__LZO_HASH_INCREMENTAL)
73
311
    lzo_xint dv;
74
311
#endif
75
311
    unsigned drun = 0;
76
311
#endif
77
311
    lzo_bytep op;
78
311
    const lzo_bytep const in_end = in + in_len;
79
311
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
311
    const lzo_bytep ii;
81
311
#if defined(LZO_HAVE_R1)
82
311
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
311
#endif
84
311
#if defined(LZO_HAVE_M3)
85
311
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
311
#endif
87
88
311
    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
311
    op = out;
109
311
    ip = in;
110
311
    ii = ip;            /* point to start of current literal run */
111
112
113
311
#if (DD_BITS > 0)
114
311
    DVAL_FIRST(dv,ip);
115
311
    UPDATE_D(dict,drun,dv,ip,in);
116
311
    ip++;
117
311
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
311
    assert(ip < ip_end);
123
311
    for (;;)
124
915k
    {
125
915k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
915k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
915k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
915k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
915k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
915k
#endif
143
144
915k
#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
901k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
853k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
853k
        if (++ip >= ip_end)
166
63
            break;
167
853k
#if (DD_BITS > 0)
168
853k
        DVAL_NEXT(dv,ip);
169
853k
#endif
170
853k
        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
311
    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
311
    if (pd(in_end,ii) > 0)
249
278
    {
250
278
        lzo_uint t = pd(in_end,ii);
251
278
        op = STORE_RUN(op,ii,t);
252
278
    }
253
254
311
    *out_len = pd(op, out);
255
311
    return LZO_E_OK;                /* compression went ok */
256
311
}
lzo1c_9.c:do_compress
Line
Count
Source
69
347
{
70
347
    const lzo_bytep ip;
71
347
#if (DD_BITS > 0)
72
347
#if defined(__LZO_HASH_INCREMENTAL)
73
347
    lzo_xint dv;
74
347
#endif
75
347
    unsigned drun = 0;
76
347
#endif
77
347
    lzo_bytep op;
78
347
    const lzo_bytep const in_end = in + in_len;
79
347
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
347
    const lzo_bytep ii;
81
347
#if defined(LZO_HAVE_R1)
82
347
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
347
#endif
84
347
#if defined(LZO_HAVE_M3)
85
347
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
347
#endif
87
88
347
    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
347
    op = out;
109
347
    ip = in;
110
347
    ii = ip;            /* point to start of current literal run */
111
112
113
347
#if (DD_BITS > 0)
114
347
    DVAL_FIRST(dv,ip);
115
347
    UPDATE_D(dict,drun,dv,ip,in);
116
347
    ip++;
117
347
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
347
    assert(ip < ip_end);
123
347
    for (;;)
124
948k
    {
125
948k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
948k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
948k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
948k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
948k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
948k
#endif
143
144
948k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
948k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
948k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
948k
#endif
150
151
948k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
901k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
901k
        if (++ip >= ip_end)
166
78
            break;
167
901k
#if (DD_BITS > 0)
168
901k
        DVAL_NEXT(dv,ip);
169
901k
#endif
170
901k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
46.9k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
46.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
46.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
46.9k
#endif
188
189
46.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
46.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
46.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
46.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
46.9k
#endif
203
204
46.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
46.6k
        assert(ii == ip);
209
210
46.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
347
    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
347
    if (pd(in_end,ii) > 0)
249
310
    {
250
310
        lzo_uint t = pd(in_end,ii);
251
310
        op = STORE_RUN(op,ii,t);
252
310
    }
253
254
347
    *out_len = pd(op, out);
255
347
    return LZO_E_OK;                /* compression went ok */
256
347
}
lzo1c_99.c:do_compress
Line
Count
Source
69
371
{
70
371
    const lzo_bytep ip;
71
371
#if (DD_BITS > 0)
72
371
#if defined(__LZO_HASH_INCREMENTAL)
73
371
    lzo_xint dv;
74
371
#endif
75
371
    unsigned drun = 0;
76
371
#endif
77
371
    lzo_bytep op;
78
371
    const lzo_bytep const in_end = in + in_len;
79
371
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
371
    const lzo_bytep ii;
81
371
#if defined(LZO_HAVE_R1)
82
371
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
371
#endif
84
371
#if defined(LZO_HAVE_M3)
85
371
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
371
#endif
87
88
371
    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
371
    op = out;
109
371
    ip = in;
110
371
    ii = ip;            /* point to start of current literal run */
111
112
113
371
#if (DD_BITS > 0)
114
371
    DVAL_FIRST(dv,ip);
115
371
    UPDATE_D(dict,drun,dv,ip,in);
116
371
    ip++;
117
371
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
371
    assert(ip < ip_end);
123
371
    for (;;)
124
1.41M
    {
125
1.41M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.41M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.41M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.41M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.41M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.41M
#endif
143
144
1.41M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
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.35M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.35M
        if (++ip >= ip_end)
166
82
            break;
167
1.35M
#if (DD_BITS > 0)
168
1.35M
        DVAL_NEXT(dv,ip);
169
1.35M
#endif
170
1.35M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
68.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
68.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
68.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
68.2k
#endif
188
189
68.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
68.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
68.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
68.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
68.2k
#endif
203
204
68.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
68.0k
        assert(ii == ip);
209
210
68.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
371
    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
371
    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
371
    *out_len = pd(op, out);
255
371
    return LZO_E_OK;                /* compression went ok */
256
371
}
257
#ifdef __cplusplus
258
} /* extern "C" */
259
#endif
260
261
262
/* vim:set ts=4 sw=4 et: */