diff options
Diffstat (limited to 'Source/Core/VideoCommon/FrameDump.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/FrameDump.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Source/Core/VideoCommon/FrameDump.cpp b/Source/Core/VideoCommon/FrameDump.cpp index 6867c0ffe8..1475328602 100644 --- a/Source/Core/VideoCommon/FrameDump.cpp +++ b/Source/Core/VideoCommon/FrameDump.cpp @@ -47,7 +47,7 @@ struct FrameDumpContext int width = 0; int height = 0; - u64 first_frame_ticks = 0; + u64 start_ticks = 0; u32 savestate_index = 0; bool gave_vfr_warning = false; @@ -111,7 +111,7 @@ std::string GetDumpPath(const std::string& extension, std::time_t time, u32 inde } // namespace -bool FrameDump::Start(int w, int h) +bool FrameDump::Start(int w, int h, u64 start_ticks) { if (IsStarted()) return true; @@ -120,16 +120,19 @@ bool FrameDump::Start(int w, int h) m_start_time = std::time(nullptr); m_file_index = 0; - return PrepareEncoding(w, h); + return PrepareEncoding(w, h, start_ticks, m_savestate_index); } -bool FrameDump::PrepareEncoding(int w, int h) +bool FrameDump::PrepareEncoding(int w, int h, u64 start_ticks, u32 savestate_index) { m_context = std::make_unique<FrameDumpContext>(); m_context->width = w; m_context->height = h; + m_context->start_ticks = start_ticks; + m_context->savestate_index = savestate_index; + InitAVCodec(); const bool success = CreateVideoFile(); if (!success) @@ -279,14 +282,8 @@ void FrameDump::AddFrame(const FrameData& frame) if (!IsStarted()) return; - if (IsFirstFrameInCurrentFile()) - { - m_context->first_frame_ticks = frame.state.ticks; - m_context->savestate_index = frame.state.savestate_index; - } - - // Calculate presentation timestamp from current ticks since first frame ticks. - const s64 pts = av_rescale_q(frame.state.ticks - m_context->first_frame_ticks, + // Calculate presentation timestamp from ticks since start. + const s64 pts = av_rescale_q(frame.state.ticks - m_context->start_ticks, AVRational{1, int(SystemTimers::GetTicksPerSecond())}, m_context->codec->time_base); @@ -300,7 +297,7 @@ void FrameDump::AddFrame(const FrameData& frame) else if (pts > m_context->last_pts + 1 && !m_context->gave_vfr_warning) { WARN_LOG_FMT(FRAMEDUMP, "PTS delta > 1. Resulting file will have variable frame rate. " - "Subsequent occurances will not be reported."); + "Subsequent occurrences will not be reported."); m_context->gave_vfr_warning = true; } } @@ -447,14 +444,15 @@ void FrameDump::CheckForConfigChange(const FrameData& frame) { Stop(); ++m_file_index; - PrepareEncoding(frame.width, frame.height); + PrepareEncoding(frame.width, frame.height, frame.state.ticks, frame.state.savestate_index); } } -FrameDump::FrameState FrameDump::FetchState(u64 ticks) const +FrameDump::FrameState FrameDump::FetchState(u64 ticks, int frame_number) const { FrameState state; state.ticks = ticks; + state.frame_number = frame_number; state.savestate_index = m_savestate_index; const auto time_base = GetTimeBaseForCurrentRefreshRate(); |
