Coverage Report

Created: 2026-09-01 07:42

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
8.98M
#define TS_PACKET_SIZE_188 188
25
72.4k
#define TS_PACKET_SIZE_192 192
26
73.0k
#define TS_PACKET_SIZE_204 204
27
3.38M
#define TS_PACKET_SIZE_MAX 204
28
5.87M
#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
148k
{
34
148k
    const uint8_t *p = p_pkt->p_buffer;
35
148k
    unsigned i_size = 4;
36
148k
    if ( p[3] & 0x20 ) // adaptation field
37
107k
        i_size += 1 + __MIN(p[4], 182);
38
148k
    return i_size;
39
148k
}
ts.c:PKTHeaderAndAFSize
Line
Count
Source
33
100k
{
34
100k
    const uint8_t *p = p_pkt->p_buffer;
35
100k
    unsigned i_size = 4;
36
100k
    if ( p[3] & 0x20 ) // adaptation field
37
77.9k
        i_size += 1 + __MIN(p[4], 182);
38
100k
    return i_size;
39
100k
}
ts_hotfixes.c:PKTHeaderAndAFSize
Line
Count
Source
33
48.4k
{
34
48.4k
    const uint8_t *p = p_pkt->p_buffer;
35
48.4k
    unsigned i_size = 4;
36
48.4k
    if ( p[3] & 0x20 ) // adaptation field
37
29.5k
        i_size += 1 + __MIN(p[4], 182);
38
48.4k
    return i_size;
39
48.4k
}
40
41
static inline int PIDGet( const block_t *p )
42
5.87M
{
43
5.87M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
5.87M
}
ts.c:PIDGet
Line
Count
Source
42
5.87M
{
43
5.87M
    return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
44
5.87M
}
Unexecuted instantiation: ts_hotfixes.c:PIDGet
45
46
static inline ts_90khz_t GetPCR( const block_t *p_pkt )
47
5.28M
{
48
5.28M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.28M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.28M
    if(unlikely(p_pkt->i_buffer < 12))
53
238
        return i_pcr;
54
55
5.28M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.28M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
2.93M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.35M
        ( p[4] >= 7 )  &&
60
1.88M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
495k
    {
62
        /* PCR is 33 bits */
63
495k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
495k
                ( (ts_90khz_t)p[7] << 17 ) |
65
495k
                ( (ts_90khz_t)p[8] << 9 ) |
66
495k
                ( (ts_90khz_t)p[9] << 1 ) |
67
495k
                ( (ts_90khz_t)p[10] >> 7 );
68
495k
    }
69
5.28M
    return i_pcr;
70
5.28M
}
ts.c:GetPCR
Line
Count
Source
47
5.23M
{
48
5.23M
    const uint8_t *p = p_pkt->p_buffer;
49
50
5.23M
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
5.23M
    if(unlikely(p_pkt->i_buffer < 12))
53
238
        return i_pcr;
54
55
5.23M
    const uint8_t i_adaption = p[3] & 0x30;
56
57
5.23M
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
2.91M
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
2.32M
        ( p[4] >= 7 )  &&
60
1.85M
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
489k
    {
62
        /* PCR is 33 bits */
63
489k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
489k
                ( (ts_90khz_t)p[7] << 17 ) |
65
489k
                ( (ts_90khz_t)p[8] << 9 ) |
66
489k
                ( (ts_90khz_t)p[9] << 1 ) |
67
489k
                ( (ts_90khz_t)p[10] >> 7 );
68
489k
    }
69
5.23M
    return i_pcr;
70
5.23M
}
ts_hotfixes.c:GetPCR
Line
Count
Source
47
48.4k
{
48
48.4k
    const uint8_t *p = p_pkt->p_buffer;
49
50
48.4k
    ts_90khz_t i_pcr = TS_90KHZ_INVALID;
51
52
48.4k
    if(unlikely(p_pkt->i_buffer < 12))
53
0
        return i_pcr;
54
55
48.4k
    const uint8_t i_adaption = p[3] & 0x30;
56
57
48.4k
    if( ( ( i_adaption == 0x30 && p[4] <= 182 ) ||   /* adaptation 0b11 */
58
19.2k
          ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */
59
29.2k
        ( p[4] >= 7 )  &&
60
27.6k
        ( p[5] & 0x10 ) ) /* PCR carry flag */
61
6.72k
    {
62
        /* PCR is 33 bits */
63
6.72k
        i_pcr = ( (ts_90khz_t)p[6] << 25 ) |
64
6.72k
                ( (ts_90khz_t)p[7] << 17 ) |
65
6.72k
                ( (ts_90khz_t)p[8] << 9 ) |
66
6.72k
                ( (ts_90khz_t)p[9] << 1 ) |
67
6.72k
                ( (ts_90khz_t)p[10] >> 7 );
68
6.72k
    }
69
48.4k
    return i_pcr;
70
48.4k
}
71
72
#endif