Skip to content

Commit 3c65c5f

Browse files
committed
AVIDump: Drop frames which are delayed over a savestate.
1 parent be29090 commit 3c65c5f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Source/Core/VideoCommon/AVIDump.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ static bool s_last_frame_is_valid = false;
4646
static bool s_start_dumping = false;
4747
static u64 s_last_pts;
4848
static int s_file_index = 0;
49+
static int s_savestate_index = 0;
50+
static int s_last_savestate_index = 0;
4951

5052
static void InitAVCodec()
5153
{
@@ -168,6 +170,14 @@ static void PreparePacket(AVPacket* pkt)
168170

169171
void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const Frame& state)
170172
{
173+
// Assume that the timing is valid, if the savestate id of the new frame
174+
// doesn't match the last one.
175+
if (state.savestate_index != s_last_savestate_index)
176+
{
177+
s_last_savestate_index = state.savestate_index;
178+
s_last_frame_is_valid = false;
179+
}
180+
171181
CheckResolution(width, height);
172182
s_src_frame->data[0] = const_cast<u8*>(data);
173183
s_src_frame->linesize[0] = stride;
@@ -285,7 +295,7 @@ void AVIDump::CloseFile()
285295

286296
void AVIDump::DoState()
287297
{
288-
s_last_frame_is_valid = false;
298+
s_savestate_index++;
289299
}
290300

291301
void AVIDump::CheckResolution(int width, int height)
@@ -310,5 +320,6 @@ AVIDump::Frame AVIDump::FetchState(u64 ticks)
310320
state.ticks = ticks;
311321
state.first_frame = Movie::GetCurrentFrame() < 1;
312322
state.ticks_per_second = SystemTimers::GetTicksPerSecond();
323+
state.savestate_index = s_savestate_index;
313324
return state;
314325
}

Source/Core/VideoCommon/AVIDump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AVIDump
1919
u64 ticks = 0;
2020
u32 ticks_per_second = 0;
2121
bool first_frame = false;
22+
int savestate_index = 0;
2223
};
2324

2425
static bool Start(int w, int h);

0 commit comments

Comments
 (0)