Coverage Report

Created: 2026-10-17 07:46

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.63M
#define TS_PACKET_SIZE_188 188
25
76.8k
#define TS_PACKET_SIZE_192 192
26
77.8k
#define TS_PACKET_SIZE_204 204
27
3.67M
#define TS_PACKET_SIZE_MAX 204
28
6.31M
#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
156k
{
34
156k
    const uint8_t *p = p_pkt->p_buffer;
35
156k
    unsigned i_size = 4;
36
156k
    if ( p[3] & 0x20 ) // adaptation field
37
113k
        i_size += 1 + __MIN(p[4], 182);
38
156k
    return i_size;
39
156k
}
ts.c:PKTHeaderAndAFSize
Line
Count
Source
33
106k
{
34
106k
    const uint8_t *p = p_pkt->p_buffer;
35
106k
    unsigned i_size = 4;
36
106k
    if ( p[3] & 0x20 ) // adaptation field
37
81.9k
        i_size += 1 + __MIN(p[4], 182);
38
106k
    return i_size;
39
106k
}
ts_hotfixes.c:PKTHeaderAndAFSize
Line
Count
Source
33
50.3k
{
34
50.3k
    const uint8_t *p = p_pkt->p_buffer;
35
50.3k
    unsigned i_size = 4;
36
50.3k
    if ( p[3] & 0x20 ) // adaptation field
37
31.8k
        i_size += 1 + __MIN(p[4], 182);
38
50.3k
    return i_size;
39
50.3k
}
40
41
static inline int PIDGet( const block_t *p )
42
6.31M
{
43
6.31M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
6.31M
}
ts.c:PIDGet
Line
Count
Source
42
6.31M
{
43
6.31M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
6.31M
}
Unexecuted instantiation: ts_hotfixes.c:PIDGet
45
46
static inline ts_90khz_t GetPCR( const block_t *p_pkt )
47
5.67M
{
48
5.67M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.67M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.67M
    if(unlikely(p_pkt->i_buffer < 12))
53
213
        return i_pcr;
54
55
5.66M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.66M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
3.08M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.58M
        ( p[4] >= 7 )  &&
60
2.12M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
610k
    {
62
        /* PCR is 33 bits */
63
610k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
610k
                ( (ts_90khz_t)p[7] << 17 ) |
65
610k
                ( (ts_90khz_t)p[8] << 9 ) |
66
610k
                ( (ts_90khz_t)p[9] << 1 ) |
67
610k
                ( (ts_90khz_t)p[10] >> 7 );
68
610k
    }
69
5.66M
    return i_pcr;
70
5.67M
}
ts.c:GetPCR
Line
Count
Source
47
5.61M
{
48
5.61M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.61M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.61M
    if(unlikely(p_pkt->i_buffer < 12))
53
213
        return i_pcr;
54
55
5.61M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.61M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
3.06M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.55M
        ( p[4] >= 7 )  &&
60
2.09M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
603k
    {
62
        /* PCR is 33 bits */
63
603k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
603k
                ( (ts_90khz_t)p[7] << 17 ) |
65
603k
                ( (ts_90khz_t)p[8] << 9 ) |
66
603k
                ( (ts_90khz_t)p[9] << 1 ) |
67
603k
                ( (ts_90khz_t)p[10] >> 7 );
68
603k
    }
69
5.61M
    return i_pcr;
70
5.61M
}
ts_hotfixes.c:GetPCR
Line
Count
Source
47
50.3k
{
48
50.3k
    const uint8_t *p = p_pkt->p_buffer;
49
50
50.3k
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
50.3k
    if(unlikely(p_pkt->i_buffer < 12))
53
0
        return i_pcr;
54
55
50.3k
    const uint8_t i_adaption = p[3] & 0x30;
56
57
50.3k
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
18.8k
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
31.5k
        ( p[4] >= 7 )  &&
60
29.9k
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
7.12k
    {
62
        /* PCR is 33 bits */
63
7.12k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
7.12k
                ( (ts_90khz_t)p[7] << 17 ) |
65
7.12k
                ( (ts_90khz_t)p[8] << 9 ) |
66
7.12k
                ( (ts_90khz_t)p[9] << 1 ) |
67
7.12k
                ( (ts_90khz_t)p[10] >> 7 );
68
7.12k
    }
69
50.3k
    return i_pcr;
70
50.3k
}
71
72
#endif