diff options
| author | degasus <wickmarkus@web.de> | 2016-10-08 12:56:28 +0200 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2016-10-10 12:03:18 +0200 |
| commit | 9f264c0872603ba1963adfa706ca7a1490bd0a24 (patch) | |
| tree | 06d4069ab0332d8e4635ffaf712d3e4d2711a42f /Source/Core/VideoCommon/AVIDump.cpp | |
| parent | a583d36c7f38fac9fb66c059bf6990bfd819591f (diff) | |
AVIDump: Move CoreTiming into caller.
Diffstat (limited to 'Source/Core/VideoCommon/AVIDump.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/AVIDump.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index 80af9f8d84..58782f9b0f 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -20,7 +20,6 @@ extern "C" { #include "Common/MsgHandler.h" #include "Core/ConfigManager.h" -#include "Core/CoreTiming.h" #include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" //for TargetRefreshRate #include "Core/Movie.h" @@ -41,6 +40,7 @@ static SwsContext* s_sws_context = nullptr; static int s_width; static int s_height; static u64 s_last_frame; +static bool s_last_frame_is_valid = false; static bool s_start_dumping = false; static bool s_stop_dumping = false; static u64 s_last_pts; @@ -51,6 +51,7 @@ static const u8* s_stored_frame_data; static int s_stored_frame_width; static int s_stored_frame_height; static int s_stored_frame_stride; +static u64 s_stored_frame_ticks; static void InitAVCodec() { @@ -71,7 +72,7 @@ bool AVIDump::Start(int w, int h) s_current_width = w; s_current_height = h; - s_last_frame = CoreTiming::GetTicks(); + s_last_frame_is_valid = false; s_last_pts = 0; s_stop_dumping = false; @@ -169,14 +170,14 @@ static void PreparePacket(AVPacket* pkt) pkt->size = 0; } -void AVIDump::AddFrame(const u8* data, int width, int height, int stride) +void AVIDump::AddFrame(const u8* data, int width, int height, int stride, u64 ticks) { // Store current frame data in case frame dumping stops before next frame update, // but make sure that you don't store the last stored frame and check the resolution upon // closing the file or else you store recursion, and dolphins don't like recursion. if (!s_stop_dumping) { - StoreFrameData(data, width, height, stride); + StoreFrameData(data, width, height, stride, ticks); CheckResolution(width, height); } s_src_frame->data[0] = const_cast<u8*>(data); @@ -205,15 +206,20 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride) // Check to see if the first frame being dumped is the first frame of output from the emulator. // This prevents an issue with starting dumping later in emulation from placing the frames // incorrectly. + if (!s_last_frame_is_valid) + { + s_last_frame = ticks; + s_last_frame_is_valid = true; + } if (!s_start_dumping && Movie::GetCurrentFrame() < 1) { - delta = CoreTiming::GetTicks(); + delta = ticks; last_pts = AV_NOPTS_VALUE; s_start_dumping = true; } else { - delta = CoreTiming::GetTicks() - s_last_frame; + delta = ticks - s_last_frame; last_pts = (s_last_pts * s_stream->codec->time_base.den) / SystemTimers::GetTicksPerSecond(); } u64 pts_in_ticks = s_last_pts + delta; @@ -221,7 +227,7 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride) (pts_in_ticks * s_stream->codec->time_base.den) / SystemTimers::GetTicksPerSecond(); if (s_scaled_frame->pts != last_pts) { - s_last_frame = CoreTiming::GetTicks(); + s_last_frame = ticks; s_last_pts = pts_in_ticks; error = avcodec_encode_video2(s_stream->codec, &pkt, s_scaled_frame, &got_packet); } @@ -255,7 +261,8 @@ void AVIDump::Stop() { s_stop_dumping = true; // Write the last stored frame just in case frame dumping stops before the next frame update - AddFrame(s_stored_frame_data, s_stored_frame_width, s_stored_frame_height, s_stored_frame_stride); + AddFrame(s_stored_frame_data, s_stored_frame_width, s_stored_frame_height, s_stored_frame_stride, + s_stored_frame_ticks); av_write_trailer(s_format_context); CloseFile(); s_file_index = 0; @@ -295,7 +302,7 @@ void AVIDump::CloseFile() void AVIDump::DoState() { - s_last_frame = CoreTiming::GetTicks(); + s_last_frame_is_valid = false; } void AVIDump::CheckResolution(int width, int height) @@ -316,10 +323,11 @@ void AVIDump::CheckResolution(int width, int height) } } -void AVIDump::StoreFrameData(const u8* data, int width, int height, int stride) +void AVIDump::StoreFrameData(const u8* data, int width, int height, int stride, u64 ticks) { s_stored_frame_data = data; s_stored_frame_width = width; s_stored_frame_height = height; s_stored_frame_stride = stride; + s_stored_frame_ticks = ticks; } |
