Coverage Report

Created: 2026-09-28 07:27

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.41M
#define TS_PACKET_SIZE_188 188
25
76.3k
#define TS_PACKET_SIZE_192 192
26
77.2k
#define TS_PACKET_SIZE_204 204
27
3.62M
#define TS_PACKET_SIZE_MAX 204
28
6.16M
#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
154k
{
34
154k
    const uint8_t *p = p_pkt->p_buffer;
35
154k
    unsigned i_size = 4;
36
154k
    if ( p[3] & 0x20 ) // adaptation field
37
110k
        i_size += 1 + __MIN(p[4], 182);
38
154k
    return i_size;
39
154k
}
ts.c:PKTHeaderAndAFSize
Line
Count
Source
33
103k
{
34
103k
    const uint8_t *p = p_pkt->p_buffer;
35
103k
    unsigned i_size = 4;
36
103k
    if ( p[3] & 0x20 ) // adaptation field
37
78.9k
        i_size += 1 + __MIN(p[4], 182);
38
103k
    return i_size;
39
103k
}
ts_hotfixes.c:PKTHeaderAndAFSize
Line
Count
Source
33
50.1k
{
34
50.1k
    const uint8_t *p = p_pkt->p_buffer;
35
50.1k
    unsigned i_size = 4;
36
50.1k
    if ( p[3] & 0x20 ) // adaptation field
37
31.4k
        i_size += 1 + __MIN(p[4], 182);
38
50.1k
    return i_size;
39
50.1k
}
40
41
static inline int PIDGet( const block_t *p )
42
6.16M
{
43
6.16M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
6.16M
}
ts.c:PIDGet
Line
Count
Source
42
6.16M
{
43
6.16M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
6.16M
}
Unexecuted instantiation: ts_hotfixes.c:PIDGet
45
46
static inline ts_90khz_t GetPCR( const block_t *p_pkt )
47
5.55M
{
48
5.55M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.55M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.55M
    if(unlikely(p_pkt->i_buffer < 12))
53
215
        return i_pcr;
54
55
5.55M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.55M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
3.05M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.49M
        ( p[4] >= 7 )  &&
60
2.02M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
570k
    {
62
        /* PCR is 33 bits */
63
570k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
570k
                ( (ts_90khz_t)p[7] << 17 ) |
65
570k
                ( (ts_90khz_t)p[8] << 9 ) |
66
570k
                ( (ts_90khz_t)p[9] << 1 ) |
67
570k
                ( (ts_90khz_t)p[10] >> 7 );
68
570k
    }
69
5.55M
    return i_pcr;
70
5.55M
}
ts.c:GetPCR
Line
Count
Source
47
5.50M
{
48
5.50M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.50M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.50M
    if(unlikely(p_pkt->i_buffer < 12))
53
215
        return i_pcr;
54
55
5.50M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.50M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
3.03M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.46M
        ( p[4] >= 7 )  &&
60
1.99M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
563k
    {
62
        /* PCR is 33 bits */
63
563k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
563k
                ( (ts_90khz_t)p[7] << 17 ) |
65
563k
                ( (ts_90khz_t)p[8] << 9 ) |
66
563k
                ( (ts_90khz_t)p[9] << 1 ) |
67
563k
                ( (ts_90khz_t)p[10] >> 7 );
68
563k
    }
69
5.50M
    return i_pcr;
70
5.50M
}
ts_hotfixes.c:GetPCR
Line
Count
Source
47
50.1k
{
48
50.1k
    const uint8_t *p = p_pkt->p_buffer;
49
50
50.1k
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
50.1k
    if(unlikely(p_pkt->i_buffer < 12))
53
0
        return i_pcr;
54
55
50.1k
    const uint8_t i_adaption = p[3] & 0x30;
56
57
50.1k
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
19.0k
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
31.1k
        ( p[4] >= 7 )  &&
60
29.5k
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
6.86k
    {
62
        /* PCR is 33 bits */
63
6.86k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
6.86k
                ( (ts_90khz_t)p[7] << 17 ) |
65
6.86k
                ( (ts_90khz_t)p[8] << 9 ) |
66
6.86k
                ( (ts_90khz_t)p[9] << 1 ) |
67
6.86k
                ( (ts_90khz_t)p[10] >> 7 );
68
6.86k
    }
69
50.1k
    return i_pcr;
70
50.1k
}
71
72
#endif