/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 | 7.88M | #define TS_PACKET_SIZE_188 188 |
25 | 43.3k | #define TS_PACKET_SIZE_192 192 |
26 | 42.7k | #define TS_PACKET_SIZE_204 204 |
27 | 2.32M | #define TS_PACKET_SIZE_MAX 204 |
28 | 5.22M | #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 | 167k | { |
34 | 167k | const uint8_t *p = p_pkt->p_buffer; |
35 | 167k | unsigned i_size = 4; |
36 | 167k | if ( p[3] & 0x20 ) // adaptation field |
37 | 125k | i_size += 1 + __MIN(p[4], 182); |
38 | 167k | return i_size; |
39 | 167k | } Line | Count | Source | 33 | 109k | { | 34 | 109k | const uint8_t *p = p_pkt->p_buffer; | 35 | 109k | unsigned i_size = 4; | 36 | 109k | if ( p[3] & 0x20 ) // adaptation field | 37 | 95.6k | i_size += 1 + __MIN(p[4], 182); | 38 | 109k | return i_size; | 39 | 109k | } |
ts_hotfixes.c:PKTHeaderAndAFSize Line | Count | Source | 33 | 57.9k | { | 34 | 57.9k | const uint8_t *p = p_pkt->p_buffer; | 35 | 57.9k | unsigned i_size = 4; | 36 | 57.9k | if ( p[3] & 0x20 ) // adaptation field | 37 | 29.4k | i_size += 1 + __MIN(p[4], 182); | 38 | 57.9k | return i_size; | 39 | 57.9k | } |
|
40 | | |
41 | | static inline int PIDGet( const block_t *p ) |
42 | 5.22M | { |
43 | 5.22M | return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2]; |
44 | 5.22M | } Line | Count | Source | 42 | 5.22M | { | 43 | 5.22M | return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2]; | 44 | 5.22M | } |
Unexecuted instantiation: ts_hotfixes.c:PIDGet |
45 | | |
46 | | static inline ts_90khz_t GetPCR( const block_t *p_pkt ) |
47 | 4.72M | { |
48 | 4.72M | const uint8_t *p = p_pkt->p_buffer; |
49 | | |
50 | 4.72M | ts_90khz_t i_pcr = TS_90KHZ_INVALID; |
51 | | |
52 | 4.72M | if(unlikely(p_pkt->i_buffer < 12)) |
53 | 140 | return i_pcr; |
54 | | |
55 | 4.72M | const uint8_t i_adaption = p[3] & 0x30; |
56 | | |
57 | 4.72M | if( ( ( i_adaption == 0x30 && p[4] <= 182 ) || /* adaptation 0b11 */ |
58 | 2.74M | ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */ |
59 | 1.98M | ( p[4] >= 7 ) && |
60 | 1.58M | ( p[5] & 0x10 ) ) /* PCR carry flag */ |
61 | 228k | { |
62 | | /* PCR is 33 bits */ |
63 | 228k | i_pcr = ( (ts_90khz_t)p[6] << 25 ) | |
64 | 228k | ( (ts_90khz_t)p[7] << 17 ) | |
65 | 228k | ( (ts_90khz_t)p[8] << 9 ) | |
66 | 228k | ( (ts_90khz_t)p[9] << 1 ) | |
67 | 228k | ( (ts_90khz_t)p[10] >> 7 ); |
68 | 228k | } |
69 | 4.72M | return i_pcr; |
70 | 4.72M | } Line | Count | Source | 47 | 4.67M | { | 48 | 4.67M | const uint8_t *p = p_pkt->p_buffer; | 49 | | | 50 | 4.67M | ts_90khz_t i_pcr = TS_90KHZ_INVALID; | 51 | | | 52 | 4.67M | if(unlikely(p_pkt->i_buffer < 12)) | 53 | 140 | return i_pcr; | 54 | | | 55 | 4.67M | const uint8_t i_adaption = p[3] & 0x30; | 56 | | | 57 | 4.67M | if( ( ( i_adaption == 0x30 && p[4] <= 182 ) || /* adaptation 0b11 */ | 58 | 2.71M | ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */ | 59 | 1.95M | ( p[4] >= 7 ) && | 60 | 1.56M | ( p[5] & 0x10 ) ) /* PCR carry flag */ | 61 | 224k | { | 62 | | /* PCR is 33 bits */ | 63 | 224k | i_pcr = ( (ts_90khz_t)p[6] << 25 ) | | 64 | 224k | ( (ts_90khz_t)p[7] << 17 ) | | 65 | 224k | ( (ts_90khz_t)p[8] << 9 ) | | 66 | 224k | ( (ts_90khz_t)p[9] << 1 ) | | 67 | 224k | ( (ts_90khz_t)p[10] >> 7 ); | 68 | 224k | } | 69 | 4.67M | return i_pcr; | 70 | 4.67M | } |
Line | Count | Source | 47 | 57.9k | { | 48 | 57.9k | const uint8_t *p = p_pkt->p_buffer; | 49 | | | 50 | 57.9k | ts_90khz_t i_pcr = TS_90KHZ_INVALID; | 51 | | | 52 | 57.9k | if(unlikely(p_pkt->i_buffer < 12)) | 53 | 0 | return i_pcr; | 54 | | | 55 | 57.9k | const uint8_t i_adaption = p[3] & 0x30; | 56 | | | 57 | 57.9k | if( ( ( i_adaption == 0x30 && p[4] <= 182 ) || /* adaptation 0b11 */ | 58 | 28.6k | ( i_adaption == 0x20 && p[4] == 183 ) ) && /* adaptation 0b10 */ | 59 | 29.3k | ( p[4] >= 7 ) && | 60 | 27.4k | ( p[5] & 0x10 ) ) /* PCR carry flag */ | 61 | 4.31k | { | 62 | | /* PCR is 33 bits */ | 63 | 4.31k | i_pcr = ( (ts_90khz_t)p[6] << 25 ) | | 64 | 4.31k | ( (ts_90khz_t)p[7] << 17 ) | | 65 | 4.31k | ( (ts_90khz_t)p[8] << 9 ) | | 66 | 4.31k | ( (ts_90khz_t)p[9] << 1 ) | | 67 | 4.31k | ( (ts_90khz_t)p[10] >> 7 ); | 68 | 4.31k | } | 69 | 57.9k | return i_pcr; | 70 | 57.9k | } |
|
71 | | |
72 | | #endif |