From 1df655e376fe59291ee5c69755f2f2a70f82ee75 Mon Sep 17 00:00:00 2001 From: altimumdelta <48530820+altimumdelta@users.noreply.github.com> Date: Mon, 18 Mar 2019 05:50:53 +0100 Subject: [PATCH] VideoCommon: Rename AVIDump to FrameDump --- Source/Core/Core/State.cpp | 4 +- Source/Core/VideoCommon/CMakeLists.txt | 4 +- .../{AVIDump.cpp => FrameDump.cpp} | 22 ++++---- .../VideoCommon/{AVIDump.h => FrameDump.h} | 2 +- Source/Core/VideoCommon/RenderBase.cpp | 51 ++++++++++--------- Source/Core/VideoCommon/RenderBase.h | 14 ++--- Source/Core/VideoCommon/VideoCommon.vcxproj | 4 +- .../VideoCommon/VideoCommon.vcxproj.filters | 4 +- 8 files changed, 53 insertions(+), 52 deletions(-) rename Source/Core/VideoCommon/{AVIDump.cpp => FrameDump.cpp} (95%) rename Source/Core/VideoCommon/{AVIDump.h => FrameDump.h} (97%) diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 758774197a..0e393ee075 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -35,7 +35,7 @@ #include "Core/NetPlayClient.h" #include "Core/PowerPC/PowerPC.h" -#include "VideoCommon/AVIDump.h" +#include "VideoCommon/FrameDump.h" #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/VideoBackendBase.h" @@ -192,7 +192,7 @@ static void DoState(PointerWrap& p) p.DoMarker("Gecko"); #if defined(HAVE_FFMPEG) - AVIDump::DoState(); + FrameDump::DoState(); #endif } diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index 92665ca6b3..9b9e36dd79 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -157,8 +157,8 @@ endif() if(FFmpeg_FOUND) target_sources(videocommon PRIVATE - AVIDump.cpp - AVIDump.h + FrameDump.cpp + FrameDump.h ) target_link_libraries(videocommon PRIVATE FFmpeg::avcodec diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/FrameDump.cpp similarity index 95% rename from Source/Core/VideoCommon/AVIDump.cpp rename to Source/Core/VideoCommon/FrameDump.cpp index 5eaa31213c..6a00ce4e12 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/FrameDump.cpp @@ -26,7 +26,7 @@ extern "C" { #include "Core/HW/VideoInterface.h" //for TargetRefreshRate #include "Core/Movie.h" -#include "VideoCommon/AVIDump.h" +#include "VideoCommon/FrameDump.h" #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/VideoConfig.h" @@ -78,7 +78,7 @@ static bool AVStreamCopyContext(AVStream* stream, AVCodecContext* codec_context) #endif } -bool AVIDump::Start(int w, int h) +bool FrameDump::Start(int w, int h) { s_pix_fmt = AV_PIX_FMT_RGBA; @@ -93,7 +93,7 @@ bool AVIDump::Start(int w, int h) if (!success) { CloseVideoFile(); - OSD::AddMessage("AVIDump Start failed"); + OSD::AddMessage("FrameDump Start failed"); } return success; } @@ -124,7 +124,7 @@ static std::string GetDumpPath(const std::string& format) return dump_path; } -bool AVIDump::CreateVideoFile() +bool FrameDump::CreateVideoFile() { const std::string& format = g_Config.sDumpFormat; @@ -180,7 +180,7 @@ bool AVIDump::CreateVideoFile() return false; } - // Force XVID FourCC for better compatibility + // Force XVID FourCC for better compatibility when using H.263 if (codec->id == AV_CODEC_ID_MPEG4) s_codec_context->codec_tag = MKTAG('X', 'V', 'I', 'D'); @@ -295,7 +295,7 @@ static void WritePacket(AVPacket& pkt) av_interleaved_write_frame(s_format_context, &pkt); } -void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const Frame& state) +void FrameDump::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. @@ -386,7 +386,7 @@ static void HandleDelayedPackets() } } -void AVIDump::Stop() +void FrameDump::Stop() { HandleDelayedPackets(); av_write_trailer(s_format_context); @@ -396,7 +396,7 @@ void AVIDump::Stop() OSD::AddMessage("Stopped dumping frames"); } -void AVIDump::CloseVideoFile() +void FrameDump::CloseVideoFile() { av_frame_free(&s_src_frame); av_frame_free(&s_scaled_frame); @@ -417,12 +417,12 @@ void AVIDump::CloseVideoFile() } } -void AVIDump::DoState() +void FrameDump::DoState() { s_savestate_index++; } -void AVIDump::CheckResolution(int width, int height) +void FrameDump::CheckResolution(int width, int height) { // We check here to see if the requested width and height have changed since the last frame which // was dumped, then create a new file accordingly. However, is it possible for the height @@ -438,7 +438,7 @@ void AVIDump::CheckResolution(int width, int height) } } -AVIDump::Frame AVIDump::FetchState(u64 ticks) +FrameDump::Frame FrameDump::FetchState(u64 ticks) { Frame state; state.ticks = ticks; diff --git a/Source/Core/VideoCommon/AVIDump.h b/Source/Core/VideoCommon/FrameDump.h similarity index 97% rename from Source/Core/VideoCommon/AVIDump.h rename to Source/Core/VideoCommon/FrameDump.h index 065a5d63d0..e61a9054eb 100644 --- a/Source/Core/VideoCommon/AVIDump.h +++ b/Source/Core/VideoCommon/FrameDump.h @@ -6,7 +6,7 @@ #include "Common/CommonTypes.h" -class AVIDump +class FrameDump { private: static bool CreateVideoFile(); diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 8c3f89de57..190a827f1b 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -48,7 +48,6 @@ #include "Core/Host.h" #include "Core/Movie.h" -#include "VideoCommon/AVIDump.h" #include "VideoCommon/AbstractFramebuffer.h" #include "VideoCommon/AbstractStagingTexture.h" #include "VideoCommon/AbstractTexture.h" @@ -57,6 +56,7 @@ #include "VideoCommon/CPMemory.h" #include "VideoCommon/CommandProcessor.h" #include "VideoCommon/FPSCounter.h" +#include "VideoCommon/FrameDump.h" #include "VideoCommon/FramebufferManager.h" #include "VideoCommon/ImageWrite.h" #include "VideoCommon/NetPlayChatUI.h" @@ -1339,7 +1339,7 @@ void Renderer::DumpCurrentFrame(const AbstractTexture* src_texture, copy_rect = src_texture->GetRect(); } - // Index 0 was just sent to AVI dump. Swap with the second texture. + // Index 0 was just sent to FFMPEG dump. Swap with the second texture. if (m_frame_dump_readback_textures[0]) std::swap(m_frame_dump_readback_textures[0], m_frame_dump_readback_textures[1]); @@ -1348,7 +1348,7 @@ void Renderer::DumpCurrentFrame(const AbstractTexture* src_texture, m_frame_dump_readback_textures[0]->CopyFromTexture(src_texture, copy_rect, 0, 0, m_frame_dump_readback_textures[0]->GetRect()); - m_last_frame_state = AVIDump::FetchState(ticks); + m_last_frame_state = FrameDump::FetchState(ticks); m_last_frame_exported = true; } @@ -1442,7 +1442,8 @@ void Renderer::ShutdownFrameDumping() tex.reset(); } -void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state) +void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, + const FrameDump::Frame& state) { m_frame_dump_config = FrameDumpConfig{data, w, h, stride, state}; @@ -1471,16 +1472,16 @@ void Renderer::FinishFrameData() void Renderer::RunFrameDumps() { Common::SetCurrentThreadName("FrameDumping"); - bool dump_to_avi = !g_ActiveConfig.bDumpFramesAsImages; + bool dump_to_ffmpeg = !g_ActiveConfig.bDumpFramesAsImages; bool frame_dump_started = false; -// If Dolphin was compiled without libav, we only support dumping to images. +// If Dolphin was compiled without ffmpeg, we only support dumping to images. #if !defined(HAVE_FFMPEG) - if (dump_to_avi) + if (dump_to_ffmpeg) { - WARN_LOG(VIDEO, "AVI frame dump requested, but Dolphin was compiled without libav. " - "Frame dump will be saved as images instead."); - dump_to_avi = false; + WARN_LOG(VIDEO, "FrameDump: Dolphin was not compiled with FFmpeg, using fallback option. " + "Frames will be saved as PNG images instead."); + dump_to_ffmpeg = false; } #endif @@ -1510,8 +1511,8 @@ void Renderer::RunFrameDumps() { if (!frame_dump_started) { - if (dump_to_avi) - frame_dump_started = StartFrameDumpToAVI(config); + if (dump_to_ffmpeg) + frame_dump_started = StartFrameDumpToFFMPEG(config); else frame_dump_started = StartFrameDumpToImage(config); @@ -1523,8 +1524,8 @@ void Renderer::RunFrameDumps() // If we failed to start frame dumping, don't write a frame. if (frame_dump_started) { - if (dump_to_avi) - DumpFrameToAVI(config); + if (dump_to_ffmpeg) + DumpFrameToFFMPEG(config); else DumpFrameToImage(config); } @@ -1536,40 +1537,40 @@ void Renderer::RunFrameDumps() if (frame_dump_started) { // No additional cleanup is needed when dumping to images. - if (dump_to_avi) - StopFrameDumpToAVI(); + if (dump_to_ffmpeg) + StopFrameDumpToFFMPEG(); } } #if defined(HAVE_FFMPEG) -bool Renderer::StartFrameDumpToAVI(const FrameDumpConfig& config) +bool Renderer::StartFrameDumpToFFMPEG(const FrameDumpConfig& config) { - return AVIDump::Start(config.width, config.height); + return FrameDump::Start(config.width, config.height); } -void Renderer::DumpFrameToAVI(const FrameDumpConfig& config) +void Renderer::DumpFrameToFFMPEG(const FrameDumpConfig& config) { - AVIDump::AddFrame(config.data, config.width, config.height, config.stride, config.state); + FrameDump::AddFrame(config.data, config.width, config.height, config.stride, config.state); } -void Renderer::StopFrameDumpToAVI() +void Renderer::StopFrameDumpToFFMPEG() { - AVIDump::Stop(); + FrameDump::Stop(); } #else -bool Renderer::StartFrameDumpToAVI(const FrameDumpConfig& config) +bool Renderer::StartFrameDumpToFFMPEG(const FrameDumpConfig& config) { return false; } -void Renderer::DumpFrameToAVI(const FrameDumpConfig& config) +void Renderer::DumpFrameToFFMPEG(const FrameDumpConfig& config) { } -void Renderer::StopFrameDumpToAVI() +void Renderer::StopFrameDumpToFFMPEG() { } diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index b9eab7f331..c85dcb1645 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -27,10 +27,10 @@ #include "Common/Event.h" #include "Common/Flag.h" #include "Common/MathUtil.h" -#include "VideoCommon/AVIDump.h" #include "VideoCommon/AsyncShaderCompiler.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/FPSCounter.h" +#include "VideoCommon/FrameDump.h" #include "VideoCommon/RenderState.h" #include "VideoCommon/TextureConfig.h" #include "VideoCommon/VideoCommon.h" @@ -337,14 +337,14 @@ private: int width; int height; int stride; - AVIDump::Frame state; + FrameDump::Frame state; } m_frame_dump_config; // Texture used for screenshot/frame dumping std::unique_ptr m_frame_dump_render_texture; std::unique_ptr m_frame_dump_render_framebuffer; std::array, 2> m_frame_dump_readback_textures; - AVIDump::Frame m_last_frame_state; + FrameDump::Frame m_last_frame_state; bool m_last_frame_exported = false; // Tracking of XFB textures so we don't render duplicate frames. @@ -355,9 +355,9 @@ private: u32 m_last_xfb_height = MAX_XFB_HEIGHT; // NOTE: The methods below are called on the framedumping thread. - bool StartFrameDumpToAVI(const FrameDumpConfig& config); - void DumpFrameToAVI(const FrameDumpConfig& config); - void StopFrameDumpToAVI(); + bool StartFrameDumpToFFMPEG(const FrameDumpConfig& config); + void DumpFrameToFFMPEG(const FrameDumpConfig& config); + void StopFrameDumpToFFMPEG(); std::string GetFrameDumpNextImageFileName() const; bool StartFrameDumpToImage(const FrameDumpConfig& config); void DumpFrameToImage(const FrameDumpConfig& config); @@ -376,7 +376,7 @@ private: const MathUtil::Rectangle& src_rect, u64 ticks); // Asynchronously encodes the specified pointer of frame data to the frame dump. - void DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state); + void DumpFrameData(const u8* data, int w, int h, int stride, const FrameDump::Frame& state); // Ensures all rendered frames are queued for encoding. void FlushFrameDump(); diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj index 51f93d0457..467d1c29e7 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj @@ -41,7 +41,7 @@ - + @@ -108,7 +108,7 @@ - + diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters index ea9e2d3346..f69a01a813 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters @@ -86,7 +86,7 @@ Shader Managers - + Util @@ -275,7 +275,7 @@ Shader Managers - + Util