]> git.sesse.net Git - nageru/blob - shared/timebase.h
Fix some leftovers in warning messages.
[nageru] / shared / timebase.h
1 #ifndef _TIMEBASE_H
2 #define _TIMEBASE_H 1
3
4 #include <ratio>
5
6 #include <stdint.h>
7
8 // Common timebase that allows us to represent one frame exactly in all the
9 // relevant frame rates:
10 //
11 //   Timebase:                1/120000
12 //   Frame at 50fps:       2400/120000
13 //   Frame at 60fps:       2000/120000
14 //   Frame at 59.94fps:    2002/120000
15 //   Frame at 23.976fps:   5005/120000
16 //
17 // If we also wanted to represent one sample at 48000 Hz, we'd need
18 // to go to 300000. Also supporting one sample at 44100 Hz would mean
19 // going to 44100000; probably a bit excessive.
20 constexpr int64_t TIMEBASE = 120000;
21
22 // Some muxes, like MP4 (or at least avformat's implementation of it),
23 // are not too fond of values above 2^31. At timebase 120000, that's only
24 // about five hours or so, so we define a coarser timebase that doesn't
25 // get 59.94 precisely (so there will be a marginal amount of pts jitter),
26 // but can do at least 50 and 60 precisely, and months of streaming.
27 #define COARSE_TIMEBASE 300
28
29 using TimebaseRatio = std::ratio<1, TIMEBASE>;
30
31 #endif  // !defined(_TIMEBASE_H)