Coverage Report

Created: 2026-08-13 07:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/modules/packetizer/hxxx_ep3b.h
Line
Count
Source
1
/*****************************************************************************
2
 * hxxx_ep3b.h
3
 *****************************************************************************
4
 * Copyright (C) 2014-2015 VLC authors and VideoLAN
5
 *                    2018 VideoLabs
6
 *
7
 * This program is free software; you can redistribute it and/or modify it
8
 * under the terms of the GNU Lesser General Public License as published by
9
 * the Free Software Foundation; either version 2.1 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public License
18
 * along with this program; if not, write to the Free Software Foundation,
19
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20
 *****************************************************************************/
21
#include <vlc_bits.h>
22
23
static inline const uint8_t *hxxx_ep3b_to_rbsp( const uint8_t *p, const uint8_t *end, unsigned *pi_prev, size_t i_count )
24
36.6M
{
25
79.8M
    for( size_t i=0; i<i_count; i++ )
26
47.4M
    {
27
47.4M
        if( ++p >= end )
28
4.20M
            return p;
29
30
43.2M
        *pi_prev = (*pi_prev << 1) | (!*p);
31
32
43.2M
        if( *p == 0x03 &&
33
244k
           ( p + 1 ) != end ) /* Never escape sequence if no next byte */
34
234k
        {
35
234k
            if( (*pi_prev & 0x06) == 0x06 )
36
52.6k
            {
37
52.6k
                ++p;
38
52.6k
                *pi_prev = !*p;
39
52.6k
            }
40
234k
        }
41
43.2M
    }
42
32.4M
    return p;
43
36.6M
}
hxxx_sei.c:hxxx_ep3b_to_rbsp
Line
Count
Source
24
4.57M
{
25
18.2M
    for( size_t i=0; i<i_count; i++ )
26
13.7M
    {
27
13.7M
        if( ++p >= end )
28
146k
            return p;
29
30
13.6M
        *pi_prev = (*pi_prev << 1) | (!*p);
31
32
13.6M
        if( *p == 0x03 &&
33
47.7k
           ( p + 1 ) != end ) /* Never escape sequence if no next byte */
34
45.5k
        {
35
45.5k
            if( (*pi_prev & 0x06) == 0x06 )
36
13.5k
            {
37
13.5k
                ++p;
38
13.5k
                *pi_prev = !*p;
39
13.5k
            }
40
45.5k
        }
41
13.6M
    }
42
4.43M
    return p;
43
4.57M
}
h264_nal.c:hxxx_ep3b_to_rbsp
Line
Count
Source
24
4.12M
{
25
8.81M
    for( size_t i=0; i<i_count; i++ )
26
4.78M
    {
27
4.78M
        if( ++p >= end )
28
105k
            return p;
29
30
4.68M
        *pi_prev = (*pi_prev << 1) | (!*p);
31
32
4.68M
        if( *p == 0x03 &&
33
22.9k
           ( p + 1 ) != end ) /* Never escape sequence if no next byte */
34
20.2k
        {
35
20.2k
            if( (*pi_prev & 0x06) == 0x06 )
36
1.22k
            {
37
1.22k
                ++p;
38
1.22k
                *pi_prev = !*p;
39
1.22k
            }
40
20.2k
        }
41
4.68M
    }
42
4.02M
    return p;
43
4.12M
}
h264_slice.c:hxxx_ep3b_to_rbsp
Line
Count
Source
24
3.26M
{
25
6.52M
    for( size_t i=0; i<i_count; i++ )
26
3.35M
    {
27
3.35M
        if( ++p >= end )
28
96.3k
            return p;
29
30
3.26M
        *pi_prev = (*pi_prev << 1) | (!*p);
31
32
3.26M
        if( *p == 0x03 &&
33
7.14k
           ( p + 1 ) != end ) /* Never escape sequence if no next byte */
34
6.64k
        {
35
6.64k
            if( (*pi_prev & 0x06) == 0x06 )
36
1.90k
            {
37
1.90k
                ++p;
38
1.90k
                *pi_prev = !*p;
39
1.90k
            }
40
6.64k
        }
41
3.26M
    }
42
3.16M
    return p;
43
3.26M
}
hevc_nal.c:hxxx_ep3b_to_rbsp
Line
Count
Source
24
22.9M
{
25
42.8M
    for( size_t i=0; i<i_count; i++ )
26
23.7M
    {
27
23.7M
        if( ++p >= end )
28
3.84M
            return p;
29
30
19.9M
        *pi_prev = (*pi_prev << 1) | (!*p);
31
32
19.9M
        if( *p == 0x03 &&
33
154k
           ( p + 1 ) != end ) /* Never escape sequence if no next byte */
34
149k
        {
35
149k
            if( (*pi_prev & 0x06) == 0x06 )
36
35.1k
            {
37
35.1k
                ++p;
38
35.1k
                *pi_prev = !*p;
39
35.1k
            }
40
149k
        }
41
19.9M
    }
42
19.1M
    return p;
43
22.9M
}
vc1.c:hxxx_ep3b_to_rbsp
Line
Count
Source
24
1.71M
{
25
3.42M
    for( size_t i=0; i<i_count; i++ )
26
1.72M
    {
27
1.72M
        if( ++p >= end )
28
12.8k
            return p;
29
30
1.70M
        *pi_prev = (*pi_prev << 1) | (!*p);
31
32
1.70M
        if( *p == 0x03 &&
33
12.1k
           ( p + 1 ) != end ) /* Never escape sequence if no next byte */
34
12.1k
        {
35
12.1k
            if( (*pi_prev & 0x06) == 0x06 )
36
867
            {
37
867
                ++p;
38
867
                *pi_prev = !*p;
39
867
            }
40
12.1k
        }
41
1.70M
    }
42
1.70M
    return p;
43
1.71M
}
44
45
#if 0
46
/* Discards emulation prevention three bytes */
47
static inline uint8_t * hxxx_ep3b_to_rbsp(const uint8_t *p_src, size_t i_src, size_t *pi_ret)
48
{
49
    uint8_t *p_dst;
50
    if(!p_src || !(p_dst = malloc(i_src)))
51
        return NULL;
52
53
    size_t j = 0;
54
    for (size_t i = 0; i < i_src; i++) {
55
        if (i < i_src - 3 &&
56
            p_src[i] == 0 && p_src[i+1] == 0 && p_src[i+2] == 3) {
57
            p_dst[j++] = 0;
58
            p_dst[j++] = 0;
59
            i += 2;
60
            continue;
61
        }
62
        p_dst[j++] = p_src[i];
63
    }
64
    *pi_ret = j;
65
    return p_dst;
66
}
67
#endif
68
69
/* vlc_bits's bs_t forward callback for stripping emulation prevention three bytes */
70
struct hxxx_bsfw_ep3b_ctx_s
71
{
72
    unsigned i_prev;
73
    size_t i_bytepos;
74
};
75
76
static void hxxx_bsfw_ep3b_ctx_init( struct hxxx_bsfw_ep3b_ctx_s *ctx )
77
5.22M
{
78
5.22M
    ctx->i_prev = 0;
79
5.22M
    ctx->i_bytepos = 0;
80
5.22M
}
hxxx_sei.c:hxxx_bsfw_ep3b_ctx_init
Line
Count
Source
77
152k
{
78
152k
    ctx->i_prev = 0;
79
152k
    ctx->i_bytepos = 0;
80
152k
}
h264_nal.c:hxxx_bsfw_ep3b_ctx_init
Line
Count
Source
77
332k
{
78
332k
    ctx->i_prev = 0;
79
332k
    ctx->i_bytepos = 0;
80
332k
}
h264_slice.c:hxxx_bsfw_ep3b_ctx_init
Line
Count
Source
77
435k
{
78
435k
    ctx->i_prev = 0;
79
435k
    ctx->i_bytepos = 0;
80
435k
}
hevc_nal.c:hxxx_bsfw_ep3b_ctx_init
Line
Count
Source
77
4.25M
{
78
4.25M
    ctx->i_prev = 0;
79
4.25M
    ctx->i_bytepos = 0;
80
4.25M
}
vc1.c:hxxx_bsfw_ep3b_ctx_init
Line
Count
Source
77
49.0k
{
78
49.0k
    ctx->i_prev = 0;
79
49.0k
    ctx->i_bytepos = 0;
80
49.0k
}
81
82
static size_t hxxx_bsfw_byte_forward_ep3b( bs_t *s, size_t i_count )
83
48.2M
{
84
48.2M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
85
48.2M
    if( s->p == NULL )
86
5.22M
    {
87
5.22M
        s->p = s->p_start;
88
5.22M
        ctx->i_bytepos = 1;
89
5.22M
        return 1;
90
5.22M
    }
91
92
42.9M
    if( s->p >= s->p_end )
93
6.34M
        return 0;
94
95
36.6M
    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
96
36.6M
    ctx->i_bytepos += i_count;
97
36.6M
    return i_count;
98
42.9M
}
hxxx_sei.c:hxxx_bsfw_byte_forward_ep3b
Line
Count
Source
83
4.94M
{
84
4.94M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
85
4.94M
    if( s->p == NULL )
86
152k
    {
87
152k
        s->p = s->p_start;
88
152k
        ctx->i_bytepos = 1;
89
152k
        return 1;
90
152k
    }
91
92
4.79M
    if( s->p >= s->p_end )
93
213k
        return 0;
94
95
4.57M
    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
96
4.57M
    ctx->i_bytepos += i_count;
97
4.57M
    return i_count;
98
4.79M
}
h264_nal.c:hxxx_bsfw_byte_forward_ep3b
Line
Count
Source
83
4.86M
{
84
4.86M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
85
4.86M
    if( s->p == NULL )
86
332k
    {
87
332k
        s->p = s->p_start;
88
332k
        ctx->i_bytepos = 1;
89
332k
        return 1;
90
332k
    }
91
92
4.53M
    if( s->p >= s->p_end )
93
404k
        return 0;
94
95
4.12M
    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
96
4.12M
    ctx->i_bytepos += i_count;
97
4.12M
    return i_count;
98
4.53M
}
h264_slice.c:hxxx_bsfw_byte_forward_ep3b
Line
Count
Source
83
3.95M
{
84
3.95M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
85
3.95M
    if( s->p == NULL )
86
435k
    {
87
435k
        s->p = s->p_start;
88
435k
        ctx->i_bytepos = 1;
89
435k
        return 1;
90
435k
    }
91
92
3.52M
    if( s->p >= s->p_end )
93
260k
        return 0;
94
95
3.26M
    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
96
3.26M
    ctx->i_bytepos += i_count;
97
3.26M
    return i_count;
98
3.52M
}
hevc_nal.c:hxxx_bsfw_byte_forward_ep3b
Line
Count
Source
83
32.6M
{
84
32.6M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
85
32.6M
    if( s->p == NULL )
86
4.25M
    {
87
4.25M
        s->p = s->p_start;
88
4.25M
        ctx->i_bytepos = 1;
89
4.25M
        return 1;
90
4.25M
    }
91
92
28.3M
    if( s->p >= s->p_end )
93
5.41M
        return 0;
94
95
22.9M
    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
96
22.9M
    ctx->i_bytepos += i_count;
97
22.9M
    return i_count;
98
28.3M
}
vc1.c:hxxx_bsfw_byte_forward_ep3b
Line
Count
Source
83
1.82M
{
84
1.82M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
85
1.82M
    if( s->p == NULL )
86
49.0k
    {
87
49.0k
        s->p = s->p_start;
88
49.0k
        ctx->i_bytepos = 1;
89
49.0k
        return 1;
90
49.0k
    }
91
92
1.77M
    if( s->p >= s->p_end )
93
57.5k
        return 0;
94
95
1.71M
    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
96
1.71M
    ctx->i_bytepos += i_count;
97
1.71M
    return i_count;
98
1.77M
}
99
100
static size_t hxxx_bsfw_byte_pos_ep3b( const bs_t *s )
101
2.40M
{
102
2.40M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
103
2.40M
    return ctx->i_bytepos;
104
2.40M
}
hxxx_sei.c:hxxx_bsfw_byte_pos_ep3b
Line
Count
Source
101
2.40M
{
102
2.40M
    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
103
2.40M
    return ctx->i_bytepos;
104
2.40M
}
Unexecuted instantiation: h264_nal.c:hxxx_bsfw_byte_pos_ep3b
Unexecuted instantiation: h264_slice.c:hxxx_bsfw_byte_pos_ep3b
Unexecuted instantiation: hevc_nal.c:hxxx_bsfw_byte_pos_ep3b
Unexecuted instantiation: vc1.c:hxxx_bsfw_byte_pos_ep3b
105
106
static const bs_byte_callbacks_t hxxx_bsfw_ep3b_callbacks =
107
{
108
    hxxx_bsfw_byte_forward_ep3b,
109
    hxxx_bsfw_byte_pos_ep3b,
110
};