DecoderAPI: use std::chrono::duration for decoder_seek*()
For type safety and code readability.
This commit is contained in:
@@ -210,11 +210,19 @@ time_from_ffmpeg(int64_t t, const AVRational time_base)
|
||||
/ (double)1024;
|
||||
}
|
||||
|
||||
template<typename Ratio>
|
||||
static constexpr AVRational
|
||||
RatioToAVRational()
|
||||
{
|
||||
return { Ratio::num, Ratio::den };
|
||||
}
|
||||
|
||||
gcc_const
|
||||
static int64_t
|
||||
time_to_ffmpeg(double t_ms, const AVRational time_base)
|
||||
time_to_ffmpeg(SongTime t, const AVRational time_base)
|
||||
{
|
||||
return av_rescale_q(t_ms, (AVRational){1, 1000},
|
||||
return av_rescale_q(t.count(),
|
||||
RatioToAVRational<SongTime::period>(),
|
||||
time_base);
|
||||
}
|
||||
|
||||
@@ -547,7 +555,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
||||
|
||||
if (cmd == DecoderCommand::SEEK) {
|
||||
int64_t where =
|
||||
time_to_ffmpeg(decoder_seek_where_ms(decoder),
|
||||
time_to_ffmpeg(decoder_seek_time(decoder),
|
||||
av_stream->time_base) +
|
||||
start_time_fallback(*av_stream);
|
||||
|
||||
|
Reference in New Issue
Block a user