dolphin/Source/Core/VideoCommon/FrameDumpFFMpeg.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
1.6 KiB
C
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
2020-10-21 14:37:16 +00:00
#include <ctime>
#include <memory>
#include "Common/CommonTypes.h"
2020-10-21 14:37:16 +00:00
struct FrameDumpContext;
class PointerWrap;
2023-01-31 06:15:09 +00:00
// Holds relevant emulation state during a rendered frame for
// when it is later asynchronously written.
struct FrameState
{
u64 ticks = 0;
int frame_number = 0;
u32 savestate_index = 0;
int refresh_rate_num = 0;
int refresh_rate_den = 0;
};
struct FrameData
{
const u8* data = nullptr;
int width = 0;
int height = 0;
int stride = 0;
FrameState state;
};
2020-10-21 14:37:16 +00:00
class FFMpegFrameDump
{
2014-06-15 03:29:05 +00:00
public:
FFMpegFrameDump();
~FFMpegFrameDump();
bool Start(int w, int h, u64 start_ticks);
2020-10-21 14:37:16 +00:00
void AddFrame(const FrameData&);
void Stop();
void DoState(PointerWrap&);
bool IsStarted() const;
FrameState FetchState(u64 ticks, int frame_number) const;
2020-10-21 14:37:16 +00:00
private:
bool IsFirstFrameInCurrentFile() const;
bool PrepareEncoding(int w, int h, u64 start_ticks, u32 savestate_index);
2020-10-21 14:37:16 +00:00
bool CreateVideoFile();
void CloseVideoFile();
void CheckForConfigChange(const FrameData&);
void ProcessPackets();
2017-05-22 19:27:10 +00:00
#if defined(HAVE_FFMPEG)
2020-10-21 14:37:16 +00:00
std::unique_ptr<FrameDumpContext> m_context;
#endif
2020-10-21 14:37:16 +00:00
// Used for FetchState:
u32 m_savestate_index = 0;
// Used for filename generation.
std::time_t m_start_time = {};
u32 m_file_index = 0;
};
2020-10-21 14:37:16 +00:00
#if !defined(HAVE_FFMPEG)
2023-01-31 06:15:09 +00:00
inline FFMpegFrameDump::FFMpegFrameDump() = default;
inline FFMpegFrameDump::~FFMpegFrameDump() = default;
2020-10-21 14:37:16 +00:00
2023-01-31 06:15:09 +00:00
inline FrameState FFMpegFrameDump::FetchState(u64 ticks, int frame_number) const
2020-10-21 14:37:16 +00:00
{
return {};
}
#endif