From e151c558bf1cd7bc96899561c5a97db541958770 Mon Sep 17 00:00:00 2001 From: Oleksandr Nemesh Date: Sat, 1 Feb 2025 20:19:58 +0200 Subject: [PATCH 1/3] uninline funcs --- src/compat.cpp | 61 +++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/src/compat.cpp b/src/compat.cpp index 35ab3f6..da33e7a 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -6,18 +6,22 @@ namespace ffmpeg { class FFMPEG_API_DLL AudioMixer { public: - void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoAudio(std::move(videoFile), std::move(audioFile), std::move(outputMp4File)); - } + void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File); + void mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate); + void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File); + }; - void mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); - } + void AudioMixer::mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoAudio(std::move(videoFile), std::move(audioFile), std::move(outputMp4File)); + } - void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); - } - }; + void AudioMixer::mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); + } + + void AudioMixer::mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); + } typedef struct RenderSettings { HardwareAccelerationType m_hardwareAccelerationType; @@ -47,26 +51,31 @@ namespace ffmpeg { } RenderSettingsV1; class FFMPEG_API_DLL Recorder { -#define self reinterpret_cast(this) public: - bool init(const RenderSettingsV1& settings) { - auto res = self->init(settings.toV2()); - return res.isOk(); - } + bool init(const RenderSettingsV1& settings); + void stop(); + bool writeFrame(const std::vector& frameData); + std::vector getAvailableCodecs(); + }; - void stop() { - self->stop(); - } +#define self reinterpret_cast(this) + bool Recorder::init(const RenderSettingsV1& settings) { + auto res = self->init(settings.toV2()); + return res.isOk(); + } - bool writeFrame(const std::vector& frameData) { - auto res = self->writeFrame(frameData); - return res.isOk(); - } + void Recorder::stop() { + self->stop(); + } - std::vector getAvailableCodecs() { - return FFMPEG_API_VERSION_NS::Recorder::getAvailableCodecs(); - } + bool Recorder::writeFrame(const std::vector& frameData) { + auto res = self->writeFrame(frameData); + return res.isOk(); + } + + std::vector Recorder::getAvailableCodecs() { + return FFMPEG_API_VERSION_NS::Recorder::getAvailableCodecs(); + } #undef self - }; } \ No newline at end of file From d42f1b6e8f7d5961626994dd3e1634809fe9657b Mon Sep 17 00:00:00 2001 From: Oleksandr Nemesh Date: Sat, 1 Feb 2025 20:25:14 +0200 Subject: [PATCH 2/3] GEODE_NOINLINE --- src/compat.cpp | 61 +++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/src/compat.cpp b/src/compat.cpp index da33e7a..fece604 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -6,22 +6,18 @@ namespace ffmpeg { class FFMPEG_API_DLL AudioMixer { public: - void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File); - void mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate); - void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File); - }; - - void AudioMixer::mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoAudio(std::move(videoFile), std::move(audioFile), std::move(outputMp4File)); - } + GEODE_NOINLINE void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoAudio(std::move(videoFile), std::move(audioFile), std::move(outputMp4File)); + } - void AudioMixer::mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); - } + GEODE_NOINLINE void mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); + } - void AudioMixer::mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); - } + GEODE_NOINLINE void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); + } + }; typedef struct RenderSettings { HardwareAccelerationType m_hardwareAccelerationType; @@ -51,31 +47,26 @@ namespace ffmpeg { } RenderSettingsV1; class FFMPEG_API_DLL Recorder { - public: - bool init(const RenderSettingsV1& settings); - void stop(); - bool writeFrame(const std::vector& frameData); - std::vector getAvailableCodecs(); - }; - #define self reinterpret_cast(this) - bool Recorder::init(const RenderSettingsV1& settings) { - auto res = self->init(settings.toV2()); - return res.isOk(); - } + public: + GEODE_NOINLINE bool init(const RenderSettingsV1& settings) { + auto res = self->init(settings.toV2()); + return res.isOk(); + } - void Recorder::stop() { - self->stop(); - } + GEODE_NOINLINE void stop() { + self->stop(); + } - bool Recorder::writeFrame(const std::vector& frameData) { - auto res = self->writeFrame(frameData); - return res.isOk(); - } + GEODE_NOINLINE bool writeFrame(const std::vector& frameData) { + auto res = self->writeFrame(frameData); + return res.isOk(); + } - std::vector Recorder::getAvailableCodecs() { - return FFMPEG_API_VERSION_NS::Recorder::getAvailableCodecs(); - } + GEODE_NOINLINE std::vector getAvailableCodecs() { + return FFMPEG_API_VERSION_NS::Recorder::getAvailableCodecs(); + } #undef self + }; } \ No newline at end of file From d5cf69ca20a852d72aa746d90e0c84f41520a8de Mon Sep 17 00:00:00 2001 From: Oleksandr Nemesh Date: Sat, 1 Feb 2025 20:37:06 +0200 Subject: [PATCH 3/3] typedefs --- src/compat.cpp | 65 ++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/compat.cpp b/src/compat.cpp index fece604..dfa33cb 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -4,20 +4,24 @@ #include "recorder.hpp" namespace ffmpeg { - class FFMPEG_API_DLL AudioMixer { + typedef class FFMPEG_API_DLL AudioMixer { public: - GEODE_NOINLINE void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoAudio(std::move(videoFile), std::move(audioFile), std::move(outputMp4File)); - } + void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File); + void mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate); + void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File); + } AudioMixerV1; - GEODE_NOINLINE void mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); - } + void AudioMixerV1::mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoAudio(std::move(videoFile), std::move(audioFile), std::move(outputMp4File)); + } - GEODE_NOINLINE void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File) { - (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); - } - }; + void AudioMixerV1::mixVideoRaw(std::filesystem::path videoFile, const std::vector& raw, std::filesystem::path outputMp4File, uint32_t sampleRate) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); + } + + void AudioMixerV1::mixVideoRaw(const std::filesystem::path& videoFile, const std::vector& raw, const std::filesystem::path &outputMp4File) { + (void) FFMPEG_API_VERSION_NS::AudioMixer::mixVideoRaw(videoFile, raw, outputMp4File); + } typedef struct RenderSettings { HardwareAccelerationType m_hardwareAccelerationType; @@ -46,27 +50,32 @@ namespace ffmpeg { } } RenderSettingsV1; - class FFMPEG_API_DLL Recorder { -#define self reinterpret_cast(this) + typedef class FFMPEG_API_DLL Recorder { public: - GEODE_NOINLINE bool init(const RenderSettingsV1& settings) { - auto res = self->init(settings.toV2()); - return res.isOk(); - } + bool init(const RenderSettingsV1& settings); + void stop(); + bool writeFrame(const std::vector& frameData); + std::vector getAvailableCodecs(); + } RecorderV1; - GEODE_NOINLINE void stop() { - self->stop(); - } +#define self reinterpret_cast(this) + bool RecorderV1::init(const RenderSettingsV1& settings) { + auto res = self->init(settings.toV2()); + return res.isOk(); + } - GEODE_NOINLINE bool writeFrame(const std::vector& frameData) { - auto res = self->writeFrame(frameData); - return res.isOk(); - } + void RecorderV1::stop() { + self->stop(); + } - GEODE_NOINLINE std::vector getAvailableCodecs() { - return FFMPEG_API_VERSION_NS::Recorder::getAvailableCodecs(); - } + bool RecorderV1::writeFrame(const std::vector& frameData) { + auto res = self->writeFrame(frameData); + return res.isOk(); + } + + std::vector RecorderV1::getAvailableCodecs() { + return FFMPEG_API_VERSION_NS::Recorder::getAvailableCodecs(); + } #undef self - }; } \ No newline at end of file