diff options
| author | JosJuice <josjuice@gmail.com> | 2020-08-11 11:16:33 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-08-11 11:17:22 +0200 |
| commit | bd87285f3a77fa99f2d2d253ccfa5c4ac1ada17b (patch) | |
| tree | 93b9964ad1f2f42153b2940e747cf175bcc70cfe /Source/Core | |
| parent | 655e92478a0b4366e9f38bdb5c33375a5ef40b6e (diff) | |
FrameDump: Don't ignore the time base numerator
Fixes a regression where f72b756 made all dumped video super long.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/VideoCommon/FrameDump.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/FrameDump.cpp b/Source/Core/VideoCommon/FrameDump.cpp index 117fc5cad8..c8ff63bcfe 100644 --- a/Source/Core/VideoCommon/FrameDump.cpp +++ b/Source/Core/VideoCommon/FrameDump.cpp @@ -295,6 +295,11 @@ static void WritePacket(AVPacket& pkt) av_interleaved_write_frame(s_format_context, &pkt); } +static u64 TicksToTimeBaseUnits(u64 ticks, AVRational time_base, u32 ticks_per_second) +{ + return ticks * time_base.den / time_base.num / ticks_per_second; +} + void FrameDump::AddFrame(const u8* data, int width, int height, int stride, const Frame& state) { // Assume that the timing is valid, if the savestate id of the new frame @@ -346,10 +351,11 @@ void FrameDump::AddFrame(const u8* data, int width, int height, int stride, cons else { delta = state.ticks - s_last_frame; - last_pts = (s_last_pts * s_codec_context->time_base.den) / state.ticks_per_second; + last_pts = TicksToTimeBaseUnits(s_last_pts, s_codec_context->time_base, state.ticks_per_second); } u64 pts_in_ticks = s_last_pts + delta; - s_scaled_frame->pts = (pts_in_ticks * s_codec_context->time_base.den) / state.ticks_per_second; + s_scaled_frame->pts = + TicksToTimeBaseUnits(pts_in_ticks, s_codec_context->time_base, state.ticks_per_second); if (s_scaled_frame->pts != last_pts) { s_last_frame = state.ticks; |
