/src/vlc/modules/demux/mpeg/timestamps.h
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * timestamps.h: MPEG TS/PS Timestamps helpers |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2004-2016 VLC authors and VideoLAN |
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_MPEG_TIMESTAMPS_H |
20 | | #define VLC_MPEG_TIMESTAMPS_H |
21 | | |
22 | | #ifndef __cplusplus |
23 | | _Static_assert(CLOCK_FREQ == 1000000, "FROM|TO_SCALE_NZ not matching CLOCK_FREQ"); |
24 | | #endif |
25 | | |
26 | 3.88M | #define FROM_SCALE_NZ(x) (((vlc_tick_t)(x) * 100 / 9)) |
27 | 1.25M | #define TO_SCALE_NZ(x) ((x) * 9 / 100) |
28 | | |
29 | 2.74M | #define FROM_SCALE(x) (VLC_TICK_0 + FROM_SCALE_NZ(x)) |
30 | 1.25M | #define TO_SCALE(x) TO_SCALE_NZ((x) - VLC_TICK_0) |
31 | | |
32 | | typedef int64_t ts_90khz_t; |
33 | 28.8M | #define TS_90KHZ_INVALID -1 |
34 | | |
35 | 250k | #define TS_33BITS_ROLL_NZ FROM_SCALE_NZ(0x1FFFFFFFF) |
36 | 114k | #define TS_33BITS_HALF_ROLL_NZ FROM_SCALE_NZ(0x0FFFFFFFF) |
37 | | |
38 | | static inline vlc_tick_t TimeStampWrapAround( vlc_tick_t i_past_pcr, vlc_tick_t i_time ) |
39 | 256k | { |
40 | 256k | if( i_past_pcr == VLC_TICK_INVALID || i_time >= i_past_pcr ) |
41 | 141k | return i_time; |
42 | | |
43 | 114k | vlc_tick_t delta = i_past_pcr - i_time; |
44 | 114k | if( delta >= TS_33BITS_HALF_ROLL_NZ ) |
45 | 83.4k | { |
46 | 83.4k | vlc_tick_t rolls = (delta + TS_33BITS_ROLL_NZ - 1) / TS_33BITS_ROLL_NZ; |
47 | 83.4k | i_time += rolls * TS_33BITS_ROLL_NZ; |
48 | 83.4k | } |
49 | | |
50 | 114k | return i_time; |
51 | 256k | } Unexecuted instantiation: ps.c:TimeStampWrapAround Unexecuted instantiation: pva.c:TimeStampWrapAround Unexecuted instantiation: ty.c:TimeStampWrapAround Unexecuted instantiation: vobsub.c:TimeStampWrapAround Line | Count | Source | 39 | 255k | { | 40 | 255k | if( i_past_pcr == VLC_TICK_INVALID || i_time >= i_past_pcr ) | 41 | 141k | return i_time; | 42 | | | 43 | 113k | vlc_tick_t delta = i_past_pcr - i_time; | 44 | 113k | if( delta >= TS_33BITS_HALF_ROLL_NZ ) | 45 | 83.1k | { | 46 | 83.1k | vlc_tick_t rolls = (delta + TS_33BITS_ROLL_NZ - 1) / TS_33BITS_ROLL_NZ; | 47 | 83.1k | i_time += rolls * TS_33BITS_ROLL_NZ; | 48 | 83.1k | } | 49 | | | 50 | 113k | return i_time; | 51 | 255k | } |
Unexecuted instantiation: ts_pid.c:TimeStampWrapAround ts_psi.c:TimeStampWrapAround Line | Count | Source | 39 | 869 | { | 40 | 869 | if( i_past_pcr == VLC_TICK_INVALID || i_time >= i_past_pcr ) | 41 | 0 | return i_time; | 42 | | | 43 | 869 | vlc_tick_t delta = i_past_pcr - i_time; | 44 | 869 | if( delta >= TS_33BITS_HALF_ROLL_NZ ) | 45 | 320 | { | 46 | 320 | vlc_tick_t rolls = (delta + TS_33BITS_ROLL_NZ - 1) / TS_33BITS_ROLL_NZ; | 47 | 320 | i_time += rolls * TS_33BITS_ROLL_NZ; | 48 | 320 | } | 49 | | | 50 | 869 | return i_time; | 51 | 869 | } |
Unexecuted instantiation: ts_si.c:TimeStampWrapAround Unexecuted instantiation: ts_psip.c:TimeStampWrapAround Unexecuted instantiation: ts_streams.c:TimeStampWrapAround Unexecuted instantiation: ts_scte.c:TimeStampWrapAround Unexecuted instantiation: ts_arib.c:TimeStampWrapAround Unexecuted instantiation: ts_sl.c:TimeStampWrapAround Unexecuted instantiation: ts_metadata.c:TimeStampWrapAround Unexecuted instantiation: ts_hotfixes.c:TimeStampWrapAround Unexecuted instantiation: ts_pes.c:TimeStampWrapAround Unexecuted instantiation: cvdsub.c:TimeStampWrapAround Unexecuted instantiation: svcdsub.c:TimeStampWrapAround Unexecuted instantiation: textst.c:TimeStampWrapAround |
52 | | |
53 | | #endif |