From 3c65c5f2c53f3efedb3bd94cf1f55ff4f90309c9 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 4 Nov 2016 18:24:03 +0100 Subject: [PATCH] AVIDump: Drop frames which are delayed over a savestate. --- Source/Core/VideoCommon/AVIDump.cpp | 13 ++++++++++++- Source/Core/VideoCommon/AVIDump.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index 1756be97a8..b442afd9fe 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -46,6 +46,8 @@ static bool s_last_frame_is_valid = false; static bool s_start_dumping = false; static u64 s_last_pts; static int s_file_index = 0; +static int s_savestate_index = 0; +static int s_last_savestate_index = 0; static void InitAVCodec() { @@ -168,6 +170,14 @@ static void PreparePacket(AVPacket* pkt) void AVIDump::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 + // doesn't match the last one. + if (state.savestate_index != s_last_savestate_index) + { + s_last_savestate_index = state.savestate_index; + s_last_frame_is_valid = false; + } + CheckResolution(width, height); s_src_frame->data[0] = const_cast(data); s_src_frame->linesize[0] = stride; @@ -285,7 +295,7 @@ void AVIDump::CloseFile() void AVIDump::DoState() { - s_last_frame_is_valid = false; + s_savestate_index++; } void AVIDump::CheckResolution(int width, int height) @@ -310,5 +320,6 @@ AVIDump::Frame AVIDump::FetchState(u64 ticks) state.ticks = ticks; state.first_frame = Movie::GetCurrentFrame() < 1; state.ticks_per_second = SystemTimers::GetTicksPerSecond(); + state.savestate_index = s_savestate_index; return state; } diff --git a/Source/Core/VideoCommon/AVIDump.h b/Source/Core/VideoCommon/AVIDump.h index bbea5e2bbf..b9158774a3 100644 --- a/Source/Core/VideoCommon/AVIDump.h +++ b/Source/Core/VideoCommon/AVIDump.h @@ -19,6 +19,7 @@ public: u64 ticks = 0; u32 ticks_per_second = 0; bool first_frame = false; + int savestate_index = 0; }; static bool Start(int w, int h);