Coverage Report

Created: 2026-08-31 06:04

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
115k
{
36
115k
    lzo_bytep op;
37
115k
    const lzo_bytep ip;
38
115k
    lzo_uint t;
39
40
115k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
115k
    op = oo;
43
115k
    ip = ii;
44
115k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
115k
    if (r_len >= 512)
48
13.7k
    {
49
13.7k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
13.7k
        lzo_uint tt = 32768u;
51
52
14.2k
        while (r_len >= (t = tt))
53
502
        {
54
502
            r_len -= t;
55
502
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
502
            MEMCPY8_DS(op, ip, t);
57
502
            LZO_STATS(lzo_stats->r0long_runs++);
58
502
        }
59
13.7k
        tt >>= 1;
60
82.3k
        do {
61
82.3k
            if (r_len >= (t = tt))
62
18.9k
            {
63
18.9k
                r_len -= t;
64
18.9k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
18.9k
                MEMCPY8_DS(op, ip, t);
66
18.9k
                LZO_STATS(lzo_stats->r0long_runs++);
67
18.9k
            }
68
82.3k
            tt >>= 1;
69
82.3k
        } while (--r_bits > 0);
70
13.7k
    }
71
115k
    assert(r_len < 512);
72
73
129k
    while (r_len >= (t = R0FAST))
74
14.4k
    {
75
14.4k
        r_len -= t;
76
14.4k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
14.4k
        MEMCPY8_DS(op, ip, t);
78
14.4k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
14.4k
    }
80
81
115k
    t = r_len;
82
115k
    if (t >= R0MIN)
83
24.8k
    {
84
        /* code a short R0 run */
85
24.8k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
24.8k
        MEMCPY_DS(op, ip, t);
87
24.8k
        LZO_STATS(lzo_stats->r0short_runs++);
88
24.8k
    }
89
90.3k
    else if (t > 0)
90
89.1k
    {
91
        /* code a short literal run */
92
89.1k
        LZO_STATS(lzo_stats->lit_runs++);
93
89.1k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
89.1k
        *op++ = LZO_BYTE(t);
95
89.1k
        MEMCPY_DS(op, ip, t);
96
89.1k
    }
97
98
115k
    return op;
99
115k
}
_lzo1b_store_run
Line
Count
Source
35
77.1k
{
36
77.1k
    lzo_bytep op;
37
77.1k
    const lzo_bytep ip;
38
77.1k
    lzo_uint t;
39
40
77.1k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
77.1k
    op = oo;
43
77.1k
    ip = ii;
44
77.1k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
77.1k
    if (r_len >= 512)
48
9.61k
    {
49
9.61k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
9.61k
        lzo_uint tt = 32768u;
51
52
9.82k
        while (r_len >= (t = tt))
53
213
        {
54
213
            r_len -= t;
55
213
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
213
            MEMCPY8_DS(op, ip, t);
57
213
            LZO_STATS(lzo_stats->r0long_runs++);
58
213
        }
59
9.61k
        tt >>= 1;
60
57.6k
        do {
61
57.6k
            if (r_len >= (t = tt))
62
13.4k
            {
63
13.4k
                r_len -= t;
64
13.4k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
13.4k
                MEMCPY8_DS(op, ip, t);
66
13.4k
                LZO_STATS(lzo_stats->r0long_runs++);
67
13.4k
            }
68
57.6k
            tt >>= 1;
69
57.6k
        } while (--r_bits > 0);
70
9.61k
    }
71
77.1k
    assert(r_len < 512);
72
73
86.8k
    while (r_len >= (t = R0FAST))
74
9.73k
    {
75
9.73k
        r_len -= t;
76
9.73k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
9.73k
        MEMCPY8_DS(op, ip, t);
78
9.73k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
9.73k
    }
80
81
77.1k
    t = r_len;
82
77.1k
    if (t >= R0MIN)
83
16.9k
    {
84
        /* code a short R0 run */
85
16.9k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
16.9k
        MEMCPY_DS(op, ip, t);
87
16.9k
        LZO_STATS(lzo_stats->r0short_runs++);
88
16.9k
    }
89
60.1k
    else if (t > 0)
90
59.3k
    {
91
        /* code a short literal run */
92
59.3k
        LZO_STATS(lzo_stats->lit_runs++);
93
59.3k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
59.3k
        *op++ = LZO_BYTE(t);
95
59.3k
        MEMCPY_DS(op, ip, t);
96
59.3k
    }
97
98
77.1k
    return op;
99
77.1k
}
_lzo1c_store_run
Line
Count
Source
35
38.0k
{
36
38.0k
    lzo_bytep op;
37
38.0k
    const lzo_bytep ip;
38
38.0k
    lzo_uint t;
39
40
38.0k
    LZO_STATS(lzo_stats->literals += r_len);
41
42
38.0k
    op = oo;
43
38.0k
    ip = ii;
44
38.0k
    assert(r_len > 0);
45
46
    /* code a long R0 run */
47
38.0k
    if (r_len >= 512)
48
4.11k
    {
49
4.11k
        unsigned r_bits = 6;        /* 256 << 6 == 16384 */
50
4.11k
        lzo_uint tt = 32768u;
51
52
4.39k
        while (r_len >= (t = tt))
53
289
        {
54
289
            r_len -= t;
55
289
            *op++ = 0; *op++ = (R0FAST - R0MIN) + 7;
56
289
            MEMCPY8_DS(op, ip, t);
57
289
            LZO_STATS(lzo_stats->r0long_runs++);
58
289
        }
59
4.11k
        tt >>= 1;
60
24.6k
        do {
61
24.6k
            if (r_len >= (t = tt))
62
5.56k
            {
63
5.56k
                r_len -= t;
64
5.56k
                *op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
65
5.56k
                MEMCPY8_DS(op, ip, t);
66
5.56k
                LZO_STATS(lzo_stats->r0long_runs++);
67
5.56k
            }
68
24.6k
            tt >>= 1;
69
24.6k
        } while (--r_bits > 0);
70
4.11k
    }
71
38.0k
    assert(r_len < 512);
72
73
42.7k
    while (r_len >= (t = R0FAST))
74
4.71k
    {
75
4.71k
        r_len -= t;
76
4.71k
        *op++ = 0; *op++ = (R0FAST - R0MIN);
77
4.71k
        MEMCPY8_DS(op, ip, t);
78
4.71k
        LZO_STATS(lzo_stats->r0fast_runs++);
79
4.71k
    }
80
81
38.0k
    t = r_len;
82
38.0k
    if (t >= R0MIN)
83
7.84k
    {
84
        /* code a short R0 run */
85
7.84k
        *op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
86
7.84k
        MEMCPY_DS(op, ip, t);
87
7.84k
        LZO_STATS(lzo_stats->r0short_runs++);
88
7.84k
    }
89
30.1k
    else if (t > 0)
90
29.7k
    {
91
        /* code a short literal run */
92
29.7k
        LZO_STATS(lzo_stats->lit_runs++);
93
29.7k
        LZO_STATS(lzo_stats->lit_run[t]++);
94
29.7k
        *op++ = LZO_BYTE(t);
95
29.7k
        MEMCPY_DS(op, ip, t);
96
29.7k
    }
97
98
38.0k
    return op;
99
38.0k
}
100
101
102
/* vim:set ts=4 sw=4 et: */