20 #ifndef MPD_FFMPEG_TIME_HXX
21 #define MPD_FFMPEG_TIME_HXX
27 #include <libavutil/avutil.h>
28 #include <libavutil/mathematics.h>
46 assert(t != (int64_t)AV_NOPTS_VALUE);
48 return (
double)av_rescale_q(t, time_base, (AVRational){1, 1024})
55 template<
typename Ratio>
56 static inline constexpr AVRational
59 return { Ratio::num, Ratio::den };
69 assert(t != (int64_t)AV_NOPTS_VALUE);
72 (AVRational){1, 1000}));
82 return t != (int64_t)AV_NOPTS_VALUE
94 return av_rescale_q(t.count(),
95 RatioToAVRational<SongTime::period>(),
102 static constexpr int64_t
105 return gcc_likely(t != int64_t(AV_NOPTS_VALUE))
static gcc_const SongTime FromFfmpegTime(int64_t t, const AVRational time_base)
Convert a FFmpeg time stamp to a SongTime.
A time stamp within a song.
static constexpr int64_t FfmpegTimestampFallback(int64_t t, int64_t fallback)
Replace #AV_NOPTS_VALUE with the given fallback.
static gcc_const SignedSongTime FromFfmpegTimeChecked(int64_t t, const AVRational time_base)
Convert a FFmpeg time stamp to a SignedSongTime.
static gcc_const int64_t ToFfmpegTime(SongTime t, const AVRational time_base)
Convert a SongTime to a FFmpeg time stamp with the given base.
static constexpr SignedSongTime Negative()
Generate a negative value.
static constexpr SongTime FromMS(rep ms)
static gcc_const double FfmpegTimeToDouble(int64_t t, const AVRational time_base)
Convert a FFmpeg time stamp to a floating point value (in seconds).
static constexpr AVRational RatioToAVRational()
Convert a std::ratio to a #AVRational.
A variant of SongTime that is based on a signed integer.