Coverage Report

Created: 2025-07-12 06:32

/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
743k
#define DI      ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,drun,dv,ii,in); MI
49
355k
#define XI      assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
50
#else
51
383k
#define DI      ++ii; DINDEX1(dindex,ii); UPDATE_I(dict,0,dindex,ii,in); MI
52
432k
#define XI      assert(ii < ip); ii = ip;
53
#endif
54
55
56
/***********************************************************************
57
// compress a block of data.
58
//
59
// I really apologize for this spaghetti code.
60
************************************************************************/
61
62
#ifdef __cplusplus
63
extern "C" {
64
#endif
65
LZO_PRIVATE(int)
66
do_compress    ( const lzo_bytep in , lzo_uint  in_len,
67
                       lzo_bytep out, lzo_uintp out_len,
68
                       lzo_voidp wrkmem )
69
5.38k
{
70
5.38k
    const lzo_bytep ip;
71
#if (DD_BITS > 0)
72
#if defined(__LZO_HASH_INCREMENTAL)
73
4.03k
    lzo_xint dv;
74
#endif
75
    unsigned drun = 0;
76
#endif
77
5.38k
    lzo_bytep op;
78
5.38k
    const lzo_bytep const in_end = in + in_len;
79
5.38k
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
5.38k
    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.46k
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
5.38k
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
#if (LZO_DETERMINISTIC)
104
3.92k
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#endif
106
107
108
5.38k
    op = out;
109
5.38k
    ip = in;
110
5.38k
    ii = ip;            /* point to start of current literal run */
111
112
113
#if (DD_BITS > 0)
114
4.03k
    DVAL_FIRST(dv,ip);
115
4.03k
    UPDATE_D(dict,drun,dv,ip,in);
116
    ip++;
117
4.03k
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
5.38k
    assert(ip < ip_end);
123
5.38k
    for (;;)
124
27.4M
    {
125
27.4M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
27.4M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
27.4M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
27.4M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
27.4M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
27.4M
#endif
143
144
27.4M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
550k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
550k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
550k
#endif
150
151
15.4M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
25.7M
literal:
162
#if (DD_BITS == 0)
163
11.9M
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
25.7M
        if (++ip >= ip_end)
166
1.27k
            break;
167
#if (DD_BITS > 0)
168
13.8M
        DVAL_NEXT(dv,ip);
169
13.8M
#endif
170
11.9M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
11.9M
match:
179
#if (DD_BITS == 0)
180
432k
        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.66M
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
1.66M
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
1.66M
#endif
188
189
1.66M
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
1.66M
        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.66M
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
1.66M
        assert(ii == ip);
209
210
1.66M
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
5.38k
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
5.38k
    if (pd(in_end,ii) > 0)
249
4.75k
    {
250
4.75k
        lzo_uint t = pd(in_end,ii);
251
4.75k
        op = STORE_RUN(op,ii,t);
252
4.75k
    }
253
254
5.38k
    *out_len = pd(op, out);
255
5.38k
    return LZO_E_OK;                /* compression went ok */
256
5.38k
}
lzo1_99.c:do_compress
Line
Count
Source
69
365
{
70
365
    const lzo_bytep ip;
71
365
#if (DD_BITS > 0)
72
365
#if defined(__LZO_HASH_INCREMENTAL)
73
365
    lzo_xint dv;
74
365
#endif
75
365
    unsigned drun = 0;
76
365
#endif
77
365
    lzo_bytep op;
78
365
    const lzo_bytep const in_end = in + in_len;
79
365
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
365
    const lzo_bytep ii;
81
#if defined(LZO_HAVE_R1)
82
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
365
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
365
#if (LZO_DETERMINISTIC)
104
365
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
365
#endif
106
107
108
365
    op = out;
109
365
    ip = in;
110
365
    ii = ip;            /* point to start of current literal run */
111
112
113
365
#if (DD_BITS > 0)
114
365
    DVAL_FIRST(dv,ip);
115
365
    UPDATE_D(dict,drun,dv,ip,in);
116
365
    ip++;
117
365
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
365
    assert(ip < ip_end);
123
365
    for (;;)
124
4.25M
    {
125
4.25M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
4.25M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
4.25M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
4.25M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
4.25M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
4.25M
#endif
143
144
4.25M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
4.25M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
4.25M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
4.25M
#endif
150
151
4.25M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.87M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
3.87M
        if (++ip >= ip_end)
166
74
            break;
167
3.87M
#if (DD_BITS > 0)
168
3.87M
        DVAL_NEXT(dv,ip);
169
3.87M
#endif
170
3.87M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
374k
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
374k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
374k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
374k
#endif
188
189
374k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
374k
        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
374k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
373k
        assert(ii == ip);
209
210
373k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
365
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
365
    if (pd(in_end,ii) > 0)
249
300
    {
250
300
        lzo_uint t = pd(in_end,ii);
251
300
        op = STORE_RUN(op,ii,t);
252
300
    }
253
254
365
    *out_len = pd(op, out);
255
365
    return LZO_E_OK;                /* compression went ok */
256
365
}
lzo1a_99.c:do_compress
Line
Count
Source
69
340
{
70
340
    const lzo_bytep ip;
71
340
#if (DD_BITS > 0)
72
340
#if defined(__LZO_HASH_INCREMENTAL)
73
340
    lzo_xint dv;
74
340
#endif
75
340
    unsigned drun = 0;
76
340
#endif
77
340
    lzo_bytep op;
78
340
    const lzo_bytep const in_end = in + in_len;
79
340
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
340
    const lzo_bytep ii;
81
340
#if defined(LZO_HAVE_R1)
82
340
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
340
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
340
    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
340
#if (LZO_DETERMINISTIC)
104
340
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
340
#endif
106
107
108
340
    op = out;
109
340
    ip = in;
110
340
    ii = ip;            /* point to start of current literal run */
111
112
113
340
#if (DD_BITS > 0)
114
340
    DVAL_FIRST(dv,ip);
115
340
    UPDATE_D(dict,drun,dv,ip,in);
116
340
    ip++;
117
340
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
340
    assert(ip < ip_end);
123
340
    for (;;)
124
2.02M
    {
125
2.02M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
2.02M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
2.02M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
2.02M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
2.02M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
2.02M
#endif
143
144
2.02M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
2.02M
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
2.02M
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
2.02M
#endif
150
151
2.02M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.90M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.90M
        if (++ip >= ip_end)
166
69
            break;
167
1.90M
#if (DD_BITS > 0)
168
1.90M
        DVAL_NEXT(dv,ip);
169
1.90M
#endif
170
1.90M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
117k
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
117k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
117k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
117k
#endif
188
189
117k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
117k
        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
117k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
116k
        assert(ii == ip);
209
210
116k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
340
    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
340
    if (pd(in_end,ii) > 0)
249
272
    {
250
272
        lzo_uint t = pd(in_end,ii);
251
272
        op = STORE_RUN(op,ii,t);
252
272
    }
253
254
340
    *out_len = pd(op, out);
255
340
    return LZO_E_OK;                /* compression went ok */
256
340
}
lzo1b_1.c:do_compress
Line
Count
Source
69
323
{
70
323
    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
323
    lzo_bytep op;
78
323
    const lzo_bytep const in_end = in + in_len;
79
323
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
323
    const lzo_bytep ii;
81
323
#if defined(LZO_HAVE_R1)
82
323
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
323
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
323
    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
323
#if (LZO_DETERMINISTIC)
104
323
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
323
#endif
106
107
108
323
    op = out;
109
323
    ip = in;
110
323
    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
323
    ip++;
120
323
#endif
121
122
323
    assert(ip < ip_end);
123
323
    for (;;)
124
947k
    {
125
947k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
947k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
947k
#if (DD_BITS == 0)
131
947k
        lzo_uint dindex;
132
947k
#endif
133
947k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
947k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
947k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
947k
#endif
143
144
947k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
48.4k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
48.4k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
48.4k
#endif
150
151
48.4k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
865k
literal:
162
865k
#if (DD_BITS == 0)
163
865k
        UPDATE_I(dict,0,dindex,ip,in);
164
865k
#endif
165
865k
        if (++ip >= ip_end)
166
93
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
864k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
864k
match:
179
82.2k
#if (DD_BITS == 0)
180
82.2k
        UPDATE_I(dict,0,dindex,ip,in);
181
82.2k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
82.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
82.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
82.2k
#endif
188
189
82.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
82.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
82.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
82.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
82.2k
#endif
203
204
82.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
82.0k
        assert(ii == ip);
209
210
82.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
323
    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
323
    if (pd(in_end,ii) > 0)
249
281
    {
250
281
        lzo_uint t = pd(in_end,ii);
251
281
        op = STORE_RUN(op,ii,t);
252
281
    }
253
254
323
    *out_len = pd(op, out);
255
323
    return LZO_E_OK;                /* compression went ok */
256
323
}
lzo1b_2.c:do_compress
Line
Count
Source
69
298
{
70
298
    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
298
    lzo_bytep op;
78
298
    const lzo_bytep const in_end = in + in_len;
79
298
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
298
    const lzo_bytep ii;
81
298
#if defined(LZO_HAVE_R1)
82
298
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
298
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
298
    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
298
#if (LZO_DETERMINISTIC)
104
298
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
298
#endif
106
107
108
298
    op = out;
109
298
    ip = in;
110
298
    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
298
    ip++;
120
298
#endif
121
122
298
    assert(ip < ip_end);
123
298
    for (;;)
124
1.33M
    {
125
1.33M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.33M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
1.33M
#if (DD_BITS == 0)
131
1.33M
        lzo_uint dindex;
132
1.33M
#endif
133
1.33M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.33M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.33M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.33M
#endif
143
144
1.33M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
88.7k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
88.7k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
88.7k
#endif
150
151
88.7k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.25M
literal:
162
1.25M
#if (DD_BITS == 0)
163
1.25M
        UPDATE_I(dict,0,dindex,ip,in);
164
1.25M
#endif
165
1.25M
        if (++ip >= ip_end)
166
91
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
1.25M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
1.25M
match:
179
79.4k
#if (DD_BITS == 0)
180
79.4k
        UPDATE_I(dict,0,dindex,ip,in);
181
79.4k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
79.4k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
79.4k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
79.4k
#endif
188
189
79.4k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
79.4k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
79.4k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
79.4k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
79.4k
#endif
203
204
79.4k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
79.2k
        assert(ii == ip);
209
210
79.2k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
298
    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
298
    if (pd(in_end,ii) > 0)
249
273
    {
250
273
        lzo_uint t = pd(in_end,ii);
251
273
        op = STORE_RUN(op,ii,t);
252
273
    }
253
254
298
    *out_len = pd(op, out);
255
298
    return LZO_E_OK;                /* compression went ok */
256
298
}
lzo1b_3.c:do_compress
Line
Count
Source
69
342
{
70
342
    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
342
    lzo_bytep op;
78
342
    const lzo_bytep const in_end = in + in_len;
79
342
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
342
    const lzo_bytep ii;
81
342
#if defined(LZO_HAVE_R1)
82
342
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
342
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
342
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
342
#if (LZO_DETERMINISTIC)
104
342
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
342
#endif
106
107
108
342
    op = out;
109
342
    ip = in;
110
342
    ii = ip;            /* point to start of current literal run */
111
112
113
#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
342
    ip++;
120
342
#endif
121
122
342
    assert(ip < ip_end);
123
342
    for (;;)
124
3.83M
    {
125
3.83M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
3.83M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
3.83M
#if (DD_BITS == 0)
131
3.83M
        lzo_uint dindex;
132
3.83M
#endif
133
3.83M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
3.83M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
3.83M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
3.83M
#endif
143
144
3.83M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
194k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
194k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
194k
#endif
150
151
194k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
3.68M
literal:
162
3.68M
#if (DD_BITS == 0)
163
3.68M
        UPDATE_I(dict,0,dindex,ip,in);
164
3.68M
#endif
165
3.68M
        if (++ip >= ip_end)
166
136
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
3.68M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
3.68M
match:
179
152k
#if (DD_BITS == 0)
180
152k
        UPDATE_I(dict,0,dindex,ip,in);
181
152k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
152k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
152k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
152k
#endif
188
189
152k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
152k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
152k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
152k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
152k
#endif
203
204
152k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
152k
        assert(ii == ip);
209
210
152k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
342
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
342
    if (pd(in_end,ii) > 0)
249
310
    {
250
310
        lzo_uint t = pd(in_end,ii);
251
310
        op = STORE_RUN(op,ii,t);
252
310
    }
253
254
342
    *out_len = pd(op, out);
255
342
    return LZO_E_OK;                /* compression went ok */
256
342
}
lzo1b_4.c:do_compress
Line
Count
Source
69
315
{
70
315
    const lzo_bytep ip;
71
315
#if (DD_BITS > 0)
72
315
#if defined(__LZO_HASH_INCREMENTAL)
73
315
    lzo_xint dv;
74
315
#endif
75
315
    unsigned drun = 0;
76
315
#endif
77
315
    lzo_bytep op;
78
315
    const lzo_bytep const in_end = in + in_len;
79
315
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
315
    const lzo_bytep ii;
81
315
#if defined(LZO_HAVE_R1)
82
315
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
315
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
315
    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
315
#if (LZO_DETERMINISTIC)
104
315
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
315
#endif
106
107
108
315
    op = out;
109
315
    ip = in;
110
315
    ii = ip;            /* point to start of current literal run */
111
112
113
315
#if (DD_BITS > 0)
114
315
    DVAL_FIRST(dv,ip);
115
315
    UPDATE_D(dict,drun,dv,ip,in);
116
315
    ip++;
117
315
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
315
    assert(ip < ip_end);
123
315
    for (;;)
124
851k
    {
125
851k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
851k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
851k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
851k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
851k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
851k
#endif
143
144
851k
#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
828k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
743k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
743k
        if (++ip >= ip_end)
166
68
            break;
167
743k
#if (DD_BITS > 0)
168
743k
        DVAL_NEXT(dv,ip);
169
743k
#endif
170
743k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
108k
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
108k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
108k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
108k
#endif
188
189
108k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
108k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
108k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
108k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
108k
#endif
203
204
108k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
108k
        assert(ii == ip);
209
210
108k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
315
    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
315
    if (pd(in_end,ii) > 0)
249
286
    {
250
286
        lzo_uint t = pd(in_end,ii);
251
286
        op = STORE_RUN(op,ii,t);
252
286
    }
253
254
315
    *out_len = pd(op, out);
255
315
    return LZO_E_OK;                /* compression went ok */
256
315
}
lzo1b_5.c:do_compress
Line
Count
Source
69
313
{
70
313
    const lzo_bytep ip;
71
313
#if (DD_BITS > 0)
72
313
#if defined(__LZO_HASH_INCREMENTAL)
73
313
    lzo_xint dv;
74
313
#endif
75
313
    unsigned drun = 0;
76
313
#endif
77
313
    lzo_bytep op;
78
313
    const lzo_bytep const in_end = in + in_len;
79
313
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
313
    const lzo_bytep ii;
81
313
#if defined(LZO_HAVE_R1)
82
313
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
313
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
313
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
313
#if (LZO_DETERMINISTIC)
104
313
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
313
#endif
106
107
108
313
    op = out;
109
313
    ip = in;
110
313
    ii = ip;            /* point to start of current literal run */
111
112
113
313
#if (DD_BITS > 0)
114
313
    DVAL_FIRST(dv,ip);
115
313
    UPDATE_D(dict,drun,dv,ip,in);
116
313
    ip++;
117
313
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
313
    assert(ip < ip_end);
123
313
    for (;;)
124
801k
    {
125
801k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
801k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
801k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
801k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
801k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
801k
#endif
143
144
801k
#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
785k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
721k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
721k
        if (++ip >= ip_end)
166
67
            break;
167
721k
#if (DD_BITS > 0)
168
721k
        DVAL_NEXT(dv,ip);
169
721k
#endif
170
721k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
79.6k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
79.6k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
79.6k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
79.6k
#endif
188
189
79.6k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
79.6k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
79.6k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
79.6k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
79.6k
#endif
203
204
79.6k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
79.4k
        assert(ii == ip);
209
210
79.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
313
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
313
    if (pd(in_end,ii) > 0)
249
280
    {
250
280
        lzo_uint t = pd(in_end,ii);
251
280
        op = STORE_RUN(op,ii,t);
252
280
    }
253
254
313
    *out_len = pd(op, out);
255
313
    return LZO_E_OK;                /* compression went ok */
256
313
}
lzo1b_6.c:do_compress
Line
Count
Source
69
310
{
70
310
    const lzo_bytep ip;
71
310
#if (DD_BITS > 0)
72
310
#if defined(__LZO_HASH_INCREMENTAL)
73
310
    lzo_xint dv;
74
310
#endif
75
310
    unsigned drun = 0;
76
310
#endif
77
310
    lzo_bytep op;
78
310
    const lzo_bytep const in_end = in + in_len;
79
310
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
310
    const lzo_bytep ii;
81
310
#if defined(LZO_HAVE_R1)
82
310
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
310
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
310
    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
310
#if (LZO_DETERMINISTIC)
104
310
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
310
#endif
106
107
108
310
    op = out;
109
310
    ip = in;
110
310
    ii = ip;            /* point to start of current literal run */
111
112
113
310
#if (DD_BITS > 0)
114
310
    DVAL_FIRST(dv,ip);
115
310
    UPDATE_D(dict,drun,dv,ip,in);
116
310
    ip++;
117
310
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
310
    assert(ip < ip_end);
123
310
    for (;;)
124
860k
    {
125
860k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
860k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
860k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
860k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
860k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
860k
#endif
143
144
860k
#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
844k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
778k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
778k
        if (++ip >= ip_end)
166
58
            break;
167
778k
#if (DD_BITS > 0)
168
778k
        DVAL_NEXT(dv,ip);
169
778k
#endif
170
778k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
81.6k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
81.6k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
81.6k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
81.6k
#endif
188
189
81.6k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
81.6k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
81.6k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
81.6k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
81.6k
#endif
203
204
81.6k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
81.4k
        assert(ii == ip);
209
210
81.4k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
310
    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
310
    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
310
    *out_len = pd(op, out);
255
310
    return LZO_E_OK;                /* compression went ok */
256
310
}
lzo1b_7.c:do_compress
Line
Count
Source
69
302
{
70
302
    const lzo_bytep ip;
71
302
#if (DD_BITS > 0)
72
302
#if defined(__LZO_HASH_INCREMENTAL)
73
302
    lzo_xint dv;
74
302
#endif
75
302
    unsigned drun = 0;
76
302
#endif
77
302
    lzo_bytep op;
78
302
    const lzo_bytep const in_end = in + in_len;
79
302
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
302
    const lzo_bytep ii;
81
302
#if defined(LZO_HAVE_R1)
82
302
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
302
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
302
    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
302
#if (LZO_DETERMINISTIC)
104
302
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
302
#endif
106
107
108
302
    op = out;
109
302
    ip = in;
110
302
    ii = ip;            /* point to start of current literal run */
111
112
113
302
#if (DD_BITS > 0)
114
302
    DVAL_FIRST(dv,ip);
115
302
    UPDATE_D(dict,drun,dv,ip,in);
116
302
    ip++;
117
302
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
302
    assert(ip < ip_end);
123
302
    for (;;)
124
754k
    {
125
754k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
754k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
754k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
754k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
754k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
754k
#endif
143
144
754k
#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
735k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
680k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
680k
        if (++ip >= ip_end)
166
64
            break;
167
680k
#if (DD_BITS > 0)
168
680k
        DVAL_NEXT(dv,ip);
169
680k
#endif
170
680k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
73.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
73.9k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
73.9k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
73.9k
#endif
188
189
73.9k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
73.9k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
73.9k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
73.9k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
73.9k
#endif
203
204
73.9k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
73.7k
        assert(ii == ip);
209
210
73.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
302
    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
302
    if (pd(in_end,ii) > 0)
249
273
    {
250
273
        lzo_uint t = pd(in_end,ii);
251
273
        op = STORE_RUN(op,ii,t);
252
273
    }
253
254
302
    *out_len = pd(op, out);
255
302
    return LZO_E_OK;                /* compression went ok */
256
302
}
lzo1b_8.c:do_compress
Line
Count
Source
69
317
{
70
317
    const lzo_bytep ip;
71
317
#if (DD_BITS > 0)
72
317
#if defined(__LZO_HASH_INCREMENTAL)
73
317
    lzo_xint dv;
74
317
#endif
75
317
    unsigned drun = 0;
76
317
#endif
77
317
    lzo_bytep op;
78
317
    const lzo_bytep const in_end = in + in_len;
79
317
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
317
    const lzo_bytep ii;
81
317
#if defined(LZO_HAVE_R1)
82
317
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
317
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
317
    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
317
#if (LZO_DETERMINISTIC)
104
317
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
317
#endif
106
107
108
317
    op = out;
109
317
    ip = in;
110
317
    ii = ip;            /* point to start of current literal run */
111
112
113
317
#if (DD_BITS > 0)
114
317
    DVAL_FIRST(dv,ip);
115
317
    UPDATE_D(dict,drun,dv,ip,in);
116
317
    ip++;
117
317
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
317
    assert(ip < ip_end);
123
317
    for (;;)
124
1.12M
    {
125
1.12M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.12M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.12M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.12M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.12M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.12M
#endif
143
144
1.12M
#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.11M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.03M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.03M
        if (++ip >= ip_end)
166
70
            break;
167
1.03M
#if (DD_BITS > 0)
168
1.03M
        DVAL_NEXT(dv,ip);
169
1.03M
#endif
170
1.03M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
90.1k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
90.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
90.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
90.1k
#endif
188
189
90.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
90.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
90.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
90.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
90.1k
#endif
203
204
90.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
89.9k
        assert(ii == ip);
209
210
89.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
317
    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
317
    if (pd(in_end,ii) > 0)
249
286
    {
250
286
        lzo_uint t = pd(in_end,ii);
251
286
        op = STORE_RUN(op,ii,t);
252
286
    }
253
254
317
    *out_len = pd(op, out);
255
317
    return LZO_E_OK;                /* compression went ok */
256
317
}
lzo1b_9.c:do_compress
Line
Count
Source
69
349
{
70
349
    const lzo_bytep ip;
71
349
#if (DD_BITS > 0)
72
349
#if defined(__LZO_HASH_INCREMENTAL)
73
349
    lzo_xint dv;
74
349
#endif
75
349
    unsigned drun = 0;
76
349
#endif
77
349
    lzo_bytep op;
78
349
    const lzo_bytep const in_end = in + in_len;
79
349
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
349
    const lzo_bytep ii;
81
349
#if defined(LZO_HAVE_R1)
82
349
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
349
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
349
    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
349
#if (LZO_DETERMINISTIC)
104
349
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
349
#endif
106
107
108
349
    op = out;
109
349
    ip = in;
110
349
    ii = ip;            /* point to start of current literal run */
111
112
113
349
#if (DD_BITS > 0)
114
349
    DVAL_FIRST(dv,ip);
115
349
    UPDATE_D(dict,drun,dv,ip,in);
116
349
    ip++;
117
349
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
349
    assert(ip < ip_end);
123
349
    for (;;)
124
717k
    {
125
717k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
717k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
717k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
717k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
717k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
717k
#endif
143
144
717k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
717k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
717k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
717k
#endif
150
151
717k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
635k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
635k
        if (++ip >= ip_end)
166
75
            break;
167
635k
#if (DD_BITS > 0)
168
635k
        DVAL_NEXT(dv,ip);
169
635k
#endif
170
635k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
82.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
82.3k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
82.3k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
82.3k
#endif
188
189
82.3k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
82.3k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
82.3k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
82.3k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
82.3k
#endif
203
204
82.3k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
82.0k
        assert(ii == ip);
209
210
82.0k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
349
    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
349
    if (pd(in_end,ii) > 0)
249
309
    {
250
309
        lzo_uint t = pd(in_end,ii);
251
309
        op = STORE_RUN(op,ii,t);
252
309
    }
253
254
349
    *out_len = pd(op, out);
255
349
    return LZO_E_OK;                /* compression went ok */
256
349
}
lzo1b_99.c:do_compress
Line
Count
Source
69
351
{
70
351
    const lzo_bytep ip;
71
351
#if (DD_BITS > 0)
72
351
#if defined(__LZO_HASH_INCREMENTAL)
73
351
    lzo_xint dv;
74
351
#endif
75
351
    unsigned drun = 0;
76
351
#endif
77
351
    lzo_bytep op;
78
351
    const lzo_bytep const in_end = in + in_len;
79
351
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
351
    const lzo_bytep ii;
81
351
#if defined(LZO_HAVE_R1)
82
351
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
351
#endif
84
#if defined(LZO_HAVE_M3)
85
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
#endif
87
88
351
    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
89
90
91
#if (LZO_COLLECT_STATS)
92
    lzo_stats->r_bits   = R_BITS;
93
    lzo_stats->m3o_bits = M3O_BITS;
94
    lzo_stats->dd_bits  = DD_BITS;
95
    lzo_stats->clevel   = CLEVEL;
96
    lzo_stats->d_bits   = D_BITS;
97
    lzo_stats->min_lookahead  = MIN_LOOKAHEAD;
98
    lzo_stats->max_lookbehind = MAX_LOOKBEHIND;
99
    lzo_stats->compress_id    = LZO_PP_MACRO_EXPAND(COMPRESS_ID);
100
#endif
101
102
    /* init dictionary */
103
351
#if (LZO_DETERMINISTIC)
104
351
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
351
#endif
106
107
108
351
    op = out;
109
351
    ip = in;
110
351
    ii = ip;            /* point to start of current literal run */
111
112
113
351
#if (DD_BITS > 0)
114
351
    DVAL_FIRST(dv,ip);
115
351
    UPDATE_D(dict,drun,dv,ip,in);
116
351
    ip++;
117
351
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
351
    assert(ip < ip_end);
123
351
    for (;;)
124
777k
    {
125
777k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
777k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
777k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
777k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
777k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
777k
#endif
143
144
777k
#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
777k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
708k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
708k
        if (++ip >= ip_end)
166
67
            break;
167
708k
#if (DD_BITS > 0)
168
708k
        DVAL_NEXT(dv,ip);
169
708k
#endif
170
708k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
68.8k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
68.8k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
68.8k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
68.8k
#endif
188
189
68.8k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
68.8k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
68.8k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
68.8k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
68.8k
#endif
203
204
68.8k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
68.6k
        assert(ii == ip);
209
210
68.6k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
351
    assert(ip <= in_end);
218
219
#if (LZO_COLLECT_STATS)
220
    {
221
        lzo_uint i;
222
        const lzo_bytep p;
223
224
        for (i = 0; i < D_SIZE; i++)
225
        {
226
            p = dict[i];
227
            if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
228
                lzo_stats->unused_dict_entries++;
229
        }
230
        lzo_stats->unused_dict_entries_percent =
231
            100.0 * lzo_stats->unused_dict_entries / D_SIZE;
232
    }
233
#endif
234
235
236
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
237
    /* return if op == out to indicate that we
238
     * couldn't compress and didn't copy anything.
239
     */
240
    if (op == out)
241
    {
242
        *out_len = 0;
243
        return LZO_E_NOT_COMPRESSIBLE;
244
    }
245
#endif
246
247
    /* store the final literal run */
248
351
    if (pd(in_end,ii) > 0)
249
313
    {
250
313
        lzo_uint t = pd(in_end,ii);
251
313
        op = STORE_RUN(op,ii,t);
252
313
    }
253
254
351
    *out_len = pd(op, out);
255
351
    return LZO_E_OK;                /* compression went ok */
256
351
}
lzo1c_1.c:do_compress
Line
Count
Source
69
391
{
70
391
    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
391
    lzo_bytep op;
78
391
    const lzo_bytep const in_end = in + in_len;
79
391
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
391
    const lzo_bytep ii;
81
391
#if defined(LZO_HAVE_R1)
82
391
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
391
#endif
84
391
#if defined(LZO_HAVE_M3)
85
391
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
391
#endif
87
88
391
    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
391
    op = out;
109
391
    ip = in;
110
391
    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
391
    ip++;
120
391
#endif
121
122
391
    assert(ip < ip_end);
123
391
    for (;;)
124
6.27M
    {
125
6.27M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
6.27M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
6.27M
#if (DD_BITS == 0)
131
6.27M
        lzo_uint dindex;
132
6.27M
#endif
133
6.27M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
6.27M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
6.27M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
6.27M
#endif
143
144
6.27M
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
218k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
218k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
218k
#endif
150
151
218k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
6.15M
literal:
162
6.15M
#if (DD_BITS == 0)
163
6.15M
        UPDATE_I(dict,0,dindex,ip,in);
164
6.15M
#endif
165
6.15M
        if (++ip >= ip_end)
166
116
            break;
167
#if (DD_BITS > 0)
168
        DVAL_NEXT(dv,ip);
169
#endif
170
6.15M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
6.15M
match:
179
119k
#if (DD_BITS == 0)
180
119k
        UPDATE_I(dict,0,dindex,ip,in);
181
119k
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
119k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
119k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
119k
#endif
188
189
119k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
119k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
119k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
119k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
119k
#endif
203
204
119k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
118k
        assert(ii == ip);
209
210
118k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
391
    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
391
    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
391
    *out_len = pd(op, out);
255
391
    return LZO_E_OK;                /* compression went ok */
256
391
}
lzo1c_5.c:do_compress
Line
Count
Source
69
324
{
70
324
    const lzo_bytep ip;
71
324
#if (DD_BITS > 0)
72
324
#if defined(__LZO_HASH_INCREMENTAL)
73
324
    lzo_xint dv;
74
324
#endif
75
324
    unsigned drun = 0;
76
324
#endif
77
324
    lzo_bytep op;
78
324
    const lzo_bytep const in_end = in + in_len;
79
324
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
324
    const lzo_bytep ii;
81
324
#if defined(LZO_HAVE_R1)
82
324
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
324
#endif
84
324
#if defined(LZO_HAVE_M3)
85
324
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
324
#endif
87
88
324
    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
324
    op = out;
109
324
    ip = in;
110
324
    ii = ip;            /* point to start of current literal run */
111
112
113
324
#if (DD_BITS > 0)
114
324
    DVAL_FIRST(dv,ip);
115
324
    UPDATE_D(dict,drun,dv,ip,in);
116
324
    ip++;
117
324
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
324
    assert(ip < ip_end);
123
324
    for (;;)
124
787k
    {
125
787k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
787k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
787k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
787k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
787k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
787k
#endif
143
144
787k
#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
773k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
726k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
726k
        if (++ip >= ip_end)
166
66
            break;
167
726k
#if (DD_BITS > 0)
168
726k
        DVAL_NEXT(dv,ip);
169
726k
#endif
170
726k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
60.2k
match:
179
#if (DD_BITS == 0)
180
        UPDATE_I(dict,0,dindex,ip,in);
181
#endif
182
        /* we have found a match of at least M2_MIN_LEN */
183
184
185
60.2k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
60.2k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
60.2k
#endif
188
189
60.2k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
60.2k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
60.2k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
60.2k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
60.2k
#endif
203
204
60.2k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
59.9k
        assert(ii == ip);
209
210
59.9k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
324
    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
324
    if (pd(in_end,ii) > 0)
249
292
    {
250
292
        lzo_uint t = pd(in_end,ii);
251
292
        op = STORE_RUN(op,ii,t);
252
292
    }
253
254
324
    *out_len = pd(op, out);
255
324
    return LZO_E_OK;                /* compression went ok */
256
324
}
lzo1c_9.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
362
#if defined(LZO_HAVE_M3)
85
362
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
362
#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
#if (LZO_DETERMINISTIC)
104
    BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
105
#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
992k
    {
125
992k
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
992k
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
992k
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
992k
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
992k
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
992k
#endif
143
144
992k
#include LZO_SEARCH_MATCH_INCLUDE_FILE
145
146
147
992k
#if !defined(LZO_TEST_MATCH_INCLUDE_FILE)
148
992k
#  define LZO_TEST_MATCH_INCLUDE_FILE       "lzo1b_tm.ch"
149
992k
#endif
150
151
992k
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
947k
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
947k
        if (++ip >= ip_end)
166
77
            break;
167
947k
#if (DD_BITS > 0)
168
947k
        DVAL_NEXT(dv,ip);
169
947k
#endif
170
947k
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
45.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
45.1k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
45.1k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
45.1k
#endif
188
189
45.1k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
45.1k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
45.1k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
45.1k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
45.1k
#endif
203
204
45.1k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
44.8k
        assert(ii == ip);
209
210
44.8k
    }
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
325
    {
250
325
        lzo_uint t = pd(in_end,ii);
251
325
        op = STORE_RUN(op,ii,t);
252
325
    }
253
254
362
    *out_len = pd(op, out);
255
362
    return LZO_E_OK;                /* compression went ok */
256
362
}
lzo1c_99.c:do_compress
Line
Count
Source
69
383
{
70
383
    const lzo_bytep ip;
71
383
#if (DD_BITS > 0)
72
383
#if defined(__LZO_HASH_INCREMENTAL)
73
383
    lzo_xint dv;
74
383
#endif
75
383
    unsigned drun = 0;
76
383
#endif
77
383
    lzo_bytep op;
78
383
    const lzo_bytep const in_end = in + in_len;
79
383
    const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD;
80
383
    const lzo_bytep ii;
81
383
#if defined(LZO_HAVE_R1)
82
383
    const lzo_bytep r1 = ip_end;    /* pointer for R1 match (none yet) */
83
383
#endif
84
383
#if defined(LZO_HAVE_M3)
85
383
    lzo_bytep m3 = out + 1;         /* pointer after last m3/m4 match */
86
383
#endif
87
88
383
    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
383
    op = out;
109
383
    ip = in;
110
383
    ii = ip;            /* point to start of current literal run */
111
112
113
383
#if (DD_BITS > 0)
114
383
    DVAL_FIRST(dv,ip);
115
383
    UPDATE_D(dict,drun,dv,ip,in);
116
383
    ip++;
117
383
    DVAL_NEXT(dv,ip);
118
#else
119
    ip++;
120
#endif
121
122
383
    assert(ip < ip_end);
123
383
    for (;;)
124
1.10M
    {
125
1.10M
        const lzo_bytep m_pos;
126
#if !defined(NDEBUG)
127
        const lzo_bytep m_pos_sav = NULL;
128
#endif
129
1.10M
        LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
130
#if (DD_BITS == 0)
131
        lzo_uint dindex;
132
#endif
133
1.10M
        lzo_uint m_len;
134
135
136
/***********************************************************************
137
// search for a match
138
************************************************************************/
139
140
1.10M
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
141
1.10M
#  define LZO_SEARCH_MATCH_INCLUDE_FILE     "lzo1b_sm.ch"
142
1.10M
#endif
143
144
1.10M
#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.10M
#include LZO_TEST_MATCH_INCLUDE_FILE
152
153
154
155
/***********************************************************************
156
// found a literal
157
************************************************************************/
158
159
160
    /* a literal */
161
1.05M
literal:
162
#if (DD_BITS == 0)
163
        UPDATE_I(dict,0,dindex,ip,in);
164
#endif
165
1.05M
        if (++ip >= ip_end)
166
83
            break;
167
1.05M
#if (DD_BITS > 0)
168
1.05M
        DVAL_NEXT(dv,ip);
169
1.05M
#endif
170
1.05M
        continue;
171
172
173
174
/***********************************************************************
175
// found a match
176
************************************************************************/
177
178
52.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
52.0k
#if !defined(LZO_CODE_RUN_INCLUDE_FILE)
186
52.0k
#  define LZO_CODE_RUN_INCLUDE_FILE     "lzo1b_cr.ch"
187
52.0k
#endif
188
189
52.0k
#include LZO_CODE_RUN_INCLUDE_FILE
190
191
192
        /* ii now points to the start of the current match */
193
52.0k
        assert(ii == ip);
194
195
196
/***********************************************************************
197
// code the match
198
************************************************************************/
199
200
52.0k
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
201
52.0k
#  define LZO_CODE_MATCH_INCLUDE_FILE   "lzo1b_cm.ch"
202
52.0k
#endif
203
204
52.0k
#include LZO_CODE_MATCH_INCLUDE_FILE
205
206
207
        /* ii now points to the start of the next literal run */
208
51.7k
        assert(ii == ip);
209
210
51.7k
    }
211
212
213
/***********************************************************************
214
// end of block
215
************************************************************************/
216
217
383
    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
383
    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
383
    *out_len = pd(op, out);
255
383
    return LZO_E_OK;                /* compression went ok */
256
383
}
257
#ifdef __cplusplus
258
} /* extern "C" */
259
#endif
260
261
262
/* vim:set ts=4 sw=4 et: */