mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 23:25:46 -04:00
Initial community commit
This commit is contained in:
9416
Src/mp3-mpg123/test/catch.hpp
Normal file
9416
Src/mp3-mpg123/test/catch.hpp
Normal file
File diff suppressed because it is too large
Load Diff
2
Src/mp3-mpg123/test/main.cpp
Normal file
2
Src/mp3-mpg123/test/main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
||||
#include "catch.hpp"
|
212
Src/mp3-mpg123/test/mp3-mpg123-test.vcproj
Normal file
212
Src/mp3-mpg123/test/mp3-mpg123-test.vcproj
Normal file
@ -0,0 +1,212 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="mp3-mpg123-test"
|
||||
ProjectGUID="{DDA33B81-0A85-4BAA-9DAC-12C0EBC80CEA}"
|
||||
RootNamespace="mp3mpg123test"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;../../Wasabi;../../libmpg123/src/libmpg123"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="../../nsutil/nsutil.lib"
|
||||
OutputFile="$(ProgramFiles)\Winamp\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
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)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
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>
|
||||
<ProjectReference
|
||||
ReferencedProjectIdentifier="{5057C6D0-F787-43EB-BA3F-8D59AB3B09D1}"
|
||||
RelativePathToProject=".\mp3-mpg123.vcproj"
|
||||
/>
|
||||
<ProjectReference
|
||||
ReferencedProjectIdentifier="{67CAA87B-7CF1-4F93-BB67-21C513F40803}"
|
||||
RelativePathToProject="..\libmpg123\ports\MSVC++\2008\libmpg123\libmpg123.vcproj"
|
||||
/>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test_adts_mpg123.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\catch.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
88
Src/mp3-mpg123/test/test_adts_mpg123.cpp
Normal file
88
Src/mp3-mpg123/test/test_adts_mpg123.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
#include "catch.hpp"
|
||||
#include "adts_mpg123.h"
|
||||
|
||||
class MemoryStreamer : public ifc_mpeg_stream_reader
|
||||
{
|
||||
public:
|
||||
MemoryStreamer(){}
|
||||
int Peek(void *buffer, size_t to_read, size_t *bytes_read)
|
||||
{
|
||||
if (to_read > this->bufferBytes) {
|
||||
to_read = this->bufferBytes;
|
||||
}
|
||||
memcpy(buffer, this->buffer, to_read);
|
||||
*bytes_read = to_read;
|
||||
return adts::SUCCESS;
|
||||
}
|
||||
|
||||
int Read(void *buffer, size_t to_read, size_t *bytes_read)
|
||||
{
|
||||
if (to_read > this->bufferBytes) {
|
||||
to_read = this->bufferBytes;
|
||||
}
|
||||
memcpy(buffer, this->buffer, to_read);
|
||||
this->buffer = (unsigned char *)this->buffer + *bytes_read;
|
||||
*bytes_read = to_read;
|
||||
bufferBytes -= to_read;
|
||||
return adts::SUCCESS;
|
||||
}
|
||||
|
||||
int EndOf()
|
||||
{
|
||||
if (bufferBytes == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
float GetGain()
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
unsigned char *buffer;
|
||||
size_t bufferBytes;
|
||||
RECVS_DISPATCH;
|
||||
};
|
||||
|
||||
#define CBCLASS MemoryStreamer
|
||||
START_DISPATCH;
|
||||
CB(MPEGSTREAM_PEEK, Peek)
|
||||
CB(MPEGSTREAM_READ, Read)
|
||||
CB(MPEGSTREAM_EOF, EndOf)
|
||||
CB(MPEGSTREAM_GAIN, GetGain)
|
||||
END_DISPATCH;
|
||||
#undef CBCLASS
|
||||
|
||||
static const unsigned char mp3_frame1[] = {
|
||||
0xFF, 0xF3, 0x70, 0x54, 0x00, 0x10, 0x2D, 0xFA, 0x96, 0x0F, 0xA0, 0x20,
|
||||
0x00, 0x81, 0xE8, 0x05, 0x2C, 0x1F, 0x40, 0x00, 0x00, 0x03, 0x51, 0xB6,
|
||||
0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3,
|
||||
0x0B, 0x05, 0x86, 0x07, 0x60, 0x2E, 0x11, 0x94, 0x0A, 0x01, 0x61, 0xA0,
|
||||
0xD0, 0xC2, 0xC5, 0xCF, 0x81, 0x41, 0x43, 0x2F, 0x44, 0x4E, 0x6E, 0x1F,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xF2, 0x01, 0xA0, 0xA2, 0x8B, 0x87, 0xF6, 0x2E,
|
||||
0x7A, 0x0A, 0x19, 0x25, 0x9F, 0x02, 0xF6, 0x40, 0xA1, 0x92, 0x2E, 0x2E,
|
||||
0x7F, 0xEE, 0xFF, 0x96, 0x1E, 0x0E, 0x2C, 0x1B, 0x87, 0xEC, 0x1C, 0x07,
|
||||
0x8A, 0x1C, 0x18, 0x58, 0x76, 0x7C, 0x0A, 0x07, 0x86, 0x5E, 0x88, 0x94,
|
||||
0xEF, 0x02, 0xF6, 0x82, 0x86, 0x49, 0x67, 0xC0, 0xBD, 0x90, 0x28, 0x64,
|
||||
0x8B, 0x8B, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBC,
|
||||
0x3D, 0xA0, 0xA2, 0x4B, 0x8B, 0x8B, 0x8A, 0x51, 0x60, 0xDC, 0x5D, 0x85,
|
||||
0x03, 0xC3, 0x2C, 0x00, 0x03, 0x31, 0xE0, 0x00, 0x7F};
|
||||
TEST_CASE("", "[adts_mpg123]") {
|
||||
|
||||
mpg123_init();
|
||||
ADTS_MPG123 mp3;
|
||||
MemoryStreamer memoryStreamer;
|
||||
REQUIRE(mp3.Initialize(false, false, false, 16, true, true, true) == adts::SUCCESS);
|
||||
REQUIRE(mp3.Open(&memoryStreamer) == true);
|
||||
size_t numBits;
|
||||
size_t numChannels;
|
||||
int sampleRate;
|
||||
memoryStreamer.buffer = (unsigned char *)mp3_frame1;
|
||||
memoryStreamer.bufferBytes = sizeof(mp3_frame1);
|
||||
size_t outputWritten=777;
|
||||
size_t bitrate=777;
|
||||
REQUIRE(mp3.Sync(&memoryStreamer, 0, 0, &outputWritten, &bitrate) == adts::SUCCESS);
|
||||
REQUIRE(bitrate == 64);
|
||||
REQUIRE(outputWritten == 0);
|
||||
|
||||
}
|
Reference in New Issue
Block a user