initial commit

main
cosmonaut 2021-11-19 14:40:34 -08:00
commit 6c52c85574
9 changed files with 387 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vs
x64

6
.gitmodules vendored Normal file
View File

@ -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

1
lib/SDL Submodule

@ -0,0 +1 @@
Subproject commit 25f9ed87ff6947d9576fc9d79dee0784e638ac58

1
lib/Theorafile Submodule

@ -0,0 +1 @@
Subproject commit 3f8bd6c77fccb45320de9af1f6b2ab55d2fca102

116
src/TheorafileGMS.c Normal file
View File

@ -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 <evan@moonside.games>
*
*/
#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);
}

61
src/TheorafileGMS.h Normal file
View File

@ -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 <evan@moonside.games>
*
*/
#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 */

81
visualc/TheorafileGMS.sln Normal file
View File

@ -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

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4F20502A-F926-4D12-872D-64AC2E065078}</ProjectGuid>
<RootNamespace>TheorafileGMS</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformToolset>v142</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Label="Vcpkg">
<VcpkgEnabled>false</VcpkgEnabled>
<VcpkgManifestInstall>false</VcpkgManifestInstall>
<VcpkgAutoLink>false</VcpkgAutoLink>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<LanguageStandard_C Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Default</LanguageStandard_C>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MultiThreadedDebugDLL</RuntimeLibrary>
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</FunctionLevelLinking>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../lib/SDL/include;../lib/Theorafile;../lib/Theorafile/lib;$(OutDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<SubSystem Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotSet</SubSystem>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">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)</AdditionalDependencies>
</Link>
<ProjectReference>
<UseLibraryDependencyInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">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)</AdditionalDependencies>
</Link>
<ProjectReference>
<UseLibraryDependencyInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</UseLibraryDependencyInputs>
</ProjectReference>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\TheorafileGMS.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\TheorafileGMS.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\SDL\VisualC\SDL\SDL.vcxproj">
<Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
</ProjectReference>
<ProjectReference Include="..\lib\Theorafile\visualc\libtheorafile\libtheorafile.vcxproj">
<Project>{90a103ef-e403-47d4-bbbb-0f206b9fa7f2}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>