mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 06:43:01 +05:00
FLAC support for utracks
This commit is contained in:
parent
c95162ace2
commit
ed410fcea2
34 changed files with 6923 additions and 6 deletions
|
@ -56,7 +56,7 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>winmm.lib;libFLAC_static_d.lib;win_utf8_io_static_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\SilentPatchSA.asi"</Command>
|
||||
|
@ -83,7 +83,7 @@
|
|||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>winmm.lib;libFLAC_static.lib;win_utf8_io_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\SilentPatchSA.asi"</Command>
|
||||
|
@ -91,6 +91,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\SilentPatch\dllmain.cpp" />
|
||||
<ClCompile Include="..\SilentPatch\AudioHardware.cpp" />
|
||||
<ClCompile Include="..\SilentPatch\General.cpp" />
|
||||
<ClCompile Include="..\SilentPatch\ModelInfoSA.cpp" />
|
||||
<ClCompile Include="..\SilentPatch\PNGFile.cpp" />
|
||||
|
@ -114,6 +115,13 @@
|
|||
<None Include="..\SilentPatch\win2000.asm" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\SilentPatch\AudioHardware.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\export.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\format.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\metadata.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\ordinals.h" />
|
||||
<ClInclude Include="..\SilentPatch\FLAC\stream_decoder.h" />
|
||||
<ClInclude Include="..\SilentPatch\General.h" />
|
||||
<ClInclude Include="..\SilentPatch\LinkList.h" />
|
||||
<ClInclude Include="..\SilentPatch\Maths.h" />
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
<Filter Include="Shaders">
|
||||
<UniqueIdentifier>{729e19b1-4747-44c3-b99e-1ecc383d1cad}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\FLAC">
|
||||
<UniqueIdentifier>{57615a2f-8bc4-461f-b9f6-86d5f8286d7a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\SilentPatch\dllmain.cpp">
|
||||
|
@ -39,6 +42,9 @@
|
|||
<ClCompile Include="..\SilentPatch\PNGFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\SilentPatch\AudioHardware.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\SilentPatch\win2000.asm">
|
||||
|
@ -73,6 +79,27 @@
|
|||
<ClInclude Include="..\SilentPatch\PNGFile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\FLAC\callback.h">
|
||||
<Filter>Header Files\FLAC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\FLAC\export.h">
|
||||
<Filter>Header Files\FLAC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\FLAC\format.h">
|
||||
<Filter>Header Files\FLAC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\FLAC\metadata.h">
|
||||
<Filter>Header Files\FLAC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\FLAC\ordinals.h">
|
||||
<Filter>Header Files\FLAC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\FLAC\stream_decoder.h">
|
||||
<Filter>Header Files\FLAC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\SilentPatch\AudioHardware.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\SilentPatch\nvc.fx">
|
||||
|
|
BIN
SAFix/libFLAC_static.lib
Normal file
BIN
SAFix/libFLAC_static.lib
Normal file
Binary file not shown.
BIN
SAFix/libFLAC_static_d.lib
Normal file
BIN
SAFix/libFLAC_static_d.lib
Normal file
Binary file not shown.
BIN
SAFix/win_utf8_io_static.lib
Normal file
BIN
SAFix/win_utf8_io_static.lib
Normal file
Binary file not shown.
BIN
SAFix/win_utf8_io_static_d.lib
Normal file
BIN
SAFix/win_utf8_io_static_d.lib
Normal file
Binary file not shown.
154
SilentPatch/AudioHardware.cpp
Normal file
154
SilentPatch/AudioHardware.cpp
Normal file
|
@ -0,0 +1,154 @@
|
|||
#include "StdAfx.h"
|
||||
#include "AudioHardware.h"
|
||||
|
||||
//WRAPPER HRESULT STDMETHODCALLTYPE CAEDataStream::Seek(LARGE_INTEGER liDistanceToMove, DWORD dwOrigin, ULARGE_INTEGER* lpNewFilePointer)
|
||||
// { EAXJMP(0x4DC340); }
|
||||
//WRAPPER HRESULT STDMETHODCALLTYPE CAEDataStream::Stat(STATSTG* pStatstg, DWORD grfStatFlag) { EAXJMP(0x4DC3A0); }
|
||||
|
||||
//WRAPPER unsigned int CAEDataStream::FillBuffer(void* pBuf, unsigned long nLen) { EAXJMP(0x4DC1C0); }
|
||||
WRAPPER bool CAEDataStream::Initialise() { EAXJMP(0x4DC2B0); }
|
||||
|
||||
FLAC__StreamDecoderReadStatus CAEFLACDecoder::read_cb(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
|
||||
{
|
||||
CAEFLACDecoder* pClientData = static_cast<CAEFLACDecoder*>(client_data);
|
||||
|
||||
ReadFile(pClientData->GetStream()->GetFile(), buffer, *bytes, reinterpret_cast<LPDWORD>(bytes), nullptr); //*bytes = pClientData->GetStream()->FillBuffer(buffer, *bytes);
|
||||
//*bytes = pClientData->GetStream()->FillBuffer(buffer, *bytes);
|
||||
|
||||
FLAC__StreamDecoderReadStatus bResult = *bytes ? FLAC__STREAM_DECODER_READ_STATUS_CONTINUE : FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static FLAC__int32* pMalloc = nullptr;
|
||||
static unsigned int nBlockSize = 0;
|
||||
|
||||
FLAC__StreamDecoderWriteStatus CAEFLACDecoder::write_cb(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
|
||||
{
|
||||
CAEFLACDecoder* pClientData = static_cast<CAEFLACDecoder*>(client_data);
|
||||
|
||||
// Obtain current sample
|
||||
pClientData->nCurrentSample = frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER ?
|
||||
frame->header.number.sample_number :
|
||||
frame->header.number.frame_number * frame->header.blocksize;
|
||||
|
||||
if ( frame->header.blocksize > nBlockSize )
|
||||
{
|
||||
// Realloc needed
|
||||
operator delete(pMalloc);
|
||||
|
||||
pMalloc = static_cast<FLAC__int32*>(operator new(frame->header.blocksize * sizeof(FLAC__int32) * 2)); // TODO: More channels?
|
||||
}
|
||||
nBlockSize = frame->header.blocksize;
|
||||
|
||||
memcpy(pMalloc, buffer[0], nBlockSize * sizeof(FLAC__int32));
|
||||
memcpy(pMalloc+nBlockSize, buffer[1], nBlockSize * sizeof(FLAC__int32));
|
||||
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
void CAEFLACDecoder::meta_cb(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata *metadata, void *client_data)
|
||||
{
|
||||
if ( metadata->type == FLAC__METADATA_TYPE_STREAMINFO )
|
||||
{
|
||||
// Cache the header
|
||||
CAEFLACDecoder* pClientData = static_cast<CAEFLACDecoder*>(client_data);
|
||||
pClientData->pStreamInfo = FLAC__metadata_object_clone(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__StreamDecoderSeekStatus CAEFLACDecoder::seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
{
|
||||
CAEFLACDecoder* pClientData = static_cast<CAEFLACDecoder*>(client_data);
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = absolute_byte_offset;
|
||||
|
||||
li.LowPart = SetFilePointer(pClientData->GetStream()->GetFile(), li.LowPart, &li.HighPart, FILE_BEGIN);
|
||||
|
||||
return li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR ? FLAC__STREAM_DECODER_SEEK_STATUS_ERROR : FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__StreamDecoderTellStatus CAEFLACDecoder::tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
|
||||
{
|
||||
CAEFLACDecoder* pClientData = static_cast<CAEFLACDecoder*>(client_data);
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = 0;
|
||||
|
||||
li.LowPart = SetFilePointer(pClientData->GetStream()->GetFile(), 0, &li.HighPart, FILE_CURRENT);
|
||||
*absolute_byte_offset = li.QuadPart;
|
||||
|
||||
return li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR ? FLAC__STREAM_DECODER_TELL_STATUS_ERROR : FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__StreamDecoderLengthStatus CAEFLACDecoder::length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
|
||||
{
|
||||
CAEFLACDecoder* pClientData = static_cast<CAEFLACDecoder*>(client_data);
|
||||
LARGE_INTEGER li;
|
||||
|
||||
BOOL bResult = GetFileSizeEx(pClientData->GetStream()->GetFile(), &li);
|
||||
*stream_length = li.QuadPart;
|
||||
|
||||
return bResult ? FLAC__STREAM_DECODER_LENGTH_STATUS_OK: FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
FLAC__bool CAEFLACDecoder::eof_cb(const FLAC__StreamDecoder *decoder, void *client_data)
|
||||
{
|
||||
|
||||
// TODO: DO
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAEFLACDecoder::error_cb(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data)
|
||||
{
|
||||
// Not implemented
|
||||
UNREFERENCED_PARAMETER(decoder);
|
||||
UNREFERENCED_PARAMETER(status);
|
||||
UNREFERENCED_PARAMETER(client_data);
|
||||
}
|
||||
|
||||
|
||||
bool CAEFLACDecoder::Initialise()
|
||||
{
|
||||
pFLACDecoder = FLAC__stream_decoder_new();
|
||||
auto result = FLAC__stream_decoder_init_stream(pFLACDecoder, read_cb, seek_cb, tell_cb, length_cb, eof_cb, write_cb, meta_cb, error_cb, this) == FLAC__STREAM_DECODER_INIT_STATUS_OK;
|
||||
|
||||
FLAC__stream_decoder_process_until_end_of_metadata(pFLACDecoder);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#include <cassert>
|
||||
|
||||
unsigned int CAEFLACDecoder::FillBuffer(void* pBuf, unsigned long nLen)
|
||||
{
|
||||
signed int nSigLen = nLen / 4;
|
||||
unsigned int nBytesDecoded = 0;
|
||||
FLAC__int16* pBuffer = static_cast<FLAC__int16*>(pBuf);
|
||||
|
||||
while ( nSigLen > 0 )
|
||||
{
|
||||
FLAC__stream_decoder_process_single(pFLACDecoder);
|
||||
|
||||
FLAC__int32* pCurrentPtr[2];
|
||||
|
||||
pCurrentPtr[0] = pMalloc;
|
||||
pCurrentPtr[1] = pMalloc+nBlockSize;
|
||||
|
||||
// Write channels
|
||||
unsigned int nToWrite = min(nLen / 4, nBlockSize);
|
||||
for ( unsigned int i = 0; i < nToWrite; i++ )
|
||||
{
|
||||
pBuffer[0] = pCurrentPtr[0][i];
|
||||
pBuffer[1] = pCurrentPtr[1][i];
|
||||
|
||||
pBuffer += 2;
|
||||
}
|
||||
|
||||
nSigLen -= nToWrite;
|
||||
nBytesDecoded += nToWrite*4;
|
||||
|
||||
if ( FLAC__stream_decoder_get_state(pFLACDecoder) == FLAC__STREAM_DECODER_END_OF_STREAM )
|
||||
break;
|
||||
}
|
||||
return nSigLen > 0 ? nLen - nBytesDecoded : nLen;
|
||||
}
|
190
SilentPatch/AudioHardware.h
Normal file
190
SilentPatch/AudioHardware.h
Normal file
|
@ -0,0 +1,190 @@
|
|||
#ifndef __AUDIOHARDWARE
|
||||
#define __AUDIOHARDWARE
|
||||
|
||||
// libflac
|
||||
#define FLAC__NO_DLL
|
||||
#include "share\compat.h"
|
||||
#include "FLAC\stream_decoder.h"
|
||||
#include "FLAC\metadata.h"
|
||||
|
||||
// IStream
|
||||
#include <Objidl.h>
|
||||
|
||||
enum eDecoderType
|
||||
{
|
||||
DECODER_NULL,
|
||||
DECODER_VORBIS,
|
||||
DECODER_WAVE,
|
||||
DECODER_WINDOWSMEDIA,
|
||||
DECODER_QUICKTIME,
|
||||
|
||||
// Custom
|
||||
DECODER_FLAC
|
||||
};
|
||||
|
||||
class NOVMT CAEDataStream : public IStream
|
||||
{
|
||||
private:
|
||||
HANDLE hHandle;
|
||||
char* pFilename;
|
||||
bool bOpened;
|
||||
DWORD dwCurrentPosition, dwStartPosition;
|
||||
DWORD dwLength;
|
||||
DWORD dwID;
|
||||
bool bEncrypted;
|
||||
LONG nRefCount;
|
||||
|
||||
public:
|
||||
void operator delete(void* data)
|
||||
{
|
||||
// Call SA operator delete
|
||||
GTAdelete(data);
|
||||
}
|
||||
|
||||
CAEDataStream(DWORD index, char* pName, int startPos, int len, bool encrypted)
|
||||
: pFilename(pName), bOpened(false), dwCurrentPosition(0), dwStartPosition(startPos),
|
||||
dwLength(len), dwID(index), bEncrypted(encrypted), nRefCount(1)
|
||||
{}
|
||||
|
||||
~CAEDataStream()
|
||||
{
|
||||
if ( bOpened )
|
||||
{
|
||||
CloseHandle(hHandle);
|
||||
bOpened = false;
|
||||
}
|
||||
GTAdelete(pFilename);
|
||||
}
|
||||
|
||||
inline DWORD GetID()
|
||||
{ return dwID; }
|
||||
inline HANDLE GetFile()
|
||||
{ return hHandle; }
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject);
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef(void);
|
||||
virtual ULONG STDMETHODCALLTYPE Release(void);
|
||||
|
||||
// ISequentialStream Interface
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead);
|
||||
virtual HRESULT STDMETHODCALLTYPE Write(void const* pv, ULONG cb, ULONG* pcbWritten);
|
||||
|
||||
// IStream Interface
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER);
|
||||
virtual HRESULT STDMETHODCALLTYPE CopyTo(IStream*, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*) ;
|
||||
virtual HRESULT STDMETHODCALLTYPE Commit(DWORD);
|
||||
virtual HRESULT STDMETHODCALLTYPE Revert(void);
|
||||
virtual HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
|
||||
virtual HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
|
||||
virtual HRESULT STDMETHODCALLTYPE Clone(IStream **);
|
||||
virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove, DWORD dwOrigin, ULARGE_INTEGER* lpNewFilePointer);
|
||||
virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag);
|
||||
|
||||
public:
|
||||
// Custom methods
|
||||
//unsigned int FillBuffer(void* pBuf, unsigned long nLen);
|
||||
bool Initialise();
|
||||
};
|
||||
|
||||
|
||||
class CAEStreamingDecoder
|
||||
{
|
||||
private:
|
||||
CAEDataStream* pStream;
|
||||
|
||||
public:
|
||||
CAEStreamingDecoder(CAEDataStream* stream)
|
||||
: pStream(stream)
|
||||
{
|
||||
if ( stream )
|
||||
stream->Initialise();
|
||||
}
|
||||
|
||||
inline CAEDataStream* GetStream()
|
||||
{ return pStream; }
|
||||
|
||||
virtual bool Initialise()=0;
|
||||
virtual unsigned int FillBuffer(void* pBuf,unsigned long nLen)=0;
|
||||
|
||||
virtual unsigned int GetStreamLengthMs()=0;
|
||||
virtual unsigned int GetStreamPlayTimeMs()=0;
|
||||
virtual void SetCursor(unsigned int nTime)=0;
|
||||
virtual unsigned int GetSampleRate()=0;
|
||||
|
||||
virtual ~CAEStreamingDecoder()
|
||||
{
|
||||
GTAdelete(pStream);
|
||||
pStream = nullptr;
|
||||
}
|
||||
|
||||
virtual unsigned int GetStreamID()=0;
|
||||
};
|
||||
|
||||
class CAEFLACDecoder : public CAEStreamingDecoder
|
||||
{
|
||||
private:
|
||||
FLAC__StreamDecoder* pFLACDecoder;
|
||||
FLAC__StreamMetadata* pStreamInfo;
|
||||
unsigned int nCurrentSample;
|
||||
|
||||
private:
|
||||
static FLAC__StreamDecoderReadStatus read_cb(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
|
||||
static FLAC__StreamDecoderWriteStatus write_cb(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data);
|
||||
static void meta_cb(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata *metadata, void *client_data);
|
||||
static void error_cb(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
|
||||
static FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
|
||||
static FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data);
|
||||
|
||||
public:
|
||||
CAEFLACDecoder(CAEDataStream* stream)
|
||||
: CAEStreamingDecoder(stream), pFLACDecoder(nullptr)
|
||||
{}
|
||||
|
||||
virtual ~CAEFLACDecoder()
|
||||
{
|
||||
if ( pFLACDecoder )
|
||||
{
|
||||
FLAC__stream_decoder_finish(pFLACDecoder);
|
||||
FLAC__stream_decoder_delete(pFLACDecoder);
|
||||
|
||||
FLAC__metadata_object_delete(pStreamInfo);
|
||||
pFLACDecoder = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual bool Initialise() override;
|
||||
|
||||
virtual unsigned int FillBuffer(void* pBuf, unsigned long nLen) override;
|
||||
|
||||
virtual unsigned int GetStreamLengthMs() override
|
||||
{
|
||||
return pStreamInfo->data.stream_info.total_samples * 1000 / pStreamInfo->data.stream_info.sample_rate;
|
||||
}
|
||||
|
||||
virtual unsigned int GetStreamPlayTimeMs() override
|
||||
{
|
||||
return nCurrentSample * 1000 / pStreamInfo->data.stream_info.sample_rate;
|
||||
}
|
||||
|
||||
virtual void SetCursor(unsigned int nTime) override
|
||||
{
|
||||
FLAC__stream_decoder_seek_absolute(pFLACDecoder, nTime * pStreamInfo->data.stream_info.sample_rate / 1000);
|
||||
}
|
||||
|
||||
virtual unsigned int GetSampleRate() override
|
||||
{
|
||||
return pStreamInfo->data.stream_info.sample_rate;
|
||||
}
|
||||
|
||||
virtual unsigned int GetStreamID() override
|
||||
{
|
||||
return GetStream()->GetID();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
185
SilentPatch/FLAC/callback.h
Normal file
185
SilentPatch/FLAC/callback.h
Normal file
|
@ -0,0 +1,185 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__CALLBACK_H
|
||||
#define FLAC__CALLBACK_H
|
||||
|
||||
#include "ordinals.h"
|
||||
#include <stdlib.h> /* for size_t */
|
||||
|
||||
/** \file include/FLAC/callback.h
|
||||
*
|
||||
* \brief
|
||||
* This module defines the structures for describing I/O callbacks
|
||||
* to the other FLAC interfaces.
|
||||
*
|
||||
* See the detailed documentation for callbacks in the
|
||||
* \link flac_callbacks callbacks \endlink module.
|
||||
*/
|
||||
|
||||
/** \defgroup flac_callbacks FLAC/callback.h: I/O callback structures
|
||||
* \ingroup flac
|
||||
*
|
||||
* \brief
|
||||
* This module defines the structures for describing I/O callbacks
|
||||
* to the other FLAC interfaces.
|
||||
*
|
||||
* The purpose of the I/O callback functions is to create a common way
|
||||
* for the metadata interfaces to handle I/O.
|
||||
*
|
||||
* Originally the metadata interfaces required filenames as the way of
|
||||
* specifying FLAC files to operate on. This is problematic in some
|
||||
* environments so there is an additional option to specify a set of
|
||||
* callbacks for doing I/O on the FLAC file, instead of the filename.
|
||||
*
|
||||
* In addition to the callbacks, a FLAC__IOHandle type is defined as an
|
||||
* opaque structure for a data source.
|
||||
*
|
||||
* The callback function prototypes are similar (but not identical) to the
|
||||
* stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use
|
||||
* stdio streams to implement the callbacks, you can pass fread, fwrite, and
|
||||
* fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or
|
||||
* FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle
|
||||
* is required. \warning You generally CANNOT directly use fseek or ftell
|
||||
* for FLAC__IOCallback_Seek or FLAC__IOCallback_Tell since on most systems
|
||||
* these use 32-bit offsets and FLAC requires 64-bit offsets to deal with
|
||||
* large files. You will have to find an equivalent function (e.g. ftello),
|
||||
* or write a wrapper. The same is true for feof() since this is usually
|
||||
* implemented as a macro, not as a function whose address can be taken.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This is the opaque handle type used by the callbacks. Typically
|
||||
* this is a \c FILE* or address of a file descriptor.
|
||||
*/
|
||||
typedef void* FLAC__IOHandle;
|
||||
|
||||
/** Signature for the read callback.
|
||||
* The signature and semantics match POSIX fread() implementations
|
||||
* and can generally be used interchangeably.
|
||||
*
|
||||
* \param ptr The address of the read buffer.
|
||||
* \param size The size of the records to be read.
|
||||
* \param nmemb The number of records to be read.
|
||||
* \param handle The handle to the data source.
|
||||
* \retval size_t
|
||||
* The number of records read.
|
||||
*/
|
||||
typedef size_t (*FLAC__IOCallback_Read) (void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
|
||||
|
||||
/** Signature for the write callback.
|
||||
* The signature and semantics match POSIX fwrite() implementations
|
||||
* and can generally be used interchangeably.
|
||||
*
|
||||
* \param ptr The address of the write buffer.
|
||||
* \param size The size of the records to be written.
|
||||
* \param nmemb The number of records to be written.
|
||||
* \param handle The handle to the data source.
|
||||
* \retval size_t
|
||||
* The number of records written.
|
||||
*/
|
||||
typedef size_t (*FLAC__IOCallback_Write) (const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
|
||||
|
||||
/** Signature for the seek callback.
|
||||
* The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT
|
||||
* EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long'
|
||||
* and 32-bits wide.
|
||||
*
|
||||
* \param handle The handle to the data source.
|
||||
* \param offset The new position, relative to \a whence
|
||||
* \param whence \c SEEK_SET, \c SEEK_CUR, or \c SEEK_END
|
||||
* \retval int
|
||||
* \c 0 on success, \c -1 on error.
|
||||
*/
|
||||
typedef int (*FLAC__IOCallback_Seek) (FLAC__IOHandle handle, FLAC__int64 offset, int whence);
|
||||
|
||||
/** Signature for the tell callback.
|
||||
* The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT
|
||||
* EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long'
|
||||
* and 32-bits wide.
|
||||
*
|
||||
* \param handle The handle to the data source.
|
||||
* \retval FLAC__int64
|
||||
* The current position on success, \c -1 on error.
|
||||
*/
|
||||
typedef FLAC__int64 (*FLAC__IOCallback_Tell) (FLAC__IOHandle handle);
|
||||
|
||||
/** Signature for the EOF callback.
|
||||
* The signature and semantics mostly match POSIX feof() but WATCHOUT:
|
||||
* on many systems, feof() is a macro, so in this case a wrapper function
|
||||
* must be provided instead.
|
||||
*
|
||||
* \param handle The handle to the data source.
|
||||
* \retval int
|
||||
* \c 0 if not at end of file, nonzero if at end of file.
|
||||
*/
|
||||
typedef int (*FLAC__IOCallback_Eof) (FLAC__IOHandle handle);
|
||||
|
||||
/** Signature for the close callback.
|
||||
* The signature and semantics match POSIX fclose() implementations
|
||||
* and can generally be used interchangeably.
|
||||
*
|
||||
* \param handle The handle to the data source.
|
||||
* \retval int
|
||||
* \c 0 on success, \c EOF on error.
|
||||
*/
|
||||
typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle);
|
||||
|
||||
/** A structure for holding a set of callbacks.
|
||||
* Each FLAC interface that requires a FLAC__IOCallbacks structure will
|
||||
* describe which of the callbacks are required. The ones that are not
|
||||
* required may be set to NULL.
|
||||
*
|
||||
* If the seek requirement for an interface is optional, you can signify that
|
||||
* a data sorce is not seekable by setting the \a seek field to \c NULL.
|
||||
*/
|
||||
typedef struct {
|
||||
FLAC__IOCallback_Read read;
|
||||
FLAC__IOCallback_Write write;
|
||||
FLAC__IOCallback_Seek seek;
|
||||
FLAC__IOCallback_Tell tell;
|
||||
FLAC__IOCallback_Eof eof;
|
||||
FLAC__IOCallback_Close close;
|
||||
} FLAC__IOCallbacks;
|
||||
|
||||
/* \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
97
SilentPatch/FLAC/export.h
Normal file
97
SilentPatch/FLAC/export.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__EXPORT_H
|
||||
#define FLAC__EXPORT_H
|
||||
|
||||
/** \file include/FLAC/export.h
|
||||
*
|
||||
* \brief
|
||||
* This module contains #defines and symbols for exporting function
|
||||
* calls, and providing version information and compiled-in features.
|
||||
*
|
||||
* See the \link flac_export export \endlink module.
|
||||
*/
|
||||
|
||||
/** \defgroup flac_export FLAC/export.h: export symbols
|
||||
* \ingroup flac
|
||||
*
|
||||
* \brief
|
||||
* This module contains #defines and symbols for exporting function
|
||||
* calls, and providing version information and compiled-in features.
|
||||
*
|
||||
* If you are compiling with MSVC and will link to the static library
|
||||
* (libFLAC.lib) you should define FLAC__NO_DLL in your project to
|
||||
* make sure the symbols are exported properly.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
|
||||
#if defined(FLAC__NO_DLL)
|
||||
#define FLAC_API
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
#ifdef FLAC_API_EXPORTS
|
||||
#define FLAC_API _declspec(dllexport)
|
||||
#else
|
||||
#define FLAC_API _declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#elif defined(FLAC__USE_VISIBILITY_ATTR)
|
||||
#define FLAC_API __attribute__ ((visibility ("default")))
|
||||
|
||||
#else
|
||||
#define FLAC_API
|
||||
|
||||
#endif
|
||||
|
||||
/** These #defines will mirror the libtool-based library version number, see
|
||||
* http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
|
||||
*/
|
||||
#define FLAC_API_VERSION_CURRENT 11
|
||||
#define FLAC_API_VERSION_REVISION 0 /**< see above */
|
||||
#define FLAC_API_VERSION_AGE 3 /**< see above */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */
|
||||
extern FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* \} */
|
||||
|
||||
#endif
|
1025
SilentPatch/FLAC/format.h
Normal file
1025
SilentPatch/FLAC/format.h
Normal file
File diff suppressed because it is too large
Load diff
2182
SilentPatch/FLAC/metadata.h
Normal file
2182
SilentPatch/FLAC/metadata.h
Normal file
File diff suppressed because it is too large
Load diff
86
SilentPatch/FLAC/ordinals.h
Normal file
86
SilentPatch/FLAC/ordinals.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__ORDINALS_H
|
||||
#define FLAC__ORDINALS_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
|
||||
/* Microsoft Visual Studio earlier than the 2010 version did not provide
|
||||
* the 1999 ISO C Standard header file <stdint.h>.
|
||||
*/
|
||||
|
||||
typedef __int8 FLAC__int8;
|
||||
typedef unsigned __int8 FLAC__uint8;
|
||||
|
||||
typedef __int16 FLAC__int16;
|
||||
typedef __int32 FLAC__int32;
|
||||
typedef __int64 FLAC__int64;
|
||||
typedef unsigned __int16 FLAC__uint16;
|
||||
typedef unsigned __int32 FLAC__uint32;
|
||||
typedef unsigned __int64 FLAC__uint64;
|
||||
|
||||
#else
|
||||
|
||||
/* For MSVC 2010 and everything else which provides <stdint.h>. */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int8_t FLAC__int8;
|
||||
typedef uint8_t FLAC__uint8;
|
||||
|
||||
typedef int16_t FLAC__int16;
|
||||
typedef int32_t FLAC__int32;
|
||||
typedef int64_t FLAC__int64;
|
||||
typedef uint16_t FLAC__uint16;
|
||||
typedef uint32_t FLAC__uint32;
|
||||
typedef uint64_t FLAC__uint64;
|
||||
|
||||
#endif
|
||||
|
||||
typedef int FLAC__bool;
|
||||
|
||||
typedef FLAC__uint8 FLAC__byte;
|
||||
|
||||
|
||||
#ifdef true
|
||||
#undef true
|
||||
#endif
|
||||
#ifdef false
|
||||
#undef false
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#endif
|
1560
SilentPatch/FLAC/stream_decoder.h
Normal file
1560
SilentPatch/FLAC/stream_decoder.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,4 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "General.h"
|
||||
|
||||
// Wrappers
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#define WINVER 0x0501
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#define WINVER 0x0500
|
||||
#define _WIN32_WINNT 0x0500
|
||||
|
||||
#include <windows.h>
|
||||
#include <limits>
|
||||
|
@ -25,6 +25,9 @@
|
|||
#include "MemoryMgr.h"
|
||||
#include "Maths.h"
|
||||
|
||||
// SA operator delete
|
||||
void GTAdelete(void* data);
|
||||
|
||||
//#define HIDE_MATERIAL
|
||||
//#define EXPAND_ALPHA_ENTITY_LISTS 800
|
||||
//#define EXPAND_BOAT_ALPHA_ATOMIC_LISTS 400
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Vehicle.h"
|
||||
#include "LinkList.h"
|
||||
#include "ModelInfoSA.h"
|
||||
#include "AudioHardware.h"
|
||||
|
||||
struct RsGlobalType
|
||||
{
|
||||
|
@ -1770,6 +1771,93 @@ void __declspec(naked) UserTracksFix()
|
|||
}
|
||||
}
|
||||
|
||||
static CAEFLACDecoder* __stdcall DecoderCtor(CAEDataStream* pData)
|
||||
{
|
||||
return new CAEFLACDecoder(pData);
|
||||
}
|
||||
|
||||
static void __stdcall StreamDtor(CAEDataStream* pData)
|
||||
{
|
||||
delete pData;
|
||||
}
|
||||
|
||||
void __declspec(naked) LoadFLAC()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
jz LoadFLAC_WindowsMedia
|
||||
sub ebp, 2
|
||||
jnz LoadFLAC_Return
|
||||
//push SIZE CAEStreamingDecoder
|
||||
//call malloc // TODO: operator new
|
||||
//mov [esp+20h+4], eax
|
||||
//test eax, eax
|
||||
//jz LoadFLAC_AllocFailed
|
||||
push esi
|
||||
//mov ecx, eax
|
||||
//call CAEFLACDecoder::CAEFLACDecoder
|
||||
call DecoderCtor
|
||||
jmp LoadFLAC_Success
|
||||
|
||||
LoadFLAC_WindowsMedia:
|
||||
mov eax, 4F3743h
|
||||
jmp eax
|
||||
|
||||
//LoadFLAC_AllocFailed:
|
||||
//xor eax, eax
|
||||
|
||||
LoadFLAC_Success:
|
||||
test eax, eax
|
||||
mov [esp+20h+4], eax
|
||||
jnz LoadFLAC_Return_NoDelete
|
||||
|
||||
LoadFLAC_Return:
|
||||
push esi
|
||||
//mov ecx, esi
|
||||
call StreamDtor
|
||||
//call CAEDataStream::~CAEDataStream
|
||||
//push esi
|
||||
//call free // TODO: operator delete
|
||||
//add esp, 4
|
||||
|
||||
LoadFLAC_Return_NoDelete:
|
||||
mov eax, [esp+20h+4]
|
||||
mov ecx, [esp+20h-0Ch]
|
||||
pop esi
|
||||
pop ebp
|
||||
pop edi
|
||||
pop ebx
|
||||
mov fs:0, ecx
|
||||
add esp, 10h
|
||||
retn 4
|
||||
}
|
||||
}
|
||||
|
||||
static struct
|
||||
{
|
||||
char Extension[8];
|
||||
unsigned int Codec;
|
||||
} UserTrackExtensions[] = { { ".ogg", DECODER_VORBIS }, { ".mp3", DECODER_QUICKTIME },
|
||||
{ ".wav", DECODER_WAVE }, { ".wma", DECODER_WINDOWSMEDIA },
|
||||
{ ".wmv", DECODER_WINDOWSMEDIA }, { ".aac", DECODER_QUICKTIME },
|
||||
{ ".m4a", DECODER_QUICKTIME }, { ".mov", DECODER_QUICKTIME },
|
||||
{ ".fla", DECODER_FLAC }, { ".flac", DECODER_FLAC } };
|
||||
|
||||
void __declspec(naked) FLACInit()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov al, 1
|
||||
mov [esi+0Dh], al
|
||||
pop esi
|
||||
jnz FLACInit_DontFallBack
|
||||
mov UserTrackExtensions+12.Codec, DECODER_WINDOWSMEDIA
|
||||
|
||||
FLACInit_DontFallBack:
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
__forceinline void Patch_SA_10()
|
||||
{
|
||||
using namespace MemoryVP;
|
||||
|
@ -1941,6 +2029,15 @@ __forceinline void Patch_SA_10()
|
|||
InjectHook(0x4D9BB5, 0x4F2FD0);
|
||||
//Nop(0x4D9BB5, 5);
|
||||
|
||||
// FLAC support
|
||||
InjectHook(0x4F373D, LoadFLAC, PATCH_JUMP);
|
||||
InjectHook(0x4F35E0, FLACInit, PATCH_JUMP);
|
||||
|
||||
Patch<const void*>(0x4F3210, UserTrackExtensions);
|
||||
Patch<const void*>(0x4F3241, &UserTrackExtensions->Codec);
|
||||
//Patch<const void*>(0x4F35E7, &UserTrackExtensions[1].Codec);
|
||||
Patch<BYTE>(0x4F322D, sizeof(UserTrackExtensions));
|
||||
|
||||
// Fixed police scanner names
|
||||
char* pScannerNames = *(char**)0x4E72D4;
|
||||
strncpy(pScannerNames + (8*113), "WESTP", 8);
|
||||
|
@ -1989,4 +2086,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
RwD3D9DeleteVertexShader(pNVCShader);
|
||||
}*/
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
WRAPPER void GTAdelete(void* data) { EAXJMP(0x82413F); }
|
209
SilentPatch/share/alloc.h
Normal file
209
SilentPatch/share/alloc.h
Normal file
|
@ -0,0 +1,209 @@
|
|||
/* alloc - Convenience routines for safely allocating memory
|
||||
* Copyright (C) 2007-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__SHARE__ALLOC_H
|
||||
#define FLAC__SHARE__ALLOC_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early
|
||||
* before #including this file, otherwise SIZE_MAX might not be defined
|
||||
*/
|
||||
|
||||
#include <limits.h> /* for SIZE_MAX */
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
|
||||
#endif
|
||||
#include <stdlib.h> /* for size_t, malloc(), etc */
|
||||
#include "share/compat.h"
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# ifndef SIZE_T_MAX
|
||||
# ifdef _MSC_VER
|
||||
# ifdef _WIN64
|
||||
# define SIZE_T_MAX 0xffffffffffffffffui64
|
||||
# else
|
||||
# define SIZE_T_MAX 0xffffffff
|
||||
# endif
|
||||
# else
|
||||
# error
|
||||
# endif
|
||||
# endif
|
||||
# define SIZE_MAX SIZE_T_MAX
|
||||
#endif
|
||||
|
||||
/* avoid malloc()ing 0 bytes, see:
|
||||
* https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003
|
||||
*/
|
||||
static inline void *safe_malloc_(size_t size)
|
||||
{
|
||||
/* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
if(!size)
|
||||
size++;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static inline void *safe_calloc_(size_t nmemb, size_t size)
|
||||
{
|
||||
if(!nmemb || !size)
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
|
||||
/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */
|
||||
|
||||
static inline void *safe_malloc_add_2op_(size_t size1, size_t size2)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
return safe_malloc_(size2);
|
||||
}
|
||||
|
||||
static inline void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
return safe_malloc_(size3);
|
||||
}
|
||||
|
||||
static inline void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
size4 += size3;
|
||||
if(size4 < size3)
|
||||
return 0;
|
||||
return safe_malloc_(size4);
|
||||
}
|
||||
|
||||
void *safe_malloc_mul_2op_(size_t size1, size_t size2) ;
|
||||
|
||||
static inline void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || !size2 || !size3)
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
size1 *= size2;
|
||||
if(size1 > SIZE_MAX / size3)
|
||||
return 0;
|
||||
return malloc(size1*size3);
|
||||
}
|
||||
|
||||
/* size1*size2 + size3 */
|
||||
static inline void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || !size2)
|
||||
return safe_malloc_(size3);
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return safe_malloc_add_2op_(size1*size2, size3);
|
||||
}
|
||||
|
||||
/* size1 * (size2 + size3) */
|
||||
static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || (!size2 && !size3))
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
size2 += size3;
|
||||
if(size2 < size3)
|
||||
return 0;
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return malloc(size1*size2);
|
||||
}
|
||||
|
||||
static inline void *safe_realloc_add_2op_(void *ptr, size_t size1, size_t size2)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
return realloc(ptr, size2);
|
||||
}
|
||||
|
||||
static inline void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
return realloc(ptr, size3);
|
||||
}
|
||||
|
||||
static inline void *safe_realloc_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
size4 += size3;
|
||||
if(size4 < size3)
|
||||
return 0;
|
||||
return realloc(ptr, size4);
|
||||
}
|
||||
|
||||
static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
|
||||
{
|
||||
if(!size1 || !size2)
|
||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return realloc(ptr, size1*size2);
|
||||
}
|
||||
|
||||
/* size1 * (size2 + size3) */
|
||||
static inline void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || (!size2 && !size3))
|
||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
||||
size2 += size3;
|
||||
if(size2 < size3)
|
||||
return 0;
|
||||
return safe_realloc_mul_2op_(ptr, size1, size2);
|
||||
}
|
||||
|
||||
#endif
|
199
SilentPatch/share/compat.h
Normal file
199
SilentPatch/share/compat.h
Normal file
|
@ -0,0 +1,199 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2012 Xiph.org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/* This is the prefered location of all CPP hackery to make $random_compiler
|
||||
* work like something approaching a C99 (or maybe more accurately GNU99)
|
||||
* compiler.
|
||||
*
|
||||
* It is assumed that this header will be included after "config.h".
|
||||
*/
|
||||
|
||||
#ifndef FLAC__SHARE__COMPAT_H
|
||||
#define FLAC__SHARE__COMPAT_H
|
||||
|
||||
#if defined _WIN32 && !defined __CYGWIN__
|
||||
/* where MSVC puts unlink() */
|
||||
# include <io.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
|
||||
#include <sys/types.h> /* for off_t */
|
||||
#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */
|
||||
#if !defined __MINGW32__
|
||||
#define fseeko _fseeki64
|
||||
#define ftello _ftelli64
|
||||
#else /* MinGW */
|
||||
#if !defined(HAVE_FSEEKO)
|
||||
#define fseeko fseeko64
|
||||
#define ftello ftello64
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define FLAC__off_t off_t
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define strtoll _strtoi64
|
||||
#define strtoull _strtoui64
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64)
|
||||
/* MSVS generates VERY slow 32-bit code with __restrict */
|
||||
#define flac_restrict __restrict
|
||||
#elif defined __GNUC__
|
||||
#define flac_restrict __restrict__
|
||||
#else
|
||||
#define flac_restrict
|
||||
#endif
|
||||
|
||||
#define FLAC__U64L(x) x##ULL
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
|
||||
#define FLAC__STRCASECMP stricmp
|
||||
#define FLAC__STRNCASECMP strnicmp
|
||||
#else
|
||||
#define FLAC__STRCASECMP strcasecmp
|
||||
#define FLAC__STRNCASECMP strncasecmp
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ || defined __EMX__
|
||||
#include <io.h> /* for _setmode(), chmod() */
|
||||
#include <fcntl.h> /* for _O_BINARY */
|
||||
#else
|
||||
#include <unistd.h> /* for chown(), unlink() */
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
|
||||
#if defined __BORLANDC__
|
||||
#include <utime.h> /* for utime() */
|
||||
#else
|
||||
#include <sys/utime.h> /* for utime() */
|
||||
#endif
|
||||
#else
|
||||
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
|
||||
#include <utime.h> /* for utime() */
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER
|
||||
# if _MSC_VER >= 1600
|
||||
/* Visual Studio 2010 has decent C99 support */
|
||||
# include <stdint.h>
|
||||
# define PRIu64 "llu"
|
||||
# define PRId64 "lld"
|
||||
# define PRIx64 "llx"
|
||||
# else
|
||||
# include <limits.h>
|
||||
# ifndef UINT32_MAX
|
||||
# define UINT32_MAX _UI32_MAX
|
||||
# endif
|
||||
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;
|
||||
# define PRIu64 "I64u"
|
||||
# define PRId64 "I64d"
|
||||
# define PRIx64 "I64x"
|
||||
# endif
|
||||
#endif /* defined _MSC_VER */
|
||||
|
||||
#ifdef _WIN32
|
||||
/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */
|
||||
#include "share/win_utf8_io.h"
|
||||
|
||||
#define flac_printf printf_utf8
|
||||
#define flac_fprintf fprintf_utf8
|
||||
#define flac_vfprintf vfprintf_utf8
|
||||
#define flac_fopen fopen_utf8
|
||||
#define flac_chmod chmod_utf8
|
||||
#define flac_utime utime_utf8
|
||||
#define flac_unlink unlink_utf8
|
||||
#define flac_rename rename_utf8
|
||||
#define flac_stat _stat64_utf8
|
||||
|
||||
#else
|
||||
|
||||
#define flac_printf printf
|
||||
#define flac_fprintf fprintf
|
||||
#define flac_vfprintf vfprintf
|
||||
#define flac_fopen fopen
|
||||
#define flac_chmod chmod
|
||||
#define flac_utime utime
|
||||
#define flac_unlink unlink
|
||||
#define flac_rename rename
|
||||
#define flac_stat stat
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define flac_stat_s __stat64 /* stat struct */
|
||||
#define flac_fstat _fstat64
|
||||
#else
|
||||
#define flac_stat_s stat /* stat struct */
|
||||
#define flac_fstat fstat
|
||||
#endif
|
||||
|
||||
#ifndef M_LN2
|
||||
#define M_LN2 0.69314718055994530942
|
||||
#endif
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
/* FLAC needs to compile and work correctly on systems with a normal ISO C99
|
||||
* snprintf as well as Microsoft Visual Studio which has an non-standards
|
||||
* conformant snprint_s function.
|
||||
*
|
||||
* This function wraps the MS version to behave more like the the ISO version.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int flac_snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* FLAC__SHARE__COMPAT_H */
|
53
SilentPatch/share/endswap.h
Normal file
53
SilentPatch/share/endswap.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2012 Xiph.org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/* It is assumed that this header will be included after "config.h". */
|
||||
|
||||
#if HAVE_BSWAP32 /* GCC and Clang */
|
||||
|
||||
#define ENDSWAP_32(x) (__builtin_bswap32 (x))
|
||||
|
||||
#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
|
||||
|
||||
#define ENDSWAP_32(x) (_byteswap_ulong (x))
|
||||
|
||||
#elif defined HAVE_BYTESWAP_H /* Linux */
|
||||
|
||||
#include <byteswap.h>
|
||||
|
||||
#define ENDSWAP_32(x) (bswap_32 (x))
|
||||
|
||||
#else
|
||||
|
||||
#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + (((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24))
|
||||
|
||||
#endif
|
||||
|
184
SilentPatch/share/getopt.h
Normal file
184
SilentPatch/share/getopt.h
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
NOTE:
|
||||
I cannot get the vanilla getopt code to work (i.e. compile only what
|
||||
is needed and not duplicate symbols found in the standard library)
|
||||
on all the platforms that FLAC supports. In particular the gating
|
||||
of code with the ELIDE_CODE #define is not accurate enough on systems
|
||||
that are POSIX but not glibc. If someone has a patch that works on
|
||||
GNU/Linux, Darwin, AND Solaris please submit it on the project page:
|
||||
http://sourceforge.net/projects/flac
|
||||
|
||||
In the meantime I have munged the global symbols and removed gates
|
||||
around code, while at the same time trying to touch the original as
|
||||
little as possible.
|
||||
*/
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef SHARE__GETOPT_H
|
||||
#define SHARE__GETOPT_H
|
||||
|
||||
/*[JEC] was:#ifndef __need_getopt*/
|
||||
/*[JEC] was:# define _GETOPT_H 1*/
|
||||
/*[JEC] was:#endif*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `share__getopt' to the caller.
|
||||
When `share__getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *share__optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `share__getopt'.
|
||||
|
||||
On entry to `share__getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `share__getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `share__optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int share__optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `share__getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int share__opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int share__optopt;
|
||||
|
||||
/*[JEC] was:#ifndef __need_getopt */
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector
|
||||
of `struct share__option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
share__no_argument (or 0) if the option does not take an argument,
|
||||
share__required_argument (or 1) if the option requires an argument,
|
||||
share__optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `share__optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `share__getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct share__option
|
||||
{
|
||||
# if defined __STDC__ && __STDC__
|
||||
const char *name;
|
||||
# else
|
||||
char *name;
|
||||
# endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct share__option'. */
|
||||
|
||||
# define share__no_argument 0
|
||||
# define share__required_argument 1
|
||||
# define share__optional_argument 2
|
||||
/*[JEC] was:#endif*/ /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `share__optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `share__optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `share__getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `share__getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `--', then non-option arguments are treated as
|
||||
arguments to the option '\0'. This behavior is specific to the GNU
|
||||
`share__getopt'. */
|
||||
|
||||
/*[JEC] was:#if defined __STDC__ && __STDC__*/
|
||||
/*[JEC] was:# ifdef __GNU_LIBRARY__*/
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int share__getopt (int argc, char *const *argv, const char *shortopts);
|
||||
/*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
|
||||
/*[JEC] was:extern int getopt ();*/
|
||||
/*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
|
||||
|
||||
/*[JEC] was:# ifndef __need_getopt*/
|
||||
extern int share__getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct share__option *longopts, int *longind);
|
||||
extern int share__getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct share__option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int share___getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct share__option *longopts, int *longind,
|
||||
int long_only);
|
||||
/*[JEC] was:# endif*/
|
||||
/*[JEC] was:#else*/ /* not __STDC__ */
|
||||
/*[JEC] was:extern int getopt ();*/
|
||||
/*[JEC] was:# ifndef __need_getopt*/
|
||||
/*[JEC] was:extern int getopt_long ();*/
|
||||
/*[JEC] was:extern int getopt_long_only ();*/
|
||||
|
||||
/*[JEC] was:extern int _getopt_internal ();*/
|
||||
/*[JEC] was:# endif*/
|
||||
/*[JEC] was:#endif*/ /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
/*[JEC] was:#undef __need_getopt*/
|
||||
|
||||
#endif /* getopt.h */
|
30
SilentPatch/share/grabbag.h
Normal file
30
SilentPatch/share/grabbag.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* grabbag - Convenience lib for various routines common to several tools
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef SHARE__GRABBAG_H
|
||||
#define SHARE__GRABBAG_H
|
||||
|
||||
/* These can't be included by themselves, only from within grabbag.h */
|
||||
#include "grabbag/cuesheet.h"
|
||||
#include "grabbag/file.h"
|
||||
#include "grabbag/picture.h"
|
||||
#include "grabbag/replaygain.h"
|
||||
#include "grabbag/seektable.h"
|
||||
|
||||
#endif
|
43
SilentPatch/share/grabbag/cuesheet.h
Normal file
43
SilentPatch/share/grabbag/cuesheet.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* grabbag - Convenience lib for various routines common to several tools
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
||||
|
||||
#ifndef GRABBAG__CUESHEET_H
|
||||
#define GRABBAG__CUESHEET_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "FLAC/metadata.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned grabbag__cuesheet_msf_to_frame(unsigned minutes, unsigned seconds, unsigned frames);
|
||||
void grabbag__cuesheet_frame_to_msf(unsigned frame, unsigned *minutes, unsigned *seconds, unsigned *frames);
|
||||
|
||||
FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
|
||||
|
||||
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
65
SilentPatch/share/grabbag/file.h
Normal file
65
SilentPatch/share/grabbag/file.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* grabbag - Convenience lib for various routines common to several tools
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* Convenience routines for manipulating files */
|
||||
|
||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
||||
|
||||
#ifndef GRABAG__FILE_H
|
||||
#define GRABAG__FILE_H
|
||||
|
||||
/* needed because of off_t */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h> /* for off_t */
|
||||
#include <stdio.h> /* for FILE */
|
||||
#include "FLAC/ordinals.h"
|
||||
#include "share/compat.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void grabbag__file_copy_metadata(const char *srcpath, const char *destpath);
|
||||
FLAC__off_t grabbag__file_get_filesize(const char *srcpath);
|
||||
const char *grabbag__file_get_basename(const char *srcpath);
|
||||
|
||||
/* read_only == false means "make file writable by user"
|
||||
* read_only == true means "make file read-only for everyone"
|
||||
*/
|
||||
FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only);
|
||||
|
||||
/* returns true iff stat() succeeds for both files and they have the same device and inode. */
|
||||
/* on windows, uses GetFileInformationByHandle() to compare */
|
||||
FLAC__bool grabbag__file_are_same(const char *f1, const char *f2);
|
||||
|
||||
/* attempts to make writable before unlinking */
|
||||
FLAC__bool grabbag__file_remove_file(const char *filename);
|
||||
|
||||
/* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */
|
||||
FILE *grabbag__file_get_binary_stdin(void);
|
||||
FILE *grabbag__file_get_binary_stdout(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
47
SilentPatch/share/grabbag/picture.h
Normal file
47
SilentPatch/share/grabbag/picture.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* grabbag - Convenience lib for various routines common to several tools
|
||||
* Copyright (C) 2006-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
||||
|
||||
#ifndef GRABBAG__PICTURE_H
|
||||
#define GRABBAG__PICTURE_H
|
||||
|
||||
#include "FLAC/metadata.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* spec should be of the form "[TYPE]|MIME_TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE", e.g.
|
||||
* "|image/jpeg|||cover.jpg"
|
||||
* "4|image/jpeg||300x300x24|backcover.jpg"
|
||||
* "|image/png|description|300x300x24/71|cover.png"
|
||||
* "-->|image/gif||300x300x24/71|http://blah.blah.blah/cover.gif"
|
||||
*
|
||||
* empty type means default to FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER
|
||||
* empty resolution spec means to get from the file (cannot get used with "-->" linked images)
|
||||
* spec and error_message must not be NULL
|
||||
*/
|
||||
FLAC__StreamMetadata *grabbag__picture_parse_specification(const char *spec, const char **error_message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
73
SilentPatch/share/grabbag/replaygain.h
Normal file
73
SilentPatch/share/grabbag/replaygain.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* grabbag - Convenience lib for various routines common to several tools
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* This wraps the replaygain_analysis lib, which is LGPL. This wrapper
|
||||
* allows analysis of different input resolutions by automatically
|
||||
* scaling the input signal
|
||||
*/
|
||||
|
||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
||||
|
||||
#ifndef GRABBAG__REPLAYGAIN_H
|
||||
#define GRABBAG__REPLAYGAIN_H
|
||||
|
||||
#include "FLAC/metadata.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const unsigned GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED;
|
||||
|
||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS; /* = "REPLAYGAIN_REFERENCE_LOUDNESS" */
|
||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN; /* = "REPLAYGAIN_TRACK_GAIN" */
|
||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK; /* = "REPLAYGAIN_TRACK_PEAK" */
|
||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN; /* = "REPLAYGAIN_ALBUM_GAIN" */
|
||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK; /* = "REPLAYGAIN_ALBUM_PEAK" */
|
||||
|
||||
FLAC__bool grabbag__replaygain_is_valid_sample_frequency(unsigned sample_frequency);
|
||||
|
||||
FLAC__bool grabbag__replaygain_init(unsigned sample_frequency);
|
||||
|
||||
/* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */
|
||||
FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, unsigned bps, unsigned samples);
|
||||
|
||||
void grabbag__replaygain_get_album(float *gain, float *peak);
|
||||
void grabbag__replaygain_get_title(float *gain, float *peak);
|
||||
|
||||
/* These three functions return an error string on error, or NULL if successful */
|
||||
const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak);
|
||||
const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak);
|
||||
const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block);
|
||||
const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak);
|
||||
const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak);
|
||||
const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime);
|
||||
const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime);
|
||||
const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime);
|
||||
const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime);
|
||||
|
||||
FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak);
|
||||
double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
39
SilentPatch/share/grabbag/seektable.h
Normal file
39
SilentPatch/share/grabbag/seektable.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* grabbag - Convenience lib for various routines common to several tools
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* Convenience routines for working with seek tables */
|
||||
|
||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
||||
|
||||
#ifndef GRABAG__SEEKTABLE_H
|
||||
#define GRABAG__SEEKTABLE_H
|
||||
|
||||
#include "FLAC/format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, unsigned sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
41
SilentPatch/share/macros.h
Normal file
41
SilentPatch/share/macros.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013 Xiph.org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* FLAC_CHECK_RETURN : Check the return value of of the provided function and
|
||||
* print and error message if it fails (ie returns a value < 0).
|
||||
*/
|
||||
|
||||
#define FLAC_CHECK_RETURN(x) \
|
||||
{ if ((x) < 0) \
|
||||
printf ("%s : %s\n", #x, strerror (errno)) ; \
|
||||
}
|
45
SilentPatch/share/private.h
Normal file
45
SilentPatch/share/private.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013 Xiph.org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__SHARE__PRIVATE_H
|
||||
#define FLAC__SHARE__PRIVATE_H
|
||||
|
||||
/*
|
||||
* Unpublished debug routines from libFLAC> This should not be used from any
|
||||
* client code other than code shipped with the FLAC sources.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
#endif /* FLAC__SHARE__PRIVATE_H */
|
59
SilentPatch/share/replaygain_analysis.h
Normal file
59
SilentPatch/share/replaygain_analysis.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* ReplayGainAnalysis - analyzes input samples and give the recommended dB change
|
||||
* Copyright (C) 2001 David Robinson and Glen Sawyer
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* concept and filter values by David Robinson (David@Robinson.org)
|
||||
* -- blame him if you think the idea is flawed
|
||||
* coding by Glen Sawyer (glensawyer@hotmail.com) 442 N 700 E, Provo, UT 84606 USA
|
||||
* -- blame him if you think this runs too slowly, or the coding is otherwise flawed
|
||||
* minor cosmetic tweaks to integrate with FLAC by Josh Coalson
|
||||
*
|
||||
* For an explanation of the concepts and the basic algorithms involved, go to:
|
||||
* http://www.replaygain.org/
|
||||
*/
|
||||
|
||||
#ifndef GAIN_ANALYSIS_H
|
||||
#define GAIN_ANALYSIS_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define GAIN_NOT_ENOUGH_SAMPLES -24601
|
||||
#define GAIN_ANALYSIS_ERROR 0
|
||||
#define GAIN_ANALYSIS_OK 1
|
||||
|
||||
#define INIT_GAIN_ANALYSIS_ERROR 0
|
||||
#define INIT_GAIN_ANALYSIS_OK 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef float Float_t; /* Type used for filtering */
|
||||
|
||||
extern Float_t ReplayGainReferenceLoudness; /* in dB SPL, currently == 89.0 */
|
||||
|
||||
int InitGainAnalysis ( long samplefreq );
|
||||
int ValidGainFrequency ( long samplefreq );
|
||||
int AnalyzeSamples ( const Float_t* left_samples, const Float_t* right_samples, size_t num_samples, int num_channels );
|
||||
Float_t GetTitleGain ( void );
|
||||
Float_t GetAlbumGain ( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GAIN_ANALYSIS_H */
|
52
SilentPatch/share/replaygain_synthesis.h
Normal file
52
SilentPatch/share/replaygain_synthesis.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* replaygain_synthesis - Routines for applying ReplayGain to a signal
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2013 Xiph.Org Foundation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
|
||||
#define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
|
||||
|
||||
#include <stdlib.h> /* for size_t */
|
||||
#include "FLAC/format.h"
|
||||
|
||||
#define FLAC_SHARE__MAX_SUPPORTED_CHANNELS FLAC__MAX_CHANNELS
|
||||
|
||||
typedef enum {
|
||||
NOISE_SHAPING_NONE = 0,
|
||||
NOISE_SHAPING_LOW = 1,
|
||||
NOISE_SHAPING_MEDIUM = 2,
|
||||
NOISE_SHAPING_HIGH = 3
|
||||
} NoiseShaping;
|
||||
|
||||
typedef struct {
|
||||
const float* FilterCoeff;
|
||||
FLAC__uint64 Mask;
|
||||
double Add;
|
||||
float Dither;
|
||||
float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */
|
||||
float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16];
|
||||
int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS];
|
||||
unsigned LastHistoryIndex;
|
||||
NoiseShaping ShapingType;
|
||||
} DitherContext;
|
||||
|
||||
void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype);
|
||||
|
||||
/* scale = (float) pow(10., (double)replaygain * 0.05); */
|
||||
size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, const unsigned source_bps, const unsigned target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context);
|
||||
|
||||
#endif
|
69
SilentPatch/share/safe_str.h
Normal file
69
SilentPatch/share/safe_str.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013 Xiph.org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/* Safe string handling functions to replace things like strcpy, strncpy,
|
||||
* strcat, strncat etc.
|
||||
* All of these functions guarantee a correctly NUL terminated string but
|
||||
* the string may be truncated if the destination buffer was too short.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__SHARE_SAFE_STR_H
|
||||
#define FLAC__SHARE_SAFE_STR_H
|
||||
|
||||
static inline char *
|
||||
safe_strncat(char *dest, const char *src, size_t dest_size)
|
||||
{
|
||||
char * ret;
|
||||
|
||||
if (dest_size < 1)
|
||||
return dest;
|
||||
|
||||
ret = strncat(dest, src, dest_size - strlen (dest));
|
||||
dest [dest_size - 1] = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
safe_strncpy(char *dest, const char *src, size_t dest_size)
|
||||
{
|
||||
char * ret;
|
||||
|
||||
if (dest_size < 1)
|
||||
return dest;
|
||||
|
||||
ret = strncpy(dest, src, dest_size);
|
||||
dest [dest_size - 1] = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* FLAC__SHARE_SAFE_STR_H */
|
25
SilentPatch/share/utf8.h
Normal file
25
SilentPatch/share/utf8.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef SHARE__UTF8_H
|
||||
#define SHARE__UTF8_H
|
||||
|
||||
/*
|
||||
* Convert a string between UTF-8 and the locale's charset.
|
||||
* Invalid bytes are replaced by '#', and characters that are
|
||||
* not available in the target encoding are replaced by '?'.
|
||||
*
|
||||
* If the locale's charset is not set explicitly then it is
|
||||
* obtained using nl_langinfo(CODESET), where available, the
|
||||
* environment variable CHARSET, or assumed to be US-ASCII.
|
||||
*
|
||||
* Return value of conversion functions:
|
||||
*
|
||||
* -1 : memory allocation failed
|
||||
* 0 : data was converted exactly
|
||||
* 1 : valid data was converted approximately (using '?')
|
||||
* 2 : input was invalid (but still converted, using '#')
|
||||
* 3 : unknown encoding (but still converted, using '?')
|
||||
*/
|
||||
|
||||
int utf8_encode(const char *from, char **to);
|
||||
int utf8_decode(const char *from, char **to);
|
||||
|
||||
#endif
|
69
SilentPatch/share/win_utf8_io.h
Normal file
69
SilentPatch/share/win_utf8_io.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013 Xiph.Org Foundation
|
||||
*
|
||||
* 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 the Xiph.org Foundation 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifndef flac__win_utf8_io_h
|
||||
#define flac__win_utf8_io_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
#include <windows.h>
|
||||
|
||||
int get_utf8_argv(int *argc, char ***argv);
|
||||
|
||||
int printf_utf8(const char *format, ...);
|
||||
int fprintf_utf8(FILE *stream, const char *format, ...);
|
||||
int vfprintf_utf8(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
FILE *fopen_utf8(const char *filename, const char *mode);
|
||||
int stat_utf8(const char *path, struct stat *buffer);
|
||||
int _stat64_utf8(const char *path, struct __stat64 *buffer);
|
||||
int chmod_utf8(const char *filename, int pmode);
|
||||
int utime_utf8(const char *filename, struct utimbuf *times);
|
||||
int unlink_utf8(const char *filename);
|
||||
int rename_utf8(const char *oldname, const char *newname);
|
||||
size_t strlen_utf8(const char *str);
|
||||
int win_get_console_width(void);
|
||||
int print_console(FILE *stream, const wchar_t *text, uint32_t len);
|
||||
HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in a new issue