Coverage Report

Created: 2026-11-12 07:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/modules/demux/mpeg/ts_packet.h
Line
Count
Source
1
/*****************************************************************************
2
 * ts_packet.h : MPEG-TS packet headers
3
 *****************************************************************************
4
 * Copyright (C) 2025 - VideoLabs, VideoLAN and VLC authors
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation; either version 2.1 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 *****************************************************************************/
19
#ifndef VLC_TS_PACKET_H
20
#define VLC_TS_PACKET_H
21
22
#include "timestamps.h"
23
24
9.77M
#define TS_PACKET_SIZE_188 188
25
78.7k
#define TS_PACKET_SIZE_192 192
26
79.8k
#define TS_PACKET_SIZE_204 204
27
3.81M
#define TS_PACKET_SIZE_MAX 204
28
6.39M
#define TS_HEADER_SIZE 4
29
30
#define AS_BUF(pkt) pkt->p_buffer,pkt->i_buffer
31
32
static inline unsigned PKTHeaderAndAFSize( const block_t *p_pkt )
33
164k
{
34
164k
    const uint8_t *p = p_pkt->p_buffer;
35
164k
    unsigned i_size = 4;
36
164k
    if ( p[3] & 0x20 ) // adaptation field
37
112k
        i_size += 1 + __MIN(p[4], 182);
38
164k
    return i_size;
39
164k
}
ts.c:PKTHeaderAndAFSize
Line
Count
Source
33
114k
{
34
114k
    const uint8_t *p = p_pkt->p_buffer;
35
114k
    unsigned i_size = 4;
36
114k
    if ( p[3] & 0x20 ) // adaptation field
37
80.8k
        i_size += 1 + __MIN(p[4], 182);
38
114k
    return i_size;
39
114k
}
ts_hotfixes.c:PKTHeaderAndAFSize
Line
Count
Source
33
49.6k
{
34
49.6k
    const uint8_t *p = p_pkt->p_buffer;
35
49.6k
    unsigned i_size = 4;
36
49.6k
    if ( p[3] & 0x20 ) // adaptation field
37
31.2k
        i_size += 1 + __MIN(p[4], 182);
38
49.6k
    return i_size;
39
49.6k
}
40
41
static inline int PIDGet( const block_t *p )
42
6.39M
{
43
6.39M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
6.39M
}
ts.c:PIDGet
Line
Count
Source
42
6.39M
{
43
6.39M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
6.39M
}
Unexecuted instantiation: ts_hotfixes.c:PIDGet
45
46
static inline ts_90khz_t GetPCR( const block_t *p_pkt )
47
5.77M
{
48
5.77M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.77M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.77M
    if(unlikely(p_pkt->i_buffer < 12))
53
170
        return i_pcr;
54
55
5.77M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.77M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
3.18M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.59M
        ( p[4] >= 7 )  &&
60
2.12M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
622k
    {
62
        /* PCR is 33 bits */
63
622k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
622k
                ( (ts_90khz_t)p[7] << 17 ) |
65
622k
                ( (ts_90khz_t)p[8] << 9 ) |
66
622k
                ( (ts_90khz_t)p[9] << 1 ) |
67
622k
                ( (ts_90khz_t)p[10] >> 7 );
68
622k
    }
69
5.77M
    return i_pcr;
70
5.77M
}
ts.c:GetPCR
Line
Count
Source
47
5.72M
{
48
5.72M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.72M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.72M
    if(unlikely(p_pkt->i_buffer < 12))
53
170
        return i_pcr;
54
55
5.72M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.72M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
3.17M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.56M
        ( p[4] >= 7 )  &&
60
2.09M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
615k
    {
62
        /* PCR is 33 bits */
63
615k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
615k
                ( (ts_90khz_t)p[7] << 17 ) |
65
615k
                ( (ts_90khz_t)p[8] << 9 ) |
66
615k
                ( (ts_90khz_t)p[9] << 1 ) |
67
615k
                ( (ts_90khz_t)p[10] >> 7 );
68
615k
    }
69
5.72M
    return i_pcr;
70
5.72M
}
ts_hotfixes.c:GetPCR
Line
Count
Source
47
49.6k
{
48
49.6k
    const uint8_t *p = p_pkt->p_buffer;
49
50
49.6k
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
49.6k
    if(unlikely(p_pkt->i_buffer < 12))
53
0
        return i_pcr;
54
55
49.6k
    const uint8_t i_adaption = p[3] & 0x30;
56
57
49.6k
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
18.6k
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
30.9k
        ( p[4] >= 7 )  &&
60
29.4k
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
7.43k
    {
62
        /* PCR is 33 bits */
63
7.43k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
7.43k
                ( (ts_90khz_t)p[7] << 17 ) |
65
7.43k
                ( (ts_90khz_t)p[8] << 9 ) |
66
7.43k
                ( (ts_90khz_t)p[9] << 1 ) |
67
7.43k
                ( (ts_90khz_t)p[10] >> 7 );
68
7.43k
    }
69
49.6k
    return i_pcr;
70
49.6k
}
71
72
#endif