Debian Codegraph @

Source/Core/VideoCommon/FrameDumpFFMpeg.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <ctime>
7 #include <limits>
8 #include <memory>
9
10 #include "Common/CommonTypes.h"
11
12 struct FrameDumpContext;
13 class PointerWrap;
14
15 // Holds relevant emulation state during a rendered frame for
16 // when it is later asynchronously written.
17 struct FrameState
18 {
19 u64 ticks = 0;
20 int frame_number = 0;
21 u32 savestate_index = 0;
22 int refresh_rate_num = 0;
23 int refresh_rate_den = 0;
24 };
25
26 struct FrameData
27 {
28 const u8* data = nullptr;
29 int width = 0;
30 int height = 0;
31 int stride = 0;
32 FrameState state;
33 };
34
35 class FFMpegFrameDump
36 {
37 public:
38 FFMpegFrameDump();
39 ~FFMpegFrameDump();
40
41 bool Start(int w, int h, u64 start_ticks);
42 void AddFrame(const FrameData&);
43 void Stop();
44 void DoState(PointerWrap&);
45 bool IsStarted() const;
46 FrameState FetchState(u64 ticks, int frame_number) const;
47
48 private:
49 bool IsFirstFrameInCurrentFile() const;
50 bool PrepareEncoding(int w, int h, u64 start_ticks, u32 savestate_index);
51 bool CreateVideoFile();
52 void CloseVideoFile();
53 void CheckForConfigChange(const FrameData&);
54 void ProcessPackets();
55
56 #if defined(HAVE_FFMPEG)
57 std::unique_ptr<FrameDumpContext> m_context;
58 #endif
59
60 // Used for FetchState:
61 u32 m_savestate_index = 0;
62
63 // Used for filename generation.
64 std::time_t m_start_time = {};
65 u32 m_file_index = 0;
66
67 // Some codecs (like MPEG4) have a limit to this
68 int64_t m_max_denominator = std::numeric_limits<s64>::max();
69 };
70
71 #if !defined(HAVE_FFMPEG)
72 inline FFMpegFrameDump::FFMpegFrameDump() = default;
73 inline FFMpegFrameDump::~FFMpegFrameDump() = default;
74
75 inline FrameState FFMpegFrameDump::FetchState(u64 ticks, int frame_number) const
76 {
77 return {};
78 }
79 #endif