Coverage Report

Created: 2026-06-08 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/lzo-2.10/src/lzo1b_r.ch
Line
Count
Source
1
/* lzo1b_r.ch -- literal run handling for the the LZO1B/LZO1C 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
// store a literal run (internal)
31
************************************************************************/
32
33
LZO_LOCAL_IMPL(lzo_bytep )
34
STORE_RUN ( lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
35
126k
{
36
126k
    lzo_bytep op;
37
126k
    const lzo_bytep ip;
38
126k
    lzo_uint t;
39
40
126k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
126k
    op = oo;
43
126k
    ip = ii;
44
126k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
126k
    if (r_len >= 512)
48
12.8k
    {
49
12.8k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
12.8k
        lzo_uint tt = 32768u;
51
52
13.3k
        while (r_len >= (t = tt))
53
531
        {
54
531
            r_len -= t;
55
531
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
531
            MEMCPY8_DS(op, ip, t);
57
531
            LZO_STATS(lzo_stats->r0long_runs++);
58
531
        }
59
12.8k
        tt >>= 1;
60
76.8k
        do {
61
76.8k
            if (r_len >= (t = tt))
62
17.4k
            {
63
17.4k
                r_len -= t;
64
17.4k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
17.4k
                MEMCPY8_DS(op, ip, t);
66
17.4k
                LZO_STATS(lzo_stats->r0long_runs++);
67
17.4k
            }
68
76.8k
            tt >>= 1;
69
76.8k
        } while (--r_bits > 0);
70
12.8k
    }
71
126k
    assert(r_len < 512);
72
73
140k
    while (r_len >= (t = R0FAST))
74
14.1k
    {
75
14.1k
        r_len -= t;
76
14.1k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
14.1k
        MEMCPY8_DS(op, ip, t);
78
14.1k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
14.1k
    }
80
81
126k
    t = r_len;
82
126k
    if (t >= R0MIN)
83
25.2k
    {
84
        /* code a short R0 run */
85
25.2k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
25.2k
        MEMCPY_DS(op, ip, t);
87
25.2k
        LZO_STATS(lzo_stats->r0short_runs++);
88
25.2k
    }
89
100k
    else if (t > 0)
90
99.9k
    {
91
        /* code a short literal run */
92
99.9k
        LZO_STATS(lzo_stats->lit_runs++);
93
99.9k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
99.9k
        *op++ = LZO_BYTE(t);
95
99.9k
        MEMCPY_DS(op, ip, t);
96
99.9k
    }
97
98
126k
    return op;
99
126k
}
_lzo1b_store_run
Line
Count
Source
35
87.1k
{
36
87.1k
    lzo_bytep op;
37
87.1k
    const lzo_bytep ip;
38
87.1k
    lzo_uint t;
39
40
87.1k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
87.1k
    op = oo;
43
87.1k
    ip = ii;
44
87.1k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
87.1k
    if (r_len >= 512)
48
8.42k
    {
49
8.42k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
8.42k
        lzo_uint tt = 32768u;
51
52
8.64k
        while (r_len >= (t = tt))
53
216
        {
54
216
            r_len -= t;
55
216
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
216
            MEMCPY8_DS(op, ip, t);
57
216
            LZO_STATS(lzo_stats->r0long_runs++);
58
216
        }
59
8.42k
        tt >>= 1;
60
50.5k
        do {
61
50.5k
            if (r_len >= (t = tt))
62
11.7k
            {
63
11.7k
                r_len -= t;
64
11.7k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
11.7k
                MEMCPY8_DS(op, ip, t);
66
11.7k
                LZO_STATS(lzo_stats->r0long_runs++);
67
11.7k
            }
68
50.5k
            tt >>= 1;
69
50.5k
        } while (--r_bits > 0);
70
8.42k
    }
71
87.1k
    assert(r_len < 512);
72
73
96.4k
    while (r_len >= (t = R0FAST))
74
9.29k
    {
75
9.29k
        r_len -= t;
76
9.29k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
9.29k
        MEMCPY8_DS(op, ip, t);
78
9.29k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
9.29k
    }
80
81
87.1k
    t = r_len;
82
87.1k
    if (t >= R0MIN)
83
16.8k
    {
84
        /* code a short R0 run */
85
16.8k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
16.8k
        MEMCPY_DS(op, ip, t);
87
16.8k
        LZO_STATS(lzo_stats->r0short_runs++);
88
16.8k
    }
89
70.3k
    else if (t > 0)
90
69.7k
    {
91
        /* code a short literal run */
92
69.7k
        LZO_STATS(lzo_stats->lit_runs++);
93
69.7k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
69.7k
        *op++ = LZO_BYTE(t);
95
69.7k
        MEMCPY_DS(op, ip, t);
96
69.7k
    }
97
98
87.1k
    return op;
99
87.1k
}
_lzo1c_store_run
Line
Count
Source
35
39.0k
{
36
39.0k
    lzo_bytep op;
37
39.0k
    const lzo_bytep ip;
38
39.0k
    lzo_uint t;
39
40
39.0k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
39.0k
    op = oo;
43
39.0k
    ip = ii;
44
39.0k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
39.0k
    if (r_len >= 512)
48
4.38k
    {
49
4.38k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
4.38k
        lzo_uint tt = 32768u;
51
52
4.69k
        while (r_len >= (t = tt))
53
315
        {
54
315
            r_len -= t;
55
315
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
315
            MEMCPY8_DS(op, ip, t);
57
315
            LZO_STATS(lzo_stats->r0long_runs++);
58
315
        }
59
4.38k
        tt >>= 1;
60
26.3k
        do {
61
26.3k
            if (r_len >= (t = tt))
62
5.77k
            {
63
5.77k
                r_len -= t;
64
5.77k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
5.77k
                MEMCPY8_DS(op, ip, t);
66
5.77k
                LZO_STATS(lzo_stats->r0long_runs++);
67
5.77k
            }
68
26.3k
            tt >>= 1;
69
26.3k
        } while (--r_bits > 0);
70
4.38k
    }
71
39.0k
    assert(r_len < 512);
72
73
43.8k
    while (r_len >= (t = R0FAST))
74
4.84k
    {
75
4.84k
        r_len -= t;
76
4.84k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
4.84k
        MEMCPY8_DS(op, ip, t);
78
4.84k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
4.84k
    }
80
81
39.0k
    t = r_len;
82
39.0k
    if (t >= R0MIN)
83
8.45k
    {
84
        /* code a short R0 run */
85
8.45k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
8.45k
        MEMCPY_DS(op, ip, t);
87
8.45k
        LZO_STATS(lzo_stats->r0short_runs++);
88
8.45k
    }
89
30.5k
    else if (t > 0)
90
30.1k
    {
91
        /* code a short literal run */
92
30.1k
        LZO_STATS(lzo_stats->lit_runs++);
93
30.1k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
30.1k
        *op++ = LZO_BYTE(t);
95
30.1k
        MEMCPY_DS(op, ip, t);
96
30.1k
    }
97
98
39.0k
    return op;
99
39.0k
}
100
101
102
/* vim:set ts=4 sw=4 et: */