diff options
author | theuni <theuni-nospam-@xbmc.org> | 2011-01-24 16:05:21 -0500 |
---|---|---|
committer | theuni <theuni-nospam-@xbmc.org> | 2011-01-24 16:05:21 -0500 |
commit | c51b1189e3d5353e842991f5859ddcea0f73e426 (patch) | |
tree | ef2cb8a6184699aa614f3655dca4ce661cdc108e /lib/xbadpcm | |
parent | be61ebdc9e897fe40c6f371111724de79ddee8d5 (diff) |
Merged cptspiff's code-reshuffle branch.
Squashed commit due to build breakage during code-reshuffle history.
Conflicts:
xbmc/Util.cpp
xbmc/cdrip/CDDARipper.cpp
xbmc/filesystem/Directory.cpp
xbmc/filesystem/File.cpp
Diffstat (limited to 'lib/xbadpcm')
-rw-r--r-- | lib/xbadpcm/ADPCMDll.cpp | 165 | ||||
-rw-r--r-- | lib/xbadpcm/Makefile.in | 18 | ||||
-rw-r--r-- | lib/xbadpcm/adpcm.sln | 21 | ||||
-rw-r--r-- | lib/xbadpcm/adpcm.vcproj | 215 | ||||
-rw-r--r-- | lib/xbadpcm/adpcm.vcxproj | 161 | ||||
-rw-r--r-- | lib/xbadpcm/adpcm.vcxproj.filters | 29 | ||||
-rw-r--r-- | lib/xbadpcm/in_xbadpcm.txt | 47 | ||||
-rw-r--r-- | lib/xbadpcm/mywav.h | 249 | ||||
-rw-r--r-- | lib/xbadpcm/uXboxAdpcmDecoder.c | 164 | ||||
-rw-r--r-- | lib/xbadpcm/uXboxAdpcmDecoder.h | 63 |
10 files changed, 1132 insertions, 0 deletions
diff --git a/lib/xbadpcm/ADPCMDll.cpp b/lib/xbadpcm/ADPCMDll.cpp new file mode 100644 index 0000000000..a5db26296e --- /dev/null +++ b/lib/xbadpcm/ADPCMDll.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2008-2010 Team XBMC + * http://www.xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifdef _LINUX +#define __declspec(x) +#endif + +extern "C" +{ +#include "mywav.h" +#include "uXboxAdpcmDecoder.h" +#include <stdlib.h> + +#define GETLENGTH(x,SAMPLERATE,NCH) (((x * 10) / ((SAMPLERATE / 100) * NCH * (16 >> 3)) / XBOX_ADPCM_SRCSIZE) * XBOX_ADPCM_DSTSIZE) + + struct ADPCMInfo + { + FILE* f; + mywav_fmtchunk fmt; + unsigned int length; + int data_offset; + char* szInputBuffer; + char* szBuf; + char* szStartOfBuf; + int bufLen; + }; + + int getwavinfo(ADPCMInfo* info) { + int wavsize; + + wavsize = mywav_data(info->f, &info->fmt); + if(wavsize >= 0) { + if(info->fmt.wFormatTag != 0x0069) { + fseek(info->f,0,SEEK_SET); + return(-1); + } + info->data_offset = ftell(info->f); + } else { + fseek(info->f,0,SEEK_END); + wavsize = ftell(info->f); + fseek(info->f,0,SEEK_SET); + } + + info->length = GETLENGTH(wavsize,info->fmt.dwSamplesPerSec,info->fmt.wChannels); + return(wavsize); +} + + + long __declspec(dllexport) DLL_LoadXWAV(const char* szFileName) + { + ADPCMInfo* info = (ADPCMInfo*)malloc(sizeof(ADPCMInfo)); + info->f = fopen(szFileName,"rb"); + if (!info->f) + { + free(info); + return 0; + } + + int iResult = getwavinfo(info); + if (iResult == -1) + { + fclose(info->f); + free(info); + return 0; + } + + info->szBuf = (char*)malloc(XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4); + info->szInputBuffer = (char*)malloc(XBOX_ADPCM_SRCSIZE*info->fmt.wChannels*4); + info->szStartOfBuf = info->szBuf+XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4; + info->bufLen = XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4; + return (long)info; + } + + void __declspec(dllexport) DLL_FreeXWAV(int info) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + fclose(pInfo->f); + free(pInfo); + } + + int __declspec(dllexport) DLL_Seek(int info, int pos) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + int offs = pInfo->data_offset + ((((pos/ 1000) * pInfo->fmt.dwSamplesPerSec) / XBOX_ADPCM_DSTSIZE) * XBOX_ADPCM_SRCSIZE * pInfo->fmt.wChannels * (16 >> 3)); + + fseek(pInfo->f,offs,SEEK_SET); + // invalidate buffer + pInfo->szStartOfBuf = pInfo->szBuf+XBOX_ADPCM_DSTSIZE*pInfo->fmt.wChannels*4; + return pos; + } + + long __declspec(dllexport) DLL_FillBuffer(int info, char* buffer, int size) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + int iCurrSize = size; + while (iCurrSize > 0) + { + if (pInfo->szStartOfBuf >= pInfo->szBuf+pInfo->bufLen) + { + // Read data into input buffer + int read = fread(pInfo->szInputBuffer,XBOX_ADPCM_SRCSIZE*pInfo->fmt.wChannels,4,pInfo->f); + if (!read) + break; + + TXboxAdpcmDecoder_Decode_Memory((uint8_t*)pInfo->szInputBuffer, read*XBOX_ADPCM_SRCSIZE*pInfo->fmt.wChannels, (uint8_t*)pInfo->szBuf, pInfo->fmt.wChannels); + pInfo->szStartOfBuf = pInfo->szBuf; + } + int iCopy=0; + if (iCurrSize > pInfo->szBuf+pInfo->bufLen-pInfo->szStartOfBuf) + iCopy = pInfo->szBuf+pInfo->bufLen-pInfo->szStartOfBuf; + else + iCopy = iCurrSize; + + memcpy(buffer,pInfo->szStartOfBuf,iCopy); + buffer += iCopy; + iCurrSize -= iCopy; + pInfo->szStartOfBuf += iCopy; + } + + return size-iCurrSize; + } + + int __declspec(dllexport) DLL_GetPlaybackRate(int info) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + return pInfo->fmt.dwSamplesPerSec; + } + + int __declspec(dllexport) DLL_GetNumberOfChannels(int info) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + return pInfo->fmt.wChannels; + } + + int __declspec(dllexport) DLL_GetSampleSize(int info) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + return pInfo->fmt.wBitsPerSample; + } + + int __declspec(dllexport) DLL_GetLength(int info) + { + ADPCMInfo* pInfo = (ADPCMInfo*)info; + return pInfo->length; + } +} + diff --git a/lib/xbadpcm/Makefile.in b/lib/xbadpcm/Makefile.in new file mode 100644 index 0000000000..0cda9ebd9e --- /dev/null +++ b/lib/xbadpcm/Makefile.in @@ -0,0 +1,18 @@ +ARCH=@ARCH@ +OBJS=uXboxAdpcmDecoder.o ADPCMDll.o +CFLAGS +=-D_LINUX -fPIC +CXXFLAGS += -D_LINUX -fPIC + +SLIB=@abs_top_srcdir@/system/players/paplayer/adpcm-@ARCH@.so + +$(SLIB): $(OBJS) +ifeq ($(findstring osx,$(ARCH)), osx) + ld -bundle -flat_namespace -undefined suppress -o $@ *.o $(BUNDLE1_O) + @abs_top_srcdir@/tools/Mach5/wrapper.rb $@;mv output.so $@ + chmod +x $@ +else + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ *.o `cat @abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper.def` @abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper.o +endif + +include @abs_top_srcdir@/Makefile.include + diff --git a/lib/xbadpcm/adpcm.sln b/lib/xbadpcm/adpcm.sln new file mode 100644 index 0000000000..448fcad143 --- /dev/null +++ b/lib/xbadpcm/adpcm.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "adpcm", "adpcm.vcproj", "{2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}.Debug.ActiveCfg = Debug|Win32 + {2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}.Debug.Build.0 = Debug|Win32 + {2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}.Release.ActiveCfg = Release|Win32 + {2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/lib/xbadpcm/adpcm.vcproj b/lib/xbadpcm/adpcm.vcproj new file mode 100644 index 0000000000..f2bbdb0cea --- /dev/null +++ b/lib/xbadpcm/adpcm.vcproj @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="libadpcm_dll" + ProjectGUID="{2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}" + RootNamespace="libadpcm_dll" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)libs\$(ProjectName)\$(ConfigurationName)\" + IntermediateDirectory="$(SolutionDir)objs\$(ProjectName)\$(ConfigurationName)\" + ConfigurationType="2" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + DisableSpecificWarnings="4244;4267;4311;4312" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + ResourceOutputFileName="" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="..\..\..\..\system\players\paplayer\adpcm.dll" + LinkIncremental="1" + GenerateDebugInformation="true" + ProgramDatabaseFile="adpcm.pdb" + SubSystem="2" + ProfileGuidedDatabase="" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + ImportLibrary="$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)libs\$(ProjectName)\$(ConfigurationName)\" + IntermediateDirectory="$(SolutionDir)objs\$(ProjectName)\$(ConfigurationName)\" + ConfigurationType="2" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + DisableSpecificWarnings="4244;4267;4311;4312" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + ResourceOutputFileName="" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="..\..\..\..\system\players\paplayer\adpcm.dll" + LinkIncremental="1" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(TargetName).pdb" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + ProfileGuidedDatabase="" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + ImportLibrary="$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\ADPCMDll.cpp" + > + </File> + <File + RelativePath=".\uXboxAdpcmDecoder.c" + > + </File> + <File + RelativePath=".\uXboxAdpcmDecoder.h" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\mywav.h" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/lib/xbadpcm/adpcm.vcxproj b/lib/xbadpcm/adpcm.vcxproj new file mode 100644 index 0000000000..8b60510099 --- /dev/null +++ b/lib/xbadpcm/adpcm.vcxproj @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.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> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectName>libadpcm_dll</ProjectName> + <ProjectGuid>{2A8CBFB5-C226-4BB3-8C03-7C75D511A4A2}</ProjectGuid> + <RootNamespace>libadpcm_dll</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + <Import Project="..\..\project\VS2010Express\XBMC for Windows.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + <Import Project="..\..\project\VS2010Express\XBMC for Windows.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)libs\$(TargetName)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)objs\$(TargetName)\$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)libs\$(TargetName)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)objs\$(TargetName)\$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> + <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> + <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> + <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">adpcm</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">adpcm</TargetName> + <CustomBuildAfterTargets Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Build</CustomBuildAfterTargets> + <CustomBuildAfterTargets Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Build</CustomBuildAfterTargets> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4244;4267;4311;4312;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <ResourceCompile> + <ResourceOutputFileName> + </ResourceOutputFileName> + </ResourceCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>adpcm.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <ImportLibrary>$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <CustomBuildStep> + <Command>copy /B /Y "$(TargetPath)" "$(SolutionDir)..\..\system\players\paplayer\$(TargetFileName)"</Command> + </CustomBuildStep> + <CustomBuildStep> + <Message>Copy output</Message> + </CustomBuildStep> + <CustomBuildStep> + <Outputs>$(SolutionDir)..\..\system\players\paplayer\$(TargetFileName)</Outputs> + <Inputs>$(TargetPath)</Inputs> + </CustomBuildStep> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4244;4267;4311;4312;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <ResourceCompile> + <ResourceOutputFileName> + </ResourceOutputFileName> + </ResourceCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <ImportLibrary>$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <CustomBuildStep> + <Command>copy /B /Y "$(TargetPath)" "$(SolutionDir)..\..\system\players\paplayer\$(TargetFileName)"</Command> + </CustomBuildStep> + <CustomBuildStep> + <Message>Copy output</Message> + </CustomBuildStep> + <CustomBuildStep> + <Outputs>$(SolutionDir)..\..\system\players\paplayer\$(TargetFileName)</Outputs> + <Inputs>$(TargetPath)</Inputs> + </CustomBuildStep> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="ADPCMDll.cpp" /> + <ClCompile Include="uXboxAdpcmDecoder.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="uXboxAdpcmDecoder.h" /> + <ClInclude Include="mywav.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/lib/xbadpcm/adpcm.vcxproj.filters b/lib/xbadpcm/adpcm.vcxproj.filters new file mode 100644 index 0000000000..ac523b1030 --- /dev/null +++ b/lib/xbadpcm/adpcm.vcxproj.filters @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="ADPCMDll.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="uXboxAdpcmDecoder.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="uXboxAdpcmDecoder.h"> + <Filter>Source Files</Filter> + </ClInclude> + <ClInclude Include="mywav.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/lib/xbadpcm/in_xbadpcm.txt b/lib/xbadpcm/in_xbadpcm.txt new file mode 100644 index 0000000000..05903cd25a --- /dev/null +++ b/lib/xbadpcm/in_xbadpcm.txt @@ -0,0 +1,47 @@ +###################################################################### + +Xbox ADPCM plugin for Winamp +by Luigi Auriemma +e-mail: aluigi@autistici.org +web: aluigi.org +plugin: http://aluigi.org/papers.htm#xbox + +###################################################################### + + +This is a plugin for Winamp which allows to play the audio compressed +with the Xbox ADPCM codec. + +For using it simply move in_xbadpcm.dll into your Plugin folder or in +the folder where is located your preferred player (Winamp, Xmplay and +many others), + +Supports wave file (tag 0x0069), raw files (like those extracted with +the old versions of my Unxwb tool), XWB/ZWB/WBA archives (the plugin +will skip the WMA and PCM audio files and the XWB file will be read as +an unique audio file, in future I hope to add subsongs handling) and +XSD/XSH archives. + +It's open source and released under the GPL license. + +More info and tools are available here: + + http://aluigi.org/papers.htm#xbox + +Note that raw audio files have no info in them (XWB archives store +these info) so the sample rate is automatically set to 44100 and the +channels to 2. +I highly suggest you to use my xbadpdec tool for adding the wave +header to your files: + + xbadpdec -a 00000000.dat 00000000.wav + +or if your game uses the 32000 or 33000 sample rate (like Unreal +Championship) use: + + xbadpdec -f 32000 -a 00000000.dat 00000000.wav + +channels number can be set with the -c option. + + +###################################################################### diff --git a/lib/xbadpcm/mywav.h b/lib/xbadpcm/mywav.h new file mode 100644 index 0000000000..f29498dba4 --- /dev/null +++ b/lib/xbadpcm/mywav.h @@ -0,0 +1,249 @@ +/* + MyWAV 0.1.1 + by Luigi Auriemma + e-mail: aluigi@autistici.org + web: aluigi.org + + Copyright 2005,2006 Luigi Auriemma + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + http://www.gnu.org/licenses/gpl.txt +*/ + +#include <string.h> + +//#include <stdint.h> +typedef unsigned char uint8_t; +typedef unsigned int uint32_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; + +#include <stdio.h> + +/* +the functions return ever 0 if success, other values (-1) if error +note that these functions have been written with compatibility in mind +so don't worry if you see useless instructions +*/ + + + +typedef struct { + uint8_t id[4]; + uint32_t size; +} mywav_chunk; + +typedef struct { + int16_t wFormatTag; + uint16_t wChannels; + uint32_t dwSamplesPerSec; + uint32_t dwAvgBytesPerSec; + uint16_t wBlockAlign; + uint16_t wBitsPerSample; +} mywav_fmtchunk; + + + + /* FILE WRITING */ + + // 8 bit +int mywav_fwi08(FILE *fd, int num) { + if(fputc((num ) & 0xff, fd) < 0) return(-1); + return(0); +} + + + + // 16 bit +int mywav_fwi16(FILE *fd, int num) { + if(fputc((num ) & 0xff, fd) < 0) return(-1); + if(fputc((num >> 8) & 0xff, fd) < 0) return(-1); + return(0); +} + + + + // 32 bit +int mywav_fwi32(FILE *fd, int num) { + if(fputc((num ) & 0xff, fd) < 0) return(-1); + if(fputc((num >> 8) & 0xff, fd) < 0) return(-1); + if(fputc((num >> 16) & 0xff, fd) < 0) return(-1); + if(fputc((num >> 24) & 0xff, fd) < 0) return(-1); + return(0); +} + + + + // data +int mywav_fwmem(FILE *fd, uint8_t *mem, int size) { + if(size) { + if(fwrite(mem, size, 1, fd) != 1) return(-1); + } + return(0); +} + + + + // chunk +int mywav_fwchunk(FILE *fd, mywav_chunk *chunk) { + if(mywav_fwmem(fd, chunk->id, 4)) return(-1); + if(mywav_fwi32(fd, chunk->size)) return(-1); + return(0); +} + + + + // fmtchunk +int mywav_fwfmtchunk(FILE *fd, mywav_fmtchunk *fmtchunk) { + if(mywav_fwi16(fd, fmtchunk->wFormatTag)) return(-1); + if(mywav_fwi16(fd, fmtchunk->wChannels)) return(-1); + if(mywav_fwi32(fd, fmtchunk->dwSamplesPerSec)) return(-1); + if(mywav_fwi32(fd, fmtchunk->dwAvgBytesPerSec)) return(-1); + if(mywav_fwi16(fd, fmtchunk->wBlockAlign)) return(-1); + if(mywav_fwi16(fd, fmtchunk->wBitsPerSample)) return(-1); + return(0); +} + + + + /* FILE READING */ + + // 8 bit +int mywav_fri08(FILE *fd, uint8_t *num) { + if(fread(num, 1, 1, fd) != 1) return(-1); + return(0); +} + + + + // 16 bit +int mywav_fri16(FILE *fd, uint16_t *num) { + uint16_t ret; + uint8_t tmp; + + if(fread(&tmp, 1, 1, fd) != 1) return(-1); ret = tmp; + if(fread(&tmp, 1, 1, fd) != 1) return(-1); ret |= (tmp << 8); + *num = ret; + return(0); +} + + + + // 32 bit +int mywav_fri32(FILE *fd, uint32_t *num) { + uint32_t ret; + uint8_t tmp; + + if(fread(&tmp, 1, 1, fd) != 1) return(-1); ret = tmp; + if(fread(&tmp, 1, 1, fd) != 1) return(-1); ret |= (tmp << 8); + if(fread(&tmp, 1, 1, fd) != 1) return(-1); ret |= (tmp << 16); + if(fread(&tmp, 1, 1, fd) != 1) return(-1); ret |= (tmp << 24); + *num = ret; + return(0); +} + + + + // data +int mywav_frmem(FILE *fd, uint8_t *mem, int size) { + if(size) { + if(fread(mem, size, 1, fd) != 1) return(-1); + } + return(0); +} + + + + // chunk +int mywav_frchunk(FILE *fd, mywav_chunk *chunk) { + if(mywav_frmem(fd, (uint8_t *)&chunk->id, 4)) return(-1); + if(mywav_fri32(fd, (uint32_t *)&chunk->size)) return(-1); + return(0); +} + + + + // fmtchunk +int mywav_frfmtchunk(FILE *fd, mywav_fmtchunk *fmtchunk) { + if(mywav_fri16(fd, (uint16_t *)&fmtchunk->wFormatTag)) return(-1); + if(mywav_fri16(fd, (uint16_t *)&fmtchunk->wChannels)) return(-1); + if(mywav_fri32(fd, (uint32_t *)&fmtchunk->dwSamplesPerSec)) return(-1); + if(mywav_fri32(fd, (uint32_t *)&fmtchunk->dwAvgBytesPerSec)) return(-1); + if(mywav_fri16(fd, (uint16_t *)&fmtchunk->wBlockAlign)) return(-1); + if(mywav_fri16(fd, (uint16_t *)&fmtchunk->wBitsPerSample)) return(-1); + return(0); +} + + + /* MYWAV MAIN FUNCTIONS */ + +int mywav_seekchunk(FILE *fd, uint8_t *find) { + mywav_chunk chunk; + + if(fseek(fd, sizeof(mywav_chunk) + 4, SEEK_SET) < 0) return(-1); + + while(!mywav_frchunk(fd, &chunk)) { + if(!memcmp(chunk.id, find, 4)) return(chunk.size); + if(fseek(fd, chunk.size, SEEK_CUR) < 0) break; + } + return(-1); +} + + + +int mywav_data(FILE *fd, mywav_fmtchunk *fmt) { + mywav_chunk chunk; + uint8_t type[4]; + + if(mywav_frchunk(fd, &chunk) < 0) return(-1); + if(mywav_frmem(fd, type, 4) < 0) return(-1); + if(memcmp(type, "WAVE", 4)) return(-1); + + if(mywav_seekchunk(fd, (uint8_t*)"fmt ") < 0) return(-1); + if(mywav_frfmtchunk(fd, fmt) < 0) return(-1); + + return(mywav_seekchunk(fd, (uint8_t*)"data")); +} + + + +int mywav_writehead(FILE *fd, mywav_fmtchunk *fmt, uint32_t data_size, uint8_t *more, int morelen) { + mywav_chunk chunk; + + memcpy(chunk.id, "RIFF", 4); + chunk.size = + 4 + + sizeof(mywav_chunk) + + sizeof(mywav_fmtchunk) + + morelen + + sizeof(mywav_chunk) + + data_size; + + if(mywav_fwchunk(fd, &chunk) < 0) return(-1); + if(mywav_fwmem(fd, (uint8_t*)"WAVE", 4) < 0) return(-1); + + memcpy(chunk.id, "fmt ", 4); + chunk.size = sizeof(mywav_fmtchunk) + morelen; + if(mywav_fwchunk(fd, &chunk) < 0) return(-1); + if(mywav_fwfmtchunk(fd, fmt) < 0) return(-1); + if(mywav_fwmem(fd, more, morelen) < 0) return(-1); + + memcpy(chunk.id, "data", 4); + chunk.size = data_size; + if(mywav_fwchunk(fd, &chunk) < 0) return(-1); + return(0); +} + diff --git a/lib/xbadpcm/uXboxAdpcmDecoder.c b/lib/xbadpcm/uXboxAdpcmDecoder.c new file mode 100644 index 0000000000..f405c42212 --- /dev/null +++ b/lib/xbadpcm/uXboxAdpcmDecoder.c @@ -0,0 +1,164 @@ +/* + TXboxAdpcmDecoder class + (c) 2005 Benjamin Haisch + + Revision 2 with stereo support + +### + C conversion 0.1.3 + by Luigi Auriemma + e-mail: aluigi@autistici.org + web: aluigi.org + + Copyright 2005,2006 Luigi Auriemma + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + http://www.gnu.org/licenses/gpl.txt +*/ + +#include "uXboxAdpcmDecoder.h" + +#define TXboxAdpcmDecoder_delimit(x,h,l) \ + if(x > h) { \ + x = h; \ + } else if(x < l) { \ + x = l; \ + } + + + +typedef struct { + int8_t Index; + int16_t StepSize; + int16_t Predictor; +} TAdpcmState; + + + +const static int16_t StepTable[89] = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, + 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, + 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, + 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, + 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, + 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, + 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 +}; + + + +const static int8_t IndexTable[16] = { + -1, -1, -1, -1, 2, 4, 6, 8, + -1, -1, -1, -1, 2, 4, 6, 8 +}; + + + +int TXboxAdpcmDecoder_DecodeSample(int Code, TAdpcmState *State) { + int Delta, + Result; + + Delta = State->StepSize >> 3; + if(Code & 4) Delta += State->StepSize; + if(Code & 2) Delta += State->StepSize >> 1; + if(Code & 1) Delta += State->StepSize >> 2; + if(Code & 8) Delta = -Delta; + Result = State->Predictor + Delta; + TXboxAdpcmDecoder_delimit(Result, 32767, -32768); + State->Index += IndexTable[Code]; + TXboxAdpcmDecoder_delimit(State->Index, 88, 0); + State->StepSize = StepTable[State->Index]; + State->Predictor = Result; + return(Result); +} + + + +int TXboxAdpcmDecoder_Decode_Memory(uint8_t *in, int inlen, uint8_t *out, int FChannels) { + TAdpcmState FAdpcmState[6]; + int16_t Buffers[6][8]; + uint32_t CodeBuf; + int i, + j, + c, + outlen; + + inlen = (inlen / XBOX_ADPCM_SRCSIZE) / FChannels; + + for(outlen = 0; inlen--; outlen++) { + for(c = 0; c < FChannels; c++) { + *out++ = in[0]; + *out++ = in[1]; + FAdpcmState[c].Predictor = in[0] | (in[1] << 8); in += 2; + FAdpcmState[c].Index = in[0] | (in[1] << 8); in += 2; + TXboxAdpcmDecoder_delimit(FAdpcmState[c].Index, 88, 0); + FAdpcmState[c].StepSize = StepTable[FAdpcmState[c].Index]; + } + for(i = 0; i < 8; i++) { + for(c = 0; c < FChannels; c++) { + CodeBuf = in[0] | (in[1] << 8) | (in[2] << 16) | (in[3] << 24); + in += 4; + for(j = 0; j < 8; j++) { + Buffers[c][j] = TXboxAdpcmDecoder_DecodeSample(CodeBuf & 15, &FAdpcmState[c]); + CodeBuf >>= 4; + } + } + for(j = 0; j < 8; j++) { + for(c = 0; c < FChannels; c++) { + *out++ = (Buffers[c][j] ) & 0xff; + *out++ = (Buffers[c][j] >> 8) & 0xff; + } + } + } + } + + return(outlen * XBOX_ADPCM_DSTSIZE * FChannels); +} + + + +int TXboxAdpcmDecoder_Decode(FILE *ASource, FILE *ADest, int SourcePos, int SourceSize, int FChannels) { + int DestSize; + uint8_t in[XBOX_ADPCM_SRCSIZE * 6], + out[XBOX_ADPCM_DSTSIZE * 6]; + + if(FChannels <= 0) return(0); + + if(SourcePos >= 0) { + if(fseek(ASource, SourcePos, SEEK_SET) < 0) return(0); + } + if(SourceSize > 0) { + SourceSize -= (SourceSize % XBOX_ADPCM_SRCSIZE); + SourceSize = (SourceSize / XBOX_ADPCM_SRCSIZE) / FChannels; + } + + for(DestSize = 0; SourceSize; SourceSize--) { + if(!fread(in, sizeof(in), 1, ASource)) break; + DestSize += TXboxAdpcmDecoder_Decode_Memory(in, sizeof(in), out, FChannels); + if(!fwrite(out, sizeof(out), 1, ADest)) break; + } + + return(DestSize); +} + + + +int TXboxAdpcmDecoder_guess_output_size(int SourceSize) { + return((SourceSize / XBOX_ADPCM_SRCSIZE) * XBOX_ADPCM_DSTSIZE); +} + diff --git a/lib/xbadpcm/uXboxAdpcmDecoder.h b/lib/xbadpcm/uXboxAdpcmDecoder.h new file mode 100644 index 0000000000..69356d4e76 --- /dev/null +++ b/lib/xbadpcm/uXboxAdpcmDecoder.h @@ -0,0 +1,63 @@ +/* + TXboxAdpcmDecoder class + (c) 2005 Benjamin Haisch + + Revision 2 with stereo support + +### + C conversion 0.1.3 + by Luigi Auriemma + e-mail: aluigi@autistici.org + web: aluigi.org + + Copyright 2005,2006 Luigi Auriemma + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + http://www.gnu.org/licenses/gpl.txt +*/ + +#include <stdio.h> + +typedef unsigned char uint8_t; +typedef unsigned int uint32_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed char int8_t; + +#define XBOX_ADPCM_SRCSIZE 36 +#define XBOX_ADPCM_DSTSIZE 130 + +int TXboxAdpcmDecoder_Decode_Memory( + uint8_t *in, // input buffer + int inlen, // input size MUST BE a multiplier of XBOX_ADPCM_SRCSIZE + uint8_t *out, // output buffer + int FChannels // channels +); + +int TXboxAdpcmDecoder_Decode( + FILE *ASource, // input file + FILE *ADest, // output file + int SourcePos, // fseek offset, use -1 for none + int SourceSize, // size of the input audio block, use -1 for all + int AChannels // number of channels, usually 2 +); + + +int TXboxAdpcmDecoder_guess_output_size( + int SourceSize // size of the input audio block +); + + |