Coverage Report

Created: 2025-10-13 06:57

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
130k
{
36
130k
    lzo_bytep op;
37
130k
    const lzo_bytep ip;
38
130k
    lzo_uint t;
39
40
130k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
130k
    op = oo;
43
130k
    ip = ii;
44
130k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
130k
    if (r_len >= 512)
48
10.6k
    {
49
10.6k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
10.6k
        lzo_uint tt = 32768u;
51
52
10.7k
        while (r_len >= (t = tt))
53
168
        {
54
168
            r_len -= t;
55
168
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
168
            MEMCPY8_DS(op, ip, t);
57
168
            LZO_STATS(lzo_stats->r0long_runs++);
58
168
        }
59
10.6k
        tt >>= 1;
60
63.7k
        do {
61
63.7k
            if (r_len >= (t = tt))
62
14.5k
            {
63
14.5k
                r_len -= t;
64
14.5k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
14.5k
                MEMCPY8_DS(op, ip, t);
66
14.5k
                LZO_STATS(lzo_stats->r0long_runs++);
67
14.5k
            }
68
63.7k
            tt >>= 1;
69
63.7k
        } while (--r_bits > 0);
70
10.6k
    }
71
130k
    assert(r_len < 512);
72
73
140k
    while (r_len >= (t = R0FAST))
74
9.79k
    {
75
9.79k
        r_len -= t;
76
9.79k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
9.79k
        MEMCPY8_DS(op, ip, t);
78
9.79k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
9.79k
    }
80
81
130k
    t = r_len;
82
130k
    if (t >= R0MIN)
83
18.5k
    {
84
        /* code a short R0 run */
85
18.5k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
18.5k
        MEMCPY_DS(op, ip, t);
87
18.5k
        LZO_STATS(lzo_stats->r0short_runs++);
88
18.5k
    }
89
112k
    else if (t > 0)
90
112k
    {
91
        /* code a short literal run */
92
112k
        LZO_STATS(lzo_stats->lit_runs++);
93
112k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
112k
        *op++ = LZO_BYTE(t);
95
112k
        MEMCPY_DS(op, ip, t);
96
112k
    }
97
98
130k
    return op;
99
130k
}
_lzo1b_store_run
Line
Count
Source
35
74.1k
{
36
74.1k
    lzo_bytep op;
37
74.1k
    const lzo_bytep ip;
38
74.1k
    lzo_uint t;
39
40
74.1k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
74.1k
    op = oo;
43
74.1k
    ip = ii;
44
74.1k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
74.1k
    if (r_len >= 512)
48
7.38k
    {
49
7.38k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
7.38k
        lzo_uint tt = 32768u;
51
52
7.43k
        while (r_len >= (t = tt))
53
51
        {
54
51
            r_len -= t;
55
51
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
51
            MEMCPY8_DS(op, ip, t);
57
51
            LZO_STATS(lzo_stats->r0long_runs++);
58
51
        }
59
7.38k
        tt >>= 1;
60
44.3k
        do {
61
44.3k
            if (r_len >= (t = tt))
62
10.0k
            {
63
10.0k
                r_len -= t;
64
10.0k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
10.0k
                MEMCPY8_DS(op, ip, t);
66
10.0k
                LZO_STATS(lzo_stats->r0long_runs++);
67
10.0k
            }
68
44.3k
            tt >>= 1;
69
44.3k
        } while (--r_bits > 0);
70
7.38k
    }
71
74.1k
    assert(r_len < 512);
72
73
81.2k
    while (r_len >= (t = R0FAST))
74
7.03k
    {
75
7.03k
        r_len -= t;
76
7.03k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
7.03k
        MEMCPY8_DS(op, ip, t);
78
7.03k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
7.03k
    }
80
81
74.1k
    t = r_len;
82
74.1k
    if (t >= R0MIN)
83
12.6k
    {
84
        /* code a short R0 run */
85
12.6k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
12.6k
        MEMCPY_DS(op, ip, t);
87
12.6k
        LZO_STATS(lzo_stats->r0short_runs++);
88
12.6k
    }
89
61.5k
    else if (t > 0)
90
61.3k
    {
91
        /* code a short literal run */
92
61.3k
        LZO_STATS(lzo_stats->lit_runs++);
93
61.3k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
61.3k
        *op++ = LZO_BYTE(t);
95
61.3k
        MEMCPY_DS(op, ip, t);
96
61.3k
    }
97
98
74.1k
    return op;
99
74.1k
}
_lzo1c_store_run
Line
Count
Source
35
56.7k
{
36
56.7k
    lzo_bytep op;
37
56.7k
    const lzo_bytep ip;
38
56.7k
    lzo_uint t;
39
40
56.7k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
56.7k
    op = oo;
43
56.7k
    ip = ii;
44
56.7k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
56.7k
    if (r_len >= 512)
48
3.23k
    {
49
3.23k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
3.23k
        lzo_uint tt = 32768u;
51
52
3.35k
        while (r_len >= (t = tt))
53
117
        {
54
117
            r_len -= t;
55
117
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
117
            MEMCPY8_DS(op, ip, t);
57
117
            LZO_STATS(lzo_stats->r0long_runs++);
58
117
        }
59
3.23k
        tt >>= 1;
60
19.4k
        do {
61
19.4k
            if (r_len >= (t = tt))
62
4.55k
            {
63
4.55k
                r_len -= t;
64
4.55k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
4.55k
                MEMCPY8_DS(op, ip, t);
66
4.55k
                LZO_STATS(lzo_stats->r0long_runs++);
67
4.55k
            }
68
19.4k
            tt >>= 1;
69
19.4k
        } while (--r_bits > 0);
70
3.23k
    }
71
56.7k
    assert(r_len < 512);
72
73
59.4k
    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.7k
    t = r_len;
82
56.7k
    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.8k
    else if (t > 0)
90
50.7k
    {
91
        /* code a short literal run */
92
50.7k
        LZO_STATS(lzo_stats->lit_runs++);
93
50.7k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
50.7k
        *op++ = LZO_BYTE(t);
95
50.7k
        MEMCPY_DS(op, ip, t);
96
50.7k
    }
97
98
56.7k
    return op;
99
56.7k
}
100
101
102
/* vim:set ts=4 sw=4 et: */