From 6c52c855745831bd58ceed310357cd9370b75a60 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 19 Nov 2021 14:40:34 -0800 Subject: [PATCH] initial commit --- .gitignore | 2 + .gitmodules | 6 ++ lib/SDL | 1 + lib/Theorafile | 1 + src/TheorafileGMS.c | 116 +++++++++++++++++++++++++++++ src/TheorafileGMS.h | 61 +++++++++++++++ visualc/TheorafileGMS.sln | 81 ++++++++++++++++++++ visualc/TheorafileGMS.vcxproj | 115 ++++++++++++++++++++++++++++ visualc/TheorafileGMS.vcxproj.user | 4 + 9 files changed, 387 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 160000 lib/SDL create mode 160000 lib/Theorafile create mode 100644 src/TheorafileGMS.c create mode 100644 src/TheorafileGMS.h create mode 100644 visualc/TheorafileGMS.sln create mode 100644 visualc/TheorafileGMS.vcxproj create mode 100644 visualc/TheorafileGMS.vcxproj.user diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c98f18f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vs +x64 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..feb7384 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "Theorafile"] + path = lib/Theorafile + url = https://github.com/FNA-XNA/Theorafile +[submodule "lib/SDL"] + path = lib/SDL + url = https://github.com/libsdl-org/SDL.git diff --git a/lib/SDL b/lib/SDL new file mode 160000 index 0000000..25f9ed8 --- /dev/null +++ b/lib/SDL @@ -0,0 +1 @@ +Subproject commit 25f9ed87ff6947d9576fc9d79dee0784e638ac58 diff --git a/lib/Theorafile b/lib/Theorafile new file mode 160000 index 0000000..3f8bd6c --- /dev/null +++ b/lib/Theorafile @@ -0,0 +1 @@ +Subproject commit 3f8bd6c77fccb45320de9af1f6b2ab55d2fca102 diff --git a/src/TheorafileGMS.c b/src/TheorafileGMS.c new file mode 100644 index 0000000..2115e3e --- /dev/null +++ b/src/TheorafileGMS.c @@ -0,0 +1,116 @@ +/* TheorafileGMS - YUV decoder for Game Maker + * + * Copyright (c) 2021 Evan Hemsley + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Evan "cosmonaut" Hemsley + * + */ + +#include "TheorafileGMS.h" +#include "theorafile.h" +#include "SDL.h" + +static inline void LogError(char* string) +{ + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", string); +} + +char* TheorafileGMS_Open(char* filename) +{ + OggTheora_File* file = SDL_malloc(sizeof(OggTheora_File)); + int err = tf_fopen(filename, file); + if (err < 0) + { + if (err == TF_EUNKNOWN) + { + LogError("An unknown error occurred! Something very wrong happened!"); + } + else if (err == TF_EUNSUPPORTED) + { + LogError("Unsupported theorafile type! Bailing!"); + } + else if (err == TF_ENODATASOURCE) + { + LogError("Unknown data source! Bailing!"); + } + else + { + LogError("An even more unknown error occurred!"); + } + + return NULL; + } + + return (char*)file; +} + +void TheorafileGMS_Close(char* filePointer) +{ + SDL_free(filePointer); +} + +double TheorafileGMS_HasVideo(char* filePointer) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + return (double)tf_hasvideo(file); +} + +double TheorafileGMS_Width(char* filePointer) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + int width; + tf_videoinfo(file, &width, NULL, NULL, NULL); + return (double)width; +} + +double TheorafileGMS_Height(char* filePointer) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + int height; + tf_videoinfo(file, NULL, &height, NULL, NULL); + return (double)height; +} + +double TheorafileGMS_FPS(char* filePointer) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + double fps; + tf_videoinfo(file, NULL, NULL, &fps, NULL); + return fps; +} + +double TheorafileGMS_EndOfStream(char* filePointer) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + return (double)tf_eos(file); +} + +void TheorafileGMS_Reset(char* filePointer) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + tf_reset(file); +} + +double TheorafileGMS_ReadVideo(char* filePointer, char* buffer, double numFrames) +{ + OggTheora_File* file = (OggTheora_File*)filePointer; + return (double)tf_readvideo(file, buffer, (int)numFrames); +} diff --git a/src/TheorafileGMS.h b/src/TheorafileGMS.h new file mode 100644 index 0000000..7de2251 --- /dev/null +++ b/src/TheorafileGMS.h @@ -0,0 +1,61 @@ +/* TheorafileGMS - YUV decoder for Game Maker + * + * Copyright (c) 2021 Evan Hemsley + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Evan "cosmonaut" Hemsley + * + */ + +#ifndef THEORAFILEGMS_H +#define THEORAFILEGMS_H + +#ifdef _WIN32 +#define THEORAFILEGMSAPI __declspec(dllexport) +#define THEORAFILEGMSCALL __cdecl +#else +#define THEORAFILEGMSAPI +#define THEORAFILEGMSCALL +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* return a file ID pointer. must use ptr() on GML side! */ + THEORAFILEGMSAPI char* TheorafileGMS_Open(char* filename); + THEORAFILEGMSAPI void TheorafileGMS_Close(char* filePointer); + THEORAFILEGMSAPI void TheorafileGMS_Reset(char* filePointer); + + THEORAFILEGMSAPI double TheorafileGMS_HasVideo(char* filePointer); + THEORAFILEGMSAPI double TheorafileGMS_Width(char* filePointer); + THEORAFILEGMSAPI double TheorafileGMS_Height(char* filePointer); + THEORAFILEGMSAPI double TheorafileGMS_FPS(char* filePointer); + THEORAFILEGMSAPI double TheorafileGMS_EndOfStream(char* filePointer); + + /* returns whether a texture update is needed or not */ + THEORAFILEGMSAPI double TheorafileGMS_ReadVideo(char* filePointer, char* buffer, double numFrames); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* THEORAFILEGMS_H */ diff --git a/visualc/TheorafileGMS.sln b/visualc/TheorafileGMS.sln new file mode 100644 index 0000000..ad6f045 --- /dev/null +++ b/visualc/TheorafileGMS.sln @@ -0,0 +1,81 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31727.386 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TheorafileGMS", "TheorafileGMS.vcxproj", "{4F20502A-F926-4D12-872D-64AC2E065078}" + ProjectSection(ProjectDependencies) = postProject + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2} = {90A103EF-E403-47D4-BBBB-0F206B9FA7F2} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtheorafile", "..\lib\Theorafile\visualc\libtheorafile\libtheorafile.vcxproj", "{90A103EF-E403-47D4-BBBB-0F206B9FA7F2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "..\lib\SDL\VisualC\SDL\SDL.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + MinSizeRel|x64 = MinSizeRel|x64 + MinSizeRel|x86 = MinSizeRel|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + RelWithDebInfo|x64 = RelWithDebInfo|x64 + RelWithDebInfo|x86 = RelWithDebInfo|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4F20502A-F926-4D12-872D-64AC2E065078}.Debug|x64.ActiveCfg = Debug|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.Debug|x64.Build.0 = Debug|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.Debug|x86.ActiveCfg = Debug|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.Debug|x86.Build.0 = Debug|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.MinSizeRel|x64.ActiveCfg = Release|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.MinSizeRel|x64.Build.0 = Release|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.MinSizeRel|x86.ActiveCfg = Debug|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.MinSizeRel|x86.Build.0 = Debug|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.Release|x64.ActiveCfg = Release|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.Release|x64.Build.0 = Release|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.Release|x86.ActiveCfg = Release|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.Release|x86.Build.0 = Release|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.RelWithDebInfo|x64.ActiveCfg = Release|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.RelWithDebInfo|x64.Build.0 = Release|x64 + {4F20502A-F926-4D12-872D-64AC2E065078}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 + {4F20502A-F926-4D12-872D-64AC2E065078}.RelWithDebInfo|x86.Build.0 = Release|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Debug|x64.ActiveCfg = Debug|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Debug|x64.Build.0 = Debug|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Debug|x86.ActiveCfg = Debug|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Debug|x86.Build.0 = Debug|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.MinSizeRel|x64.ActiveCfg = Debug|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.MinSizeRel|x64.Build.0 = Debug|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.MinSizeRel|x86.ActiveCfg = Debug|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.MinSizeRel|x86.Build.0 = Debug|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Release|x64.ActiveCfg = Release|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Release|x64.Build.0 = Release|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Release|x86.ActiveCfg = Release|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Release|x86.Build.0 = Release|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.RelWithDebInfo|x64.ActiveCfg = Release|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.RelWithDebInfo|x64.Build.0 = Release|x64 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.RelWithDebInfo|x86.Build.0 = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.ActiveCfg = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.Build.0 = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x86.ActiveCfg = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x86.Build.0 = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.MinSizeRel|x64.ActiveCfg = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.MinSizeRel|x64.Build.0 = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.MinSizeRel|x86.ActiveCfg = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.MinSizeRel|x86.Build.0 = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.ActiveCfg = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.Build.0 = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x86.ActiveCfg = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x86.Build.0 = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.RelWithDebInfo|x64.ActiveCfg = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.RelWithDebInfo|x64.Build.0 = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.RelWithDebInfo|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7B2DB465-0A55-3811-9EF4-A520B47653D2} + EndGlobalSection +EndGlobal diff --git a/visualc/TheorafileGMS.vcxproj b/visualc/TheorafileGMS.vcxproj new file mode 100644 index 0000000..a344b40 --- /dev/null +++ b/visualc/TheorafileGMS.vcxproj @@ -0,0 +1,115 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {4F20502A-F926-4D12-872D-64AC2E065078} + TheorafileGMS + 10.0 + + + + DynamicLibrary + true + MultiByte + + + DynamicLibrary + false + true + MultiByte + + + v142 + + + v142 + + + v142 + + + v142 + false + + + + + + + + + + false + false + false + + + + Level3 + Disabled + Default + MultiThreadedDebugDLL + true + ../lib/SDL/include;../lib/Theorafile;../lib/Theorafile/lib;$(OutDir) + + + DebugFull + NotSet + SetupAPI.lib;Version.lib;Winmm.lib;Imm32.lib;libucrt.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + false + + + + + Level3 + MaxSpeed + false + true + MultiThreaded + + + true + true + libucrt.lib;SetupAPI.lib;Version.lib;Winmm.lib;Imm32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + true + + + + + + + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} + + + {90a103ef-e403-47d4-bbbb-0f206b9fa7f2} + + + + + + \ No newline at end of file diff --git a/visualc/TheorafileGMS.vcxproj.user b/visualc/TheorafileGMS.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/visualc/TheorafileGMS.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file