@@ -46,6 +46,8 @@ static bool s_last_frame_is_valid = false;
4646static bool s_start_dumping = false ;
4747static u64 s_last_pts;
4848static int s_file_index = 0 ;
49+ static int s_savestate_index = 0 ;
50+ static int s_last_savestate_index = 0 ;
4951
5052static void InitAVCodec ()
5153{
@@ -168,6 +170,14 @@ static void PreparePacket(AVPacket* pkt)
168170
169171void 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
286296void AVIDump::DoState ()
287297{
288- s_last_frame_is_valid = false ;
298+ s_savestate_index++ ;
289299}
290300
291301void 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}
0 commit comments