Coverage Report

Created: 2025-11-24 06:26

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
131k
{
36
131k
    lzo_bytep op;
37
131k
    const lzo_bytep ip;
38
131k
    lzo_uint t;
39
40
131k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
131k
    op = oo;
43
131k
    ip = ii;
44
131k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
131k
    if (r_len >= 512)
48
11.4k
    {
49
11.4k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
11.4k
        lzo_uint tt = 32768u;
51
52
11.6k
        while (r_len >= (t = tt))
53
175
        {
54
175
            r_len -= t;
55
175
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
175
            MEMCPY8_DS(op, ip, t);
57
175
            LZO_STATS(lzo_stats->r0long_runs++);
58
175
        }
59
11.4k
        tt >>= 1;
60
68.7k
        do {
61
68.7k
            if (r_len >= (t = tt))
62
15.8k
            {
63
15.8k
                r_len -= t;
64
15.8k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
15.8k
                MEMCPY8_DS(op, ip, t);
66
15.8k
                LZO_STATS(lzo_stats->r0long_runs++);
67
15.8k
            }
68
68.7k
            tt >>= 1;
69
68.7k
        } while (--r_bits > 0);
70
11.4k
    }
71
131k
    assert(r_len < 512);
72
73
141k
    while (r_len >= (t = R0FAST))
74
10.1k
    {
75
10.1k
        r_len -= t;
76
10.1k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
10.1k
        MEMCPY8_DS(op, ip, t);
78
10.1k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
10.1k
    }
80
81
131k
    t = r_len;
82
131k
    if (t >= R0MIN)
83
19.2k
    {
84
        /* code a short R0 run */
85
19.2k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
19.2k
        MEMCPY_DS(op, ip, t);
87
19.2k
        LZO_STATS(lzo_stats->r0short_runs++);
88
19.2k
    }
89
112k
    else if (t > 0)
90
111k
    {
91
        /* code a short literal run */
92
111k
        LZO_STATS(lzo_stats->lit_runs++);
93
111k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
111k
        *op++ = LZO_BYTE(t);
95
111k
        MEMCPY_DS(op, ip, t);
96
111k
    }
97
98
131k
    return op;
99
131k
}
_lzo1b_store_run
Line
Count
Source
35
75.0k
{
36
75.0k
    lzo_bytep op;
37
75.0k
    const lzo_bytep ip;
38
75.0k
    lzo_uint t;
39
40
75.0k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
75.0k
    op = oo;
43
75.0k
    ip = ii;
44
75.0k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
75.0k
    if (r_len >= 512)
48
8.17k
    {
49
8.17k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
8.17k
        lzo_uint tt = 32768u;
51
52
8.22k
        while (r_len >= (t = tt))
53
54
        {
54
54
            r_len -= t;
55
54
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
54
            MEMCPY8_DS(op, ip, t);
57
54
            LZO_STATS(lzo_stats->r0long_runs++);
58
54
        }
59
8.17k
        tt >>= 1;
60
49.0k
        do {
61
49.0k
            if (r_len >= (t = tt))
62
11.2k
            {
63
11.2k
                r_len -= t;
64
11.2k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
11.2k
                MEMCPY8_DS(op, ip, t);
66
11.2k
                LZO_STATS(lzo_stats->r0long_runs++);
67
11.2k
            }
68
49.0k
            tt >>= 1;
69
49.0k
        } while (--r_bits > 0);
70
8.17k
    }
71
75.0k
    assert(r_len < 512);
72
73
82.4k
    while (r_len >= (t = R0FAST))
74
7.40k
    {
75
7.40k
        r_len -= t;
76
7.40k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
7.40k
        MEMCPY8_DS(op, ip, t);
78
7.40k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
7.40k
    }
80
81
75.0k
    t = r_len;
82
75.0k
    if (t >= R0MIN)
83
13.3k
    {
84
        /* code a short R0 run */
85
13.3k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
13.3k
        MEMCPY_DS(op, ip, t);
87
13.3k
        LZO_STATS(lzo_stats->r0short_runs++);
88
13.3k
    }
89
61.6k
    else if (t > 0)
90
61.5k
    {
91
        /* code a short literal run */
92
61.5k
        LZO_STATS(lzo_stats->lit_runs++);
93
61.5k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
61.5k
        *op++ = LZO_BYTE(t);
95
61.5k
        MEMCPY_DS(op, ip, t);
96
61.5k
    }
97
98
75.0k
    return op;
99
75.0k
}
_lzo1c_store_run
Line
Count
Source
35
56.3k
{
36
56.3k
    lzo_bytep op;
37
56.3k
    const lzo_bytep ip;
38
56.3k
    lzo_uint t;
39
40
56.3k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
56.3k
    op = oo;
43
56.3k
    ip = ii;
44
56.3k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
56.3k
    if (r_len >= 512)
48
3.28k
    {
49
3.28k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
3.28k
        lzo_uint tt = 32768u;
51
52
3.40k
        while (r_len >= (t = tt))
53
121
        {
54
121
            r_len -= t;
55
121
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
121
            MEMCPY8_DS(op, ip, t);
57
121
            LZO_STATS(lzo_stats->r0long_runs++);
58
121
        }
59
3.28k
        tt >>= 1;
60
19.6k
        do {
61
19.6k
            if (r_len >= (t = tt))
62
4.62k
            {
63
4.62k
                r_len -= t;
64
4.62k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
4.62k
                MEMCPY8_DS(op, ip, t);
66
4.62k
                LZO_STATS(lzo_stats->r0long_runs++);
67
4.62k
            }
68
19.6k
            tt >>= 1;
69
19.6k
        } while (--r_bits > 0);
70
3.28k
    }
71
56.3k
    assert(r_len < 512);
72
73
59.1k
    while (r_len >= (t = R0FAST))
74
2.75k
    {
75
2.75k
        r_len -= t;
76
2.75k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
2.75k
        MEMCPY8_DS(op, ip, t);
78
2.75k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
2.75k
    }
80
81
56.3k
    t = r_len;
82
56.3k
    if (t >= R0MIN)
83
5.90k
    {
84
        /* code a short R0 run */
85
5.90k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
5.90k
        MEMCPY_DS(op, ip, t);
87
5.90k
        LZO_STATS(lzo_stats->r0short_runs++);
88
5.90k
    }
89
50.4k
    else if (t > 0)
90
50.3k
    {
91
        /* code a short literal run */
92
50.3k
        LZO_STATS(lzo_stats->lit_runs++);
93
50.3k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
50.3k
        *op++ = LZO_BYTE(t);
95
50.3k
        MEMCPY_DS(op, ip, t);
96
50.3k
    }
97
98
56.3k
    return op;
99
56.3k
}
100
101
102
/* vim:set ts=4 sw=4 et: */