Coverage Report

Created: 2026-10-17 06:33

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
532k
#define DI      ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,drun,dv,ii,in); MI
49
273k
#define XI      assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
50
#else
51
225k
#define DI      ++ii; DINDEX1(dindex,ii); UPDATE_I(dict,0,dindex,ii,in); MI
52
323k
#define XI      assert(ii < ip); ii = ip;
53
#endif
54
55
56
/***********************************************************************
57
// compress a block of data.
58
//
59
// I really apologize for this spaghetti code.
60
************************************************************************/
61
62
#ifdef __cplusplus
63
extern "C" {
64
#endif
65
LZO_PRIVATE(int)
66
do_compress    ( const lzo_bytep in , lzo_uint  in_len,
67
                       lzo_bytep out, lzo_uintp out_len,
68
                       lzo_voidp wrkmem )
69
6.01k
{
70
6.01k
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
4.55k
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
6.01k
    lzo_bytep op;
78
6.01k
    const lzo_bytep const in_end = in + in_len;
79
6.01k
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
6.01k
    const lzo_bytep ii;
81
#if defined(LZO_HAVE_R1)
82
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
#endif
84
#if defined(LZO_HAVE_M3)
85
1.70k
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
6.01k
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
4.30k
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
6.01k
    op = out;
109
6.01k
    ip = in;
110
6.01k
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
4.55k
    DVAL_FIRST(dv,ip);
115
4.55k
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
4.55k
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
6.01k
    assert(ip < ip_end);
123
6.01k
    for (;;)
124
48.5M
    {
125
48.5M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
48.5M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
48.5M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
48.5M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
48.5M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
48.5M
#endif
143
144
48.5M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
425k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
425k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
425k
#endif
150
151
38.2M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
47.4M
literal:
162
#if (DD_BITS == 0)
163
10.3M
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
47.4M
        if (++ip >= ip_end)
166
1.71k
            break;
167
#if (DD_BITS > 0)
168
37.1M
        DVAL_NEXT(dv,ip);
169
37.1M
#endif
170
10.3M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
10.3M
match:
179
#if (DD_BITS == 0)
180
323k
        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.10M
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
1.10M
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
1.10M
#endif
188
189
1.10M
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
1.10M
        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.10M
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
1.10M
        assert(ii == ip);
209
210
1.10M
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
6.01k
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
6.01k
    if (pd(in_end,ii) > 0)
249
5.38k
    {
250
5.38k
        lzo_uint t = pd(in_end,ii);
251
5.38k
        op = STORE_RUN(op,ii,t);
252
5.38k
    }
253
254
6.01k
    *out_len = pd(op, out);
255
6.01k
    return LZO_E_OK;                /* compression went ok */
256
6.01k
}
lzo1_99.c:do_compress
Line
Count
Source
69
378
{
70
378
    const lzo_bytep ip;
71
378
#if (DD_BITS > 0)
72
378
#if defined(__LZO_HASH_INCREMENTAL)
73
378
    lzo_xint dv;
74
378
#endif
75
378
    unsigned drun = 0;
76
378
#endif
77
378
    lzo_bytep op;
78
378
    const lzo_bytep const in_end = in + in_len;
79
378
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
378
    const lzo_bytep ii;
81
#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
378
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
378
#if (LZO_DETERMINISTIC)
104
378
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
378
#endif
106
107
108
378
    op = out;
109
378
    ip = in;
110
378
    ii = ip;            /* point to start of current literal run */
111
112
113
378
#if (DD_BITS > 0)
114
378
    DVAL_FIRST(dv,ip);
115
378
    UPDATE_D(dict,drun,dv,ip,in);
116
378
    ip++;
117
378
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
378
    assert(ip < ip_end);
123
378
    for (;;)
124
7.81M
    {
125
7.81M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
7.81M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
7.81M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
7.81M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
7.81M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
7.81M
#endif
143
144
7.81M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
7.81M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
7.81M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
7.81M
#endif
150
151
7.81M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
7.74M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
7.74M
        if (++ip >= ip_end)
166
106
            break;
167
7.74M
#if (DD_BITS > 0)
168
7.74M
        DVAL_NEXT(dv,ip);
169
7.74M
#endif
170
7.74M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
69.9k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
69.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
69.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
69.9k
#endif
188
189
69.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
69.9k
        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
69.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
69.6k
        assert(ii == ip);
209
210
69.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
378
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
378
    if (pd(in_end,ii) > 0)
249
307
    {
250
307
        lzo_uint t = pd(in_end,ii);
251
307
        op = STORE_RUN(op,ii,t);
252
307
    }
253
254
378
    *out_len = pd(op, out);
255
378
    return LZO_E_OK;                /* compression went ok */
256
378
}
lzo1a_99.c:do_compress
Line
Count
Source
69
370
{
70
370
    const lzo_bytep ip;
71
370
#if (DD_BITS > 0)
72
370
#if defined(__LZO_HASH_INCREMENTAL)
73
370
    lzo_xint dv;
74
370
#endif
75
370
    unsigned drun = 0;
76
370
#endif
77
370
    lzo_bytep op;
78
370
    const lzo_bytep const in_end = in + in_len;
79
370
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
370
    const lzo_bytep ii;
81
370
#if defined(LZO_HAVE_R1)
82
370
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
370
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
370
    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
370
#if (LZO_DETERMINISTIC)
104
370
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
370
#endif
106
107
108
370
    op = out;
109
370
    ip = in;
110
370
    ii = ip;            /* point to start of current literal run */
111
112
113
370
#if (DD_BITS > 0)
114
370
    DVAL_FIRST(dv,ip);
115
370
    UPDATE_D(dict,drun,dv,ip,in);
116
370
    ip++;
117
370
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
370
    assert(ip < ip_end);
123
370
    for (;;)
124
9.99M
    {
125
9.99M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
9.99M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
9.99M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
9.99M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
9.99M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
9.99M
#endif
143
144
9.99M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
9.99M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
9.99M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
9.99M
#endif
150
151
9.99M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
9.90M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
9.90M
        if (++ip >= ip_end)
166
103
            break;
167
9.90M
#if (DD_BITS > 0)
168
9.90M
        DVAL_NEXT(dv,ip);
169
9.90M
#endif
170
9.90M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
87.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
87.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
87.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
87.7k
#endif
188
189
87.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
87.7k
        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
87.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
87.4k
        assert(ii == ip);
209
210
87.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
370
    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
370
    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
370
    *out_len = pd(op, out);
255
370
    return LZO_E_OK;                /* compression went ok */
256
370
}
lzo1b_1.c:do_compress
Line
Count
Source
69
354
{
70
354
    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
354
    lzo_bytep op;
78
354
    const lzo_bytep const in_end = in + in_len;
79
354
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
354
    const lzo_bytep ii;
81
354
#if defined(LZO_HAVE_R1)
82
354
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
354
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
354
    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
354
#if (LZO_DETERMINISTIC)
104
354
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
354
#endif
106
107
108
354
    op = out;
109
354
    ip = in;
110
354
    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
354
    ip++;
120
354
#endif
121
122
354
    assert(ip < ip_end);
123
354
    for (;;)
124
2.22M
    {
125
2.22M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.22M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
2.22M
#if (DD_BITS == 0)
131
2.22M
        lzo_uint dindex;
132
2.22M
#endif
133
2.22M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.22M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.22M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.22M
#endif
143
144
2.22M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
89.3k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
89.3k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
89.3k
#endif
150
151
89.3k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.14M
literal:
162
2.14M
#if (DD_BITS == 0)
163
2.14M
        UPDATE_I(dict,0,dindex,ip,in);
164
2.14M
#endif
165
2.14M
        if (++ip >= ip_end)
166
139
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
2.14M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
2.14M
match:
179
77.9k
#if (DD_BITS == 0)
180
77.9k
        UPDATE_I(dict,0,dindex,ip,in);
181
77.9k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
77.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
77.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
77.9k
#endif
188
189
77.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
77.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
77.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
77.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
77.9k
#endif
203
204
77.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
77.7k
        assert(ii == ip);
209
210
77.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
354
    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
354
    if (pd(in_end,ii) > 0)
249
323
    {
250
323
        lzo_uint t = pd(in_end,ii);
251
323
        op = STORE_RUN(op,ii,t);
252
323
    }
253
254
354
    *out_len = pd(op, out);
255
354
    return LZO_E_OK;                /* compression went ok */
256
354
}
lzo1b_2.c:do_compress
Line
Count
Source
69
325
{
70
325
    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
325
    lzo_bytep op;
78
325
    const lzo_bytep const in_end = in + in_len;
79
325
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
325
    const lzo_bytep ii;
81
325
#if defined(LZO_HAVE_R1)
82
325
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
325
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
325
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
325
#if (LZO_DETERMINISTIC)
104
325
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
325
#endif
106
107
108
325
    op = out;
109
325
    ip = in;
110
325
    ii = ip;            /* point to start of current literal run */
111
112
113
#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
325
    ip++;
120
325
#endif
121
122
325
    assert(ip < ip_end);
123
325
    for (;;)
124
1.69M
    {
125
1.69M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.69M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.69M
#if (DD_BITS == 0)
131
1.69M
        lzo_uint dindex;
132
1.69M
#endif
133
1.69M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.69M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.69M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.69M
#endif
143
144
1.69M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
82.4k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
82.4k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
82.4k
#endif
150
151
82.4k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.57M
literal:
162
1.57M
#if (DD_BITS == 0)
163
1.57M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.57M
#endif
165
1.57M
        if (++ip >= ip_end)
166
123
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.57M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.57M
match:
179
129k
#if (DD_BITS == 0)
180
129k
        UPDATE_I(dict,0,dindex,ip,in);
181
129k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
129k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
129k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
129k
#endif
188
189
129k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
129k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
129k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
129k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
129k
#endif
203
204
129k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
128k
        assert(ii == ip);
209
210
128k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
325
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
325
    if (pd(in_end,ii) > 0)
249
306
    {
250
306
        lzo_uint t = pd(in_end,ii);
251
306
        op = STORE_RUN(op,ii,t);
252
306
    }
253
254
325
    *out_len = pd(op, out);
255
325
    return LZO_E_OK;                /* compression went ok */
256
325
}
lzo1b_3.c:do_compress
Line
Count
Source
69
339
{
70
339
    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
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
#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
339
    ip++;
120
339
#endif
121
122
339
    assert(ip < ip_end);
123
339
    for (;;)
124
1.04M
    {
125
1.04M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.04M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.04M
#if (DD_BITS == 0)
131
1.04M
        lzo_uint dindex;
132
1.04M
#endif
133
1.04M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.04M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.04M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.04M
#endif
143
144
1.04M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
52.6k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
52.6k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
52.6k
#endif
150
151
52.6k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
992k
literal:
162
992k
#if (DD_BITS == 0)
163
992k
        UPDATE_I(dict,0,dindex,ip,in);
164
992k
#endif
165
992k
        if (++ip >= ip_end)
166
115
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
991k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
991k
match:
179
48.5k
#if (DD_BITS == 0)
180
48.5k
        UPDATE_I(dict,0,dindex,ip,in);
181
48.5k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
48.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
48.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
48.5k
#endif
188
189
48.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
48.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
48.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
48.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
48.5k
#endif
203
204
48.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
48.2k
        assert(ii == ip);
209
210
48.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
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
314
    {
250
314
        lzo_uint t = pd(in_end,ii);
251
314
        op = STORE_RUN(op,ii,t);
252
314
    }
253
254
339
    *out_len = pd(op, out);
255
339
    return LZO_E_OK;                /* compression went ok */
256
339
}
lzo1b_4.c:do_compress
Line
Count
Source
69
369
{
70
369
    const lzo_bytep ip;
71
369
#if (DD_BITS > 0)
72
369
#if defined(__LZO_HASH_INCREMENTAL)
73
369
    lzo_xint dv;
74
369
#endif
75
369
    unsigned drun = 0;
76
369
#endif
77
369
    lzo_bytep op;
78
369
    const lzo_bytep const in_end = in + in_len;
79
369
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
369
    const lzo_bytep ii;
81
369
#if defined(LZO_HAVE_R1)
82
369
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
369
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
369
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
369
#if (LZO_DETERMINISTIC)
104
369
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
369
#endif
106
107
108
369
    op = out;
109
369
    ip = in;
110
369
    ii = ip;            /* point to start of current literal run */
111
112
113
369
#if (DD_BITS > 0)
114
369
    DVAL_FIRST(dv,ip);
115
369
    UPDATE_D(dict,drun,dv,ip,in);
116
369
    ip++;
117
369
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
369
    assert(ip < ip_end);
123
369
    for (;;)
124
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.87M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.77M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.77M
        if (++ip >= ip_end)
166
117
            break;
167
1.77M
#if (DD_BITS > 0)
168
1.77M
        DVAL_NEXT(dv,ip);
169
1.77M
#endif
170
1.77M
        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
123k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
123k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
123k
#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
369
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
369
    if (pd(in_end,ii) > 0)
249
350
    {
250
350
        lzo_uint t = pd(in_end,ii);
251
350
        op = STORE_RUN(op,ii,t);
252
350
    }
253
254
369
    *out_len = pd(op, out);
255
369
    return LZO_E_OK;                /* compression went ok */
256
369
}
lzo1b_5.c:do_compress
Line
Count
Source
69
316
{
70
316
    const lzo_bytep ip;
71
316
#if (DD_BITS > 0)
72
316
#if defined(__LZO_HASH_INCREMENTAL)
73
316
    lzo_xint dv;
74
316
#endif
75
316
    unsigned drun = 0;
76
316
#endif
77
316
    lzo_bytep op;
78
316
    const lzo_bytep const in_end = in + in_len;
79
316
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
316
    const lzo_bytep ii;
81
316
#if defined(LZO_HAVE_R1)
82
316
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
316
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
316
    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
316
#if (LZO_DETERMINISTIC)
104
316
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
316
#endif
106
107
108
316
    op = out;
109
316
    ip = in;
110
316
    ii = ip;            /* point to start of current literal run */
111
112
113
316
#if (DD_BITS > 0)
114
316
    DVAL_FIRST(dv,ip);
115
316
    UPDATE_D(dict,drun,dv,ip,in);
116
316
    ip++;
117
316
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
316
    assert(ip < ip_end);
123
316
    for (;;)
124
592k
    {
125
592k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
592k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
592k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
592k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
592k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
592k
#endif
143
144
592k
#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
584k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
562k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
562k
        if (++ip >= ip_end)
166
67
            break;
167
562k
#if (DD_BITS > 0)
168
562k
        DVAL_NEXT(dv,ip);
169
562k
#endif
170
562k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
30.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
30.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
30.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
30.1k
#endif
188
189
30.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
30.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
30.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
30.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
30.1k
#endif
203
204
30.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
29.9k
        assert(ii == ip);
209
210
29.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
316
    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
316
    if (pd(in_end,ii) > 0)
249
287
    {
250
287
        lzo_uint t = pd(in_end,ii);
251
287
        op = STORE_RUN(op,ii,t);
252
287
    }
253
254
316
    *out_len = pd(op, out);
255
316
    return LZO_E_OK;                /* compression went ok */
256
316
}
lzo1b_6.c:do_compress
Line
Count
Source
69
355
{
70
355
    const lzo_bytep ip;
71
355
#if (DD_BITS > 0)
72
355
#if defined(__LZO_HASH_INCREMENTAL)
73
355
    lzo_xint dv;
74
355
#endif
75
355
    unsigned drun = 0;
76
355
#endif
77
355
    lzo_bytep op;
78
355
    const lzo_bytep const in_end = in + in_len;
79
355
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
355
    const lzo_bytep ii;
81
355
#if defined(LZO_HAVE_R1)
82
355
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
355
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
355
    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
355
#if (LZO_DETERMINISTIC)
104
355
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
355
#endif
106
107
108
355
    op = out;
109
355
    ip = in;
110
355
    ii = ip;            /* point to start of current literal run */
111
112
113
355
#if (DD_BITS > 0)
114
355
    DVAL_FIRST(dv,ip);
115
355
    UPDATE_D(dict,drun,dv,ip,in);
116
355
    ip++;
117
355
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
355
    assert(ip < ip_end);
123
355
    for (;;)
124
2.31M
    {
125
2.31M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.31M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.31M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.31M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.31M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.31M
#endif
143
144
2.31M
#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.30M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.27M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.27M
        if (++ip >= ip_end)
166
88
            break;
167
2.27M
#if (DD_BITS > 0)
168
2.27M
        DVAL_NEXT(dv,ip);
169
2.27M
#endif
170
2.27M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
41.9k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
41.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
41.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
41.9k
#endif
188
189
41.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
41.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
41.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
41.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
41.9k
#endif
203
204
41.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
41.6k
        assert(ii == ip);
209
210
41.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
355
    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
355
    if (pd(in_end,ii) > 0)
249
321
    {
250
321
        lzo_uint t = pd(in_end,ii);
251
321
        op = STORE_RUN(op,ii,t);
252
321
    }
253
254
355
    *out_len = pd(op, out);
255
355
    return LZO_E_OK;                /* compression went ok */
256
355
}
lzo1b_7.c:do_compress
Line
Count
Source
69
348
{
70
348
    const lzo_bytep ip;
71
348
#if (DD_BITS > 0)
72
348
#if defined(__LZO_HASH_INCREMENTAL)
73
348
    lzo_xint dv;
74
348
#endif
75
348
    unsigned drun = 0;
76
348
#endif
77
348
    lzo_bytep op;
78
348
    const lzo_bytep const in_end = in + in_len;
79
348
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
348
    const lzo_bytep ii;
81
348
#if defined(LZO_HAVE_R1)
82
348
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
348
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
348
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
348
#if (LZO_DETERMINISTIC)
104
348
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
348
#endif
106
107
108
348
    op = out;
109
348
    ip = in;
110
348
    ii = ip;            /* point to start of current literal run */
111
112
113
348
#if (DD_BITS > 0)
114
348
    DVAL_FIRST(dv,ip);
115
348
    UPDATE_D(dict,drun,dv,ip,in);
116
348
    ip++;
117
348
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
348
    assert(ip < ip_end);
123
348
    for (;;)
124
723k
    {
125
723k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
723k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
723k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
723k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
723k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
723k
#endif
143
144
723k
#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
713k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
685k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
685k
        if (++ip >= ip_end)
166
83
            break;
167
685k
#if (DD_BITS > 0)
168
685k
        DVAL_NEXT(dv,ip);
169
685k
#endif
170
685k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
37.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
37.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
37.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
37.7k
#endif
188
189
37.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
37.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
37.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
37.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
37.7k
#endif
203
204
37.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
37.4k
        assert(ii == ip);
209
210
37.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
348
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
348
    if (pd(in_end,ii) > 0)
249
323
    {
250
323
        lzo_uint t = pd(in_end,ii);
251
323
        op = STORE_RUN(op,ii,t);
252
323
    }
253
254
348
    *out_len = pd(op, out);
255
348
    return LZO_E_OK;                /* compression went ok */
256
348
}
lzo1b_8.c:do_compress
Line
Count
Source
69
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
2.07M
    {
125
2.07M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.07M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.07M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.07M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.07M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.07M
#endif
143
144
2.07M
#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.05M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.99M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.99M
        if (++ip >= ip_end)
166
97
            break;
167
1.99M
#if (DD_BITS > 0)
168
1.99M
        DVAL_NEXT(dv,ip);
169
1.99M
#endif
170
1.99M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
80.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
80.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
80.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
80.3k
#endif
188
189
80.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
80.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
80.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
80.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
80.3k
#endif
203
204
80.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
80.0k
        assert(ii == ip);
209
210
80.0k
    }
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
334
    {
250
334
        lzo_uint t = pd(in_end,ii);
251
334
        op = STORE_RUN(op,ii,t);
252
334
    }
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
390
{
70
390
    const lzo_bytep ip;
71
390
#if (DD_BITS > 0)
72
390
#if defined(__LZO_HASH_INCREMENTAL)
73
390
    lzo_xint dv;
74
390
#endif
75
390
    unsigned drun = 0;
76
390
#endif
77
390
    lzo_bytep op;
78
390
    const lzo_bytep const in_end = in + in_len;
79
390
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
390
    const lzo_bytep ii;
81
390
#if defined(LZO_HAVE_R1)
82
390
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
390
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
390
    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
390
#if (LZO_DETERMINISTIC)
104
390
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
390
#endif
106
107
108
390
    op = out;
109
390
    ip = in;
110
390
    ii = ip;            /* point to start of current literal run */
111
112
113
390
#if (DD_BITS > 0)
114
390
    DVAL_FIRST(dv,ip);
115
390
    UPDATE_D(dict,drun,dv,ip,in);
116
390
    ip++;
117
390
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
390
    assert(ip < ip_end);
123
390
    for (;;)
124
487k
    {
125
487k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
487k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
487k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
487k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
487k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
487k
#endif
143
144
487k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
487k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
487k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
487k
#endif
150
151
487k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
439k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
439k
        if (++ip >= ip_end)
166
90
            break;
167
439k
#if (DD_BITS > 0)
168
439k
        DVAL_NEXT(dv,ip);
169
439k
#endif
170
439k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
47.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
47.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
47.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
47.7k
#endif
188
189
47.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
47.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
47.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
47.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
47.7k
#endif
203
204
47.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
47.4k
        assert(ii == ip);
209
210
47.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
390
    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
390
    if (pd(in_end,ii) > 0)
249
333
    {
250
333
        lzo_uint t = pd(in_end,ii);
251
333
        op = STORE_RUN(op,ii,t);
252
333
    }
253
254
390
    *out_len = pd(op, out);
255
390
    return LZO_E_OK;                /* compression went ok */
256
390
}
lzo1b_99.c:do_compress
Line
Count
Source
69
400
{
70
400
    const lzo_bytep ip;
71
400
#if (DD_BITS > 0)
72
400
#if defined(__LZO_HASH_INCREMENTAL)
73
400
    lzo_xint dv;
74
400
#endif
75
400
    unsigned drun = 0;
76
400
#endif
77
400
    lzo_bytep op;
78
400
    const lzo_bytep const in_end = in + in_len;
79
400
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
400
    const lzo_bytep ii;
81
400
#if defined(LZO_HAVE_R1)
82
400
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
400
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
400
    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
400
#if (LZO_DETERMINISTIC)
104
400
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
400
#endif
106
107
108
400
    op = out;
109
400
    ip = in;
110
400
    ii = ip;            /* point to start of current literal run */
111
112
113
400
#if (DD_BITS > 0)
114
400
    DVAL_FIRST(dv,ip);
115
400
    UPDATE_D(dict,drun,dv,ip,in);
116
400
    ip++;
117
400
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
400
    assert(ip < ip_end);
123
400
    for (;;)
124
1.52M
    {
125
1.52M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.52M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.52M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.52M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.52M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.52M
#endif
143
144
1.52M
#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.52M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.45M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.45M
        if (++ip >= ip_end)
166
83
            break;
167
1.45M
#if (DD_BITS > 0)
168
1.45M
        DVAL_NEXT(dv,ip);
169
1.45M
#endif
170
1.45M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
70.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
70.7k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
70.7k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
70.7k
#endif
188
189
70.7k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
70.7k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
70.7k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
70.7k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
70.7k
#endif
203
204
70.7k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
70.3k
        assert(ii == ip);
209
210
70.3k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
400
    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
400
    if (pd(in_end,ii) > 0)
249
349
    {
250
349
        lzo_uint t = pd(in_end,ii);
251
349
        op = STORE_RUN(op,ii,t);
252
349
    }
253
254
400
    *out_len = pd(op, out);
255
400
    return LZO_E_OK;                /* compression went ok */
256
400
}
lzo1c_1.c:do_compress
Line
Count
Source
69
444
{
70
444
    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
444
    lzo_bytep op;
78
444
    const lzo_bytep const in_end = in + in_len;
79
444
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
444
    const lzo_bytep ii;
81
444
#if defined(LZO_HAVE_R1)
82
444
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
444
#endif
84
444
#if defined(LZO_HAVE_M3)
85
444
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
444
#endif
87
88
444
    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
444
    op = out;
109
444
    ip = in;
110
444
    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
444
    ip++;
120
444
#endif
121
122
444
    assert(ip < ip_end);
123
444
    for (;;)
124
5.70M
    {
125
5.70M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
5.70M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
5.70M
#if (DD_BITS == 0)
131
5.70M
        lzo_uint dindex;
132
5.70M
#endif
133
5.70M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
5.70M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
5.70M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
5.70M
#endif
143
144
5.70M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
201k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
201k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
201k
#endif
150
151
201k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
5.63M
literal:
162
5.63M
#if (DD_BITS == 0)
163
5.63M
        UPDATE_I(dict,0,dindex,ip,in);
164
5.63M
#endif
165
5.63M
        if (++ip >= ip_end)
166
185
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
5.63M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
5.63M
match:
179
68.0k
#if (DD_BITS == 0)
180
68.0k
        UPDATE_I(dict,0,dindex,ip,in);
181
68.0k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
68.0k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
68.0k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
68.0k
#endif
188
189
68.0k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
68.0k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
68.0k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
68.0k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
68.0k
#endif
203
204
68.0k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
67.8k
        assert(ii == ip);
209
210
67.8k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
444
    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
444
    if (pd(in_end,ii) > 0)
249
391
    {
250
391
        lzo_uint t = pd(in_end,ii);
251
391
        op = STORE_RUN(op,ii,t);
252
391
    }
253
254
444
    *out_len = pd(op, out);
255
444
    return LZO_E_OK;                /* compression went ok */
256
444
}
lzo1c_5.c:do_compress
Line
Count
Source
69
398
{
70
398
    const lzo_bytep ip;
71
398
#if (DD_BITS > 0)
72
398
#if defined(__LZO_HASH_INCREMENTAL)
73
398
    lzo_xint dv;
74
398
#endif
75
398
    unsigned drun = 0;
76
398
#endif
77
398
    lzo_bytep op;
78
398
    const lzo_bytep const in_end = in + in_len;
79
398
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
398
    const lzo_bytep ii;
81
398
#if defined(LZO_HAVE_R1)
82
398
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
398
#endif
84
398
#if defined(LZO_HAVE_M3)
85
398
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
398
#endif
87
88
398
    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
398
    op = out;
109
398
    ip = in;
110
398
    ii = ip;            /* point to start of current literal run */
111
112
113
398
#if (DD_BITS > 0)
114
398
    DVAL_FIRST(dv,ip);
115
398
    UPDATE_D(dict,drun,dv,ip,in);
116
398
    ip++;
117
398
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
398
    assert(ip < ip_end);
123
398
    for (;;)
124
2.63M
    {
125
2.63M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.63M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.63M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.63M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.63M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.63M
#endif
143
144
2.63M
#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.61M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
2.57M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
2.57M
        if (++ip >= ip_end)
166
109
            break;
167
2.57M
#if (DD_BITS > 0)
168
2.57M
        DVAL_NEXT(dv,ip);
169
2.57M
#endif
170
2.57M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
60.0k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
60.0k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
60.0k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
60.0k
#endif
188
189
60.0k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
60.0k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
60.0k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
60.0k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
60.0k
#endif
203
204
60.0k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
59.7k
        assert(ii == ip);
209
210
59.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
398
    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
398
    if (pd(in_end,ii) > 0)
249
369
    {
250
369
        lzo_uint t = pd(in_end,ii);
251
369
        op = STORE_RUN(op,ii,t);
252
369
    }
253
254
398
    *out_len = pd(op, out);
255
398
    return LZO_E_OK;                /* compression went ok */
256
398
}
lzo1c_9.c:do_compress
Line
Count
Source
69
419
{
70
419
    const lzo_bytep ip;
71
419
#if (DD_BITS > 0)
72
419
#if defined(__LZO_HASH_INCREMENTAL)
73
419
    lzo_xint dv;
74
419
#endif
75
419
    unsigned drun = 0;
76
419
#endif
77
419
    lzo_bytep op;
78
419
    const lzo_bytep const in_end = in + in_len;
79
419
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
419
    const lzo_bytep ii;
81
419
#if defined(LZO_HAVE_R1)
82
419
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
419
#endif
84
419
#if defined(LZO_HAVE_M3)
85
419
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
419
#endif
87
88
419
    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
419
    op = out;
109
419
    ip = in;
110
419
    ii = ip;            /* point to start of current literal run */
111
112
113
419
#if (DD_BITS > 0)
114
419
    DVAL_FIRST(dv,ip);
115
419
    UPDATE_D(dict,drun,dv,ip,in);
116
419
    ip++;
117
419
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
419
    assert(ip < ip_end);
123
419
    for (;;)
124
3.04M
    {
125
3.04M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
3.04M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
3.04M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
3.04M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
3.04M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
3.04M
#endif
143
144
3.04M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
3.04M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
3.04M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
3.04M
#endif
150
151
3.04M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.00M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
3.00M
        if (++ip >= ip_end)
166
113
            break;
167
3.00M
#if (DD_BITS > 0)
168
3.00M
        DVAL_NEXT(dv,ip);
169
3.00M
#endif
170
3.00M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
37.9k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
37.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
37.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
37.9k
#endif
188
189
37.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
37.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
37.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
37.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
37.9k
#endif
203
204
37.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
37.6k
        assert(ii == ip);
209
210
37.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
419
    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
419
    if (pd(in_end,ii) > 0)
249
368
    {
250
368
        lzo_uint t = pd(in_end,ii);
251
368
        op = STORE_RUN(op,ii,t);
252
368
    }
253
254
419
    *out_len = pd(op, out);
255
419
    return LZO_E_OK;                /* compression went ok */
256
419
}
lzo1c_99.c:do_compress
Line
Count
Source
69
445
{
70
445
    const lzo_bytep ip;
71
445
#if (DD_BITS > 0)
72
445
#if defined(__LZO_HASH_INCREMENTAL)
73
445
    lzo_xint dv;
74
445
#endif
75
445
    unsigned drun = 0;
76
445
#endif
77
445
    lzo_bytep op;
78
445
    const lzo_bytep const in_end = in + in_len;
79
445
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
445
    const lzo_bytep ii;
81
445
#if defined(LZO_HAVE_R1)
82
445
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
445
#endif
84
445
#if defined(LZO_HAVE_M3)
85
445
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
445
#endif
87
88
445
    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
445
    op = out;
109
445
    ip = in;
110
445
    ii = ip;            /* point to start of current literal run */
111
112
113
445
#if (DD_BITS > 0)
114
445
    DVAL_FIRST(dv,ip);
115
445
    UPDATE_D(dict,drun,dv,ip,in);
116
445
    ip++;
117
445
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
445
    assert(ip < ip_end);
123
445
    for (;;)
124
4.81M
    {
125
4.81M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
4.81M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
4.81M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
4.81M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
4.81M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
4.81M
#endif
143
144
4.81M
#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.81M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
4.71M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
4.71M
        if (++ip >= ip_end)
166
95
            break;
167
4.71M
#if (DD_BITS > 0)
168
4.71M
        DVAL_NEXT(dv,ip);
169
4.71M
#endif
170
4.71M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
95.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
95.5k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
95.5k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
95.5k
#endif
188
189
95.5k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
95.5k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
95.5k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
95.5k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
95.5k
#endif
203
204
95.5k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
95.2k
        assert(ii == ip);
209
210
95.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
445
    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
445
    if (pd(in_end,ii) > 0)
249
394
    {
250
394
        lzo_uint t = pd(in_end,ii);
251
394
        op = STORE_RUN(op,ii,t);
252
394
    }
253
254
445
    *out_len = pd(op, out);
255
445
    return LZO_E_OK;                /* compression went ok */
256
445
}
257
#ifdef __cplusplus
258
} /* extern "C" */
259
#endif
260
261
262
/* vim:set ts=4 sw=4 et: */