From 0e06345df6b1cb12d38beb1d8f529f6b919c4b62 Mon Sep 17 00:00:00 2001 From: 9vult Date: Tue, 24 Sep 2024 23:27:39 -0400 Subject: [PATCH] genericize pixelize lib --- Holo/Plugins/LibassSource.cs | 14 ++++---- Wrappers/Pixelize/CMakeLists.txt | 32 ------------------- Wrappers/{Pixelize => SpeedDemon}/.gitignore | 0 Wrappers/SpeedDemon/CMakeLists.txt | 32 +++++++++++++++++++ .../include/SpeedDemon.hpp} | 10 +++--- .../src/SpeedDemon.cpp} | 6 ++-- 6 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 Wrappers/Pixelize/CMakeLists.txt rename Wrappers/{Pixelize => SpeedDemon}/.gitignore (100%) create mode 100644 Wrappers/SpeedDemon/CMakeLists.txt rename Wrappers/{Pixelize/include/pixelize.hpp => SpeedDemon/include/SpeedDemon.hpp} (57%) rename Wrappers/{Pixelize/src/pixelize.cpp => SpeedDemon/src/SpeedDemon.cpp} (86%) diff --git a/Holo/Plugins/LibassSource.cs b/Holo/Plugins/LibassSource.cs index 6ce03a4..5ec4198 100644 --- a/Holo/Plugins/LibassSource.cs +++ b/Holo/Plugins/LibassSource.cs @@ -46,17 +46,17 @@ public unsafe void DrawSubtitles(ref VideoFrame frame, long time) { // Copy frame data from copy fixed (byte* ptr = frame.Copy) - Pixelize_External.CopyFrame(ptr, frame.Data, frame.Width * frame.Height * BGRA_WIDTH); + SpeedDemon_External.CopyFrame(ptr, frame.Data, frame.Width * frame.Height * BGRA_WIDTH); } else { // Copy frame data to copy frame.Copy = new byte[frame.Width * frame.Height * BGRA_WIDTH]; fixed (byte* ptr = frame.Copy) - Pixelize_External.CopyFrame(frame.Data, ptr, frame.Width * frame.Height * BGRA_WIDTH); + SpeedDemon_External.CopyFrame(frame.Data, ptr, frame.Width * frame.Height * BGRA_WIDTH); } - Pixelize_External.RenderSubs(frame.Data, frame.Width, frame.Height, image); + SpeedDemon_External.RenderSubs(frame.Data, frame.Width, frame.Height, image); } public void LoadSubtitles(File file, int time = -1) @@ -127,15 +127,15 @@ public IDictionary GetProperties() throw new NotImplementedException(); } - private partial class Pixelize_External + private partial class SpeedDemon_External { - [LibraryImport("Pixelize", EntryPoint = "render_subs")] + [LibraryImport("SpeedDemon", EntryPoint = "render_subs")] public static unsafe partial void RenderSubs(IntPtr frameData, int width, int height, LibassCS.Structures.NativeImage* img); - [LibraryImport("Pixelize", EntryPoint = "copy_frame")] + [LibraryImport("SpeedDemon", EntryPoint = "copy_frame")] public static unsafe partial void CopyFrame(IntPtr source, byte* destination, int size); - [LibraryImport("Pixelize", EntryPoint = "copy_frame")] + [LibraryImport("SpeedDemon", EntryPoint = "copy_frame")] public static unsafe partial void CopyFrame(byte* source, IntPtr destination, int size); } } diff --git a/Wrappers/Pixelize/CMakeLists.txt b/Wrappers/Pixelize/CMakeLists.txt deleted file mode 100644 index b9f20ad..0000000 --- a/Wrappers/Pixelize/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(Pixelize VERSION 1.0 LANGUAGES CXX) - -# Define library output type -add_library(Pixelize SHARED - src/pixelize.cpp -) - -# Add include directories -target_include_directories(Pixelize PUBLIC include) - -# Cross-platform dynamic library properties -if(WIN32) - set_target_properties(Pixelize PROPERTIES - PREFIX "" - SUFFIX ".dll") -elseif(APPLE) - set_target_properties(Pixelize PROPERTIES - PREFIX "" # lib? - SUFFIX ".dylib") -else() - set_target_properties(Pixelize PROPERTIES - PREFIX "" # lib? - SUFFIX ".so") -endif() - -# Set the C++ standard -set_target_properties(Pixelize PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES) - -# Installation (optional) -install(TARGETS Pixelize DESTINATION lib) -install(FILES include/pixelize.h DESTINATION include) diff --git a/Wrappers/Pixelize/.gitignore b/Wrappers/SpeedDemon/.gitignore similarity index 100% rename from Wrappers/Pixelize/.gitignore rename to Wrappers/SpeedDemon/.gitignore diff --git a/Wrappers/SpeedDemon/CMakeLists.txt b/Wrappers/SpeedDemon/CMakeLists.txt new file mode 100644 index 0000000..6eacbc4 --- /dev/null +++ b/Wrappers/SpeedDemon/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.10) +project(SpeedDemon VERSION 1.0 LANGUAGES CXX) + +# Define library output type +add_library(SpeedDemon SHARED + src/SpeedDemon.cpp +) + +# Add include directories +target_include_directories(SpeedDemon PUBLIC include) + +# Cross-platform dynamic library properties +if(WIN32) + set_target_properties(SpeedDemon PROPERTIES + PREFIX "" + SUFFIX ".dll") +elseif(APPLE) + set_target_properties(SpeedDemon PROPERTIES + PREFIX "" # lib? + SUFFIX ".dylib") +else() + set_target_properties(SpeedDemon PROPERTIES + PREFIX "" # lib? + SUFFIX ".so") +endif() + +# Set the C++ standard +set_target_properties(SpeedDemon PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES) + +# Installation (optional) +install(TARGETS SpeedDemon DESTINATION lib) +install(FILES include/SpeedDemon.h DESTINATION include) diff --git a/Wrappers/Pixelize/include/pixelize.hpp b/Wrappers/SpeedDemon/include/SpeedDemon.hpp similarity index 57% rename from Wrappers/Pixelize/include/pixelize.hpp rename to Wrappers/SpeedDemon/include/SpeedDemon.hpp index bc76075..ef8b226 100644 --- a/Wrappers/Pixelize/include/pixelize.hpp +++ b/Wrappers/SpeedDemon/include/SpeedDemon.hpp @@ -8,11 +8,11 @@ extern "C" { #endif // Export macro -#ifndef PIXELIZE_API +#ifndef SPEED_DEMON_API #ifdef _WIN32 - #define PIXELIZE_API __declspec(dllexport) + #define SPEED_DEMON_API __declspec(dllexport) #else - #define PIXELIZE_API __attribute__((visibility("default"))) + #define SPEED_DEMON_API __attribute__((visibility("default"))) #endif #endif @@ -30,9 +30,9 @@ typedef struct ass_image { } type; } ASS_Image; -PIXELIZE_API void copy_frame(unsigned char* source, unsigned char* destination, int size); +SPEED_DEMON_API void copy_frame(unsigned char* source, unsigned char* destination, int size); -PIXELIZE_API void render_subs(unsigned char* frameData, int width, int height, ASS_Image* img); +SPEED_DEMON_API void render_subs(unsigned char* frameData, int width, int height, ASS_Image* img); #ifdef __cplusplus } diff --git a/Wrappers/Pixelize/src/pixelize.cpp b/Wrappers/SpeedDemon/src/SpeedDemon.cpp similarity index 86% rename from Wrappers/Pixelize/src/pixelize.cpp rename to Wrappers/SpeedDemon/src/SpeedDemon.cpp index 7d62402..cd219e1 100644 --- a/Wrappers/Pixelize/src/pixelize.cpp +++ b/Wrappers/SpeedDemon/src/SpeedDemon.cpp @@ -1,10 +1,10 @@ -#include "pixelize.hpp" +#include "SpeedDemon.hpp" -PIXELIZE_API void copy_frame(unsigned char* source, unsigned char* destination, int size) { +SPEED_DEMON_API void copy_frame(unsigned char* source, unsigned char* destination, int size) { std::copy(source, source + size, destination); } -PIXELIZE_API void render_subs(unsigned char* frameData, int width, int height, ASS_Image* img) { +SPEED_DEMON_API void render_subs(unsigned char* frameData, int width, int height, ASS_Image* img) { for (; img; img = img->next) { unsigned int o = 255 - img->color & 0xFF; unsigned int r = img->color >> 24;