VideoCommon: Rename AVIDump to FrameDump

This commit is contained in:
altimumdelta 2019-03-18 05:50:53 +01:00
parent 4f6cdfe686
commit 1df655e376
8 changed files with 53 additions and 52 deletions

View File

@ -35,7 +35,7 @@
#include "Core/NetPlayClient.h" #include "Core/NetPlayClient.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include "VideoCommon/AVIDump.h" #include "VideoCommon/FrameDump.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoBackendBase.h"
@ -192,7 +192,7 @@ static void DoState(PointerWrap& p)
p.DoMarker("Gecko"); p.DoMarker("Gecko");
#if defined(HAVE_FFMPEG) #if defined(HAVE_FFMPEG)
AVIDump::DoState(); FrameDump::DoState();
#endif #endif
} }

View File

@ -157,8 +157,8 @@ endif()
if(FFmpeg_FOUND) if(FFmpeg_FOUND)
target_sources(videocommon PRIVATE target_sources(videocommon PRIVATE
AVIDump.cpp FrameDump.cpp
AVIDump.h FrameDump.h
) )
target_link_libraries(videocommon PRIVATE target_link_libraries(videocommon PRIVATE
FFmpeg::avcodec FFmpeg::avcodec

View File

@ -26,7 +26,7 @@ extern "C" {
#include "Core/HW/VideoInterface.h" //for TargetRefreshRate #include "Core/HW/VideoInterface.h" //for TargetRefreshRate
#include "Core/Movie.h" #include "Core/Movie.h"
#include "VideoCommon/AVIDump.h" #include "VideoCommon/FrameDump.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
@ -78,7 +78,7 @@ static bool AVStreamCopyContext(AVStream* stream, AVCodecContext* codec_context)
#endif #endif
} }
bool AVIDump::Start(int w, int h) bool FrameDump::Start(int w, int h)
{ {
s_pix_fmt = AV_PIX_FMT_RGBA; s_pix_fmt = AV_PIX_FMT_RGBA;
@ -93,7 +93,7 @@ bool AVIDump::Start(int w, int h)
if (!success) if (!success)
{ {
CloseVideoFile(); CloseVideoFile();
OSD::AddMessage("AVIDump Start failed"); OSD::AddMessage("FrameDump Start failed");
} }
return success; return success;
} }
@ -124,7 +124,7 @@ static std::string GetDumpPath(const std::string& format)
return dump_path; return dump_path;
} }
bool AVIDump::CreateVideoFile() bool FrameDump::CreateVideoFile()
{ {
const std::string& format = g_Config.sDumpFormat; const std::string& format = g_Config.sDumpFormat;
@ -180,7 +180,7 @@ bool AVIDump::CreateVideoFile()
return false; 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) if (codec->id == AV_CODEC_ID_MPEG4)
s_codec_context->codec_tag = MKTAG('X', 'V', 'I', 'D'); 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); 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 // Assume that the timing is valid, if the savestate id of the new frame
// doesn't match the last one. // doesn't match the last one.
@ -386,7 +386,7 @@ static void HandleDelayedPackets()
} }
} }
void AVIDump::Stop() void FrameDump::Stop()
{ {
HandleDelayedPackets(); HandleDelayedPackets();
av_write_trailer(s_format_context); av_write_trailer(s_format_context);
@ -396,7 +396,7 @@ void AVIDump::Stop()
OSD::AddMessage("Stopped dumping frames"); OSD::AddMessage("Stopped dumping frames");
} }
void AVIDump::CloseVideoFile() void FrameDump::CloseVideoFile()
{ {
av_frame_free(&s_src_frame); av_frame_free(&s_src_frame);
av_frame_free(&s_scaled_frame); av_frame_free(&s_scaled_frame);
@ -417,12 +417,12 @@ void AVIDump::CloseVideoFile()
} }
} }
void AVIDump::DoState() void FrameDump::DoState()
{ {
s_savestate_index++; 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 // 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 // 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; Frame state;
state.ticks = ticks; state.ticks = ticks;

View File

@ -6,7 +6,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
class AVIDump class FrameDump
{ {
private: private:
static bool CreateVideoFile(); static bool CreateVideoFile();

View File

@ -48,7 +48,6 @@
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/Movie.h" #include "Core/Movie.h"
#include "VideoCommon/AVIDump.h"
#include "VideoCommon/AbstractFramebuffer.h" #include "VideoCommon/AbstractFramebuffer.h"
#include "VideoCommon/AbstractStagingTexture.h" #include "VideoCommon/AbstractStagingTexture.h"
#include "VideoCommon/AbstractTexture.h" #include "VideoCommon/AbstractTexture.h"
@ -57,6 +56,7 @@
#include "VideoCommon/CPMemory.h" #include "VideoCommon/CPMemory.h"
#include "VideoCommon/CommandProcessor.h" #include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/FPSCounter.h" #include "VideoCommon/FPSCounter.h"
#include "VideoCommon/FrameDump.h"
#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/ImageWrite.h" #include "VideoCommon/ImageWrite.h"
#include "VideoCommon/NetPlayChatUI.h" #include "VideoCommon/NetPlayChatUI.h"
@ -1339,7 +1339,7 @@ void Renderer::DumpCurrentFrame(const AbstractTexture* src_texture,
copy_rect = src_texture->GetRect(); 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]) if (m_frame_dump_readback_textures[0])
std::swap(m_frame_dump_readback_textures[0], m_frame_dump_readback_textures[1]); 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]->CopyFromTexture(src_texture, copy_rect, 0, 0,
m_frame_dump_readback_textures[0]->GetRect()); 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; m_last_frame_exported = true;
} }
@ -1442,7 +1442,8 @@ void Renderer::ShutdownFrameDumping()
tex.reset(); 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}; m_frame_dump_config = FrameDumpConfig{data, w, h, stride, state};
@ -1471,16 +1472,16 @@ void Renderer::FinishFrameData()
void Renderer::RunFrameDumps() void Renderer::RunFrameDumps()
{ {
Common::SetCurrentThreadName("FrameDumping"); Common::SetCurrentThreadName("FrameDumping");
bool dump_to_avi = !g_ActiveConfig.bDumpFramesAsImages; bool dump_to_ffmpeg = !g_ActiveConfig.bDumpFramesAsImages;
bool frame_dump_started = false; 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 !defined(HAVE_FFMPEG)
if (dump_to_avi) if (dump_to_ffmpeg)
{ {
WARN_LOG(VIDEO, "AVI frame dump requested, but Dolphin was compiled without libav. " WARN_LOG(VIDEO, "FrameDump: Dolphin was not compiled with FFmpeg, using fallback option. "
"Frame dump will be saved as images instead."); "Frames will be saved as PNG images instead.");
dump_to_avi = false; dump_to_ffmpeg = false;
} }
#endif #endif
@ -1510,8 +1511,8 @@ void Renderer::RunFrameDumps()
{ {
if (!frame_dump_started) if (!frame_dump_started)
{ {
if (dump_to_avi) if (dump_to_ffmpeg)
frame_dump_started = StartFrameDumpToAVI(config); frame_dump_started = StartFrameDumpToFFMPEG(config);
else else
frame_dump_started = StartFrameDumpToImage(config); 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 we failed to start frame dumping, don't write a frame.
if (frame_dump_started) if (frame_dump_started)
{ {
if (dump_to_avi) if (dump_to_ffmpeg)
DumpFrameToAVI(config); DumpFrameToFFMPEG(config);
else else
DumpFrameToImage(config); DumpFrameToImage(config);
} }
@ -1536,40 +1537,40 @@ void Renderer::RunFrameDumps()
if (frame_dump_started) if (frame_dump_started)
{ {
// No additional cleanup is needed when dumping to images. // No additional cleanup is needed when dumping to images.
if (dump_to_avi) if (dump_to_ffmpeg)
StopFrameDumpToAVI(); StopFrameDumpToFFMPEG();
} }
} }
#if defined(HAVE_FFMPEG) #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 #else
bool Renderer::StartFrameDumpToAVI(const FrameDumpConfig& config) bool Renderer::StartFrameDumpToFFMPEG(const FrameDumpConfig& config)
{ {
return false; return false;
} }
void Renderer::DumpFrameToAVI(const FrameDumpConfig& config) void Renderer::DumpFrameToFFMPEG(const FrameDumpConfig& config)
{ {
} }
void Renderer::StopFrameDumpToAVI() void Renderer::StopFrameDumpToFFMPEG()
{ {
} }

View File

@ -27,10 +27,10 @@
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/Flag.h" #include "Common/Flag.h"
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
#include "VideoCommon/AVIDump.h"
#include "VideoCommon/AsyncShaderCompiler.h" #include "VideoCommon/AsyncShaderCompiler.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/FPSCounter.h" #include "VideoCommon/FPSCounter.h"
#include "VideoCommon/FrameDump.h"
#include "VideoCommon/RenderState.h" #include "VideoCommon/RenderState.h"
#include "VideoCommon/TextureConfig.h" #include "VideoCommon/TextureConfig.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
@ -337,14 +337,14 @@ private:
int width; int width;
int height; int height;
int stride; int stride;
AVIDump::Frame state; FrameDump::Frame state;
} m_frame_dump_config; } m_frame_dump_config;
// Texture used for screenshot/frame dumping // Texture used for screenshot/frame dumping
std::unique_ptr<AbstractTexture> m_frame_dump_render_texture; std::unique_ptr<AbstractTexture> m_frame_dump_render_texture;
std::unique_ptr<AbstractFramebuffer> m_frame_dump_render_framebuffer; std::unique_ptr<AbstractFramebuffer> m_frame_dump_render_framebuffer;
std::array<std::unique_ptr<AbstractStagingTexture>, 2> m_frame_dump_readback_textures; std::array<std::unique_ptr<AbstractStagingTexture>, 2> m_frame_dump_readback_textures;
AVIDump::Frame m_last_frame_state; FrameDump::Frame m_last_frame_state;
bool m_last_frame_exported = false; bool m_last_frame_exported = false;
// Tracking of XFB textures so we don't render duplicate frames. // Tracking of XFB textures so we don't render duplicate frames.
@ -355,9 +355,9 @@ private:
u32 m_last_xfb_height = MAX_XFB_HEIGHT; u32 m_last_xfb_height = MAX_XFB_HEIGHT;
// NOTE: The methods below are called on the framedumping thread. // NOTE: The methods below are called on the framedumping thread.
bool StartFrameDumpToAVI(const FrameDumpConfig& config); bool StartFrameDumpToFFMPEG(const FrameDumpConfig& config);
void DumpFrameToAVI(const FrameDumpConfig& config); void DumpFrameToFFMPEG(const FrameDumpConfig& config);
void StopFrameDumpToAVI(); void StopFrameDumpToFFMPEG();
std::string GetFrameDumpNextImageFileName() const; std::string GetFrameDumpNextImageFileName() const;
bool StartFrameDumpToImage(const FrameDumpConfig& config); bool StartFrameDumpToImage(const FrameDumpConfig& config);
void DumpFrameToImage(const FrameDumpConfig& config); void DumpFrameToImage(const FrameDumpConfig& config);
@ -376,7 +376,7 @@ private:
const MathUtil::Rectangle<int>& src_rect, u64 ticks); const MathUtil::Rectangle<int>& src_rect, u64 ticks);
// Asynchronously encodes the specified pointer of frame data to the frame dump. // 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. // Ensures all rendered frames are queued for encoding.
void FlushFrameDump(); void FlushFrameDump();

View File

@ -41,7 +41,7 @@
<ClCompile Include="AbstractTexture.cpp" /> <ClCompile Include="AbstractTexture.cpp" />
<ClCompile Include="AsyncRequests.cpp" /> <ClCompile Include="AsyncRequests.cpp" />
<ClCompile Include="AsyncShaderCompiler.cpp" /> <ClCompile Include="AsyncShaderCompiler.cpp" />
<ClCompile Include="AVIDump.cpp" /> <ClCompile Include="FrameDump.cpp" />
<ClCompile Include="BoundingBox.cpp" /> <ClCompile Include="BoundingBox.cpp" />
<ClCompile Include="BPFunctions.cpp" /> <ClCompile Include="BPFunctions.cpp" />
<ClCompile Include="BPMemory.cpp" /> <ClCompile Include="BPMemory.cpp" />
@ -108,7 +108,7 @@
<ClInclude Include="AbstractTexture.h" /> <ClInclude Include="AbstractTexture.h" />
<ClInclude Include="AsyncRequests.h" /> <ClInclude Include="AsyncRequests.h" />
<ClInclude Include="AsyncShaderCompiler.h" /> <ClInclude Include="AsyncShaderCompiler.h" />
<ClInclude Include="AVIDump.h" /> <ClInclude Include="FrameDump.h" />
<ClInclude Include="BoundingBox.h" /> <ClInclude Include="BoundingBox.h" />
<ClInclude Include="BPFunctions.h" /> <ClInclude Include="BPFunctions.h" />
<ClInclude Include="BPMemory.h" /> <ClInclude Include="BPMemory.h" />

View File

@ -86,7 +86,7 @@
<ClCompile Include="VertexShaderManager.cpp"> <ClCompile Include="VertexShaderManager.cpp">
<Filter>Shader Managers</Filter> <Filter>Shader Managers</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="AVIDump.cpp"> <ClCompile Include="FrameDump.cpp">
<Filter>Util</Filter> <Filter>Util</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="FPSCounter.cpp"> <ClCompile Include="FPSCounter.cpp">
@ -275,7 +275,7 @@
<ClInclude Include="VertexShaderManager.h"> <ClInclude Include="VertexShaderManager.h">
<Filter>Shader Managers</Filter> <Filter>Shader Managers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="AVIDump.h"> <ClInclude Include="FrameDump.h">
<Filter>Util</Filter> <Filter>Util</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FPSCounter.h"> <ClInclude Include="FPSCounter.h">