Skip to content

Commit

Permalink
Rename AVIDump to FrameDump
Browse files Browse the repository at this point in the history
  • Loading branch information
altimumdelta committed May 28, 2019
1 parent 526698d commit 6dc00ca
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/State.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -192,7 +192,7 @@ static void DoState(PointerWrap& p)
p.DoMarker("Gecko");

#if defined(HAVE_FFMPEG)
AVIDump::DoState();
FrameDump::DoState();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/CMakeLists.txt
Expand Up @@ -87,7 +87,7 @@ else()
endif()

if(FFmpeg_FOUND)
target_sources(videocommon PRIVATE AVIDump.cpp)
target_sources(videocommon PRIVATE FrameDump.cpp)
target_link_libraries(videocommon PRIVATE
FFmpeg::avcodec
FFmpeg::avformat
Expand Down
Expand Up @@ -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"

Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;

Expand All @@ -151,7 +151,8 @@ bool AVIDump::CreateVideoFile()

const std::string& codec_name = g_Config.bUseFFV1 ? "ffv1" : g_Config.sDumpCodec;

AVCodecID codec_id = output_format->video_codec;
// MKV's default video codec is H.264
AVCodecID codec_id = AV_CODEC_ID_MPEG4;

if (!codec_name.empty())
{
Expand Down Expand Up @@ -180,7 +181,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');

Expand Down Expand Up @@ -295,7 +296,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.
Expand Down Expand Up @@ -386,7 +387,7 @@ static void HandleDelayedPackets()
}
}

void AVIDump::Stop()
void FrameDump::Stop()
{
HandleDelayedPackets();
av_write_trailer(s_format_context);
Expand All @@ -396,7 +397,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);
Expand All @@ -417,12 +418,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
Expand All @@ -438,7 +439,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;
Expand Down
Expand Up @@ -6,7 +6,7 @@

#include "Common/CommonTypes.h"

class AVIDump
class FrameDump
{
private:
static bool CreateVideoFile();
Expand Down
50 changes: 25 additions & 25 deletions Source/Core/VideoCommon/RenderBase.cpp
Expand Up @@ -48,7 +48,7 @@
#include "Core/Host.h"
#include "Core/Movie.h"

#include "VideoCommon/AVIDump.h"
#include "VideoCommon/FrameDump.h"
#include "VideoCommon/AbstractFramebuffer.h"
#include "VideoCommon/AbstractStagingTexture.h"
#include "VideoCommon/AbstractTexture.h"
Expand Down Expand Up @@ -1345,7 +1345,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]);

Expand All @@ -1354,7 +1354,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;
}

Expand Down Expand Up @@ -1448,7 +1448,7 @@ 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};

Expand Down Expand Up @@ -1477,16 +1477,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."
"FrameDump: Frames will be saved as PNG images instead.");
dump_to_ffmpeg = false;
}
#endif

Expand Down Expand Up @@ -1516,8 +1516,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);

Expand All @@ -1529,8 +1529,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);
}
Expand All @@ -1542,40 +1542,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()
{
}

Expand Down
14 changes: 7 additions & 7 deletions Source/Core/VideoCommon/RenderBase.h
Expand Up @@ -26,7 +26,7 @@
#include "Common/Event.h"
#include "Common/Flag.h"
#include "Common/MathUtil.h"
#include "VideoCommon/AVIDump.h"
#include "VideoCommon/FrameDump.h"
#include "VideoCommon/AsyncShaderCompiler.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/FPSCounter.h"
Expand Down Expand Up @@ -338,14 +338,14 @@ class Renderer
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.
Expand All @@ -356,9 +356,9 @@ class Renderer
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);
Expand All @@ -377,7 +377,7 @@ class Renderer
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();
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/VideoCommon.vcxproj
Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/VideoCommon.vcxproj.filters
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 6dc00ca

Please sign in to comment.