diff options
| author | Chris Burgener <christhecoolist@gmail.com> | 2016-06-27 22:39:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-27 22:39:19 -0400 |
| commit | 28a3691e70ba2a1b37dbb58b22dfd35336c99a80 (patch) | |
| tree | 508deec015b6907a063aa197a089678e2604ae00 /Source/Core/VideoCommon | |
| parent | 93a5efa347c62ca97e375a1a226d7741d584fd2f (diff) | |
| parent | f31adf9635283a288b4765b07b01bfa700dd50b2 (diff) | |
Merge pull request #3930 from RisingFog/split_video_dump_resolution
Split Video Dumps on Resolution Change
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/AVIDump.cpp | 28 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/AVIDump.h | 1 |
2 files changed, 28 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index eba3da3e32..6989db11d9 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -45,6 +45,10 @@ static int s_size; static u64 s_last_frame; static bool s_start_dumping = false; static u64 s_last_pts; +static int s_current_width; +static int s_current_height; +static int s_file_index = 0; +static AVIDump::DumpFormat s_current_format; static void InitAVCodec() { @@ -63,8 +67,12 @@ bool AVIDump::Start(int w, int h, DumpFormat format) else s_pix_fmt = AV_PIX_FMT_RGBA; + s_current_format = format; + s_width = w; s_height = h; + s_current_width = w; + s_current_height = h; s_last_frame = CoreTiming::GetTicks(); s_last_pts = 0; @@ -81,8 +89,11 @@ bool AVIDump::CreateFile() AVCodec* codec = nullptr; s_format_context = avformat_alloc_context(); + std::stringstream s_file_index_str; + s_file_index_str << s_file_index; snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s", - (File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump0.avi").c_str()); + (File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump" + s_file_index_str.str() + ".avi") + .c_str()); File::CreateFullPath(s_format_context->filename); // Ask to delete file @@ -156,6 +167,7 @@ static void PreparePacket(AVPacket* pkt) void AVIDump::AddFrame(const u8* data, int width, int height) { + CheckResolution(width, height); avpicture_fill((AVPicture*)s_src_frame, const_cast<u8*>(data), s_pix_fmt, width, height); // Convert image from {BGR24, RGBA} to desired pixel format, and scale to initial @@ -232,6 +244,7 @@ void AVIDump::Stop() { av_write_trailer(s_format_context); CloseFile(); + s_file_index = 0; NOTICE_LOG(VIDEO, "Stopping frame dump"); } @@ -273,3 +286,16 @@ void AVIDump::DoState() { s_last_frame = CoreTiming::GetTicks(); } + +void AVIDump::CheckResolution(int width, int height) +{ + if (width != s_current_width || height != s_current_height) + { + int temp_file_index = s_file_index; + Stop(); + s_file_index = temp_file_index + 1; + Start(width, height, s_current_format); + s_current_width = width; + s_current_height = height; + } +} diff --git a/Source/Core/VideoCommon/AVIDump.h b/Source/Core/VideoCommon/AVIDump.h index caac19da43..b4b87f90de 100644 --- a/Source/Core/VideoCommon/AVIDump.h +++ b/Source/Core/VideoCommon/AVIDump.h @@ -11,6 +11,7 @@ class AVIDump private: static bool CreateFile(); static void CloseFile(); + static void CheckResolution(int width, int height); public: enum class DumpFormat |
