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/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
}

View File

@ -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

View File

@ -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;

View File

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

View File

@ -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()
{
}

View File

@ -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<AbstractTexture> m_frame_dump_render_texture;
std::unique_ptr<AbstractFramebuffer> m_frame_dump_render_framebuffer;
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;
// 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<int>& 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();

View File

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

View File

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