/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 | 12.8k | #define FROM_SCALE_NZ(x) (((vlc_tick_t)(x) * 100 / 9)) |
27 | | #define TO_SCALE_NZ(x) ((x) * 9 / 100) |
28 | | |
29 | 2.63k | #define FROM_SCALE(x) (VLC_TICK_0 + FROM_SCALE_NZ(x)) |
30 | | #define TO_SCALE(x) TO_SCALE_NZ((x) - VLC_TICK_0) |
31 | | |
32 | | typedef int64_t ts_90khz_t; |
33 | 17.4k | #define TS_90KHZ_INVALID -1 |
34 | | |
35 | | #define TS_33BITS_ROLL_NZ FROM_SCALE_NZ(0x1FFFFFFFF) |
36 | | #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 | 0 | { |
40 | 0 | if( i_past_pcr == VLC_TICK_INVALID || i_time >= i_past_pcr ) |
41 | 0 | return i_time; |
42 | 0 |
|
43 | 0 | vlc_tick_t delta = i_past_pcr - i_time; |
44 | 0 | if( delta >= TS_33BITS_HALF_ROLL_NZ ) |
45 | 0 | { |
46 | 0 | vlc_tick_t rolls = (delta + TS_33BITS_ROLL_NZ - 1) / TS_33BITS_ROLL_NZ; |
47 | 0 | i_time += rolls * TS_33BITS_ROLL_NZ; |
48 | 0 | } |
49 | 0 |
|
50 | 0 | return i_time; |
51 | 0 | } Unexecuted instantiation: ps.c:TimeStampWrapAround Unexecuted instantiation: pva.c:TimeStampWrapAround Unexecuted instantiation: ty.c:TimeStampWrapAround Unexecuted instantiation: cvdsub.c:TimeStampWrapAround Unexecuted instantiation: svcdsub.c:TimeStampWrapAround Unexecuted instantiation: textst.c:TimeStampWrapAround |
52 | | |
53 | | #endif |