mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
x64 build for wavpack, library updated to 4.5.0
This commit is contained in:
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools", "CUETools.csproj", "{EF351583-A9CD-4530-92C3-20AC02136BC2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9AE965C4-301E-4C01-B90F-297AF341ACC6} = {9AE965C4-301E-4C01-B90F-297AF341ACC6}
|
||||
{E70FA90A-7012-4A52-86B5-362B699D1540} = {E70FA90A-7012-4A52-86B5-362B699D1540}
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000} = {CC2E74B6-534A-43D8-9F16-AC03FE955000}
|
||||
{E70FA90A-7012-4A52-86B5-362B699D1540} = {E70FA90A-7012-4A52-86B5-362B699D1540}
|
||||
{9AE965C4-301E-4C01-B90F-297AF341ACC6} = {9AE965C4-301E-4C01-B90F-297AF341ACC6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLACDotNet", "..\FLACDotNet\FLACDotNet.vcproj", "{E70FA90A-7012-4A52-86B5-362B699D1540}"
|
||||
@@ -15,8 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLACDotNet", "..\FLACDotNet
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APEDotNet", "..\APEDotNet\APEDotNet.vcproj", "{9AE965C4-301E-4C01-B90F-297AF341ACC6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{CA200BCB-DFC6-4153-9BD4-785BC768B26B} = {CA200BCB-DFC6-4153-9BD4-785BC768B26B}
|
||||
{0B9C97D4-61B8-4294-A1DF-BA90752A1779} = {0B9C97D4-61B8-4294-A1DF-BA90752A1779}
|
||||
{CA200BCB-DFC6-4153-9BD4-785BC768B26B} = {CA200BCB-DFC6-4153-9BD4-785BC768B26B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodecLibs", "CodecLibs", "{8B179853-B7D6-479C-B8B2-6CBCE835D040}"
|
||||
@@ -24,6 +24,7 @@ EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WavPackDotNet", "..\WavPackDotNet\WavPackDotNet.vcproj", "{CC2E74B6-534A-43D8-9F16-AC03FE955000}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{CA200BCB-DFC6-4153-9BD4-785BC768B26B} = {CA200BCB-DFC6-4153-9BD4-785BC768B26B}
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F} = {5CCCB9CF-0384-458F-BA08-72B73866840F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MACLib", "..\MAC_SDK\Source\MACLib\MACLib.vcproj", "{0B9C97D4-61B8-4294-A1DF-BA90752A1779}"
|
||||
@@ -34,6 +35,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libFLAC_static", "..\flac\s
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APETagDotNet", "..\APETagDotNet\APETagDotNet.csproj", "{CA200BCB-DFC6-4153-9BD4-785BC768B26B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavpack", "..\wavpack-4.5.0\src\libwavpack.vcproj", "{5CCCB9CF-0384-458F-BA08-72B73866840F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -93,13 +96,15 @@ Global
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x64.Build.0 = Debug|x64
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x86.Build.0 = Debug|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|Win32.Build.0 = Release|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x64.ActiveCfg = Release|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x64.ActiveCfg = Release|x64
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x64.Build.0 = Release|x64
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x86.ActiveCfg = Release|Win32
|
||||
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x86.Build.0 = Release|Win32
|
||||
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
@@ -146,6 +151,20 @@ Global
|
||||
{CA200BCB-DFC6-4153-9BD4-785BC768B26B}.Release|x64.Build.0 = Release|x64
|
||||
{CA200BCB-DFC6-4153-9BD4-785BC768B26B}.Release|x86.ActiveCfg = Release|x86
|
||||
{CA200BCB-DFC6-4153-9BD4-785BC768B26B}.Release|x86.Build.0 = Release|x86
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|x64.Build.0 = Debug|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|Win32.Build.0 = Release|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|x64.ActiveCfg = Release|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|x64.Build.0 = Release|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -156,5 +175,6 @@ Global
|
||||
{E70FA90A-7012-4A52-86B5-362B699D1540} = {85F88959-C9E9-4989-ACB1-67BA9D1BEFE7}
|
||||
{0B9C97D4-61B8-4294-A1DF-BA90752A1779} = {8B179853-B7D6-479C-B8B2-6CBCE835D040}
|
||||
{4CEFBC84-C215-11DB-8314-0800200C9A66} = {8B179853-B7D6-479C-B8B2-6CBCE835D040}
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F} = {8B179853-B7D6-479C-B8B2-6CBCE835D040}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Binary file not shown.
@@ -36,15 +36,8 @@ using namespace APETagsDotNet;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include "WavPack\wavpack.h"
|
||||
#include "wavpack.h"
|
||||
#include <string.h>
|
||||
//typedef char str_ansi;
|
||||
//typedef wchar_t str_utf16;
|
||||
//#define BOOL int
|
||||
//#define TRUE 1
|
||||
//#define FALSE 0
|
||||
//#include "..\MAC_SDK\Shared\SmartPtr.h"
|
||||
//#include "..\MAC_SDK\Shared\APETag.h"
|
||||
|
||||
namespace WavPackDotNet {
|
||||
int write_block(void *id, void *data, int32_t length);
|
||||
@@ -63,7 +56,7 @@ namespace WavPackDotNet {
|
||||
memcpy ((void*) pPath, (const wchar_t*)pathChars.ToPointer(), pathLen*sizeof(wchar_t));
|
||||
Marshal::FreeHGlobal(pathChars);
|
||||
|
||||
_wpc = WavpackOpenFileInput(pPath, errorMessage, OPEN_WVC, 0);
|
||||
_wpc = WavpackOpenFileInput (pPath, errorMessage, OPEN_WVC, 0);
|
||||
if (_wpc == NULL) {
|
||||
throw gcnew Exception("Unable to initialize the decoder.");
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
@@ -41,6 +44,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../wavpack-4.5.0/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
@@ -58,7 +62,6 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="WavPack\libwavpack.lib $(NOINHERIT)"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
AssemblyDebug="1"
|
||||
@@ -115,6 +118,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../wavpack-4.5.0/include"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
@@ -133,7 +137,6 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="WavPack\libwavpack.lib $(NOINHERIT)"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
@@ -164,6 +167,157 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../wavpack-4.5.0/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
AssemblyDebug="1"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../wavpack-4.5.0/include"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
<AssemblyReference
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// wavpack.h
|
||||
|
||||
#ifndef WAVPACK_H
|
||||
#define WAVPACK_H
|
||||
|
||||
// This header file contains all the definitions required to use the
|
||||
// functions in "wputils.c" to read and write WavPack files and streams.
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#include <stdlib.h>
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef float float32_t;
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
#if !defined(__GNUC__) || defined(WIN32)
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
#endif
|
||||
|
||||
// RIFF / wav header formats (these occur at the beginning of both wav files
|
||||
// and pre-4.0 WavPack files that are not in the "raw" mode). Generally, an
|
||||
// application using the library to read or write WavPack files will not be
|
||||
// concerned with any of these.
|
||||
|
||||
typedef struct {
|
||||
char ckID [4];
|
||||
uint32_t ckSize;
|
||||
char formType [4];
|
||||
} RiffChunkHeader;
|
||||
|
||||
typedef struct {
|
||||
char ckID [4];
|
||||
uint32_t ckSize;
|
||||
} ChunkHeader;
|
||||
|
||||
#define ChunkHeaderFormat "4L"
|
||||
|
||||
typedef struct {
|
||||
ushort FormatTag, NumChannels;
|
||||
uint32_t SampleRate, BytesPerSecond;
|
||||
ushort BlockAlign, BitsPerSample;
|
||||
ushort cbSize, ValidBitsPerSample;
|
||||
int32_t ChannelMask;
|
||||
ushort SubFormat;
|
||||
char GUID [14];
|
||||
} WaveHeader;
|
||||
|
||||
#define WaveHeaderFormat "SSLLSSSSLS"
|
||||
|
||||
// This is the ONLY structure that occurs in WavPack files (as of version
|
||||
// 4.0), and is the preamble to every block in both the .wv and .wvc
|
||||
// files (in little-endian format). Normally, this structure has no use
|
||||
// to an application using the library to read or write WavPack files,
|
||||
// but if an application needs to manually parse WavPack files then this
|
||||
// would be used (with appropriate endian correction).
|
||||
|
||||
typedef struct {
|
||||
char ckID [4];
|
||||
uint32_t ckSize;
|
||||
short version;
|
||||
uchar track_no, index_no;
|
||||
uint32_t total_samples, block_index, block_samples, flags, crc;
|
||||
} WavpackHeader;
|
||||
|
||||
#define WavpackHeaderFormat "4LS2LLLLL"
|
||||
|
||||
// or-values for WavpackHeader.flags
|
||||
#define BYTES_STORED 3 // 1-4 bytes/sample
|
||||
#define MONO_FLAG 4 // not stereo
|
||||
#define HYBRID_FLAG 8 // hybrid mode
|
||||
#define JOINT_STEREO 0x10 // joint stereo
|
||||
#define CROSS_DECORR 0x20 // no-delay cross decorrelation
|
||||
#define HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
|
||||
#define FLOAT_DATA 0x80 // ieee 32-bit floating point data
|
||||
|
||||
#define INT32_DATA 0x100 // special extended int handling
|
||||
#define HYBRID_BITRATE 0x200 // bitrate noise (hybrid mode only)
|
||||
#define HYBRID_BALANCE 0x400 // balance noise (hybrid stereo mode only)
|
||||
|
||||
#define INITIAL_BLOCK 0x800 // initial block of multichannel segment
|
||||
#define FINAL_BLOCK 0x1000 // final block of multichannel segment
|
||||
|
||||
#define SHIFT_LSB 13
|
||||
#define SHIFT_MASK (0x1fL << SHIFT_LSB)
|
||||
|
||||
#define MAG_LSB 18
|
||||
#define MAG_MASK (0x1fL << MAG_LSB)
|
||||
|
||||
#define SRATE_LSB 23
|
||||
#define SRATE_MASK (0xfL << SRATE_LSB)
|
||||
|
||||
#define FALSE_STEREO 0x40000000 // block is stereo, but data is mono
|
||||
|
||||
#define IGNORED_FLAGS 0x18000000 // reserved, but ignore if encountered
|
||||
#define NEW_SHAPING 0x20000000 // use IIR filter for negative shaping
|
||||
#define UNKNOWN_FLAGS 0x80000000 // also reserved, but refuse decode if
|
||||
// encountered
|
||||
|
||||
#define MONO_DATA (MONO_FLAG | FALSE_STEREO)
|
||||
|
||||
#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode
|
||||
#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode or encode
|
||||
#define CUR_STREAM_VERS 0x405 // stream version we are writing now
|
||||
|
||||
// These are the mask bit definitions for the metadata chunk id byte (see format.txt)
|
||||
|
||||
#define ID_UNIQUE 0x3f
|
||||
#define ID_OPTIONAL_DATA 0x20
|
||||
#define ID_ODD_SIZE 0x40
|
||||
#define ID_LARGE 0x80
|
||||
|
||||
#define ID_DUMMY 0x0
|
||||
#define ID_ENCODER_INFO 0x1
|
||||
#define ID_DECORR_TERMS 0x2
|
||||
#define ID_DECORR_WEIGHTS 0x3
|
||||
#define ID_DECORR_SAMPLES 0x4
|
||||
#define ID_ENTROPY_VARS 0x5
|
||||
#define ID_HYBRID_PROFILE 0x6
|
||||
#define ID_SHAPING_WEIGHTS 0x7
|
||||
#define ID_FLOAT_INFO 0x8
|
||||
#define ID_INT32_INFO 0x9
|
||||
#define ID_WV_BITSTREAM 0xa
|
||||
#define ID_WVC_BITSTREAM 0xb
|
||||
#define ID_WVX_BITSTREAM 0xc
|
||||
#define ID_CHANNEL_INFO 0xd
|
||||
|
||||
#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1)
|
||||
#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2)
|
||||
#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3) // never used (APEv2)
|
||||
#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4) // never used (APEv2)
|
||||
#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
|
||||
#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
|
||||
#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
|
||||
|
||||
///////////////////////// WavPack Configuration ///////////////////////////////
|
||||
|
||||
// This external structure is used during encode to provide configuration to
|
||||
// the encoding engine and during decoding to provide fle information back to
|
||||
// the higher level functions. Not all fields are used in both modes.
|
||||
|
||||
typedef struct {
|
||||
float bitrate, shaping_weight;
|
||||
int bits_per_sample, bytes_per_sample;
|
||||
int qmode, flags, xmode, num_channels, float_norm_exp;
|
||||
int32_t block_samples, extra_flags, sample_rate, channel_mask;
|
||||
uchar md5_checksum [16], md5_read;
|
||||
int num_tag_strings;
|
||||
char **tag_strings;
|
||||
} WavpackConfig;
|
||||
|
||||
#define CONFIG_HYBRID_FLAG 8 // hybrid mode
|
||||
#define CONFIG_JOINT_STEREO 0x10 // joint stereo
|
||||
#define CONFIG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
|
||||
#define CONFIG_FAST_FLAG 0x200 // fast mode
|
||||
#define CONFIG_HIGH_FLAG 0x800 // high quality mode
|
||||
#define CONFIG_VERY_HIGH_FLAG 0x1000 // very high
|
||||
#define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample
|
||||
#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified
|
||||
#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified
|
||||
#define CONFIG_CREATE_EXE 0x40000 // create executable
|
||||
#define CONFIG_CREATE_WVC 0x80000 // create correction file
|
||||
#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression
|
||||
#define CONFIG_CALC_NOISE 0x800000 // calc noise in hybrid mode
|
||||
#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode
|
||||
#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints
|
||||
#define CONFIG_MD5_CHECKSUM 0x8000000 // store MD5 signature
|
||||
#define CONFIG_OPTIMIZE_MONO 0x80000000 // optimize for mono streams posing as stereo
|
||||
|
||||
////////////// Callbacks used for reading & writing WavPack streams //////////
|
||||
|
||||
typedef struct {
|
||||
int32_t (*read_bytes)(void *id, void *data, int32_t bcount);
|
||||
uint32_t (*get_pos)(void *id);
|
||||
int (*set_pos_abs)(void *id, uint32_t pos);
|
||||
int (*set_pos_rel)(void *id, int32_t delta, int mode);
|
||||
int (*push_back_byte)(void *id, int c);
|
||||
uint32_t (*get_length)(void *id);
|
||||
int (*can_seek)(void *id);
|
||||
|
||||
// this callback is for writing edited tags only
|
||||
int32_t (*write_bytes)(void *id, void *data, int32_t bcount);
|
||||
} WavpackStreamReader;
|
||||
|
||||
typedef int (*WavpackBlockOutput)(void *id, void *data, int32_t bcount);
|
||||
|
||||
//////////////////////////// function prototypes /////////////////////////////
|
||||
|
||||
// Note: See wputils.c sourcecode for descriptions for using these functions.
|
||||
|
||||
typedef void WavpackContext;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WavpackContext *WavpackOpenFileInputEx (WavpackStreamReader *reader, void *wv_id, void *wvc_id, char *error, int flags, int norm_offset);
|
||||
WavpackContext *WavpackOpenFileInput (const wchar_t *infilename, char *error, int flags, int norm_offset);
|
||||
|
||||
#define OPEN_WVC 0x1 // open/read "correction" file
|
||||
#define OPEN_TAGS 0x2 // read ID3v1 / APEv2 tags (seekable file)
|
||||
#define OPEN_WRAPPER 0x4 // make audio wrapper available (i.e. RIFF)
|
||||
#define OPEN_2CH_MAX 0x8 // open multichannel as stereo (no downmix)
|
||||
#define OPEN_NORMALIZE 0x10 // normalize floating point data to +/- 1.0
|
||||
#define OPEN_STREAMING 0x20 // "streaming" mode blindly unpacks blocks
|
||||
// w/o regard to header file position info
|
||||
#define OPEN_EDIT_TAGS 0x40 // allow editing of tags
|
||||
|
||||
int WavpackGetMode (WavpackContext *wpc);
|
||||
|
||||
#define MODE_WVC 0x1
|
||||
#define MODE_LOSSLESS 0x2
|
||||
#define MODE_HYBRID 0x4
|
||||
#define MODE_FLOAT 0x8
|
||||
#define MODE_VALID_TAG 0x10
|
||||
#define MODE_HIGH 0x20
|
||||
#define MODE_FAST 0x40
|
||||
#define MODE_EXTRA 0x80
|
||||
#define MODE_APETAG 0x100
|
||||
#define MODE_SFX 0x200
|
||||
#define MODE_VERY_HIGH 0x400
|
||||
#define MODE_MD5 0x800
|
||||
|
||||
char *WavpackGetErrorMessage (WavpackContext *wpc);
|
||||
int WavpackGetVersion (WavpackContext *wpc);
|
||||
uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples);
|
||||
uint32_t WavpackGetNumSamples (WavpackContext *wpc);
|
||||
uint32_t WavpackGetSampleIndex (WavpackContext *wpc);
|
||||
int WavpackGetNumErrors (WavpackContext *wpc);
|
||||
int WavpackLossyBlocks (WavpackContext *wpc);
|
||||
int WavpackSeekSample (WavpackContext *wpc, uint32_t sample);
|
||||
WavpackContext *WavpackCloseFile (WavpackContext *wpc);
|
||||
uint32_t WavpackGetSampleRate (WavpackContext *wpc);
|
||||
int WavpackGetBitsPerSample (WavpackContext *wpc);
|
||||
int WavpackGetBytesPerSample (WavpackContext *wpc);
|
||||
int WavpackGetNumChannels (WavpackContext *wpc);
|
||||
int WavpackGetChannelMask (WavpackContext *wpc);
|
||||
int WavpackGetReducedChannels (WavpackContext *wpc);
|
||||
int WavpackGetFloatNormExp (WavpackContext *wpc);
|
||||
int WavpackGetMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
uint32_t WavpackGetWrapperBytes (WavpackContext *wpc);
|
||||
uchar *WavpackGetWrapperData (WavpackContext *wpc);
|
||||
void WavpackFreeWrapper (WavpackContext *wpc);
|
||||
void WavpackSeekTrailingWrapper (WavpackContext *wpc);
|
||||
double WavpackGetProgress (WavpackContext *wpc);
|
||||
uint32_t WavpackGetFileSize (WavpackContext *wpc);
|
||||
double WavpackGetRatio (WavpackContext *wpc);
|
||||
double WavpackGetAverageBitrate (WavpackContext *wpc, int count_wvc);
|
||||
double WavpackGetInstantBitrate (WavpackContext *wpc);
|
||||
int WavpackGetNumTagItems (WavpackContext *wpc);
|
||||
int WavpackGetTagItem (WavpackContext *wpc, const char *item, char *value, int size);
|
||||
int WavpackGetTagItemIndexed (WavpackContext *wpc, int index, char *item, int size);
|
||||
int WavpackAppendTagItem (WavpackContext *wpc, const char *item, const char *value, int vsize);
|
||||
int WavpackDeleteTagItem (WavpackContext *wpc, const char *item);
|
||||
int WavpackWriteTag (WavpackContext *wpc);
|
||||
|
||||
WavpackContext *WavpackOpenFileOutput (WavpackBlockOutput blockout, void *wv_id, void *wvc_id);
|
||||
int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples);
|
||||
int WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount);
|
||||
int WavpackStoreMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
int WavpackPackInit (WavpackContext *wpc);
|
||||
int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count);
|
||||
int WavpackFlushSamples (WavpackContext *wpc);
|
||||
void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block);
|
||||
void *WavpackGetWrapperLocation (void *first_block, uint32_t *size);
|
||||
double WavpackGetEncodedNoise (WavpackContext *wpc, double *peak);
|
||||
|
||||
void WavpackFloatNormalize (int32_t *values, int32_t num_values, int delta_exp);
|
||||
|
||||
void WavpackLittleEndianToNative (void *data, char *format);
|
||||
void WavpackNativeToLittleEndian (void *data, char *format);
|
||||
|
||||
uint32_t WavpackGetLibraryVersion ();
|
||||
const char *WavpackGetLibraryVersionString ();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
379
wavpack-4.5.0/ChangeLog
Normal file
379
wavpack-4.5.0/ChangeLog
Normal file
@@ -0,0 +1,379 @@
|
||||
----------------------------
|
||||
Release 4.50 - June 13, 2008
|
||||
----------------------------
|
||||
|
||||
WavPack Library Source Code - 4.50
|
||||
----------------------------------
|
||||
added: dynamic noise shaping for improved hybrid quality
|
||||
added: option to merge blocks of similar redundancy
|
||||
added: ability to store and retrieve extra mode level
|
||||
fixed: alignment fault on some big-endian machines
|
||||
fixed: compiling with enable-mmx on gcc 4.3.x (thanks Joachim)
|
||||
improved: allow bitrate to be calculated for files down to 1/10 second
|
||||
improved: decoding of corrupt files (prevents heap overrun crashes)
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.50
|
||||
-----------------------------------------
|
||||
added: dynamic noise shaping for improved hybrid quality
|
||||
added: --channel-order option to reorder nonconforming multichannel files
|
||||
added: --merge-blocks option to optimize storage of LossyWAV output files
|
||||
added: ignore -o on Windows for compatibility with Linux version
|
||||
fixed: alignment fault on some big-endian machines
|
||||
improved: reformatted and expanded --help display
|
||||
|
||||
wvunpack.exe (command-line decoder) - 4.50
|
||||
------------------------------------------
|
||||
fixed: don't ignore fractions of seconds in --skip option
|
||||
added: show extra level and dns status for newer files (-s command)
|
||||
added: ignore -o on Windows for compatibility with Linux version
|
||||
improved: decoding of corrupt files (prevents heap overrun crashes)
|
||||
improved: display bitrate for files down to 1/10 second
|
||||
|
||||
in_wv.dll (winamp plugin) - 2.5
|
||||
-------------------------------
|
||||
added: transcoding API (allows CD burning, format conversion, ReplayGain calc, etc.)
|
||||
added: metadata writing API (for Auto-Tag, etc.)
|
||||
added: full Unicode support for info box (older Winamps) and media library
|
||||
added: standard Winamp metadata display & edit for newer Winamps
|
||||
added: option to pass multichannel audio
|
||||
added: option to pass all audio as 16-bit (for better compatibility)
|
||||
added: option to output 24-bit audio when ReplayGain is active
|
||||
added: genre display to info box (older Winamps)
|
||||
fixed: seek bar sometimes vacillates when moved
|
||||
fixed: crash when winamp is opened with files in playlist moved or deleted
|
||||
improved: hi-res audio now output as 24-bit (not 32-bit) for better compatibility (EQ, etc.)
|
||||
improved: performance of adding tracks to library, especially from network drives
|
||||
improved: decoding of corrupt files (prevents heap overrun crashes)
|
||||
|
||||
cool_wv4.flt (CoolEdit / Audition filter) - 2.9
|
||||
-----------------------------------------------
|
||||
added: about box
|
||||
added: dynamic noise shaping for improved hybrid quality
|
||||
improved: display bitrate for files as short as 1/10 second
|
||||
improved: decoding of corrupt files (prevents heap overrun crashes)
|
||||
improved: replace "extra processing" switch with a slider (0-6)
|
||||
|
||||
|
||||
--------------------------
|
||||
Release 4.41 - May 6, 2007
|
||||
--------------------------
|
||||
|
||||
WavPack Library Source Code - 4.41
|
||||
----------------------------------
|
||||
added: create wavpackdll.dll for Windows (not used yet)
|
||||
fixed: corrupt floating-point audio on big-endian machines
|
||||
fixed: put MSVC projects in their own subdir (fixed build problems)
|
||||
fixed: limit RIFF data buffering to 16 MB to prevent out-of-memory crash
|
||||
improved: attempt to mute errors when decoding corrupt legacy WavPack files
|
||||
improved: overall performance enhancements of 10% to 30% (depending on mode)
|
||||
added: MMX intrinsics for 24-bit (and higher) stereo encoding (thanks to
|
||||
Joachim Henke)
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.41
|
||||
-----------------------------------------
|
||||
fixed: corrupt floating-point audio on big-endian machines
|
||||
improved: refuse to encode WAV files over 4 GB or with over 16 MB RIFF data
|
||||
improved: overall performance enhancements of 10% to 30% (depending on mode)
|
||||
added: MMX intrinsics for 24-bit (and higher) stereo encoding (thanks to
|
||||
Joachim Henke)
|
||||
|
||||
wvunpack.exe (command-line decoder) - 4.41
|
||||
------------------------------------------
|
||||
fixed: corrupt floating-point audio on big-endian machines
|
||||
fixed: restore files mistakenly encoded with huge RIFF chunks
|
||||
improved: attempt to mute errors when decoding corrupt legacy WavPack files
|
||||
improved: overall performance enhancements of 10% to 30% (depending on mode)
|
||||
added: --skip and --until commands to unpack specified range of audio data
|
||||
added: MMX intrinsics for 24-bit (and higher) stereo encoding (thanks to
|
||||
Joachim Henke)
|
||||
|
||||
wvgain.exe (command-line ReplayGain scanner) - 4.41
|
||||
---------------------------------------------------
|
||||
improved: overall performance enhancements of 10% to 30% (depending on mode)
|
||||
added: MMX intrinsics for 24-bit (and higher) stereo encoding (thanks to
|
||||
Joachim Henke)
|
||||
|
||||
cool_wv4.flt (CoolEdit / Audition filter) - 2.8
|
||||
-----------------------------------------------
|
||||
fixed: read all RIFF metadata from files created in other applications
|
||||
improved: attempt to mute errors when decoding corrupt legacy WavPack files
|
||||
improved: overall performance enhancements of 10% to 30% (depending on mode)
|
||||
added: MMX intrinsics for 24-bit (and higher) stereo encoding (thanks to
|
||||
Joachim Henke)
|
||||
|
||||
|
||||
-------------------------------
|
||||
Release 4.40 - December 3, 2006
|
||||
-------------------------------
|
||||
|
||||
WavPack Library Source Code - 4.40
|
||||
----------------------------------
|
||||
added: new hardware-friendly "high" mode that compresses almost as well as
|
||||
old "high" mode but decodes significantly faster; old "high" mode
|
||||
now available as "very high"
|
||||
added: option added to improve compression of mono material in stereo files
|
||||
(requires at least version 4.3 decoder)
|
||||
added: function to obtain channel mapping information on decoding
|
||||
added: function to get trailing wrapper info (RIFF) without decoding file
|
||||
improved: "extra" mode levels 1-3 completely revamped, fast enough for use
|
||||
improved: reorganized to create a standard library that should more easily
|
||||
integrate into other applications; eliminated namespace issues
|
||||
improved: more robust handling of corrupt files
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.40
|
||||
-----------------------------------------
|
||||
added: accepts long option names including --help for full usage info
|
||||
added: new hardware-friendly "high" mode that compresses almost as well as
|
||||
old "high" mode but decodes significantly faster; old "high" mode
|
||||
now available as "very high" (-hh)
|
||||
added: --optimize-mono option added to improve compression of mono material
|
||||
in stereo files (requires at least version 4.3 decoder)
|
||||
improved: "extra" mode levels 1-3 completely revamped, fast enough for use
|
||||
improved: switched to Microsoft Visual Studio 2005 (win32 only)
|
||||
removed: support for Windows 95
|
||||
|
||||
wvunpack.exe (command-line decoder) - 4.40
|
||||
------------------------------------------
|
||||
added: cuesheet extraction (to .cue file or stdout)
|
||||
added: wav header generation on decode for files with missing RIFF
|
||||
information, or forced with -w option
|
||||
added: more summary info (wrapper info + channel assignments)
|
||||
improved: more robust handling of corrupt files
|
||||
improved: separate options for raw (-r) and blind stream decoding (-b)
|
||||
improved: switched to Microsoft Visual Studio 2005 (win32 only)
|
||||
removed: support for Windows 95
|
||||
|
||||
wvgain.exe (command-line ReplayGain scanner) - 4.40
|
||||
---------------------------------------------------
|
||||
improved: switched to Microsoft Visual Studio 2005 (win32 only)
|
||||
removed: support for Windows 95
|
||||
|
||||
wvselfx.exe (self-extraction stub) - 4.40
|
||||
------------------------------------------
|
||||
added: automatic cuesheet extraction (if present in APEv2 tag)
|
||||
|
||||
in_wv.dll (winamp plugin) - 2.4
|
||||
-------------------------------
|
||||
fixed: quietly skips deleted files in playlist
|
||||
improved: more robust handling of corrupt files
|
||||
improved: APEv2 tags are read even if followed by ID3v1 tag
|
||||
|
||||
cool_wv4.flt (CoolEdit / Audition filter) - 2.7
|
||||
-----------------------------------------------
|
||||
added: new hardware-friendly "high" mode that compresses almost as well as
|
||||
old "high" mode but decodes significantly faster; old "high" mode
|
||||
now available as "v. high"
|
||||
improved: more robust handling of corrupt files
|
||||
|
||||
|
||||
----------------------
|
||||
Update - April 5, 2006
|
||||
----------------------
|
||||
|
||||
WavPack Library Source Code - 4.32
|
||||
wavpack.exe (command-line encoder) - 4.32
|
||||
-----------------------------------------
|
||||
fixed: generating RIFF headers on big-endian machines caused crash
|
||||
|
||||
|
||||
--------------------------
|
||||
Update - December 10, 2005
|
||||
--------------------------
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.31
|
||||
wvunpack.exe (command-line decoder) - 4.31
|
||||
------------------------------------------
|
||||
fixed: detect debug mode in all cases (win32 only)
|
||||
improved: use latest service pack and SDK for building (win32 only)
|
||||
improved: better directory choice for logging file (win32 only)
|
||||
improved: allow shell to expand wildcards (*nix only)
|
||||
added: option (-o) to specify output directory or path (*nix only)
|
||||
added: option (-t) to copy timestamp (*nix only)
|
||||
|
||||
wvgain.exe (command-line ReplayGain scanner) - 4.31
|
||||
---------------------------------------------------
|
||||
new
|
||||
|
||||
WavPack Library Source Code - 4.31
|
||||
----------------------------------
|
||||
fixed: failing seek with some files that had been played to the end
|
||||
fixed: small memory leak when opening hybrid lossless files
|
||||
improved: signed characters no longer must be default
|
||||
improved: APEv2 tags are read even if followed by ID3v1 tag
|
||||
improved: limited APEv2 tag editing capability
|
||||
|
||||
|
||||
------------------------------
|
||||
Release 4.3 - November 1, 2005
|
||||
------------------------------
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.3
|
||||
----------------------------------------
|
||||
fixed: bug causing termination error with very wide screen widths
|
||||
added: command-line option (-l) to use low priority for batch operation
|
||||
added: command-line option (-r) to generate a fresh RIFF header
|
||||
added: debug mode (rename to wavpack_debug.exe)
|
||||
added: automatically detect lower resolution data even without -x1
|
||||
added: src and dst dirs are searched also for tag source files (handy for EAC)
|
||||
added: wildcard accepted for tag source files (handy for EAC)
|
||||
added: handle non-standard sampling rates
|
||||
improved: returns error status for any error
|
||||
improved: use longer blocks in multichannel files (better "high" compression)
|
||||
|
||||
wvunpack.exe (command-line decoder) - 4.3
|
||||
-----------------------------------------
|
||||
fixed: very rare decoding bug causing overflow with hi-res files
|
||||
fixed: bug causing termination error with very wide screen widths
|
||||
fixed: formatting error in duration display
|
||||
added: command-line option (-ss) to include tags in summary dump
|
||||
added: command-line option (-l) to use low priority for batch operation
|
||||
added: debug mode (rename to wvunpack_debug.exe)
|
||||
improved: returns error status for any error
|
||||
improved: more robust decoding of damaged (or invalid) files
|
||||
|
||||
in_wv.dll (winamp plugin) - 2.3
|
||||
nxWavPack.dll (Nero plugin) - 1.2
|
||||
WavPack_Apollo.dll (Apollo plugin) - 1.3
|
||||
cool_wv4.flt (CoolEdit / Audition filter) - 2.6
|
||||
-----------------------------------------------
|
||||
fixed: very rare decoding bug causing overflow with hi-res files
|
||||
improved: handle ID3v1.1 tags (now includes track number)
|
||||
improved: more robust decoding of damaged (or invalid) files
|
||||
added: handle non-standard sampling rates
|
||||
|
||||
foo_wavpack.dll (foobar plugin) - 2.3
|
||||
-----------------------------------------------
|
||||
fixed: any error during WavPack file open caused crash if wvc file present
|
||||
fixed: very rare decoding bug causing overflow with hi-res files
|
||||
improved: more robust decoding of damaged (or invalid) files
|
||||
added: handle non-standard sampling rates
|
||||
|
||||
WavPack Library Source Code - 4.3
|
||||
---------------------------------
|
||||
fixed: very rare decoding bug causing overflow with hi-res files
|
||||
added: automatic generation of RIFF wav header during encoding
|
||||
added: new functions to access tags by index (instead of item name)
|
||||
added: automatically detect lower resolution data during encoding
|
||||
added: handle non-standard sampling rates
|
||||
improved: more robust decoding of damaged (or invalid) files
|
||||
improved: use longer blocks in multichannel files (better "high" compression)
|
||||
improved: two structures renamed to avoid namespace conflict
|
||||
removed: legacy code for Borland compiler
|
||||
|
||||
|
||||
--------------------------
|
||||
Update - September 1, 2005
|
||||
--------------------------
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.22
|
||||
cool_wv4.flt (CoolEdit / Audition filter) - 2.5
|
||||
-----------------------------------------------
|
||||
fixed: possible corrupt files written (24 or 32-bit + "extra" mode)
|
||||
|
||||
|
||||
---------------------------
|
||||
Release 4.2 - April 2, 2005
|
||||
---------------------------
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.2
|
||||
----------------------------------------
|
||||
fixed: handling of wav files larger than 2 gig
|
||||
improved: stereo lossless encoding speed (including "extra" mode)
|
||||
added: -i option to ignore length specified in wav header
|
||||
added: -w option to write APEv2 tags directly from command line
|
||||
|
||||
wvunpack.exe (command-line decoder) - 4.2
|
||||
-----------------------------------------
|
||||
improved: decoding speed
|
||||
|
||||
in_wv.dll (winamp plugin) - 2.2
|
||||
-------------------------------
|
||||
added: winamp media library support
|
||||
improved: decoding speed
|
||||
|
||||
foo_wavpack.dll (foobar plugin) - 2.2
|
||||
-------------------------------------
|
||||
improved: decoding speed
|
||||
|
||||
nxWavPack.dll (Nero plugin) - 1.1
|
||||
Cool_wv4.flt (CoolEdit / Audition filter) - 2.4
|
||||
-----------------------------------------------
|
||||
fixed: handling of wav files larger than 2 gig
|
||||
improved: encoding and decoding speed
|
||||
|
||||
WavPack Library Source Code - 4.2
|
||||
---------------------------------
|
||||
improved: encoding and decoding speed
|
||||
fixed: works correctly with 64-bit compilers
|
||||
added: mode bit to open files in "streaming" mode
|
||||
|
||||
|
||||
--------------------------
|
||||
Update - December 12, 2004
|
||||
--------------------------
|
||||
|
||||
WavPack_Apollo.dll (Apollo plugin) - 1.2
|
||||
----------------------------------------
|
||||
fixed: crash when Apollo opened and WavPack plugin can't find config file
|
||||
|
||||
|
||||
--------------------------------
|
||||
Release 4.1 - September 14, 2004
|
||||
--------------------------------
|
||||
|
||||
wavpack.exe (command-line encoder) - 4.1
|
||||
----------------------------------------
|
||||
fixed: hybrid mode + "extra" mode + very low bitrates making corrupt files
|
||||
fixed: mono or multichannel files causing crash (no corruption possible)
|
||||
added: third name specification for "correction" file (EAC specific)
|
||||
added: -t option to preserve timestamps
|
||||
added: error summary for batch mode
|
||||
|
||||
wvunpack.exe (command-line decoder) - 4.1
|
||||
-----------------------------------------
|
||||
fixed: hybrid mode decoding bugs (very obscure situations)
|
||||
added: -s option to dump file summary to stdout
|
||||
added: -t option to preserve timestamps
|
||||
added: error summary for batch mode
|
||||
|
||||
wvselfx.exe (self-extraction stub) - 4.1
|
||||
----------------------------------------
|
||||
fixed: hybrid mode decoding bugs (very obscure situations)
|
||||
|
||||
in_wv.dll (winamp plugin) - 2.1
|
||||
-------------------------------
|
||||
fixed: international characters in tags display properly (UTF-8 to Ansi)
|
||||
added: maximum tag data field width changed from 64 chars to 128 chars
|
||||
added: new infobox items including encoder version & modes, track #, md5
|
||||
|
||||
foo_wavpack.dll (foobar plugin) - 2.1
|
||||
-------------------------------------
|
||||
added: new database items including encoder version & modes and md5
|
||||
|
||||
WavPack_Apollo.dll (Apollo plugin) - 1.1
|
||||
----------------------------------------
|
||||
fixed: international characters in tags display properly (UTF-8 to Ansi)
|
||||
|
||||
Cool_wv4.flt (CoolEdit / Audition filter) - 2.2
|
||||
-----------------------------------------------
|
||||
fixed: hybrid mode + "extra" mode + very low bitrates making corrupt files
|
||||
fixed: saving mono file causing crash (no corruption possible)
|
||||
fixed: hybrid mode decoding bugs (very obscure situations)
|
||||
fixed: partial saves (with "Cancel") have incorrect RIFF header if unpacked
|
||||
|
||||
nxWavPack.dll (Nero plugin) - 1.0
|
||||
---------------------------------
|
||||
new
|
||||
|
||||
WavPack Library Source Code - 4.1
|
||||
---------------------------------
|
||||
fixed: hybrid mode + "extra" mode + very low bitrates making corrupt files
|
||||
fixed: mono or multichannel files causing crash (no corruption possible)
|
||||
fixed: hybrid mode decoding bugs (very obscure situations)
|
||||
added: mode bits for determining additional encode info (extra, sfx)
|
||||
added: function to return total compressed file length (including wvc)
|
||||
added: function to return encoder version (1, 2, 3, or 4)
|
||||
added: ability to obtain MD5 sum before decoding file (requires seek to end)
|
||||
added: mode bit for determining tag type (for proper character translation)
|
||||
added: ability to encode WavPack files without knowing length in advance
|
||||
added: option for small "information only" version of library
|
||||
103
wavpack-4.5.0/README
Normal file
103
wavpack-4.5.0/README
Normal file
@@ -0,0 +1,103 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
This package contains all the source code required to build the WavPack
|
||||
command-line programs and the WavPack library and it has been tested on many
|
||||
platforms.
|
||||
|
||||
On Windows there are solution and project files for Visual Studio 2005 and
|
||||
additional sourcecode to build the CoolEdit/Audition plugin and the winamp
|
||||
plugin. The CoolEdit/Audition plugin provides a good example for using the
|
||||
library to both read and write WavPack files.
|
||||
|
||||
To build everything on Linux, type:
|
||||
|
||||
1. ./configure [--enable-mmx]
|
||||
2. make
|
||||
3. make install (optionally, to install into /usr/local/bin)
|
||||
|
||||
If you are using the code directly from SVN (rather than a distribution)
|
||||
then you will need to do a ./autogen.sh before the configure step. For
|
||||
processors that support MMX, use the --enable-mmx switch to utilize MMX
|
||||
intrinsics to speed up encoding of stereo 24-bit (and higher) audio.
|
||||
|
||||
Notes:
|
||||
|
||||
1. There are two documentation files contained in the distribution:
|
||||
|
||||
doc/library_use.txt contains a detailed description of the API provided
|
||||
by WavPack library appropriate for read and writing
|
||||
WavPack files
|
||||
|
||||
doc/file_format.txt contains a description of the WavPack file format,
|
||||
including details needed for parsing WavPack blocks
|
||||
and interpreting the block header and flags
|
||||
|
||||
There is also a description of the WavPack algorithms in the forth edition
|
||||
of David Salomon's book "Data Compression: The Complete Reference". The
|
||||
section on WavPack can be found here:
|
||||
|
||||
www.wavpack.com/WavPack.pdf
|
||||
|
||||
2. This code is designed to be easy to port to other platforms. File I/O is
|
||||
done with streams and all file functions (except "fopen") are handled in
|
||||
a wrapper in the "utils.c" module. The code is endian-independent.
|
||||
|
||||
To maintain compatibility on various platforms, the following conventions
|
||||
are used: A "short" must be 16-bits and an "int" must be 32-bits.
|
||||
The "long" type is not used. The "char" type must be 8-bits, signed or
|
||||
unsigned.
|
||||
|
||||
3. For WavPack file decoding, a library interface in "wputils.c" provides all
|
||||
the functionality required for both the winamp plugin and the "wvunpack"
|
||||
command-line program (including the transparent decoding of "correction"
|
||||
files). There is also an alternate entry point that uses reader callbacks
|
||||
for all input, although in this case it is the caller's responsibility to
|
||||
to open the "correction" file. The header file "include/wavpack.h"
|
||||
includes everything needed while hiding all the WavPack internals from the
|
||||
application.
|
||||
|
||||
4. For WavPack file creation, the library interface in "wputils.c" provides
|
||||
all the functionality for both the Audition filter and the "wavpack"
|
||||
command-line program. No file I/O is performed by the library when creating
|
||||
WavPack files. Instead, the user supplies a "write_block" function that
|
||||
accepts completed WavPack blocks. It is also possible to append APEv2 tags
|
||||
to WavPack files during creation and edit APEv2 tags on existing files
|
||||
(although there is no support currently for "binary" fields in the tags).
|
||||
|
||||
5. The following #define's can be optionally used to eliminate some functionality
|
||||
to create smaller binaries. It is important that they must be specified
|
||||
the same for the compilation of ALL files:
|
||||
|
||||
NO_UNPACK no unpacking of audio samples from WavPack files
|
||||
(also don't include unpack.c)
|
||||
NO_PACK no creating WavPack files from raw audio data
|
||||
(also don't include pack.c, extra1.c and extra2.c)
|
||||
INFO_ONLY to obtain information from WavPack files, but not audio
|
||||
(also don't include pack.c, extra1.c and extra2.c)
|
||||
NO_SEEKING to not allow seeking to a specific sample index (unpack only)
|
||||
NO_USE_FSTREAMS to not open WavPack files by name using fstreams
|
||||
NO_TAGS to not read specified fields from ID3v1 and APEv2 tags and
|
||||
create APEv2 tags
|
||||
VER4_ONLY to only handle WavPack files from versions 4.0 onward
|
||||
WIN32 required for Win32 platform
|
||||
|
||||
6. There are alternate versions of this library available specifically designed
|
||||
for "resource limited" CPUs or hardware encoding and decoding. There is the
|
||||
"tiny decoder" library which works with less than 32k of code and less than
|
||||
4k of data and has assembly language optimizations for the ARM and Freescale
|
||||
ColdFire CPUs. The "tiny encoder" is also designed for embedded use and
|
||||
handles the pure lossless, lossy, and hybrid lossless modes. Neither of the
|
||||
"tiny" versions use any memory allocation functions nor do they require
|
||||
floating-point arithmetic support.
|
||||
|
||||
For applications requiring very low latency, there is a special version of
|
||||
the library that supports a variation on the regular WavPack block format
|
||||
to facilitate this.
|
||||
|
||||
7. Questions or comments should be directed to david@wavpack.com
|
||||
@@ -121,7 +121,7 @@ typedef struct {
|
||||
|
||||
#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode
|
||||
#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode or encode
|
||||
#define CUR_STREAM_VERS 0x405 // stream version we are writing now
|
||||
#define CUR_STREAM_VERS 0x407 // stream version we are writing now
|
||||
|
||||
// These are the mask bit definitions for the metadata chunk id byte (see format.txt)
|
||||
|
||||
@@ -178,6 +178,7 @@ typedef struct {
|
||||
#define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample
|
||||
#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified
|
||||
#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified
|
||||
#define CONFIG_DYNAMIC_SHAPING 0x20000 // dynamic noise shaping
|
||||
#define CONFIG_CREATE_EXE 0x40000 // create executable
|
||||
#define CONFIG_CREATE_WVC 0x80000 // create correction file
|
||||
#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression
|
||||
@@ -185,6 +186,7 @@ typedef struct {
|
||||
#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode
|
||||
#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints
|
||||
#define CONFIG_MD5_CHECKSUM 0x8000000 // store MD5 signature
|
||||
#define CONFIG_MERGE_BLOCKS 0x10000000 // merge blocks of equal redundancy (for lossyWAV)
|
||||
#define CONFIG_OPTIMIZE_MONO 0x80000000 // optimize for mono streams posing as stereo
|
||||
|
||||
////////////// Callbacks used for reading & writing WavPack streams //////////
|
||||
@@ -235,11 +237,13 @@ int WavpackGetMode (WavpackContext *wpc);
|
||||
#define MODE_VALID_TAG 0x10
|
||||
#define MODE_HIGH 0x20
|
||||
#define MODE_FAST 0x40
|
||||
#define MODE_EXTRA 0x80
|
||||
#define MODE_EXTRA 0x80 // extra mode used, see MODE_XMODE for possible level
|
||||
#define MODE_APETAG 0x100
|
||||
#define MODE_SFX 0x200
|
||||
#define MODE_VERY_HIGH 0x400
|
||||
#define MODE_MD5 0x800
|
||||
#define MODE_XMODE 0x7000 // mask for extra level (1-6, 0=unknown)
|
||||
#define MODE_DNS 0x8000
|
||||
|
||||
char *WavpackGetErrorMessage (WavpackContext *wpc);
|
||||
int WavpackGetVersion (WavpackContext *wpc);
|
||||
@@ -290,8 +294,8 @@ void WavpackFloatNormalize (int32_t *values, int32_t num_values, int delta_exp);
|
||||
void WavpackLittleEndianToNative (void *data, char *format);
|
||||
void WavpackNativeToLittleEndian (void *data, char *format);
|
||||
|
||||
uint32_t WavpackGetLibraryVersion ();
|
||||
const char *WavpackGetLibraryVersionString ();
|
||||
uint32_t WavpackGetLibraryVersion (void);
|
||||
const char *WavpackGetLibraryVersionString (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
25
wavpack-4.5.0/license.txt
Normal file
25
wavpack-4.5.0/license.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 1998 - 2008 Conifer Software
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Conifer Software nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
271
wavpack-4.5.0/src/bits.c
Normal file
271
wavpack-4.5.0/src/bits.c
Normal file
@@ -0,0 +1,271 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// bits.c
|
||||
|
||||
// This module provides utilities to support the BitStream structure which is
|
||||
// used to read and write all WavPack audio data streams. It also contains a
|
||||
// wrapper for the stream I/O functions and a set of functions dealing with
|
||||
// endian-ness, both for enhancing portability. Finally, a debug wrapper for
|
||||
// the malloc() system is provided.
|
||||
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
////////////////////////// Bitstream functions ////////////////////////////////
|
||||
|
||||
#if !defined(NO_UNPACK) || defined(INFO_ONLY)
|
||||
|
||||
// Open the specified BitStream and associate with the specified buffer.
|
||||
|
||||
static void bs_read (Bitstream *bs);
|
||||
|
||||
void bs_open_read (Bitstream *bs, void *buffer_start, void *buffer_end)
|
||||
{
|
||||
bs->error = bs->sr = bs->bc = 0;
|
||||
bs->ptr = (bs->buf = buffer_start) - 1;
|
||||
bs->end = buffer_end;
|
||||
bs->wrap = bs_read;
|
||||
}
|
||||
|
||||
// This function is only called from the getbit() and getbits() macros when
|
||||
// the BitStream has been exhausted and more data is required. Sinve these
|
||||
// bistreams no longer access files, this function simple sets an error and
|
||||
// resets the buffer.
|
||||
|
||||
static void bs_read (Bitstream *bs)
|
||||
{
|
||||
bs->ptr = bs->buf - 1;
|
||||
bs->error = 1;
|
||||
}
|
||||
|
||||
// This function is called to close the bitstream. It returns the number of
|
||||
// full bytes actually read as bits.
|
||||
|
||||
uint32_t bs_close_read (Bitstream *bs)
|
||||
{
|
||||
uint32_t bytes_read;
|
||||
|
||||
if (bs->bc < sizeof (*(bs->ptr)) * 8)
|
||||
bs->ptr++;
|
||||
|
||||
bytes_read = (uint32_t)(bs->ptr - bs->buf) * sizeof (*(bs->ptr));
|
||||
|
||||
if (!(bytes_read & 1))
|
||||
++bytes_read;
|
||||
|
||||
CLEAR (*bs);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_PACK
|
||||
|
||||
// Open the specified BitStream using the specified buffer pointers. It is
|
||||
// assumed that enough buffer space has been allocated for all data that will
|
||||
// be written, otherwise an error will be generated.
|
||||
|
||||
static void bs_write (Bitstream *bs);
|
||||
|
||||
void bs_open_write (Bitstream *bs, void *buffer_start, void *buffer_end)
|
||||
{
|
||||
bs->error = bs->sr = bs->bc = 0;
|
||||
bs->ptr = bs->buf = buffer_start;
|
||||
bs->end = buffer_end;
|
||||
bs->wrap = bs_write;
|
||||
}
|
||||
|
||||
// This function is only called from the putbit() and putbits() macros when
|
||||
// the buffer is full, which is now flagged as an error.
|
||||
|
||||
static void bs_write (Bitstream *bs)
|
||||
{
|
||||
bs->ptr = bs->buf;
|
||||
bs->error = 1;
|
||||
}
|
||||
|
||||
// This function forces a flushing write of the specified BitStream, and
|
||||
// returns the total number of bytes written into the buffer.
|
||||
|
||||
uint32_t bs_close_write (Bitstream *bs)
|
||||
{
|
||||
uint32_t bytes_written;
|
||||
|
||||
if (bs->error)
|
||||
return (uint32_t) -1;
|
||||
|
||||
while (1) {
|
||||
while (bs->bc)
|
||||
putbit_1 (bs);
|
||||
|
||||
bytes_written = (uint32_t)(bs->ptr - bs->buf) * sizeof (*(bs->ptr));
|
||||
|
||||
if (bytes_written & 1) {
|
||||
putbit_1 (bs);
|
||||
}
|
||||
else
|
||||
break;
|
||||
};
|
||||
|
||||
CLEAR (*bs);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////// Endian Correction Routines ////////////////////////////
|
||||
|
||||
void little_endian_to_native (void *data, char *format)
|
||||
{
|
||||
uchar *cp = (uchar *) data;
|
||||
int32_t temp;
|
||||
|
||||
while (*format) {
|
||||
switch (*format) {
|
||||
case 'L':
|
||||
temp = cp [0] + ((int32_t) cp [1] << 8) + ((int32_t) cp [2] << 16) + ((int32_t) cp [3] << 24);
|
||||
* (int32_t *) cp = temp;
|
||||
cp += 4;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
temp = cp [0] + (cp [1] << 8);
|
||||
* (short *) cp = (short) temp;
|
||||
cp += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isdigit (*format))
|
||||
cp += *format - '0';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
format++;
|
||||
}
|
||||
}
|
||||
|
||||
void native_to_little_endian (void *data, char *format)
|
||||
{
|
||||
uchar *cp = (uchar *) data;
|
||||
int32_t temp;
|
||||
|
||||
while (*format) {
|
||||
switch (*format) {
|
||||
case 'L':
|
||||
temp = * (int32_t *) cp;
|
||||
*cp++ = (uchar) temp;
|
||||
*cp++ = (uchar) (temp >> 8);
|
||||
*cp++ = (uchar) (temp >> 16);
|
||||
*cp++ = (uchar) (temp >> 24);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
temp = * (short *) cp;
|
||||
*cp++ = (uchar) temp;
|
||||
*cp++ = (uchar) (temp >> 8);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isdigit (*format))
|
||||
cp += *format - '0';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
format++;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////// Debug Wrapper for Malloc ///////////////////////////
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
|
||||
void *vptrs [512];
|
||||
|
||||
static void *add_ptr (void *ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 512; ++i)
|
||||
if (!vptrs [i]) {
|
||||
vptrs [i] = ptr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 512)
|
||||
error_line ("too many mallocs!");
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void *del_ptr (void *ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 512; ++i)
|
||||
if (vptrs [i] == ptr) {
|
||||
vptrs [i] = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 512)
|
||||
error_line ("free invalid ptr!");
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *malloc_db (uint32_t size)
|
||||
{
|
||||
if (size)
|
||||
return add_ptr (malloc (size));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void free_db (void *ptr)
|
||||
{
|
||||
if (ptr)
|
||||
free (del_ptr (ptr));
|
||||
}
|
||||
|
||||
void *realloc_db (void *ptr, uint32_t size)
|
||||
{
|
||||
if (ptr && size)
|
||||
return add_ptr (realloc (del_ptr (ptr), size));
|
||||
else if (size)
|
||||
return malloc_db (size);
|
||||
else
|
||||
free_db (ptr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t dump_alloc (void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (j = i = 0; i < 512; ++i)
|
||||
if (vptrs [i])
|
||||
j++;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
#endif
|
||||
671
wavpack-4.5.0/src/extra1.c
Normal file
671
wavpack-4.5.0/src/extra1.c
Normal file
@@ -0,0 +1,671 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// extra1.c
|
||||
|
||||
// This module handles the "extra" mode for mono files.
|
||||
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
//#define USE_OVERHEAD
|
||||
#define LOG_LIMIT 6912
|
||||
//#define EXTRA_DUMP
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
#define malloc malloc_db
|
||||
#define realloc realloc_db
|
||||
#define free free_db
|
||||
void *malloc_db (uint32_t size);
|
||||
void *realloc_db (void *ptr, uint32_t size);
|
||||
void free_db (void *ptr);
|
||||
int32_t dump_alloc (void);
|
||||
#endif
|
||||
|
||||
//////////////////////////////// local tables ///////////////////////////////
|
||||
|
||||
typedef struct {
|
||||
int32_t *sampleptrs [MAX_NTERMS+2];
|
||||
struct decorr_pass dps [MAX_NTERMS];
|
||||
int nterms, log_limit;
|
||||
uint32_t best_bits;
|
||||
} WavpackExtraInfo;
|
||||
|
||||
static void decorr_mono_pass (int32_t *in_samples, int32_t *out_samples, uint32_t num_samples, struct decorr_pass *dpp, int dir)
|
||||
{
|
||||
int m = 0, i;
|
||||
|
||||
dpp->sum_A = 0;
|
||||
|
||||
if (dir < 0) {
|
||||
out_samples += (num_samples - 1);
|
||||
in_samples += (num_samples - 1);
|
||||
dir = -1;
|
||||
}
|
||||
else
|
||||
dir = 1;
|
||||
|
||||
dpp->weight_A = restore_weight (store_weight (dpp->weight_A));
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
dpp->samples_A [i] = exp2s (log2s (dpp->samples_A [i]));
|
||||
|
||||
if (dpp->term > MAX_TERM) {
|
||||
while (num_samples--) {
|
||||
int32_t left, sam_A;
|
||||
|
||||
if (dpp->term & 1)
|
||||
sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1];
|
||||
else
|
||||
sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1;
|
||||
|
||||
dpp->samples_A [1] = dpp->samples_A [0];
|
||||
dpp->samples_A [0] = left = in_samples [0];
|
||||
|
||||
left -= apply_weight (dpp->weight_A, sam_A);
|
||||
update_weight (dpp->weight_A, dpp->delta, sam_A, left);
|
||||
dpp->sum_A += dpp->weight_A;
|
||||
out_samples [0] = left;
|
||||
in_samples += dir;
|
||||
out_samples += dir;
|
||||
}
|
||||
}
|
||||
else if (dpp->term > 0) {
|
||||
while (num_samples--) {
|
||||
int k = (m + dpp->term) & (MAX_TERM - 1);
|
||||
int32_t left, sam_A;
|
||||
|
||||
sam_A = dpp->samples_A [m];
|
||||
dpp->samples_A [k] = left = in_samples [0];
|
||||
m = (m + 1) & (MAX_TERM - 1);
|
||||
|
||||
left -= apply_weight (dpp->weight_A, sam_A);
|
||||
update_weight (dpp->weight_A, dpp->delta, sam_A, left);
|
||||
dpp->sum_A += dpp->weight_A;
|
||||
out_samples [0] = left;
|
||||
in_samples += dir;
|
||||
out_samples += dir;
|
||||
}
|
||||
}
|
||||
|
||||
if (m && dpp->term > 0 && dpp->term <= MAX_TERM) {
|
||||
int32_t temp_A [MAX_TERM];
|
||||
int k;
|
||||
|
||||
memcpy (temp_A, dpp->samples_A, sizeof (dpp->samples_A));
|
||||
|
||||
for (k = 0; k < MAX_TERM; k++) {
|
||||
dpp->samples_A [k] = temp_A [m];
|
||||
m = (m + 1) & (MAX_TERM - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void reverse_mono_decorr (struct decorr_pass *dpp)
|
||||
{
|
||||
if (dpp->term > MAX_TERM) {
|
||||
int32_t sam_A;
|
||||
|
||||
if (dpp->term & 1)
|
||||
sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1];
|
||||
else
|
||||
sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1;
|
||||
|
||||
dpp->samples_A [1] = dpp->samples_A [0];
|
||||
dpp->samples_A [0] = sam_A;
|
||||
|
||||
if (dpp->term & 1)
|
||||
sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1];
|
||||
else
|
||||
sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1;
|
||||
|
||||
dpp->samples_A [1] = sam_A;
|
||||
}
|
||||
else if (dpp->term > 1) {
|
||||
int i = 0, j = dpp->term - 1, cnt = dpp->term / 2;
|
||||
|
||||
while (cnt--) {
|
||||
i &= (MAX_TERM - 1);
|
||||
j &= (MAX_TERM - 1);
|
||||
dpp->samples_A [i] ^= dpp->samples_A [j];
|
||||
dpp->samples_A [j] ^= dpp->samples_A [i];
|
||||
dpp->samples_A [i++] ^= dpp->samples_A [j--];
|
||||
}
|
||||
|
||||
// CLEAR (dpp->samples_A);
|
||||
}
|
||||
}
|
||||
|
||||
static void decorr_mono_buffer (int32_t *samples, int32_t *outsamples, uint32_t num_samples, struct decorr_pass *dpp, int tindex)
|
||||
{
|
||||
struct decorr_pass dp, *dppi = dpp + tindex;
|
||||
int delta = dppi->delta, pre_delta, term = dppi->term;
|
||||
|
||||
if (delta == 7)
|
||||
pre_delta = 7;
|
||||
else if (delta < 2)
|
||||
pre_delta = 3;
|
||||
else
|
||||
pre_delta = delta + 1;
|
||||
|
||||
CLEAR (dp);
|
||||
dp.term = term;
|
||||
dp.delta = pre_delta;
|
||||
decorr_mono_pass (samples, outsamples, num_samples > 2048 ? 2048 : num_samples, &dp, -1);
|
||||
dp.delta = delta;
|
||||
|
||||
if (tindex == 0)
|
||||
reverse_mono_decorr (&dp);
|
||||
else
|
||||
CLEAR (dp.samples_A);
|
||||
|
||||
memcpy (dppi->samples_A, dp.samples_A, sizeof (dp.samples_A));
|
||||
dppi->weight_A = dp.weight_A;
|
||||
|
||||
if (delta == 0) {
|
||||
dp.delta = 1;
|
||||
decorr_mono_pass (samples, outsamples, num_samples, &dp, 1);
|
||||
dp.delta = 0;
|
||||
memcpy (dp.samples_A, dppi->samples_A, sizeof (dp.samples_A));
|
||||
dppi->weight_A = dp.weight_A = dp.sum_A / num_samples;
|
||||
}
|
||||
|
||||
// if (memcmp (dppi, &dp, sizeof (dp)))
|
||||
// error_line ("decorr_passes don't match, delta = %d", delta);
|
||||
|
||||
decorr_mono_pass (samples, outsamples, num_samples, &dp, 1);
|
||||
}
|
||||
|
||||
static int log2overhead (int first_term, int num_terms)
|
||||
{
|
||||
#ifdef USE_OVERHEAD
|
||||
if (first_term > MAX_TERM)
|
||||
return (4 + num_terms * 2) << 11;
|
||||
else
|
||||
return (2 + num_terms * 2) << 11;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void recurse_mono (WavpackContext *wpc, WavpackExtraInfo *info, int depth, int delta, uint32_t input_bits)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
int term, branches = ((wpc->config.extra_flags & EXTRA_BRANCHES) >> 6) - depth;
|
||||
int32_t *samples, *outsamples;
|
||||
uint32_t term_bits [22], bits;
|
||||
|
||||
if (branches < 1 || depth + 1 == info->nterms)
|
||||
branches = 1;
|
||||
|
||||
CLEAR (term_bits);
|
||||
samples = info->sampleptrs [depth];
|
||||
outsamples = info->sampleptrs [depth + 1];
|
||||
|
||||
for (term = 1; term <= 18; ++term) {
|
||||
if (term == 17 && branches == 1 && depth + 1 < info->nterms)
|
||||
continue;
|
||||
|
||||
if (term > 8 && term < 17)
|
||||
continue;
|
||||
|
||||
if ((wpc->config.flags & CONFIG_FAST_FLAG) && (term > 4 && term < 17))
|
||||
continue;
|
||||
|
||||
info->dps [depth].term = term;
|
||||
info->dps [depth].delta = delta;
|
||||
decorr_mono_buffer (samples, outsamples, wps->wphdr.block_samples, info->dps, depth);
|
||||
bits = log2buffer (outsamples, wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (info->dps [0].term, depth + 1);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
info->best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
memcpy (wps->decorr_passes, info->dps, sizeof (info->dps [0]) * (depth + 1));
|
||||
memcpy (info->sampleptrs [info->nterms + 1], info->sampleptrs [depth + 1], wps->wphdr.block_samples * 4);
|
||||
}
|
||||
|
||||
term_bits [term + 3] = bits;
|
||||
}
|
||||
|
||||
while (depth + 1 < info->nterms && branches--) {
|
||||
uint32_t local_best_bits = input_bits;
|
||||
int best_term = 0, i;
|
||||
|
||||
for (i = 0; i < 22; ++i)
|
||||
if (term_bits [i] && term_bits [i] < local_best_bits) {
|
||||
local_best_bits = term_bits [i];
|
||||
// term_bits [i] = 0;
|
||||
best_term = i - 3;
|
||||
}
|
||||
|
||||
if (!best_term)
|
||||
break;
|
||||
|
||||
term_bits [best_term + 3] = 0;
|
||||
|
||||
info->dps [depth].term = best_term;
|
||||
info->dps [depth].delta = delta;
|
||||
decorr_mono_buffer (samples, outsamples, wps->wphdr.block_samples, info->dps, depth);
|
||||
|
||||
// if (log2buffer (outsamples, wps->wphdr.block_samples * 2, 0) != local_best_bits)
|
||||
// error_line ("data doesn't match!");
|
||||
|
||||
recurse_mono (wpc, info, depth + 1, delta, local_best_bits);
|
||||
}
|
||||
}
|
||||
|
||||
static void delta_mono (WavpackContext *wpc, WavpackExtraInfo *info)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
int lower = FALSE, delta, d;
|
||||
uint32_t bits;
|
||||
|
||||
if (wps->decorr_passes [0].term)
|
||||
delta = wps->decorr_passes [0].delta;
|
||||
else
|
||||
return;
|
||||
|
||||
for (d = delta - 1; d >= 0; --d) {
|
||||
int i;
|
||||
|
||||
if (!d && (wps->wphdr.flags & HYBRID_FLAG))
|
||||
break;
|
||||
|
||||
for (i = 0; i < info->nterms && wps->decorr_passes [i].term; ++i) {
|
||||
info->dps [i].term = wps->decorr_passes [i].term;
|
||||
info->dps [i].delta = d;
|
||||
decorr_mono_buffer (info->sampleptrs [i], info->sampleptrs [i+1], wps->wphdr.block_samples, info->dps, i);
|
||||
}
|
||||
|
||||
bits = log2buffer (info->sampleptrs [i], wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (wps->decorr_passes [0].term, i);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
lower = TRUE;
|
||||
info->best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
memcpy (wps->decorr_passes, info->dps, sizeof (info->dps [0]) * i);
|
||||
memcpy (info->sampleptrs [info->nterms + 1], info->sampleptrs [i], wps->wphdr.block_samples * 4);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (d = delta + 1; !lower && d <= 7; ++d) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < info->nterms && wps->decorr_passes [i].term; ++i) {
|
||||
info->dps [i].term = wps->decorr_passes [i].term;
|
||||
info->dps [i].delta = d;
|
||||
decorr_mono_buffer (info->sampleptrs [i], info->sampleptrs [i+1], wps->wphdr.block_samples, info->dps, i);
|
||||
}
|
||||
|
||||
bits = log2buffer (info->sampleptrs [i], wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (wps->decorr_passes [0].term, i);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
info->best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
memcpy (wps->decorr_passes, info->dps, sizeof (info->dps [0]) * i);
|
||||
memcpy (info->sampleptrs [info->nterms + 1], info->sampleptrs [i], wps->wphdr.block_samples * 4);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sort_mono (WavpackContext *wpc, WavpackExtraInfo *info)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
int reversed = TRUE;
|
||||
uint32_t bits;
|
||||
|
||||
while (reversed) {
|
||||
int ri, i;
|
||||
|
||||
memcpy (info->dps, wps->decorr_passes, sizeof (wps->decorr_passes));
|
||||
reversed = FALSE;
|
||||
|
||||
for (ri = 0; ri < info->nterms && wps->decorr_passes [ri].term; ++ri) {
|
||||
|
||||
if (ri + 1 >= info->nterms || !wps->decorr_passes [ri+1].term)
|
||||
break;
|
||||
|
||||
if (wps->decorr_passes [ri].term == wps->decorr_passes [ri+1].term) {
|
||||
decorr_mono_buffer (info->sampleptrs [ri], info->sampleptrs [ri+1], wps->wphdr.block_samples, info->dps, ri);
|
||||
continue;
|
||||
}
|
||||
|
||||
info->dps [ri] = wps->decorr_passes [ri+1];
|
||||
info->dps [ri+1] = wps->decorr_passes [ri];
|
||||
|
||||
for (i = ri; i < info->nterms && wps->decorr_passes [i].term; ++i)
|
||||
decorr_mono_buffer (info->sampleptrs [i], info->sampleptrs [i+1], wps->wphdr.block_samples, info->dps, i);
|
||||
|
||||
bits = log2buffer (info->sampleptrs [i], wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (wps->decorr_passes [0].term, i);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
reversed = TRUE;
|
||||
info->best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
memcpy (wps->decorr_passes, info->dps, sizeof (info->dps [0]) * i);
|
||||
memcpy (info->sampleptrs [info->nterms + 1], info->sampleptrs [i], wps->wphdr.block_samples * 4);
|
||||
}
|
||||
else {
|
||||
info->dps [ri] = wps->decorr_passes [ri];
|
||||
info->dps [ri+1] = wps->decorr_passes [ri+1];
|
||||
decorr_mono_buffer (info->sampleptrs [ri], info->sampleptrs [ri+1], wps->wphdr.block_samples, info->dps, ri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const uint32_t xtable [] = { 91, 123, 187, 251 };
|
||||
|
||||
static void analyze_mono (WavpackContext *wpc, int32_t *samples, int do_samples)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
WavpackExtraInfo info;
|
||||
int i;
|
||||
|
||||
#ifdef LOG_LIMIT
|
||||
info.log_limit = (((wps->wphdr.flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
|
||||
|
||||
if (info.log_limit > LOG_LIMIT)
|
||||
info.log_limit = LOG_LIMIT;
|
||||
#else
|
||||
info.log_limit = 0;
|
||||
#endif
|
||||
|
||||
if (wpc->config.flags & (CONFIG_HIGH_FLAG | CONFIG_VERY_HIGH_FLAG))
|
||||
wpc->config.extra_flags = xtable [wpc->config.xmode - 4];
|
||||
else
|
||||
wpc->config.extra_flags = xtable [wpc->config.xmode - 3];
|
||||
|
||||
info.nterms = wps->num_terms;
|
||||
|
||||
for (i = 0; i < info.nterms + 2; ++i)
|
||||
info.sampleptrs [i] = malloc (wps->wphdr.block_samples * 4);
|
||||
|
||||
memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
|
||||
memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 4);
|
||||
|
||||
for (i = 0; i < info.nterms && info.dps [i].term; ++i)
|
||||
decorr_mono_pass (info.sampleptrs [i], info.sampleptrs [i + 1], wps->wphdr.block_samples, info.dps + i, 1);
|
||||
|
||||
info.best_bits = log2buffer (info.sampleptrs [info.nterms], wps->wphdr.block_samples, 0) * 1;
|
||||
info.best_bits += log2overhead (info.dps [0].term, i);
|
||||
memcpy (info.sampleptrs [info.nterms + 1], info.sampleptrs [i], wps->wphdr.block_samples * 4);
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_BRANCHES)
|
||||
recurse_mono (wpc, &info, 0, (int) floor (wps->delta_decay + 0.5),
|
||||
log2buffer (info.sampleptrs [0], wps->wphdr.block_samples, 0));
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_SORT_FIRST)
|
||||
sort_mono (wpc, &info);
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_TRY_DELTAS) {
|
||||
delta_mono (wpc, &info);
|
||||
|
||||
if ((wpc->config.extra_flags & EXTRA_ADJUST_DELTAS) && wps->decorr_passes [0].term)
|
||||
wps->delta_decay = (float)((wps->delta_decay * 2.0 + wps->decorr_passes [0].delta) / 3.0);
|
||||
else
|
||||
wps->delta_decay = 2.0;
|
||||
}
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_SORT_LAST)
|
||||
sort_mono (wpc, &info);
|
||||
|
||||
if (do_samples)
|
||||
memcpy (samples, info.sampleptrs [info.nterms + 1], wps->wphdr.block_samples * 4);
|
||||
|
||||
for (i = 0; i < info.nterms; ++i)
|
||||
if (!wps->decorr_passes [i].term)
|
||||
break;
|
||||
|
||||
wps->num_terms = i;
|
||||
|
||||
for (i = 0; i < info.nterms + 2; ++i)
|
||||
free (info.sampleptrs [i]);
|
||||
}
|
||||
|
||||
static void mono_add_noise (WavpackStream *wps, int32_t *lptr, int32_t *rptr)
|
||||
{
|
||||
int shaping_weight, new = wps->wphdr.flags & NEW_SHAPING;
|
||||
short *shaping_array = wps->dc.shaping_array;
|
||||
int32_t error = 0, temp, cnt;
|
||||
|
||||
scan_word (wps, rptr, wps->wphdr.block_samples, -1);
|
||||
cnt = wps->wphdr.block_samples;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_SHAPE) {
|
||||
while (cnt--) {
|
||||
if (shaping_array)
|
||||
shaping_weight = *shaping_array++;
|
||||
else
|
||||
shaping_weight = (wps->dc.shaping_acc [0] += wps->dc.shaping_delta [0]) >> 16;
|
||||
|
||||
temp = -apply_weight (shaping_weight, error);
|
||||
|
||||
if (new && shaping_weight < 0 && temp) {
|
||||
if (temp == error)
|
||||
temp = (temp < 0) ? temp + 1 : temp - 1;
|
||||
|
||||
lptr [0] += (error = nosend_word (wps, rptr [0], 0) - rptr [0] + temp);
|
||||
}
|
||||
else
|
||||
lptr [0] += (error = nosend_word (wps, rptr [0], 0) - rptr [0]) + temp;
|
||||
|
||||
lptr++;
|
||||
rptr++;
|
||||
}
|
||||
|
||||
if (!shaping_array)
|
||||
wps->dc.shaping_acc [0] -= wps->dc.shaping_delta [0] * wps->wphdr.block_samples;
|
||||
}
|
||||
else
|
||||
while (cnt--) {
|
||||
lptr [0] += nosend_word (wps, rptr [0], 0) - rptr [0];
|
||||
lptr++;
|
||||
rptr++;
|
||||
}
|
||||
}
|
||||
|
||||
void execute_mono (WavpackContext *wpc, int32_t *samples, int no_history, int do_samples)
|
||||
{
|
||||
int32_t *temp_buffer [2], *best_buffer, *noisy_buffer = NULL;
|
||||
struct decorr_pass temp_decorr_pass, save_decorr_passes [MAX_NTERMS];
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
int32_t num_samples = wps->wphdr.block_samples;
|
||||
int32_t buf_size = sizeof (int32_t) * num_samples;
|
||||
uint32_t best_size = (uint32_t) -1, size;
|
||||
int log_limit, pi, i;
|
||||
|
||||
for (i = 0; i < num_samples; ++i)
|
||||
if (samples [i])
|
||||
break;
|
||||
|
||||
if (i == num_samples) {
|
||||
CLEAR (wps->decorr_passes);
|
||||
wps->num_terms = 0;
|
||||
init_words (wps);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef LOG_LIMIT
|
||||
log_limit = (((wps->wphdr.flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
|
||||
|
||||
if (log_limit > LOG_LIMIT)
|
||||
log_limit = LOG_LIMIT;
|
||||
#else
|
||||
log_limit = 0;
|
||||
#endif
|
||||
|
||||
CLEAR (save_decorr_passes);
|
||||
temp_buffer [0] = malloc (buf_size);
|
||||
temp_buffer [1] = malloc (buf_size);
|
||||
best_buffer = malloc (buf_size);
|
||||
|
||||
if (wps->num_passes > 1 && (wps->wphdr.flags & HYBRID_FLAG)) {
|
||||
CLEAR (temp_decorr_pass);
|
||||
temp_decorr_pass.delta = 2;
|
||||
temp_decorr_pass.term = 18;
|
||||
|
||||
decorr_mono_pass (samples, temp_buffer [0],
|
||||
num_samples > 2048 ? 2048 : num_samples, &temp_decorr_pass, -1);
|
||||
|
||||
reverse_mono_decorr (&temp_decorr_pass);
|
||||
decorr_mono_pass (samples, temp_buffer [0], num_samples, &temp_decorr_pass, 1);
|
||||
CLEAR (temp_decorr_pass);
|
||||
temp_decorr_pass.delta = 2;
|
||||
temp_decorr_pass.term = 17;
|
||||
|
||||
decorr_mono_pass (temp_buffer [0], temp_buffer [1],
|
||||
num_samples > 2048 ? 2048 : num_samples, &temp_decorr_pass, -1);
|
||||
|
||||
decorr_mono_pass (temp_buffer [0], temp_buffer [1], num_samples, &temp_decorr_pass, 1);
|
||||
noisy_buffer = malloc (buf_size);
|
||||
memcpy (noisy_buffer, samples, buf_size);
|
||||
mono_add_noise (wps, noisy_buffer, temp_buffer [1]);
|
||||
no_history = 1;
|
||||
}
|
||||
|
||||
if (no_history || wps->num_passes >= 7)
|
||||
wps->best_decorr = wps->mask_decorr = 0;
|
||||
|
||||
for (pi = 0; pi < wps->num_passes;) {
|
||||
const WavpackDecorrSpec *wpds;
|
||||
int nterms, c, j;
|
||||
|
||||
if (!pi)
|
||||
c = wps->best_decorr;
|
||||
else {
|
||||
if (wps->mask_decorr == 0)
|
||||
c = 0;
|
||||
else
|
||||
c = (wps->best_decorr & (wps->mask_decorr - 1)) | wps->mask_decorr;
|
||||
|
||||
if (c == wps->best_decorr) {
|
||||
wps->mask_decorr = wps->mask_decorr ? ((wps->mask_decorr << 1) & (wps->num_decorrs - 1)) : 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
wpds = &wps->decorr_specs [c];
|
||||
nterms = (int) strlen (wpds->terms);
|
||||
|
||||
while (1) {
|
||||
memcpy (temp_buffer [0], noisy_buffer ? noisy_buffer : samples, buf_size);
|
||||
CLEAR (save_decorr_passes);
|
||||
|
||||
for (j = 0; j < nterms; ++j) {
|
||||
CLEAR (temp_decorr_pass);
|
||||
temp_decorr_pass.delta = wpds->delta;
|
||||
temp_decorr_pass.term = wpds->terms [j];
|
||||
|
||||
if (temp_decorr_pass.term < 0)
|
||||
temp_decorr_pass.term = 1;
|
||||
|
||||
decorr_mono_pass (temp_buffer [j&1], temp_buffer [~j&1],
|
||||
num_samples > 2048 ? 2048 : num_samples, &temp_decorr_pass, -1);
|
||||
|
||||
if (j) {
|
||||
CLEAR (temp_decorr_pass.samples_A);
|
||||
}
|
||||
else
|
||||
reverse_mono_decorr (&temp_decorr_pass);
|
||||
|
||||
memcpy (save_decorr_passes + j, &temp_decorr_pass, sizeof (struct decorr_pass));
|
||||
decorr_mono_pass (temp_buffer [j&1], temp_buffer [~j&1], num_samples, &temp_decorr_pass, 1);
|
||||
}
|
||||
|
||||
size = log2buffer (temp_buffer [j&1], num_samples, log_limit);
|
||||
|
||||
if (size == (uint32_t) -1 && nterms)
|
||||
nterms >>= 1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
size += log2overhead (wpds->terms [0], nterms);
|
||||
|
||||
if (size < best_size) {
|
||||
memcpy (best_buffer, temp_buffer [j&1], buf_size);
|
||||
memcpy (wps->decorr_passes, save_decorr_passes, sizeof (struct decorr_pass) * MAX_NTERMS);
|
||||
wps->num_terms = nterms;
|
||||
wps->best_decorr = c;
|
||||
best_size = size;
|
||||
}
|
||||
|
||||
if (pi++)
|
||||
wps->mask_decorr = wps->mask_decorr ? ((wps->mask_decorr << 1) & (wps->num_decorrs - 1)) : 1;
|
||||
}
|
||||
|
||||
if (wpc->config.xmode > 3) {
|
||||
if (noisy_buffer) {
|
||||
analyze_mono (wpc, noisy_buffer, do_samples);
|
||||
|
||||
if (do_samples)
|
||||
memcpy (samples, noisy_buffer, buf_size);
|
||||
}
|
||||
else
|
||||
analyze_mono (wpc, samples, do_samples);
|
||||
}
|
||||
else if (do_samples)
|
||||
memcpy (samples, best_buffer, buf_size);
|
||||
|
||||
if (no_history || wpc->config.xmode > 3)
|
||||
scan_word (wps, best_buffer, num_samples, -1);
|
||||
|
||||
if (noisy_buffer)
|
||||
free (noisy_buffer);
|
||||
|
||||
free (temp_buffer [1]);
|
||||
free (temp_buffer [0]);
|
||||
free (best_buffer);
|
||||
|
||||
#ifdef EXTRA_DUMP
|
||||
if (1) {
|
||||
char string [256], substring [20];
|
||||
int i;
|
||||
|
||||
sprintf (string, "M: terms =");
|
||||
|
||||
for (i = 0; i < wps->num_terms; ++i) {
|
||||
if (wps->decorr_passes [i].term) {
|
||||
if (i && wps->decorr_passes [i-1].delta == wps->decorr_passes [i].delta)
|
||||
sprintf (substring, " %d", wps->decorr_passes [i].term);
|
||||
else
|
||||
sprintf (substring, " %d->%d", wps->decorr_passes [i].term,
|
||||
wps->decorr_passes [i].delta);
|
||||
}
|
||||
else
|
||||
sprintf (substring, " *");
|
||||
|
||||
strcat (string, substring);
|
||||
}
|
||||
|
||||
error_line (string);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
1355
wavpack-4.5.0/src/extra2.c
Normal file
1355
wavpack-4.5.0/src/extra2.c
Normal file
File diff suppressed because it is too large
Load Diff
371
wavpack-4.5.0/src/float.c
Normal file
371
wavpack-4.5.0/src/float.c
Normal file
@@ -0,0 +1,371 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// float.c
|
||||
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
#define malloc malloc_db
|
||||
#define realloc realloc_db
|
||||
#define free free_db
|
||||
void *malloc_db (uint32_t size);
|
||||
void *realloc_db (void *ptr, uint32_t size);
|
||||
void free_db (void *ptr);
|
||||
int32_t dump_alloc (void);
|
||||
#endif
|
||||
|
||||
#ifndef NO_PACK
|
||||
|
||||
void write_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
char *byteptr;
|
||||
|
||||
byteptr = wpmd->data = malloc (4);
|
||||
wpmd->id = ID_FLOAT_INFO;
|
||||
*byteptr++ = wps->float_flags;
|
||||
*byteptr++ = wps->float_shift;
|
||||
*byteptr++ = wps->float_max_exp;
|
||||
*byteptr++ = wps->float_norm_exp;
|
||||
wpmd->byte_length = (int32_t)(byteptr - (char *) wpmd->data);
|
||||
}
|
||||
|
||||
int scan_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
||||
{
|
||||
int32_t shifted_ones = 0, shifted_zeros = 0, shifted_both = 0;
|
||||
int32_t false_zeros = 0, neg_zeros = 0;
|
||||
uint32_t ordata = 0, crc = 0xffffffff;
|
||||
int32_t count, value, shift_count;
|
||||
int max_exp = 0;
|
||||
f32 *dp;
|
||||
|
||||
wps->float_shift = wps->float_flags = 0;
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++) {
|
||||
crc = crc * 27 + get_mantissa (*dp) * 9 + get_exponent (*dp) * 3 + get_sign (*dp);
|
||||
|
||||
if (get_exponent (*dp) > max_exp && get_exponent (*dp) < 255)
|
||||
max_exp = get_exponent (*dp);
|
||||
}
|
||||
|
||||
wps->crc_x = crc;
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++) {
|
||||
if (get_exponent (*dp) == 255) {
|
||||
wps->float_flags |= FLOAT_EXCEPTIONS;
|
||||
value = 0x1000000;
|
||||
shift_count = 0;
|
||||
}
|
||||
else if (get_exponent (*dp)) {
|
||||
shift_count = max_exp - get_exponent (*dp);
|
||||
value = 0x800000 + get_mantissa (*dp);
|
||||
}
|
||||
else {
|
||||
shift_count = max_exp ? max_exp - 1 : 0;
|
||||
value = get_mantissa (*dp);
|
||||
|
||||
// if (get_mantissa (*dp))
|
||||
// denormals++;
|
||||
}
|
||||
|
||||
if (shift_count < 25)
|
||||
value >>= shift_count;
|
||||
else
|
||||
value = 0;
|
||||
|
||||
if (!value) {
|
||||
if (get_exponent (*dp) || get_mantissa (*dp))
|
||||
++false_zeros;
|
||||
else if (get_sign (*dp))
|
||||
++neg_zeros;
|
||||
}
|
||||
else if (shift_count) {
|
||||
int32_t mask = (1 << shift_count) - 1;
|
||||
|
||||
if (!(get_mantissa (*dp) & mask))
|
||||
shifted_zeros++;
|
||||
else if ((get_mantissa (*dp) & mask) == mask)
|
||||
shifted_ones++;
|
||||
else
|
||||
shifted_both++;
|
||||
}
|
||||
|
||||
ordata |= value;
|
||||
* (int32_t *) dp = (get_sign (*dp)) ? -value : value;
|
||||
}
|
||||
|
||||
wps->float_max_exp = max_exp;
|
||||
|
||||
if (shifted_both)
|
||||
wps->float_flags |= FLOAT_SHIFT_SENT;
|
||||
else if (shifted_ones && !shifted_zeros)
|
||||
wps->float_flags |= FLOAT_SHIFT_ONES;
|
||||
else if (shifted_ones && shifted_zeros)
|
||||
wps->float_flags |= FLOAT_SHIFT_SAME;
|
||||
else if (ordata && !(ordata & 1)) {
|
||||
while (!(ordata & 1)) {
|
||||
wps->float_shift++;
|
||||
ordata >>= 1;
|
||||
}
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++)
|
||||
* (int32_t *) dp >>= wps->float_shift;
|
||||
}
|
||||
|
||||
wps->wphdr.flags &= ~MAG_MASK;
|
||||
|
||||
while (ordata) {
|
||||
wps->wphdr.flags += 1 << MAG_LSB;
|
||||
ordata >>= 1;
|
||||
}
|
||||
|
||||
if (false_zeros || neg_zeros)
|
||||
wps->float_flags |= FLOAT_ZEROS_SENT;
|
||||
|
||||
if (neg_zeros)
|
||||
wps->float_flags |= FLOAT_NEG_ZEROS;
|
||||
|
||||
// error_line ("samples = %d, max exp = %d, pre-shift = %d, denormals = %d",
|
||||
// num_values, max_exp, wps->float_shift, denormals);
|
||||
// if (wps->float_flags & FLOAT_EXCEPTIONS)
|
||||
// error_line ("exceptions!");
|
||||
// error_line ("shifted ones/zeros/both = %d/%d/%d, true/neg/false zeros = %d/%d/%d",
|
||||
// shifted_ones, shifted_zeros, shifted_both, true_zeros, neg_zeros, false_zeros);
|
||||
|
||||
return wps->float_flags & (FLOAT_EXCEPTIONS | FLOAT_ZEROS_SENT | FLOAT_SHIFT_SENT | FLOAT_SHIFT_SAME);
|
||||
}
|
||||
|
||||
void send_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
||||
{
|
||||
int max_exp = wps->float_max_exp;
|
||||
int32_t count, value, shift_count;
|
||||
f32 *dp;
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++) {
|
||||
if (get_exponent (*dp) == 255) {
|
||||
if (get_mantissa (*dp)) {
|
||||
putbit_1 (&wps->wvxbits);
|
||||
putbits (get_mantissa (*dp), 23, &wps->wvxbits);
|
||||
}
|
||||
else {
|
||||
putbit_0 (&wps->wvxbits);
|
||||
}
|
||||
|
||||
value = 0x1000000;
|
||||
shift_count = 0;
|
||||
}
|
||||
else if (get_exponent (*dp)) {
|
||||
shift_count = max_exp - get_exponent (*dp);
|
||||
value = 0x800000 + get_mantissa (*dp);
|
||||
}
|
||||
else {
|
||||
shift_count = max_exp ? max_exp - 1 : 0;
|
||||
value = get_mantissa (*dp);
|
||||
}
|
||||
|
||||
if (shift_count < 25)
|
||||
value >>= shift_count;
|
||||
else
|
||||
value = 0;
|
||||
|
||||
if (!value) {
|
||||
if (wps->float_flags & FLOAT_ZEROS_SENT) {
|
||||
if (get_exponent (*dp) || get_mantissa (*dp)) {
|
||||
putbit_1 (&wps->wvxbits);
|
||||
putbits (get_mantissa (*dp), 23, &wps->wvxbits);
|
||||
|
||||
if (max_exp >= 25) {
|
||||
putbits (get_exponent (*dp), 8, &wps->wvxbits);
|
||||
}
|
||||
|
||||
putbit (get_sign (*dp), &wps->wvxbits);
|
||||
}
|
||||
else {
|
||||
putbit_0 (&wps->wvxbits);
|
||||
|
||||
if (wps->float_flags & FLOAT_NEG_ZEROS)
|
||||
putbit (get_sign (*dp), &wps->wvxbits);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (shift_count) {
|
||||
if (wps->float_flags & FLOAT_SHIFT_SENT) {
|
||||
int32_t data = get_mantissa (*dp) & ((1 << shift_count) - 1);
|
||||
putbits (data, shift_count, &wps->wvxbits);
|
||||
}
|
||||
else if (wps->float_flags & FLOAT_SHIFT_SAME) {
|
||||
putbit (get_mantissa (*dp) & 1, &wps->wvxbits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(NO_UNPACK) || defined(INFO_ONLY)
|
||||
|
||||
int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
int bytecnt = wpmd->byte_length;
|
||||
char *byteptr = wpmd->data;
|
||||
|
||||
if (bytecnt != 4)
|
||||
return FALSE;
|
||||
|
||||
wps->float_flags = *byteptr++;
|
||||
wps->float_shift = *byteptr++;
|
||||
wps->float_max_exp = *byteptr++;
|
||||
wps->float_norm_exp = *byteptr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_UNPACK
|
||||
|
||||
static void float_values_nowvx (WavpackStream *wps, int32_t *values, int32_t num_values);
|
||||
|
||||
void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
|
||||
{
|
||||
uint32_t crc = wps->crc_x;
|
||||
|
||||
if (!bs_is_open (&wps->wvxbits)) {
|
||||
float_values_nowvx (wps, values, num_values);
|
||||
return;
|
||||
}
|
||||
|
||||
while (num_values--) {
|
||||
int shift_count = 0, exp = wps->float_max_exp;
|
||||
f32 outval = 0;
|
||||
uint32_t temp;
|
||||
|
||||
if (*values == 0) {
|
||||
if (wps->float_flags & FLOAT_ZEROS_SENT) {
|
||||
if (getbit (&wps->wvxbits)) {
|
||||
getbits (&temp, 23, &wps->wvxbits);
|
||||
set_mantissa (outval, temp);
|
||||
|
||||
if (exp >= 25) {
|
||||
getbits (&temp, 8, &wps->wvxbits);
|
||||
set_exponent (outval, temp);
|
||||
}
|
||||
|
||||
set_sign (outval, getbit (&wps->wvxbits));
|
||||
}
|
||||
else if (wps->float_flags & FLOAT_NEG_ZEROS)
|
||||
set_sign (outval, getbit (&wps->wvxbits));
|
||||
}
|
||||
}
|
||||
else {
|
||||
*values <<= wps->float_shift;
|
||||
|
||||
if (*values < 0) {
|
||||
*values = -*values;
|
||||
set_sign (outval, 1);
|
||||
}
|
||||
|
||||
if (*values == 0x1000000) {
|
||||
if (getbit (&wps->wvxbits)) {
|
||||
getbits (&temp, 23, &wps->wvxbits);
|
||||
set_mantissa (outval, temp);
|
||||
}
|
||||
|
||||
set_exponent (outval, 255);
|
||||
}
|
||||
else {
|
||||
if (exp)
|
||||
while (!(*values & 0x800000) && --exp) {
|
||||
shift_count++;
|
||||
*values <<= 1;
|
||||
}
|
||||
|
||||
if (shift_count) {
|
||||
if ((wps->float_flags & FLOAT_SHIFT_ONES) ||
|
||||
((wps->float_flags & FLOAT_SHIFT_SAME) && getbit (&wps->wvxbits)))
|
||||
*values |= ((1 << shift_count) - 1);
|
||||
else if (wps->float_flags & FLOAT_SHIFT_SENT) {
|
||||
getbits (&temp, shift_count, &wps->wvxbits);
|
||||
*values |= temp & ((1 << shift_count) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
set_mantissa (outval, *values);
|
||||
set_exponent (outval, exp);
|
||||
}
|
||||
}
|
||||
|
||||
crc = crc * 27 + get_mantissa (outval) * 9 + get_exponent (outval) * 3 + get_sign (outval);
|
||||
* (f32 *) values++ = outval;
|
||||
}
|
||||
|
||||
wps->crc_x = crc;
|
||||
}
|
||||
|
||||
static void float_values_nowvx (WavpackStream *wps, int32_t *values, int32_t num_values)
|
||||
{
|
||||
while (num_values--) {
|
||||
int shift_count = 0, exp = wps->float_max_exp;
|
||||
f32 outval = 0;
|
||||
|
||||
if (*values) {
|
||||
*values <<= wps->float_shift;
|
||||
|
||||
if (*values < 0) {
|
||||
*values = -*values;
|
||||
set_sign (outval, 1);
|
||||
}
|
||||
|
||||
if (*values >= 0x1000000) {
|
||||
while (*values & 0xf000000) {
|
||||
*values >>= 1;
|
||||
++exp;
|
||||
}
|
||||
}
|
||||
else if (exp) {
|
||||
while (!(*values & 0x800000) && --exp) {
|
||||
shift_count++;
|
||||
*values <<= 1;
|
||||
}
|
||||
|
||||
if (shift_count && (wps->float_flags & FLOAT_SHIFT_ONES))
|
||||
*values |= ((1 << shift_count) - 1);
|
||||
}
|
||||
|
||||
set_mantissa (outval, *values);
|
||||
set_exponent (outval, exp);
|
||||
}
|
||||
|
||||
* (f32 *) values++ = outval;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void WavpackFloatNormalize (int32_t *values, int32_t num_values, int delta_exp)
|
||||
{
|
||||
f32 *fvalues = (f32 *) values;
|
||||
int exp;
|
||||
|
||||
if (!delta_exp)
|
||||
return;
|
||||
|
||||
while (num_values--) {
|
||||
if ((exp = get_exponent (*fvalues)) == 0 || exp + delta_exp <= 0)
|
||||
*fvalues = 0;
|
||||
else if (exp == 255 || (exp += delta_exp) >= 255) {
|
||||
set_exponent (*fvalues, 255);
|
||||
set_mantissa (*fvalues, 0);
|
||||
}
|
||||
else
|
||||
set_exponent (*fvalues, exp);
|
||||
|
||||
fvalues++;
|
||||
}
|
||||
}
|
||||
26
wavpack-4.5.0/src/libwavpack.sln
Normal file
26
wavpack-4.5.0/src/libwavpack.sln
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavpack", "libwavpack.vcproj", "{5CCCB9CF-0384-458F-BA08-72B73866840F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Debug|x64.Build.0 = Debug|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|Win32.Build.0 = Release|Win32
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|x64.ActiveCfg = Release|x64
|
||||
{5CCCB9CF-0384-458F-BA08-72B73866840F}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
359
wavpack-4.5.0/src/libwavpack.vcproj
Normal file
359
wavpack-4.5.0/src/libwavpack.vcproj
Normal file
@@ -0,0 +1,359 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="libwavpack"
|
||||
ProjectGUID="{5CCCB9CF-0384-458F-BA08-72B73866840F}"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;OPT_MMX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;OPT_SSE2"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;OPT_MMX"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="true"
|
||||
DisableLanguageExtensions="false"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
OmitDefaultLibName="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
IgnoreAllDefaultLibraries="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;OPT_SSE2"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="true"
|
||||
DisableLanguageExtensions="false"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
OmitDefaultLibName="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
IgnoreAllDefaultLibraries="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\unpack3.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wavpack_local.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\bits.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\extra1.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\extra2.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\float.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\metadata.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pack.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unpack.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unpack3.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\words.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wputils.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
313
wavpack-4.5.0/src/metadata.c
Normal file
313
wavpack-4.5.0/src/metadata.c
Normal file
@@ -0,0 +1,313 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// metadata.c
|
||||
|
||||
// This module handles the metadata structure introduced in WavPack 4.0
|
||||
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
#define malloc malloc_db
|
||||
#define realloc realloc_db
|
||||
#define free free_db
|
||||
void *malloc_db (uint32_t size);
|
||||
void *realloc_db (void *ptr, uint32_t size);
|
||||
void free_db (void *ptr);
|
||||
int32_t dump_alloc (void);
|
||||
#endif
|
||||
|
||||
#if !defined(NO_UNPACK) || defined(INFO_ONLY)
|
||||
|
||||
int read_metadata_buff (WavpackMetadata *wpmd, uchar *blockbuff, uchar **buffptr)
|
||||
{
|
||||
WavpackHeader *wphdr = (WavpackHeader *) blockbuff;
|
||||
uchar *buffend = blockbuff + wphdr->ckSize + 8;
|
||||
|
||||
if (buffend - *buffptr < 2)
|
||||
return FALSE;
|
||||
|
||||
wpmd->id = *(*buffptr)++;
|
||||
wpmd->byte_length = *(*buffptr)++ << 1;
|
||||
|
||||
if (wpmd->id & ID_LARGE) {
|
||||
wpmd->id &= ~ID_LARGE;
|
||||
|
||||
if (buffend - *buffptr < 2)
|
||||
return FALSE;
|
||||
|
||||
wpmd->byte_length += *(*buffptr)++ << 9;
|
||||
wpmd->byte_length += *(*buffptr)++ << 17;
|
||||
}
|
||||
|
||||
if (wpmd->id & ID_ODD_SIZE) {
|
||||
wpmd->id &= ~ID_ODD_SIZE;
|
||||
wpmd->byte_length--;
|
||||
}
|
||||
|
||||
if (wpmd->byte_length) {
|
||||
if (buffend - *buffptr < wpmd->byte_length + (wpmd->byte_length & 1)) {
|
||||
wpmd->data = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wpmd->data = *buffptr;
|
||||
(*buffptr) += wpmd->byte_length + (wpmd->byte_length & 1);
|
||||
}
|
||||
else
|
||||
wpmd->data = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
|
||||
switch (wpmd->id) {
|
||||
case ID_DUMMY:
|
||||
return TRUE;
|
||||
|
||||
case ID_DECORR_TERMS:
|
||||
return read_decorr_terms (wps, wpmd);
|
||||
|
||||
case ID_DECORR_WEIGHTS:
|
||||
return read_decorr_weights (wps, wpmd);
|
||||
|
||||
case ID_DECORR_SAMPLES:
|
||||
return read_decorr_samples (wps, wpmd);
|
||||
|
||||
case ID_ENTROPY_VARS:
|
||||
return read_entropy_vars (wps, wpmd);
|
||||
|
||||
case ID_HYBRID_PROFILE:
|
||||
return read_hybrid_profile (wps, wpmd);
|
||||
|
||||
case ID_SHAPING_WEIGHTS:
|
||||
return read_shaping_info (wps, wpmd);
|
||||
|
||||
case ID_FLOAT_INFO:
|
||||
return read_float_info (wps, wpmd);
|
||||
|
||||
case ID_INT32_INFO:
|
||||
return read_int32_info (wps, wpmd);
|
||||
|
||||
case ID_CHANNEL_INFO:
|
||||
return read_channel_info (wpc, wpmd);
|
||||
|
||||
case ID_CONFIG_BLOCK:
|
||||
return read_config_info (wpc, wpmd);
|
||||
|
||||
case ID_SAMPLE_RATE:
|
||||
return read_sample_rate (wpc, wpmd);
|
||||
|
||||
case ID_WV_BITSTREAM:
|
||||
return init_wv_bitstream (wps, wpmd);
|
||||
|
||||
case ID_WVC_BITSTREAM:
|
||||
return init_wvc_bitstream (wps, wpmd);
|
||||
|
||||
case ID_WVX_BITSTREAM:
|
||||
return init_wvx_bitstream (wps, wpmd);
|
||||
|
||||
case ID_RIFF_HEADER: case ID_RIFF_TRAILER:
|
||||
return read_wrapper_data (wpc, wpmd);
|
||||
|
||||
case ID_MD5_CHECKSUM:
|
||||
if (wpmd->byte_length == 16) {
|
||||
memcpy (wpc->config.md5_checksum, wpmd->data, 16);
|
||||
wpc->config.flags |= CONFIG_MD5_CHECKSUM;
|
||||
wpc->config.md5_read = 1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_PACK
|
||||
|
||||
int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end)
|
||||
{
|
||||
uint32_t mdsize = wpmd->byte_length + (wpmd->byte_length & 1);
|
||||
WavpackHeader *wphdr = (WavpackHeader *) buffer_start;
|
||||
|
||||
if (wpmd->byte_length & 1)
|
||||
((char *) wpmd->data) [wpmd->byte_length] = 0;
|
||||
|
||||
mdsize += (wpmd->byte_length > 510) ? 4 : 2;
|
||||
buffer_start += wphdr->ckSize + 8;
|
||||
|
||||
if (buffer_start + mdsize >= buffer_end)
|
||||
return FALSE;
|
||||
|
||||
buffer_start [0] = wpmd->id | (wpmd->byte_length & 1 ? ID_ODD_SIZE : 0);
|
||||
buffer_start [1] = (wpmd->byte_length + 1) >> 1;
|
||||
|
||||
if (wpmd->byte_length > 510) {
|
||||
buffer_start [0] |= ID_LARGE;
|
||||
buffer_start [2] = (wpmd->byte_length + 1) >> 9;
|
||||
buffer_start [3] = (wpmd->byte_length + 1) >> 17;
|
||||
}
|
||||
|
||||
if (wpmd->data && wpmd->byte_length) {
|
||||
if (wpmd->byte_length > 510) {
|
||||
buffer_start [0] |= ID_LARGE;
|
||||
buffer_start [2] = (wpmd->byte_length + 1) >> 9;
|
||||
buffer_start [3] = (wpmd->byte_length + 1) >> 17;
|
||||
memcpy (buffer_start + 4, wpmd->data, mdsize - 4);
|
||||
}
|
||||
else
|
||||
memcpy (buffer_start + 2, wpmd->data, mdsize - 2);
|
||||
}
|
||||
|
||||
wphdr->ckSize += mdsize;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int add_to_metadata (WavpackContext *wpc, void *data, uint32_t bcount, uchar id)
|
||||
{
|
||||
WavpackMetadata *mdp;
|
||||
uchar *src = data;
|
||||
|
||||
while (bcount) {
|
||||
if (wpc->metacount) {
|
||||
uint32_t bc = bcount;
|
||||
|
||||
mdp = wpc->metadata + wpc->metacount - 1;
|
||||
|
||||
if (mdp->id == id) {
|
||||
if (wpc->metabytes + bcount > 1000000)
|
||||
bc = 1000000 - wpc->metabytes;
|
||||
|
||||
mdp->data = realloc (mdp->data, mdp->byte_length + bc);
|
||||
memcpy ((char *) mdp->data + mdp->byte_length, src, bc);
|
||||
mdp->byte_length += bc;
|
||||
wpc->metabytes += bc;
|
||||
bcount -= bc;
|
||||
src += bc;
|
||||
|
||||
if (wpc->metabytes >= 1000000 && !write_metadata_block (wpc))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (bcount) {
|
||||
wpc->metadata = realloc (wpc->metadata, (wpc->metacount + 1) * sizeof (WavpackMetadata));
|
||||
mdp = wpc->metadata + wpc->metacount++;
|
||||
mdp->byte_length = 0;
|
||||
mdp->data = NULL;
|
||||
mdp->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *write_metadata (WavpackMetadata *wpmd, char *outdata)
|
||||
{
|
||||
uchar id = wpmd->id, wordlen [3];
|
||||
|
||||
wordlen [0] = (wpmd->byte_length + 1) >> 1;
|
||||
wordlen [1] = (wpmd->byte_length + 1) >> 9;
|
||||
wordlen [2] = (wpmd->byte_length + 1) >> 17;
|
||||
|
||||
if (wpmd->byte_length & 1) {
|
||||
// ((char *) wpmd->data) [wpmd->byte_length] = 0;
|
||||
id |= ID_ODD_SIZE;
|
||||
}
|
||||
|
||||
if (wordlen [1] || wordlen [2])
|
||||
id |= ID_LARGE;
|
||||
|
||||
*outdata++ = id;
|
||||
*outdata++ = wordlen [0];
|
||||
|
||||
if (id & ID_LARGE) {
|
||||
*outdata++ = wordlen [1];
|
||||
*outdata++ = wordlen [2];
|
||||
}
|
||||
|
||||
if (wpmd->data && wpmd->byte_length) {
|
||||
memcpy (outdata, wpmd->data, wpmd->byte_length);
|
||||
outdata += wpmd->byte_length;
|
||||
|
||||
if (wpmd->byte_length & 1)
|
||||
*outdata++ = 0;
|
||||
}
|
||||
|
||||
return outdata;
|
||||
}
|
||||
|
||||
int write_metadata_block (WavpackContext *wpc)
|
||||
{
|
||||
char *block_buff, *block_ptr;
|
||||
WavpackHeader *wphdr;
|
||||
|
||||
if (wpc->metacount) {
|
||||
int metacount = wpc->metacount, block_size = sizeof (WavpackHeader);
|
||||
WavpackMetadata *wpmdp = wpc->metadata;
|
||||
|
||||
while (metacount--) {
|
||||
block_size += wpmdp->byte_length + (wpmdp->byte_length & 1);
|
||||
block_size += (wpmdp->byte_length > 510) ? 4 : 2;
|
||||
wpmdp++;
|
||||
}
|
||||
|
||||
wphdr = (WavpackHeader *) (block_buff = malloc (block_size));
|
||||
|
||||
CLEAR (*wphdr);
|
||||
memcpy (wphdr->ckID, "wvpk", 4);
|
||||
wphdr->total_samples = wpc->total_samples;
|
||||
wphdr->version = wpc->stream_version;
|
||||
wphdr->ckSize = block_size - 8;
|
||||
wphdr->block_samples = 0;
|
||||
|
||||
block_ptr = (char *)(wphdr + 1);
|
||||
|
||||
wpmdp = wpc->metadata;
|
||||
|
||||
while (wpc->metacount) {
|
||||
block_ptr = write_metadata (wpmdp, block_ptr);
|
||||
wpc->metabytes -= wpmdp->byte_length;
|
||||
free_metadata (wpmdp++);
|
||||
wpc->metacount--;
|
||||
}
|
||||
|
||||
free (wpc->metadata);
|
||||
wpc->metadata = NULL;
|
||||
native_to_little_endian ((WavpackHeader *) block_buff, WavpackHeaderFormat);
|
||||
|
||||
if (!wpc->blockout (wpc->wv_out, block_buff, block_size)) {
|
||||
free (block_buff);
|
||||
strcpy (wpc->error_message, "can't write WavPack data, disk probably full!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
free (block_buff);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void free_metadata (WavpackMetadata *wpmd)
|
||||
{
|
||||
if (wpmd->data) {
|
||||
free (wpmd->data);
|
||||
wpmd->data = NULL;
|
||||
}
|
||||
}
|
||||
2992
wavpack-4.5.0/src/pack.c
Normal file
2992
wavpack-4.5.0/src/pack.c
Normal file
File diff suppressed because it is too large
Load Diff
1399
wavpack-4.5.0/src/unpack.c
Normal file
1399
wavpack-4.5.0/src/unpack.c
Normal file
File diff suppressed because it is too large
Load Diff
2195
wavpack-4.5.0/src/unpack3.c
Normal file
2195
wavpack-4.5.0/src/unpack3.c
Normal file
File diff suppressed because it is too large
Load Diff
113
wavpack-4.5.0/src/unpack3.h
Normal file
113
wavpack-4.5.0/src/unpack3.h
Normal file
@@ -0,0 +1,113 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// wavpack3.h
|
||||
|
||||
// This header file contains all the additional definitions required for
|
||||
// decoding old (versions 1, 2 & 3) WavPack files.
|
||||
|
||||
typedef struct {
|
||||
ushort FormatTag, NumChannels;
|
||||
uint32_t SampleRate, BytesPerSecond;
|
||||
ushort BlockAlign, BitsPerSample;
|
||||
} WaveHeader3;
|
||||
|
||||
#define WaveHeader3Format "SSLLSS"
|
||||
|
||||
typedef struct {
|
||||
char ckID [4];
|
||||
int32_t ckSize;
|
||||
short version;
|
||||
short bits; // added for version 2.00
|
||||
short flags, shift; // added for version 3.00
|
||||
int32_t total_samples, crc, crc2;
|
||||
char extension [4], extra_bc, extras [3];
|
||||
} WavpackHeader3;
|
||||
|
||||
#define WavpackHeader3Format "4LSSSSLLL4L"
|
||||
|
||||
// these flags added for version 3
|
||||
|
||||
#undef MONO_FLAG // these definitions changed for WavPack 4.0
|
||||
#undef CROSS_DECORR
|
||||
#undef JOINT_STEREO
|
||||
|
||||
#define MONO_FLAG 1 // not stereo
|
||||
#define FAST_FLAG 2 // non-adaptive predictor and stereo mode
|
||||
#define RAW_FLAG 4 // raw mode (no .wav header)
|
||||
#define CALC_NOISE 8 // calc noise in lossy mode (no longer stored)
|
||||
#define HIGH_FLAG 0x10 // high quality mode (all modes)
|
||||
#define BYTES_3 0x20 // files have 3-byte samples
|
||||
#define OVER_20 0x40 // samples are over 20 bits
|
||||
#define WVC_FLAG 0x80 // create/use .wvc (no longer stored)
|
||||
#define LOSSY_SHAPE 0x100 // noise shape (lossy mode only)
|
||||
#define VERY_FAST_FLAG 0x200 // double fast (no longer stored)
|
||||
#define NEW_HIGH_FLAG 0x400 // new high quality mode (lossless only)
|
||||
#define CANCEL_EXTREME 0x800 // cancel EXTREME_DECORR
|
||||
#define CROSS_DECORR 0x1000 // decorrelate chans (with EXTREME_DECORR flag)
|
||||
#define NEW_DECORR_FLAG 0x2000 // new high-mode decorrelator
|
||||
#define JOINT_STEREO 0x4000 // joint stereo (lossy and high lossless)
|
||||
#define EXTREME_DECORR 0x8000 // extra decorrelation (+ enables other flags)
|
||||
|
||||
#define STORED_FLAGS 0xfd77 // these are only flags that affect unpacking
|
||||
#define NOT_STORED_FLAGS (~STORED_FLAGS & 0xffff)
|
||||
|
||||
// BitStream stuff (bits.c)
|
||||
|
||||
typedef struct bs3 {
|
||||
void (*wrap)(struct bs3 *bs);
|
||||
uchar *buf, *end, *ptr;
|
||||
uint32_t bufsiz, fpos, sr;
|
||||
WavpackStreamReader *reader;
|
||||
int error, bc;
|
||||
void *id;
|
||||
} Bitstream3;
|
||||
|
||||
#define K_DEPTH 3
|
||||
#define MAX_NTERMS3 18
|
||||
|
||||
typedef struct {
|
||||
WavpackHeader3 wphdr;
|
||||
Bitstream3 wvbits, wvcbits;
|
||||
uint32_t sample_index;
|
||||
int num_terms;
|
||||
|
||||
#ifndef NO_SEEKING
|
||||
struct index_point {
|
||||
char saved;
|
||||
uint32_t sample_index;
|
||||
} index_points [256];
|
||||
|
||||
uchar *unpack_data;
|
||||
uint32_t unpack_size;
|
||||
#endif
|
||||
|
||||
struct {
|
||||
int32_t sum_level, left_level, right_level, diff_level;
|
||||
int last_extra_bits, extra_bits_count, m;
|
||||
int32_t error [2], crc;
|
||||
int32_t sample [2] [2];
|
||||
int weight [2] [1];
|
||||
} dc;
|
||||
|
||||
struct decorr_pass decorr_passes [MAX_NTERMS3];
|
||||
|
||||
struct {
|
||||
uint index [2], k_value [2], ave_k [2];
|
||||
uint32_t zeros_acc, ave_level [K_DEPTH] [2];
|
||||
} w1;
|
||||
|
||||
struct { int last_dbits [2], last_delta_sign [2], bit_limit; } w2;
|
||||
|
||||
struct { int ave_dbits [2], bit_limit; } w3;
|
||||
|
||||
struct {
|
||||
uint32_t fast_level [2], slow_level [2];
|
||||
int bits_acc [2], bitrate;
|
||||
} w4;
|
||||
} WavpackStream3;
|
||||
@@ -176,7 +176,7 @@ typedef struct {
|
||||
|
||||
#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode
|
||||
#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode or encode
|
||||
#define CUR_STREAM_VERS 0x406 // stream version we are [normally] writing now
|
||||
#define CUR_STREAM_VERS 0x407 // stream version we are [normally] writing now
|
||||
|
||||
|
||||
//////////////////////////// WavPack Metadata /////////////////////////////////
|
||||
@@ -248,6 +248,7 @@ typedef struct {
|
||||
#define CONFIG_AUTO_SHAPING 0x4000 // automatic noise shaping
|
||||
#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified
|
||||
#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified
|
||||
#define CONFIG_DYNAMIC_SHAPING 0x20000 // dynamic noise shaping
|
||||
#define CONFIG_CREATE_EXE 0x40000 // create executable
|
||||
#define CONFIG_CREATE_WVC 0x80000 // create correction file
|
||||
#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression
|
||||
@@ -256,12 +257,17 @@ typedef struct {
|
||||
#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode
|
||||
#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints
|
||||
#define CONFIG_MD5_CHECKSUM 0x8000000 // compute & store MD5 signature
|
||||
#define CONFIG_MERGE_BLOCKS 0x10000000 // merge blocks of equal redundancy (for lossyWAV)
|
||||
#define CONFIG_OPTIMIZE_MONO 0x80000000 // optimize for mono streams posing as stereo
|
||||
|
||||
/*
|
||||
* These config flags are no longer used (or were never used) although there
|
||||
* may be WavPack files that have some of these bits set in the config
|
||||
* metadata structure, so be careful reusing them for something else.
|
||||
* These config flags were never actually used, or are no longer used, or are
|
||||
* used for something else now. They may be used in the future for what they
|
||||
* say, or for something else. WavPack files in the wild *may* have some of
|
||||
* these bit set in their config flags (with these older meanings), but only
|
||||
* if the stream version is 0x410 or less than 0x407. Of course, this is not
|
||||
* very important because once the file has been encoded, the config bits are
|
||||
* just for information purposes (i.e., they do not affect decoding),
|
||||
*
|
||||
#define CONFIG_ADOBE_MODE 0x100 // "adobe" mode for 32-bit floats
|
||||
#define CONFIG_VERY_FAST_FLAG 0x400 // double fast
|
||||
@@ -352,10 +358,12 @@ typedef struct {
|
||||
struct {
|
||||
int32_t shaping_acc [2], shaping_delta [2], error [2];
|
||||
double noise_sum, noise_ave, noise_max;
|
||||
short *shaping_data, *shaping_array;
|
||||
int32_t shaping_samples;
|
||||
} dc;
|
||||
|
||||
struct decorr_pass decorr_passes [MAX_NTERMS];
|
||||
WavpackDecorrSpec *decorr_specs;
|
||||
struct decorr_pass decorr_passes [MAX_NTERMS], analysis_pass;
|
||||
const WavpackDecorrSpec *decorr_specs;
|
||||
} WavpackStream;
|
||||
|
||||
// flags for float_flags:
|
||||
@@ -406,7 +414,7 @@ typedef struct {
|
||||
|
||||
uint32_t filelen, file2len, filepos, file2pos, total_samples, crc_errors, first_flags;
|
||||
int wvc_flag, open_flags, norm_offset, reduced_channels, lossy_blocks, close_files;
|
||||
uint32_t block_samples, max_samples, acc_samples, initial_index;
|
||||
uint32_t block_samples, ave_block_samples, block_boundary, max_samples, acc_samples, initial_index;
|
||||
int riff_header_added, riff_header_created;
|
||||
M_Tag m_tag;
|
||||
|
||||
@@ -650,12 +658,15 @@ int WavpackGetMode (WavpackContext *wpc);
|
||||
#define MODE_VALID_TAG 0x10
|
||||
#define MODE_HIGH 0x20
|
||||
#define MODE_FAST 0x40
|
||||
#define MODE_EXTRA 0x80
|
||||
#define MODE_EXTRA 0x80 // extra mode used, see MODE_XMODE for possible level
|
||||
#define MODE_APETAG 0x100
|
||||
#define MODE_SFX 0x200
|
||||
#define MODE_VERY_HIGH 0x400
|
||||
#define MODE_MD5 0x800
|
||||
#define MODE_XMODE 0x7000 // mask for extra level (1-6, 0=unknown)
|
||||
#define MODE_DNS 0x8000
|
||||
|
||||
char *WavpackGetErrorMessage (WavpackContext *wpc);
|
||||
int WavpackGetVersion (WavpackContext *wpc);
|
||||
uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples);
|
||||
uint32_t WavpackGetNumSamples (WavpackContext *wpc);
|
||||
@@ -670,6 +681,7 @@ int WavpackGetBytesPerSample (WavpackContext *wpc);
|
||||
int WavpackGetNumChannels (WavpackContext *wpc);
|
||||
int WavpackGetChannelMask (WavpackContext *wpc);
|
||||
int WavpackGetReducedChannels (WavpackContext *wpc);
|
||||
int WavpackGetFloatNormExp (WavpackContext *wpc);
|
||||
int WavpackGetMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
uint32_t WavpackGetWrapperBytes (WavpackContext *wpc);
|
||||
uchar *WavpackGetWrapperData (WavpackContext *wpc);
|
||||
@@ -700,6 +712,9 @@ void *WavpackGetWrapperLocation (void *first_block, uint32_t *size);
|
||||
void WavpackLittleEndianToNative (void *data, char *format);
|
||||
void WavpackNativeToLittleEndian (void *data, char *format);
|
||||
|
||||
uint32_t WavpackGetLibraryVersion (void);
|
||||
const char *WavpackGetLibraryVersionString (void);
|
||||
|
||||
///////////////////////////// SIMD helper macros /////////////////////////////
|
||||
|
||||
#ifdef OPT_MMX
|
||||
@@ -719,10 +734,11 @@ typedef int __v4hi __attribute__ ((__mode__ (__V4HI__)));
|
||||
#define _m_pxor(m1, m2) (__m64) __builtin_ia32_pxor ((__di) m1, (__di) m2)
|
||||
#else
|
||||
typedef int __m64 __attribute__ ((__vector_size__ (8)));
|
||||
#define _m_paddsw(m1, m2) __builtin_ia32_paddsw (m1, m2)
|
||||
typedef short __m64_16 __attribute__ ((__vector_size__ (8)));
|
||||
#define _m_paddsw(m1, m2) (__m64) __builtin_ia32_paddsw ((__m64_16) m1, (__m64_16) m2)
|
||||
#define _m_pand(m1, m2) __builtin_ia32_pand (m1, m2)
|
||||
#define _m_pandn(m1, m2) __builtin_ia32_pandn (m1, m2)
|
||||
#define _m_pmaddwd(m1, m2) __builtin_ia32_pmaddwd (m1, m2)
|
||||
#define _m_pmaddwd(m1, m2) __builtin_ia32_pmaddwd ((__m64_16) m1, (__m64_16) m2)
|
||||
#define _m_por(m1, m2) __builtin_ia32_por (m1, m2)
|
||||
#define _m_pxor(m1, m2) __builtin_ia32_pxor (m1, m2)
|
||||
#endif
|
||||
19
wavpack-4.5.0/src/wavpack_version.h
Normal file
19
wavpack-4.5.0/src/wavpack_version.h
Normal file
@@ -0,0 +1,19 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// wavpack_version.h
|
||||
|
||||
#ifndef WAVPACK_VERSION_H
|
||||
#define WAVPACK_VERSION_H
|
||||
|
||||
#define LIBWAVPACK_MAJOR 4
|
||||
#define LIBWAVPACK_MINOR 50
|
||||
#define LIBWAVPACK_MICRO 0
|
||||
#define LIBWAVPACK_VERSION_STRING "4.50.0"
|
||||
|
||||
#endif
|
||||
1468
wavpack-4.5.0/src/words.c
Normal file
1468
wavpack-4.5.0/src/words.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,7 @@ static void free_streams (WavpackContext *wpc);
|
||||
|
||||
///////////////////////////// local table storage ////////////////////////////
|
||||
|
||||
const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050,
|
||||
static const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050,
|
||||
24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 };
|
||||
|
||||
///////////////////////////// executable code ////////////////////////////////
|
||||
@@ -362,6 +362,8 @@ WavpackContext *WavpackOpenFileInputEx (WavpackStreamReader *reader, void *wv_id
|
||||
// MODE_VERY_HIGH: file was created in the "very high" mode (or in
|
||||
// the "high" mode prior to 4.4)
|
||||
// MODE_MD5: file contains an MD5 checksum
|
||||
// MODE_XMODE: level used for extra mode (1-6, 0=unknown)
|
||||
// MODE_DNS: dynamic noise shaping
|
||||
|
||||
int WavpackGetMode (WavpackContext *wpc)
|
||||
{
|
||||
@@ -382,7 +384,7 @@ int WavpackGetMode (WavpackContext *wpc)
|
||||
if (wpc->config.flags & CONFIG_FLOAT_DATA)
|
||||
mode |= MODE_FLOAT;
|
||||
|
||||
if (wpc->config.flags & CONFIG_HIGH_FLAG) {
|
||||
if (wpc->config.flags & (CONFIG_HIGH_FLAG | CONFIG_VERY_HIGH_FLAG)) {
|
||||
mode |= MODE_HIGH;
|
||||
|
||||
if ((wpc->config.flags & CONFIG_VERY_HIGH_FLAG) ||
|
||||
@@ -394,7 +396,7 @@ int WavpackGetMode (WavpackContext *wpc)
|
||||
mode |= MODE_FAST;
|
||||
|
||||
if (wpc->config.flags & CONFIG_EXTRA_MODE)
|
||||
mode |= MODE_EXTRA;
|
||||
mode |= (MODE_EXTRA | (wpc->config.xmode << 12));
|
||||
|
||||
if (wpc->config.flags & CONFIG_CREATE_EXE)
|
||||
mode |= MODE_SFX;
|
||||
@@ -402,6 +404,10 @@ int WavpackGetMode (WavpackContext *wpc)
|
||||
if (wpc->config.flags & CONFIG_MD5_CHECKSUM)
|
||||
mode |= MODE_MD5;
|
||||
|
||||
if ((wpc->config.flags & CONFIG_HYBRID_FLAG) && (wpc->config.flags & CONFIG_DYNAMIC_SHAPING) &&
|
||||
wpc->streams [0] && wpc->streams [0]->wphdr.version >= 0x407)
|
||||
mode |= MODE_DNS;
|
||||
|
||||
#ifndef NO_TAGS
|
||||
if (valid_tag (&wpc->m_tag)) {
|
||||
mode |= MODE_VALID_TAG;
|
||||
@@ -618,6 +624,16 @@ uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t sa
|
||||
|
||||
offset++;
|
||||
}
|
||||
else if (offset == num_channels - 1) {
|
||||
while (samcnt--) {
|
||||
dst [0] = src [0];
|
||||
dst += num_channels;
|
||||
src += 2;
|
||||
}
|
||||
|
||||
wpc->crc_errors++;
|
||||
offset++;
|
||||
}
|
||||
else {
|
||||
while (samcnt--) {
|
||||
dst [0] = *src++;
|
||||
@@ -628,7 +644,7 @@ uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t sa
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
if ((wps->wphdr.flags & FINAL_BLOCK) || wpc->num_streams == MAX_STREAMS)
|
||||
if ((wps->wphdr.flags & FINAL_BLOCK) || wpc->num_streams == MAX_STREAMS || offset == num_channels)
|
||||
break;
|
||||
else
|
||||
wpc->current_stream++;
|
||||
@@ -891,17 +907,17 @@ static int get_ape_tag_item (M_Tag *m_tag, const char *item, char *value, int si
|
||||
char *q = p + m_tag->ape_tag_hdr.length - sizeof (APE_Tag_Hdr);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < m_tag->ape_tag_hdr.item_count; ++i) {
|
||||
for (i = 0; i < m_tag->ape_tag_hdr.item_count && q - p > 8; ++i) {
|
||||
int vsize, flags, isize;
|
||||
|
||||
vsize = * (int32_t *) p; p += 4;
|
||||
flags = * (int32_t *) p; p += 4;
|
||||
isize = (int) strlen (p);
|
||||
isize = (int) strnlen (p, q - p);
|
||||
|
||||
little_endian_to_native (&vsize, "L");
|
||||
little_endian_to_native (&flags, "L");
|
||||
|
||||
if (p + isize + vsize + 1 > q)
|
||||
if (vsize < 0 || vsize > m_tag->ape_tag_hdr.length || p + isize + vsize + 1 > q)
|
||||
break;
|
||||
|
||||
if (isize && vsize && !stricmp (item, p) && !(flags & 6)) {
|
||||
@@ -1009,17 +1025,17 @@ static int get_ape_tag_item_indexed (M_Tag *m_tag, int index, char *item, int si
|
||||
char *q = p + m_tag->ape_tag_hdr.length - sizeof (APE_Tag_Hdr);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < m_tag->ape_tag_hdr.item_count && index >= 0; ++i) {
|
||||
for (i = 0; i < m_tag->ape_tag_hdr.item_count && index >= 0 && q - p > 8; ++i) {
|
||||
int vsize, flags, isize;
|
||||
|
||||
vsize = * (int32_t *) p; p += 4;
|
||||
flags = * (int32_t *) p; p += 4;
|
||||
isize = (int) strlen (p);
|
||||
isize = (int) strnlen (p, q - p);
|
||||
|
||||
little_endian_to_native (&vsize, "L");
|
||||
little_endian_to_native (&flags, "L");
|
||||
|
||||
if (p + isize + vsize + 1 > q)
|
||||
if (vsize < 0 || vsize > m_tag->ape_tag_hdr.length || p + isize + vsize + 1 > q)
|
||||
break;
|
||||
|
||||
if (isize && vsize && !(flags & 6) && !index--) {
|
||||
@@ -1190,7 +1206,7 @@ int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_
|
||||
wpc->config.flags = config->flags;
|
||||
|
||||
if (config->flags & CONFIG_VERY_HIGH_FLAG)
|
||||
config->flags |= CONFIG_HIGH_FLAG;
|
||||
wpc->config.flags |= CONFIG_HIGH_FLAG;
|
||||
|
||||
if (config->float_norm_exp) {
|
||||
wpc->config.float_norm_exp = config->float_norm_exp;
|
||||
@@ -1317,9 +1333,6 @@ int WavpackPackInit (WavpackContext *wpc)
|
||||
if (wpc->metabytes > 4096)
|
||||
write_metadata_block (wpc);
|
||||
|
||||
if (wpc->config.block_samples)
|
||||
wpc->block_samples = wpc->config.block_samples;
|
||||
else {
|
||||
if (wpc->config.flags & CONFIG_HIGH_FLAG)
|
||||
wpc->block_samples = wpc->config.sample_rate;
|
||||
else if (!(wpc->config.sample_rate % 2))
|
||||
@@ -1332,8 +1345,19 @@ int WavpackPackInit (WavpackContext *wpc)
|
||||
|
||||
while (wpc->block_samples * wpc->config.num_channels < 40000)
|
||||
wpc->block_samples *= 2;
|
||||
|
||||
if (wpc->config.block_samples) {
|
||||
if ((wpc->config.flags & CONFIG_MERGE_BLOCKS) &&
|
||||
wpc->block_samples > (uint32_t) wpc->config.block_samples) {
|
||||
wpc->block_boundary = wpc->config.block_samples;
|
||||
wpc->block_samples /= wpc->config.block_samples;
|
||||
wpc->block_samples *= wpc->config.block_samples;
|
||||
}
|
||||
else
|
||||
wpc->block_samples = wpc->config.block_samples;
|
||||
}
|
||||
|
||||
wpc->ave_block_samples = wpc->block_samples;
|
||||
wpc->max_samples = wpc->block_samples + (wpc->block_samples >> 1);
|
||||
|
||||
for (wpc->current_stream = 0; wpc->streams [wpc->current_stream]; wpc->current_stream++) {
|
||||
@@ -1590,6 +1614,9 @@ static int pack_streams (WavpackContext *wpc, uint32_t block_samples)
|
||||
result = pack_block (wpc, wps->sample_buffer);
|
||||
wps->blockbuff = wps->block2buff = NULL;
|
||||
|
||||
if (wps->wphdr.block_samples != block_samples)
|
||||
block_samples = wps->wphdr.block_samples;
|
||||
|
||||
if (!result) {
|
||||
strcpy (wpc->error_message, "output buffer overflowed!");
|
||||
break;
|
||||
@@ -1625,6 +1652,7 @@ static int pack_streams (WavpackContext *wpc, uint32_t block_samples)
|
||||
}
|
||||
|
||||
wpc->current_stream = 0;
|
||||
wpc->ave_block_samples = (wpc->ave_block_samples * 0x7 + block_samples + 0x4) >> 3;
|
||||
wpc->acc_samples -= block_samples;
|
||||
free (outbuff);
|
||||
|
||||
@@ -1648,11 +1676,19 @@ void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block)
|
||||
little_endian_to_native (first_block, WavpackHeaderFormat);
|
||||
((WavpackHeader *) first_block)->total_samples = WavpackGetSampleIndex (wpc);
|
||||
|
||||
/* note that since the RIFF wrapper will not necessarily be properly aligned,
|
||||
we copy it into a newly allocated buffer before modifying it */
|
||||
|
||||
if (wpc->riff_header_created) {
|
||||
if (WavpackGetWrapperLocation (first_block, &wrapper_size)) {
|
||||
RiffChunkHeader *riffhdr = WavpackGetWrapperLocation (first_block, NULL);
|
||||
ChunkHeader *datahdr = (ChunkHeader *)((char *) riffhdr + wrapper_size - sizeof (ChunkHeader));
|
||||
uint32_t data_size = WavpackGetSampleIndex (wpc) * WavpackGetNumChannels (wpc) * WavpackGetBytesPerSample (wpc);
|
||||
RiffChunkHeader *riffhdr;
|
||||
ChunkHeader *datahdr;
|
||||
void *wrapper_buff;
|
||||
|
||||
riffhdr = wrapper_buff = malloc (wrapper_size);
|
||||
memcpy (wrapper_buff, WavpackGetWrapperLocation (first_block, NULL), wrapper_size);
|
||||
datahdr = (ChunkHeader *)((char *) riffhdr + wrapper_size - sizeof (ChunkHeader));
|
||||
|
||||
if (!strncmp (riffhdr->ckID, "RIFF", 4)) {
|
||||
little_endian_to_native (riffhdr, ChunkHeaderFormat);
|
||||
@@ -1665,6 +1701,9 @@ void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block)
|
||||
datahdr->ckSize = data_size;
|
||||
native_to_little_endian (datahdr, ChunkHeaderFormat);
|
||||
}
|
||||
|
||||
memcpy (WavpackGetWrapperLocation (first_block, NULL), wrapper_buff, wrapper_size);
|
||||
free (wrapper_buff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1745,7 +1784,7 @@ static void *find_metadata (void *wavpack_block, int desired_id, uint32_t *size)
|
||||
dp += meta_bc;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2013,7 +2052,7 @@ double WavpackGetAverageBitrate (WavpackContext *wpc, int count_wvc)
|
||||
double output_time = (double) wpc->total_samples / wpc->config.sample_rate;
|
||||
double input_size = (double) wpc->filelen + (count_wvc ? wpc->file2len : 0);
|
||||
|
||||
if (output_time >= 1.0 && input_size >= 1.0)
|
||||
if (output_time >= 0.1 && input_size >= 1.0)
|
||||
return input_size * 8.0 / output_time;
|
||||
}
|
||||
|
||||
@@ -2267,6 +2306,11 @@ static void free_streams (WavpackContext *wpc)
|
||||
wpc->streams [si]->sample_buffer = NULL;
|
||||
}
|
||||
|
||||
if (wpc->streams [si]->dc.shaping_data) {
|
||||
free (wpc->streams [si]->dc.shaping_data);
|
||||
wpc->streams [si]->dc.shaping_data = NULL;
|
||||
}
|
||||
|
||||
if (si) {
|
||||
wpc->num_streams--;
|
||||
free (wpc->streams [si]);
|
||||
@@ -2297,7 +2341,7 @@ static void free_tag (M_Tag *m_tag)
|
||||
{
|
||||
if (m_tag->ape_tag_data) {
|
||||
free (m_tag->ape_tag_data);
|
||||
m_tag->ape_tag_data = 0;
|
||||
m_tag->ape_tag_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2313,7 +2357,7 @@ static void free_tag (M_Tag *m_tag)
|
||||
|
||||
static uint32_t read_next_header (WavpackStreamReader *reader, void *id, WavpackHeader *wphdr)
|
||||
{
|
||||
char buffer [sizeof (*wphdr)], *sp = buffer + sizeof (*wphdr), *ep = sp;
|
||||
unsigned char buffer [sizeof (*wphdr)], *sp = buffer + sizeof (*wphdr), *ep = sp;
|
||||
uint32_t bytes_skipped = 0;
|
||||
int bleft;
|
||||
|
||||
@@ -2331,8 +2375,8 @@ static uint32_t read_next_header (WavpackStreamReader *reader, void *id, Wavpack
|
||||
sp = buffer;
|
||||
|
||||
if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' &&
|
||||
!(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 &&
|
||||
sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff)) {
|
||||
!(*++sp & 1) && sp [2] < 16 && !sp [3] && (sp [2] || sp [1] || *sp > 24) && sp [5] == 4 &&
|
||||
sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff) && sp [18] < 3 && !sp [19]) {
|
||||
memcpy (wphdr, buffer, sizeof (*wphdr));
|
||||
little_endian_to_native (wphdr, WavpackHeaderFormat);
|
||||
return bytes_skipped;
|
||||
@@ -2562,7 +2606,7 @@ static int read_wvc_block (WavpackContext *wpc)
|
||||
if (wpc->reader->read_bytes (wpc->wvc_in, wps->block2buff + 32, wphdr.ckSize - 24) !=
|
||||
wphdr.ckSize - 24 || (wphdr.flags & UNKNOWN_FLAGS)) {
|
||||
free (wps->block2buff);
|
||||
wps->block2buff = 0;
|
||||
wps->block2buff = NULL;
|
||||
wps->wvc_skip = TRUE;
|
||||
wpc->crc_errors++;
|
||||
return FALSE;
|
||||
@@ -2594,7 +2638,7 @@ static int read_wvc_block (WavpackContext *wpc)
|
||||
|
||||
static uint32_t find_header (WavpackStreamReader *reader, void *id, uint32_t filepos, WavpackHeader *wphdr)
|
||||
{
|
||||
char *buffer = malloc (BUFSIZE), *sp = buffer, *ep = buffer;
|
||||
unsigned char *buffer = malloc (BUFSIZE), *sp = buffer, *ep = buffer;
|
||||
|
||||
if (filepos != (uint32_t) -1 && reader->set_pos_abs (id, filepos)) {
|
||||
free (buffer);
|
||||
@@ -2630,14 +2674,14 @@ static uint32_t find_header (WavpackStreamReader *reader, void *id, uint32_t fil
|
||||
|
||||
while (sp + 32 <= ep)
|
||||
if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' &&
|
||||
!(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 &&
|
||||
sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff)) {
|
||||
!(*++sp & 1) && sp [2] < 16 && !sp [3] && (sp [2] || sp [1] || *sp > 24) && sp [5] == 4 &&
|
||||
sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff) && sp [18] < 3 && !sp [19]) {
|
||||
memcpy (wphdr, sp - 4, sizeof (*wphdr));
|
||||
little_endian_to_native (wphdr, WavpackHeaderFormat);
|
||||
|
||||
if (wphdr->block_samples && (wphdr->flags & INITIAL_BLOCK)) {
|
||||
free (buffer);
|
||||
return reader->get_pos (id) - (ep - sp + 4);
|
||||
return reader->get_pos (id) - (uint32_t)(ep - sp + 4);
|
||||
}
|
||||
|
||||
if (wphdr->ckSize > 1024)
|
||||
@@ -2730,6 +2774,7 @@ static uint32_t find_sample (WavpackContext *wpc, void *infile, uint32_t header_
|
||||
|
||||
static int load_tag (WavpackContext *wpc)
|
||||
{
|
||||
int ape_tag_length, ape_tag_items;
|
||||
M_Tag *m_tag = &wpc->m_tag;
|
||||
|
||||
CLEAR (*m_tag);
|
||||
@@ -2753,17 +2798,20 @@ static int load_tag (WavpackContext *wpc)
|
||||
m_tag->ape_tag_hdr.length < (1024 * 1024) &&
|
||||
(m_tag->ape_tag_data = malloc (m_tag->ape_tag_hdr.length)) != NULL) {
|
||||
|
||||
ape_tag_items = m_tag->ape_tag_hdr.item_count;
|
||||
ape_tag_length = m_tag->ape_tag_hdr.length;
|
||||
|
||||
if (m_tag->id3_tag.tag_id [0] == 'T')
|
||||
m_tag->tag_file_pos = -(int32_t)sizeof (ID3_Tag);
|
||||
else
|
||||
m_tag->tag_file_pos = 0;
|
||||
|
||||
m_tag->tag_file_pos -= m_tag->ape_tag_hdr.length + sizeof (APE_Tag_Hdr);
|
||||
m_tag->tag_file_pos -= ape_tag_length + sizeof (APE_Tag_Hdr);
|
||||
wpc->reader->set_pos_rel (wpc->wv_in, m_tag->tag_file_pos, SEEK_END);
|
||||
memset (m_tag->ape_tag_data, 0, m_tag->ape_tag_hdr.length);
|
||||
memset (m_tag->ape_tag_data, 0, ape_tag_length);
|
||||
|
||||
if (wpc->reader->read_bytes (wpc->wv_in, &m_tag->ape_tag_hdr, sizeof (APE_Tag_Hdr)) != sizeof (APE_Tag_Hdr) ||
|
||||
strncmp (m_tag->ape_tag_hdr.ID, "APETAGEX", 8)) {
|
||||
if (wpc->reader->read_bytes (wpc->wv_in, &m_tag->ape_tag_hdr, sizeof (APE_Tag_Hdr)) !=
|
||||
sizeof (APE_Tag_Hdr) || strncmp (m_tag->ape_tag_hdr.ID, "APETAGEX", 8)) {
|
||||
free (m_tag->ape_tag_data);
|
||||
CLEAR (*m_tag);
|
||||
return FALSE; // something's wrong...
|
||||
@@ -2771,16 +2819,15 @@ static int load_tag (WavpackContext *wpc)
|
||||
|
||||
little_endian_to_native (&m_tag->ape_tag_hdr, APE_Tag_Hdr_Format);
|
||||
|
||||
if (m_tag->ape_tag_hdr.version != 2000 || !m_tag->ape_tag_hdr.item_count ||
|
||||
m_tag->ape_tag_hdr.length < sizeof (m_tag->ape_tag_hdr) ||
|
||||
m_tag->ape_tag_hdr.length > (1024 * 1024)) {
|
||||
if (m_tag->ape_tag_hdr.version != 2000 || m_tag->ape_tag_hdr.item_count != ape_tag_items ||
|
||||
m_tag->ape_tag_hdr.length != ape_tag_length) {
|
||||
free (m_tag->ape_tag_data);
|
||||
CLEAR (*m_tag);
|
||||
return FALSE; // something's wrong...
|
||||
}
|
||||
|
||||
if (wpc->reader->read_bytes (wpc->wv_in, m_tag->ape_tag_data, m_tag->ape_tag_hdr.length - sizeof (APE_Tag_Hdr)) !=
|
||||
m_tag->ape_tag_hdr.length - sizeof (APE_Tag_Hdr)) {
|
||||
if (wpc->reader->read_bytes (wpc->wv_in, m_tag->ape_tag_data,
|
||||
ape_tag_length - sizeof (APE_Tag_Hdr)) != ape_tag_length - sizeof (APE_Tag_Hdr)) {
|
||||
free (m_tag->ape_tag_data);
|
||||
CLEAR (*m_tag);
|
||||
return FALSE; // something's wrong...
|
||||
@@ -2867,14 +2914,14 @@ void WavpackNativeToLittleEndian (void *data, char *format)
|
||||
native_to_little_endian (data, format);
|
||||
}
|
||||
|
||||
uint32_t WavpackGetLibraryVersion ()
|
||||
uint32_t WavpackGetLibraryVersion (void)
|
||||
{
|
||||
return (LIBWAVPACK_MAJOR<<16)
|
||||
|(LIBWAVPACK_MINOR<<8)
|
||||
|(LIBWAVPACK_MICRO<<0);
|
||||
}
|
||||
|
||||
const char *WavpackGetLibraryVersionString ()
|
||||
const char *WavpackGetLibraryVersionString (void)
|
||||
{
|
||||
return LIBWAVPACK_VERSION_STRING;
|
||||
}
|
||||
Reference in New Issue
Block a user