Coverage Report

Created: 2026-09-06 06:32

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
692k
#define DI      ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,drun,dv,ii,in); MI
49
323k
#define XI      assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
50
#else
51
239k
#define DI      ++ii; DINDEX1(dindex,ii); UPDATE_I(dict,0,dindex,ii,in); MI
52
308k
#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
5.88k
{
70
5.88k
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
4.43k
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
5.88k
    lzo_bytep op;
78
5.88k
    const lzo_bytep const in_end = in + in_len;
79
5.88k
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
5.88k
    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.67k
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
5.88k
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
4.20k
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
5.88k
    op = out;
109
5.88k
    ip = in;
110
5.88k
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
4.43k
    DVAL_FIRST(dv,ip);
115
4.43k
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
4.43k
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
5.88k
    assert(ip < ip_end);
123
5.88k
    for (;;)
124
47.1M
    {
125
47.1M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
47.1M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
47.1M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
47.1M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
47.1M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
47.1M
#endif
143
144
47.1M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
371k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
371k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
371k
#endif
150
151
37.4M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
45.9M
literal:
162
#if (DD_BITS == 0)
163
9.57M
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
45.9M
        if (++ip >= ip_end)
166
1.68k
            break;
167
#if (DD_BITS > 0)
168
36.3M
        DVAL_NEXT(dv,ip);
169
36.3M
#endif
170
9.57M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
9.57M
match:
179
#if (DD_BITS == 0)
180
308k
        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.14M
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
1.14M
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
1.14M
#endif
188
189
1.14M
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
1.14M
        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.14M
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
1.13M
        assert(ii == ip);
209
210
1.13M
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
5.88k
    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
5.88k
    if (pd(in_end,ii) > 0)
249
5.30k
    {
250
5.30k
        lzo_uint t = pd(in_end,ii);
251
5.30k
        op = STORE_RUN(op,ii,t);
252
5.30k
    }
253
254
5.88k
    *out_len = pd(op, out);
255
5.88k
    return LZO_E_OK;                /* compression went ok */
256
5.88k
}
lzo1_99.c:do_compress
Line
Count
Source
69
365
{
70
365
    const lzo_bytep ip;
71
365
#if (DD_BITS > 0)
72
365
#if defined(__LZO_HASH_INCREMENTAL)
73
365
    lzo_xint dv;
74
365
#endif
75
365
    unsigned drun = 0;
76
365
#endif
77
365
    lzo_bytep op;
78
365
    const lzo_bytep const in_end = in + in_len;
79
365
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
365
    const lzo_bytep ii;
81
#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
365
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
365
#if (LZO_DETERMINISTIC)
104
365
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
365
#endif
106
107
108
365
    op = out;
109
365
    ip = in;
110
365
    ii = ip;            /* point to start of current literal run */
111
112
113
365
#if (DD_BITS > 0)
114
365
    DVAL_FIRST(dv,ip);
115
365
    UPDATE_D(dict,drun,dv,ip,in);
116
365
    ip++;
117
365
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
365
    assert(ip < ip_end);
123
365
    for (;;)
124
9.40M
    {
125
9.40M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
9.40M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
9.40M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
9.40M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
9.40M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
9.40M
#endif
143
144
9.40M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
9.40M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
9.40M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
9.40M
#endif
150
151
9.40M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
9.32M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
9.32M
        if (++ip >= ip_end)
166
103
            break;
167
9.32M
#if (DD_BITS > 0)
168
9.32M
        DVAL_NEXT(dv,ip);
169
9.32M
#endif
170
9.32M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
85.6k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
85.6k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
85.6k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
85.6k
#endif
188
189
85.6k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
85.6k
        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
85.6k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
85.3k
        assert(ii == ip);
209
210
85.3k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
365
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
365
    if (pd(in_end,ii) > 0)
249
301
    {
250
301
        lzo_uint t = pd(in_end,ii);
251
301
        op = STORE_RUN(op,ii,t);
252
301
    }
253
254
365
    *out_len = pd(op, out);
255
365
    return LZO_E_OK;                /* compression went ok */
256
365
}
lzo1a_99.c:do_compress
Line
Count
Source
69
365
{
70
365
    const lzo_bytep ip;
71
365
#if (DD_BITS > 0)
72
365
#if defined(__LZO_HASH_INCREMENTAL)
73
365
    lzo_xint dv;
74
365
#endif
75
365
    unsigned drun = 0;
76
365
#endif
77
365
    lzo_bytep op;
78
365
    const lzo_bytep const in_end = in + in_len;
79
365
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
365
    const lzo_bytep ii;
81
365
#if defined(LZO_HAVE_R1)
82
365
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
365
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
365
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
365
#if (LZO_DETERMINISTIC)
104
365
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
365
#endif
106
107
108
365
    op = out;
109
365
    ip = in;
110
365
    ii = ip;            /* point to start of current literal run */
111
112
113
365
#if (DD_BITS > 0)
114
365
    DVAL_FIRST(dv,ip);
115
365
    UPDATE_D(dict,drun,dv,ip,in);
116
365
    ip++;
117
365
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
365
    assert(ip < ip_end);
123
365
    for (;;)
124
9.36M
    {
125
9.36M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
9.36M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
9.36M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
9.36M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
9.36M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
9.36M
#endif
143
144
9.36M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
9.36M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
9.36M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
9.36M
#endif
150
151
9.36M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
9.24M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
9.24M
        if (++ip >= ip_end)
166
104
            break;
167
9.24M
#if (DD_BITS > 0)
168
9.24M
        DVAL_NEXT(dv,ip);
169
9.24M
#endif
170
9.24M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
123k
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
123k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
123k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
123k
#endif
188
189
123k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
123k
        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
123k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
123k
        assert(ii == ip);
209
210
123k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
365
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
365
    if (pd(in_end,ii) > 0)
249
312
    {
250
312
        lzo_uint t = pd(in_end,ii);
251
312
        op = STORE_RUN(op,ii,t);
252
312
    }
253
254
365
    *out_len = pd(op, out);
255
365
    return LZO_E_OK;                /* compression went ok */
256
365
}
lzo1b_1.c:do_compress
Line
Count
Source
69
351
{
70
351
    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
351
    lzo_bytep op;
78
351
    const lzo_bytep const in_end = in + in_len;
79
351
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
351
    const lzo_bytep ii;
81
351
#if defined(LZO_HAVE_R1)
82
351
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
351
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
351
    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
351
#if (LZO_DETERMINISTIC)
104
351
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
351
#endif
106
107
108
351
    op = out;
109
351
    ip = in;
110
351
    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
351
    ip++;
120
351
#endif
121
122
351
    assert(ip < ip_end);
123
351
    for (;;)
124
2.36M
    {
125
2.36M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.36M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
2.36M
#if (DD_BITS == 0)
131
2.36M
        lzo_uint dindex;
132
2.36M
#endif
133
2.36M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.36M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.36M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.36M
#endif
143
144
2.36M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
91.4k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
91.4k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
91.4k
#endif
150
151
91.4k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.26M
literal:
162
2.26M
#if (DD_BITS == 0)
163
2.26M
        UPDATE_I(dict,0,dindex,ip,in);
164
2.26M
#endif
165
2.26M
        if (++ip >= ip_end)
166
158
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
2.26M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
2.26M
match:
179
98.5k
#if (DD_BITS == 0)
180
98.5k
        UPDATE_I(dict,0,dindex,ip,in);
181
98.5k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
98.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
98.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
98.5k
#endif
188
189
98.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
98.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
98.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
98.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
98.5k
#endif
203
204
98.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
98.3k
        assert(ii == ip);
209
210
98.3k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
351
    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
351
    if (pd(in_end,ii) > 0)
249
330
    {
250
330
        lzo_uint t = pd(in_end,ii);
251
330
        op = STORE_RUN(op,ii,t);
252
330
    }
253
254
351
    *out_len = pd(op, out);
255
351
    return LZO_E_OK;                /* compression went ok */
256
351
}
lzo1b_2.c:do_compress
Line
Count
Source
69
318
{
70
318
    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
318
    lzo_bytep op;
78
318
    const lzo_bytep const in_end = in + in_len;
79
318
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
318
    const lzo_bytep ii;
81
318
#if defined(LZO_HAVE_R1)
82
318
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
318
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
318
    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
318
#if (LZO_DETERMINISTIC)
104
318
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
318
#endif
106
107
108
318
    op = out;
109
318
    ip = in;
110
318
    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
318
    ip++;
120
318
#endif
121
122
318
    assert(ip < ip_end);
123
318
    for (;;)
124
1.64M
    {
125
1.64M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.64M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.64M
#if (DD_BITS == 0)
131
1.64M
        lzo_uint dindex;
132
1.64M
#endif
133
1.64M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.64M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.64M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.64M
#endif
143
144
1.64M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
69.4k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
69.4k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
69.4k
#endif
150
151
69.4k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.56M
literal:
162
1.56M
#if (DD_BITS == 0)
163
1.56M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.56M
#endif
165
1.56M
        if (++ip >= ip_end)
166
126
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.56M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.56M
match:
179
78.8k
#if (DD_BITS == 0)
180
78.8k
        UPDATE_I(dict,0,dindex,ip,in);
181
78.8k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
78.8k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
78.8k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
78.8k
#endif
188
189
78.8k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
78.8k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
78.8k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
78.8k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
78.8k
#endif
203
204
78.8k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
78.6k
        assert(ii == ip);
209
210
78.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
318
    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
318
    if (pd(in_end,ii) > 0)
249
303
    {
250
303
        lzo_uint t = pd(in_end,ii);
251
303
        op = STORE_RUN(op,ii,t);
252
303
    }
253
254
318
    *out_len = pd(op, out);
255
318
    return LZO_E_OK;                /* compression went ok */
256
318
}
lzo1b_3.c:do_compress
Line
Count
Source
69
329
{
70
329
    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
329
    lzo_bytep op;
78
329
    const lzo_bytep const in_end = in + in_len;
79
329
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
329
    const lzo_bytep ii;
81
329
#if defined(LZO_HAVE_R1)
82
329
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
329
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
329
    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
329
#if (LZO_DETERMINISTIC)
104
329
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
329
#endif
106
107
108
329
    op = out;
109
329
    ip = in;
110
329
    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
329
    ip++;
120
329
#endif
121
122
329
    assert(ip < ip_end);
123
329
    for (;;)
124
1.09M
    {
125
1.09M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.09M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.09M
#if (DD_BITS == 0)
131
1.09M
        lzo_uint dindex;
132
1.09M
#endif
133
1.09M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.09M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.09M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.09M
#endif
143
144
1.09M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
51.0k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
51.0k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
51.0k
#endif
150
151
51.0k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.01M
literal:
162
1.01M
#if (DD_BITS == 0)
163
1.01M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.01M
#endif
165
1.01M
        if (++ip >= ip_end)
166
111
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.01M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.01M
match:
179
80.4k
#if (DD_BITS == 0)
180
80.4k
        UPDATE_I(dict,0,dindex,ip,in);
181
80.4k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
80.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
80.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
80.4k
#endif
188
189
80.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
80.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
80.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
80.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
80.4k
#endif
203
204
80.4k
#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
329
    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
329
    if (pd(in_end,ii) > 0)
249
298
    {
250
298
        lzo_uint t = pd(in_end,ii);
251
298
        op = STORE_RUN(op,ii,t);
252
298
    }
253
254
329
    *out_len = pd(op, out);
255
329
    return LZO_E_OK;                /* compression went ok */
256
329
}
lzo1b_4.c:do_compress
Line
Count
Source
69
361
{
70
361
    const lzo_bytep ip;
71
361
#if (DD_BITS > 0)
72
361
#if defined(__LZO_HASH_INCREMENTAL)
73
361
    lzo_xint dv;
74
361
#endif
75
361
    unsigned drun = 0;
76
361
#endif
77
361
    lzo_bytep op;
78
361
    const lzo_bytep const in_end = in + in_len;
79
361
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
361
    const lzo_bytep ii;
81
361
#if defined(LZO_HAVE_R1)
82
361
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
361
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
361
    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
361
#if (LZO_DETERMINISTIC)
104
361
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
361
#endif
106
107
108
361
    op = out;
109
361
    ip = in;
110
361
    ii = ip;            /* point to start of current literal run */
111
112
113
361
#if (DD_BITS > 0)
114
361
    DVAL_FIRST(dv,ip);
115
361
    UPDATE_D(dict,drun,dv,ip,in);
116
361
    ip++;
117
361
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
361
    assert(ip < ip_end);
123
361
    for (;;)
124
1.60M
    {
125
1.60M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.60M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.60M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.60M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.60M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.60M
#endif
143
144
1.60M
#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.58M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.47M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.47M
        if (++ip >= ip_end)
166
103
            break;
167
1.47M
#if (DD_BITS > 0)
168
1.47M
        DVAL_NEXT(dv,ip);
169
1.47M
#endif
170
1.47M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
130k
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
130k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
130k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
130k
#endif
188
189
130k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
130k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
130k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
130k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
130k
#endif
203
204
130k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
129k
        assert(ii == ip);
209
210
129k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
361
    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
361
    if (pd(in_end,ii) > 0)
249
339
    {
250
339
        lzo_uint t = pd(in_end,ii);
251
339
        op = STORE_RUN(op,ii,t);
252
339
    }
253
254
361
    *out_len = pd(op, out);
255
361
    return LZO_E_OK;                /* compression went ok */
256
361
}
lzo1b_5.c:do_compress
Line
Count
Source
69
313
{
70
313
    const lzo_bytep ip;
71
313
#if (DD_BITS > 0)
72
313
#if defined(__LZO_HASH_INCREMENTAL)
73
313
    lzo_xint dv;
74
313
#endif
75
313
    unsigned drun = 0;
76
313
#endif
77
313
    lzo_bytep op;
78
313
    const lzo_bytep const in_end = in + in_len;
79
313
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
313
    const lzo_bytep ii;
81
313
#if defined(LZO_HAVE_R1)
82
313
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
313
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
313
    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
313
#if (LZO_DETERMINISTIC)
104
313
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
313
#endif
106
107
108
313
    op = out;
109
313
    ip = in;
110
313
    ii = ip;            /* point to start of current literal run */
111
112
113
313
#if (DD_BITS > 0)
114
313
    DVAL_FIRST(dv,ip);
115
313
    UPDATE_D(dict,drun,dv,ip,in);
116
313
    ip++;
117
313
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
313
    assert(ip < ip_end);
123
313
    for (;;)
124
482k
    {
125
482k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
482k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
482k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
482k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
482k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
482k
#endif
143
144
482k
#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
472k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
445k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
445k
        if (++ip >= ip_end)
166
71
            break;
167
445k
#if (DD_BITS > 0)
168
445k
        DVAL_NEXT(dv,ip);
169
445k
#endif
170
445k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
36.7k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
36.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
36.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
36.7k
#endif
188
189
36.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
36.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
36.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
36.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
36.7k
#endif
203
204
36.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
36.5k
        assert(ii == ip);
209
210
36.5k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
313
    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
313
    if (pd(in_end,ii) > 0)
249
290
    {
250
290
        lzo_uint t = pd(in_end,ii);
251
290
        op = STORE_RUN(op,ii,t);
252
290
    }
253
254
313
    *out_len = pd(op, out);
255
313
    return LZO_E_OK;                /* compression went ok */
256
313
}
lzo1b_6.c:do_compress
Line
Count
Source
69
342
{
70
342
    const lzo_bytep ip;
71
342
#if (DD_BITS > 0)
72
342
#if defined(__LZO_HASH_INCREMENTAL)
73
342
    lzo_xint dv;
74
342
#endif
75
342
    unsigned drun = 0;
76
342
#endif
77
342
    lzo_bytep op;
78
342
    const lzo_bytep const in_end = in + in_len;
79
342
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
342
    const lzo_bytep ii;
81
342
#if defined(LZO_HAVE_R1)
82
342
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
342
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
342
    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
342
#if (LZO_DETERMINISTIC)
104
342
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
342
#endif
106
107
108
342
    op = out;
109
342
    ip = in;
110
342
    ii = ip;            /* point to start of current literal run */
111
112
113
342
#if (DD_BITS > 0)
114
342
    DVAL_FIRST(dv,ip);
115
342
    UPDATE_D(dict,drun,dv,ip,in);
116
342
    ip++;
117
342
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
342
    assert(ip < ip_end);
123
342
    for (;;)
124
1.89M
    {
125
1.89M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.89M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.89M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.89M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.89M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.89M
#endif
143
144
1.89M
#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.88M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.84M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.84M
        if (++ip >= ip_end)
166
91
            break;
167
1.84M
#if (DD_BITS > 0)
168
1.84M
        DVAL_NEXT(dv,ip);
169
1.84M
#endif
170
1.84M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
52.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
52.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
52.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
52.4k
#endif
188
189
52.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
52.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
52.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
52.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
52.4k
#endif
203
204
52.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
52.2k
        assert(ii == ip);
209
210
52.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
342
    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
342
    if (pd(in_end,ii) > 0)
249
317
    {
250
317
        lzo_uint t = pd(in_end,ii);
251
317
        op = STORE_RUN(op,ii,t);
252
317
    }
253
254
342
    *out_len = pd(op, out);
255
342
    return LZO_E_OK;                /* compression went ok */
256
342
}
lzo1b_7.c:do_compress
Line
Count
Source
69
339
{
70
339
    const lzo_bytep ip;
71
339
#if (DD_BITS > 0)
72
339
#if defined(__LZO_HASH_INCREMENTAL)
73
339
    lzo_xint dv;
74
339
#endif
75
339
    unsigned drun = 0;
76
339
#endif
77
339
    lzo_bytep op;
78
339
    const lzo_bytep const in_end = in + in_len;
79
339
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
339
    const lzo_bytep ii;
81
339
#if defined(LZO_HAVE_R1)
82
339
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
339
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
339
    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
339
#if (LZO_DETERMINISTIC)
104
339
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
339
#endif
106
107
108
339
    op = out;
109
339
    ip = in;
110
339
    ii = ip;            /* point to start of current literal run */
111
112
113
339
#if (DD_BITS > 0)
114
339
    DVAL_FIRST(dv,ip);
115
339
    UPDATE_D(dict,drun,dv,ip,in);
116
339
    ip++;
117
339
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
339
    assert(ip < ip_end);
123
339
    for (;;)
124
1.00M
    {
125
1.00M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.00M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.00M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.00M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.00M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.00M
#endif
143
144
1.00M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
998k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
961k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
961k
        if (++ip >= ip_end)
166
90
            break;
167
960k
#if (DD_BITS > 0)
168
960k
        DVAL_NEXT(dv,ip);
169
960k
#endif
170
960k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
48.3k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
48.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
48.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
48.3k
#endif
188
189
48.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
48.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
48.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
48.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
48.3k
#endif
203
204
48.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
48.1k
        assert(ii == ip);
209
210
48.1k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
339
    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
339
    if (pd(in_end,ii) > 0)
249
313
    {
250
313
        lzo_uint t = pd(in_end,ii);
251
313
        op = STORE_RUN(op,ii,t);
252
313
    }
253
254
339
    *out_len = pd(op, out);
255
339
    return LZO_E_OK;                /* compression went ok */
256
339
}
lzo1b_8.c:do_compress
Line
Count
Source
69
362
{
70
362
    const lzo_bytep ip;
71
362
#if (DD_BITS > 0)
72
362
#if defined(__LZO_HASH_INCREMENTAL)
73
362
    lzo_xint dv;
74
362
#endif
75
362
    unsigned drun = 0;
76
362
#endif
77
362
    lzo_bytep op;
78
362
    const lzo_bytep const in_end = in + in_len;
79
362
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
362
    const lzo_bytep ii;
81
362
#if defined(LZO_HAVE_R1)
82
362
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
362
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
362
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
362
#if (LZO_DETERMINISTIC)
104
362
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
362
#endif
106
107
108
362
    op = out;
109
362
    ip = in;
110
362
    ii = ip;            /* point to start of current literal run */
111
112
113
362
#if (DD_BITS > 0)
114
362
    DVAL_FIRST(dv,ip);
115
362
    UPDATE_D(dict,drun,dv,ip,in);
116
362
    ip++;
117
362
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
362
    assert(ip < ip_end);
123
362
    for (;;)
124
1.25M
    {
125
1.25M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.25M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.25M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.25M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.25M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.25M
#endif
143
144
1.25M
#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.22M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.17M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.17M
        if (++ip >= ip_end)
166
96
            break;
167
1.17M
#if (DD_BITS > 0)
168
1.17M
        DVAL_NEXT(dv,ip);
169
1.17M
#endif
170
1.17M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
73.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
73.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
73.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
73.4k
#endif
188
189
73.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
73.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
73.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
73.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
73.4k
#endif
203
204
73.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
73.1k
        assert(ii == ip);
209
210
73.1k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
362
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
362
    if (pd(in_end,ii) > 0)
249
338
    {
250
338
        lzo_uint t = pd(in_end,ii);
251
338
        op = STORE_RUN(op,ii,t);
252
338
    }
253
254
362
    *out_len = pd(op, out);
255
362
    return LZO_E_OK;                /* compression went ok */
256
362
}
lzo1b_9.c:do_compress
Line
Count
Source
69
373
{
70
373
    const lzo_bytep ip;
71
373
#if (DD_BITS > 0)
72
373
#if defined(__LZO_HASH_INCREMENTAL)
73
373
    lzo_xint dv;
74
373
#endif
75
373
    unsigned drun = 0;
76
373
#endif
77
373
    lzo_bytep op;
78
373
    const lzo_bytep const in_end = in + in_len;
79
373
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
373
    const lzo_bytep ii;
81
373
#if defined(LZO_HAVE_R1)
82
373
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
373
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
373
    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
373
#if (LZO_DETERMINISTIC)
104
373
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
373
#endif
106
107
108
373
    op = out;
109
373
    ip = in;
110
373
    ii = ip;            /* point to start of current literal run */
111
112
113
373
#if (DD_BITS > 0)
114
373
    DVAL_FIRST(dv,ip);
115
373
    UPDATE_D(dict,drun,dv,ip,in);
116
373
    ip++;
117
373
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
373
    assert(ip < ip_end);
123
373
    for (;;)
124
495k
    {
125
495k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
495k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
495k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
495k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
495k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
495k
#endif
143
144
495k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
495k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
495k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
495k
#endif
150
151
495k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
438k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
438k
        if (++ip >= ip_end)
166
88
            break;
167
438k
#if (DD_BITS > 0)
168
438k
        DVAL_NEXT(dv,ip);
169
438k
#endif
170
438k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
56.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
56.8k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
56.8k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
56.8k
#endif
188
189
56.8k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
56.8k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
56.8k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
56.8k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
56.8k
#endif
203
204
56.8k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
56.5k
        assert(ii == ip);
209
210
56.5k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
373
    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
373
    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
373
    *out_len = pd(op, out);
255
373
    return LZO_E_OK;                /* compression went ok */
256
373
}
lzo1b_99.c:do_compress
Line
Count
Source
69
388
{
70
388
    const lzo_bytep ip;
71
388
#if (DD_BITS > 0)
72
388
#if defined(__LZO_HASH_INCREMENTAL)
73
388
    lzo_xint dv;
74
388
#endif
75
388
    unsigned drun = 0;
76
388
#endif
77
388
    lzo_bytep op;
78
388
    const lzo_bytep const in_end = in + in_len;
79
388
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
388
    const lzo_bytep ii;
81
388
#if defined(LZO_HAVE_R1)
82
388
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
388
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
388
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
388
#if (LZO_DETERMINISTIC)
104
388
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
388
#endif
106
107
108
388
    op = out;
109
388
    ip = in;
110
388
    ii = ip;            /* point to start of current literal run */
111
112
113
388
#if (DD_BITS > 0)
114
388
    DVAL_FIRST(dv,ip);
115
388
    UPDATE_D(dict,drun,dv,ip,in);
116
388
    ip++;
117
388
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
388
    assert(ip < ip_end);
123
388
    for (;;)
124
842k
    {
125
842k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
842k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
842k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
842k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
842k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
842k
#endif
143
144
842k
#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
842k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
778k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
778k
        if (++ip >= ip_end)
166
78
            break;
167
778k
#if (DD_BITS > 0)
168
778k
        DVAL_NEXT(dv,ip);
169
778k
#endif
170
778k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
64.1k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
64.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
64.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
64.1k
#endif
188
189
64.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
64.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
64.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
64.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
64.1k
#endif
203
204
64.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
63.8k
        assert(ii == ip);
209
210
63.8k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
388
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
388
    if (pd(in_end,ii) > 0)
249
352
    {
250
352
        lzo_uint t = pd(in_end,ii);
251
352
        op = STORE_RUN(op,ii,t);
252
352
    }
253
254
388
    *out_len = pd(op, out);
255
388
    return LZO_E_OK;                /* compression went ok */
256
388
}
lzo1c_1.c:do_compress
Line
Count
Source
69
452
{
70
452
    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
452
    lzo_bytep op;
78
452
    const lzo_bytep const in_end = in + in_len;
79
452
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
452
    const lzo_bytep ii;
81
452
#if defined(LZO_HAVE_R1)
82
452
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
452
#endif
84
452
#if defined(LZO_HAVE_M3)
85
452
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
452
#endif
87
88
452
    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
452
    op = out;
109
452
    ip = in;
110
452
    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
452
    ip++;
120
452
#endif
121
122
452
    assert(ip < ip_end);
123
452
    for (;;)
124
4.79M
    {
125
4.79M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
4.79M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
4.79M
#if (DD_BITS == 0)
131
4.79M
        lzo_uint dindex;
132
4.79M
#endif
133
4.79M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
4.79M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
4.79M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
4.79M
#endif
143
144
4.79M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
159k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
159k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
159k
#endif
150
151
159k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
4.73M
literal:
162
4.73M
#if (DD_BITS == 0)
163
4.73M
        UPDATE_I(dict,0,dindex,ip,in);
164
4.73M
#endif
165
4.73M
        if (++ip >= ip_end)
166
175
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
4.73M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
4.73M
match:
179
50.9k
#if (DD_BITS == 0)
180
50.9k
        UPDATE_I(dict,0,dindex,ip,in);
181
50.9k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
50.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
50.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
50.9k
#endif
188
189
50.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
50.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
50.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
50.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
50.9k
#endif
203
204
50.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
50.6k
        assert(ii == ip);
209
210
50.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
452
    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
452
    if (pd(in_end,ii) > 0)
249
396
    {
250
396
        lzo_uint t = pd(in_end,ii);
251
396
        op = STORE_RUN(op,ii,t);
252
396
    }
253
254
452
    *out_len = pd(op, out);
255
452
    return LZO_E_OK;                /* compression went ok */
256
452
}
lzo1c_5.c:do_compress
Line
Count
Source
69
386
{
70
386
    const lzo_bytep ip;
71
386
#if (DD_BITS > 0)
72
386
#if defined(__LZO_HASH_INCREMENTAL)
73
386
    lzo_xint dv;
74
386
#endif
75
386
    unsigned drun = 0;
76
386
#endif
77
386
    lzo_bytep op;
78
386
    const lzo_bytep const in_end = in + in_len;
79
386
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
386
    const lzo_bytep ii;
81
386
#if defined(LZO_HAVE_R1)
82
386
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
386
#endif
84
386
#if defined(LZO_HAVE_M3)
85
386
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
386
#endif
87
88
386
    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
386
    op = out;
109
386
    ip = in;
110
386
    ii = ip;            /* point to start of current literal run */
111
112
113
386
#if (DD_BITS > 0)
114
386
    DVAL_FIRST(dv,ip);
115
386
    UPDATE_D(dict,drun,dv,ip,in);
116
386
    ip++;
117
386
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
386
    assert(ip < ip_end);
123
386
    for (;;)
124
2.89M
    {
125
2.89M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.89M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.89M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.89M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.89M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.89M
#endif
143
144
2.89M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
2.88M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.82M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.82M
        if (++ip >= ip_end)
166
96
            break;
167
2.82M
#if (DD_BITS > 0)
168
2.82M
        DVAL_NEXT(dv,ip);
169
2.82M
#endif
170
2.82M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
73.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
73.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
73.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
73.5k
#endif
188
189
73.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
73.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
73.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
73.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
73.5k
#endif
203
204
73.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
73.2k
        assert(ii == ip);
209
210
73.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
386
    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
386
    if (pd(in_end,ii) > 0)
249
360
    {
250
360
        lzo_uint t = pd(in_end,ii);
251
360
        op = STORE_RUN(op,ii,t);
252
360
    }
253
254
386
    *out_len = pd(op, out);
255
386
    return LZO_E_OK;                /* compression went ok */
256
386
}
lzo1c_9.c:do_compress
Line
Count
Source
69
408
{
70
408
    const lzo_bytep ip;
71
408
#if (DD_BITS > 0)
72
408
#if defined(__LZO_HASH_INCREMENTAL)
73
408
    lzo_xint dv;
74
408
#endif
75
408
    unsigned drun = 0;
76
408
#endif
77
408
    lzo_bytep op;
78
408
    const lzo_bytep const in_end = in + in_len;
79
408
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
408
    const lzo_bytep ii;
81
408
#if defined(LZO_HAVE_R1)
82
408
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
408
#endif
84
408
#if defined(LZO_HAVE_M3)
85
408
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
408
#endif
87
88
408
    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
408
    op = out;
109
408
    ip = in;
110
408
    ii = ip;            /* point to start of current literal run */
111
112
113
408
#if (DD_BITS > 0)
114
408
    DVAL_FIRST(dv,ip);
115
408
    UPDATE_D(dict,drun,dv,ip,in);
116
408
    ip++;
117
408
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
408
    assert(ip < ip_end);
123
408
    for (;;)
124
3.38M
    {
125
3.38M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
3.38M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
3.38M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
3.38M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
3.38M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
3.38M
#endif
143
144
3.38M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
3.38M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
3.38M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
3.38M
#endif
150
151
3.38M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.36M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
3.36M
        if (++ip >= ip_end)
166
105
            break;
167
3.36M
#if (DD_BITS > 0)
168
3.36M
        DVAL_NEXT(dv,ip);
169
3.36M
#endif
170
3.36M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
26.3k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
26.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
26.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
26.3k
#endif
188
189
26.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
26.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
26.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
26.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
26.3k
#endif
203
204
26.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
25.9k
        assert(ii == ip);
209
210
25.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
408
    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
408
    if (pd(in_end,ii) > 0)
249
359
    {
250
359
        lzo_uint t = pd(in_end,ii);
251
359
        op = STORE_RUN(op,ii,t);
252
359
    }
253
254
408
    *out_len = pd(op, out);
255
408
    return LZO_E_OK;                /* compression went ok */
256
408
}
lzo1c_99.c:do_compress
Line
Count
Source
69
429
{
70
429
    const lzo_bytep ip;
71
429
#if (DD_BITS > 0)
72
429
#if defined(__LZO_HASH_INCREMENTAL)
73
429
    lzo_xint dv;
74
429
#endif
75
429
    unsigned drun = 0;
76
429
#endif
77
429
    lzo_bytep op;
78
429
    const lzo_bytep const in_end = in + in_len;
79
429
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
429
    const lzo_bytep ii;
81
429
#if defined(LZO_HAVE_R1)
82
429
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
429
#endif
84
429
#if defined(LZO_HAVE_M3)
85
429
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
429
#endif
87
88
429
    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
429
    op = out;
109
429
    ip = in;
110
429
    ii = ip;            /* point to start of current literal run */
111
112
113
429
#if (DD_BITS > 0)
114
429
    DVAL_FIRST(dv,ip);
115
429
    UPDATE_D(dict,drun,dv,ip,in);
116
429
    ip++;
117
429
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
429
    assert(ip < ip_end);
123
429
    for (;;)
124
4.57M
    {
125
4.57M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
4.57M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
4.57M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
4.57M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
4.57M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
4.57M
#endif
143
144
4.57M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
0
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
0
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
0
#endif
150
151
4.57M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
4.51M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
4.51M
        if (++ip >= ip_end)
166
93
            break;
167
4.51M
#if (DD_BITS > 0)
168
4.51M
        DVAL_NEXT(dv,ip);
169
4.51M
#endif
170
4.51M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
61.7k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
61.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
61.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
61.7k
#endif
188
189
61.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
61.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
61.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
61.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
61.7k
#endif
203
204
61.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
61.3k
        assert(ii == ip);
209
210
61.3k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
429
    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
429
    if (pd(in_end,ii) > 0)
249
389
    {
250
389
        lzo_uint t = pd(in_end,ii);
251
389
        op = STORE_RUN(op,ii,t);
252
389
    }
253
254
429
    *out_len = pd(op, out);
255
429
    return LZO_E_OK;                /* compression went ok */
256
429
}
257
#ifdef __cplusplus
258
} /* extern "C" */
259
#endif
260
261
262
/* vim:set ts=4 sw=4 et: */