ape_reader: Properly fix the build under GCC 7.
Since we cannot '#define wchar_t char' anymore, we need to properly fix the source code to work with char instead.
This commit is contained in:
@@ -32,7 +32,7 @@ int TPositionBridgeIO::Close()
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int TPositionBridgeIO::Create(const wchar_t* oName)
|
int TPositionBridgeIO::Create(const char* oName)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ int TPositionBridgeIO::Delete()
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int TPositionBridgeIO::GetName(wchar_t* oBuffer)
|
int TPositionBridgeIO::GetName(char* oBuffer)
|
||||||
{
|
{
|
||||||
strcpy(oBuffer, "<TPositionBridgeIO>");
|
strcpy(oBuffer, "<TPositionBridgeIO>");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -68,7 +68,7 @@ int TPositionBridgeIO::GetSize()
|
|||||||
return aSize;
|
return aSize;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int TPositionBridgeIO::Open(const wchar_t* oName)
|
int TPositionBridgeIO::Open(const char* oName)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
TPositionBridgeIO();
|
TPositionBridgeIO();
|
||||||
virtual ~TPositionBridgeIO();
|
virtual ~TPositionBridgeIO();
|
||||||
|
|
||||||
virtual int Open(const wchar_t* oName);
|
virtual int Open(const char* oName);
|
||||||
virtual int Close();
|
virtual int Close();
|
||||||
|
|
||||||
virtual int Read(void* oBuf, unsigned int oBytesToRead, unsigned int* oBytesRead);
|
virtual int Read(void* oBuf, unsigned int oBytesToRead, unsigned int* oBytesRead);
|
||||||
@@ -24,14 +24,14 @@ public:
|
|||||||
|
|
||||||
virtual int Seek(int oDistance, unsigned int oMoveMode);
|
virtual int Seek(int oDistance, unsigned int oMoveMode);
|
||||||
|
|
||||||
virtual int Create(const wchar_t* oName);
|
virtual int Create(const char* oName);
|
||||||
virtual int Delete();
|
virtual int Delete();
|
||||||
|
|
||||||
virtual int SetEOF();
|
virtual int SetEOF();
|
||||||
|
|
||||||
virtual int GetPosition();
|
virtual int GetPosition();
|
||||||
virtual int GetSize();
|
virtual int GetSize();
|
||||||
virtual int GetName(wchar_t* oBuffer);
|
virtual int GetName(char* oBuffer);
|
||||||
|
|
||||||
status_t SetPositionIO(BPositionIO* oPositionIO);
|
status_t SetPositionIO(BPositionIO* oPositionIO);
|
||||||
|
|
||||||
|
|||||||
@@ -28,19 +28,19 @@ CAPECompress::~CAPECompress()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAPECompress::Start(const wchar_t * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes)
|
int CAPECompress::Start(const char* pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes)
|
||||||
{
|
{
|
||||||
m_pioOutput = new IO_CLASS_NAME;
|
m_pioOutput = new IO_CLASS_NAME;
|
||||||
m_bOwnsOutputIO = TRUE;
|
m_bOwnsOutputIO = TRUE;
|
||||||
|
|
||||||
if (m_pioOutput->Create(pOutputFilename) != 0)
|
if (m_pioOutput->Create(pOutputFilename) != 0)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_OUTPUT_FILE;
|
return ERROR_INVALID_OUTPUT_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_spAPECompressCreate->Start(m_pioOutput, pwfeInput, nMaxAudioBytes, nCompressionLevel,
|
m_spAPECompressCreate->Start(m_pioOutput, pwfeInput, nMaxAudioBytes, nCompressionLevel,
|
||||||
pHeaderData, nHeaderBytes);
|
pHeaderData, nHeaderBytes);
|
||||||
|
|
||||||
SAFE_ARRAY_DELETE(m_pBuffer)
|
SAFE_ARRAY_DELETE(m_pBuffer)
|
||||||
m_nBufferSize = m_spAPECompressCreate->GetFullFrameBytes();
|
m_nBufferSize = m_spAPECompressCreate->GetFullFrameBytes();
|
||||||
m_pBuffer = new unsigned char [m_nBufferSize];
|
m_pBuffer = new unsigned char [m_nBufferSize];
|
||||||
@@ -74,31 +74,31 @@ int CAPECompress::UnlockBuffer(int nBytesAdded, BOOL bProcess)
|
|||||||
{
|
{
|
||||||
if (m_bBufferLocked == FALSE)
|
if (m_bBufferLocked == FALSE)
|
||||||
return ERROR_UNDEFINED;
|
return ERROR_UNDEFINED;
|
||||||
|
|
||||||
m_nBufferTail += nBytesAdded;
|
m_nBufferTail += nBytesAdded;
|
||||||
m_bBufferLocked = FALSE;
|
m_bBufferLocked = FALSE;
|
||||||
|
|
||||||
if (bProcess)
|
if (bProcess)
|
||||||
{
|
{
|
||||||
int nRetVal = ProcessBuffer();
|
int nRetVal = ProcessBuffer();
|
||||||
if (nRetVal != 0) { return nRetVal; }
|
if (nRetVal != 0) { return nRetVal; }
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char * CAPECompress::LockBuffer(int * pBytesAvailable)
|
unsigned char * CAPECompress::LockBuffer(int * pBytesAvailable)
|
||||||
{
|
{
|
||||||
if (m_pBuffer == NULL) { return NULL; }
|
if (m_pBuffer == NULL) { return NULL; }
|
||||||
|
|
||||||
if (m_bBufferLocked)
|
if (m_bBufferLocked)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
m_bBufferLocked = TRUE;
|
m_bBufferLocked = TRUE;
|
||||||
|
|
||||||
if (pBytesAvailable)
|
if (pBytesAvailable)
|
||||||
*pBytesAvailable = GetBufferBytesAvailable();
|
*pBytesAvailable = GetBufferBytesAvailable();
|
||||||
|
|
||||||
return &m_pBuffer[m_nBufferTail];
|
return &m_pBuffer[m_nBufferTail];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ int CAPECompress::AddData(unsigned char * pData, int nBytes)
|
|||||||
if (m_pBuffer == NULL) return ERROR_INSUFFICIENT_MEMORY;
|
if (m_pBuffer == NULL) return ERROR_INSUFFICIENT_MEMORY;
|
||||||
|
|
||||||
int nBytesDone = 0;
|
int nBytesDone = 0;
|
||||||
|
|
||||||
while (nBytesDone < nBytes)
|
while (nBytesDone < nBytes)
|
||||||
{
|
{
|
||||||
// lock the buffer
|
// lock the buffer
|
||||||
@@ -115,11 +115,11 @@ int CAPECompress::AddData(unsigned char * pData, int nBytes)
|
|||||||
unsigned char * pBuffer = LockBuffer(&nBytesAvailable);
|
unsigned char * pBuffer = LockBuffer(&nBytesAvailable);
|
||||||
if (pBuffer == NULL || nBytesAvailable <= 0)
|
if (pBuffer == NULL || nBytesAvailable <= 0)
|
||||||
return ERROR_UNDEFINED;
|
return ERROR_UNDEFINED;
|
||||||
|
|
||||||
// calculate how many bytes to copy and add that much to the buffer
|
// calculate how many bytes to copy and add that much to the buffer
|
||||||
int nBytesToProcess = min(nBytesAvailable, nBytes - nBytesDone);
|
int nBytesToProcess = min(nBytesAvailable, nBytes - nBytesDone);
|
||||||
memcpy(pBuffer, &pData[nBytesDone], nBytesToProcess);
|
memcpy(pBuffer, &pData[nBytesDone], nBytesToProcess);
|
||||||
|
|
||||||
// unlock the buffer (fail if not successful)
|
// unlock the buffer (fail if not successful)
|
||||||
int nRetVal = UnlockBuffer(nBytesToProcess);
|
int nRetVal = UnlockBuffer(nBytesToProcess);
|
||||||
if (nRetVal != ERROR_SUCCESS)
|
if (nRetVal != ERROR_SUCCESS)
|
||||||
@@ -130,7 +130,7 @@ int CAPECompress::AddData(unsigned char * pData, int nBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAPECompress::Finish(unsigned char * pTerminatingData, int nTerminatingBytes, int nWAVTerminatingBytes)
|
int CAPECompress::Finish(unsigned char * pTerminatingData, int nTerminatingBytes, int nWAVTerminatingBytes)
|
||||||
{
|
{
|
||||||
@@ -146,33 +146,33 @@ int CAPECompress::Kill()
|
|||||||
int CAPECompress::ProcessBuffer(BOOL bFinalize)
|
int CAPECompress::ProcessBuffer(BOOL bFinalize)
|
||||||
{
|
{
|
||||||
if (m_pBuffer == NULL) { return ERROR_UNDEFINED; }
|
if (m_pBuffer == NULL) { return ERROR_UNDEFINED; }
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// process as much as possible
|
// process as much as possible
|
||||||
int nThreshold = (bFinalize) ? 0 : m_spAPECompressCreate->GetFullFrameBytes();
|
int nThreshold = (bFinalize) ? 0 : m_spAPECompressCreate->GetFullFrameBytes();
|
||||||
|
|
||||||
while ((m_nBufferTail - m_nBufferHead) >= nThreshold)
|
while ((m_nBufferTail - m_nBufferHead) >= nThreshold)
|
||||||
{
|
{
|
||||||
int nFrameBytes = min(m_spAPECompressCreate->GetFullFrameBytes(), m_nBufferTail - m_nBufferHead);
|
int nFrameBytes = min(m_spAPECompressCreate->GetFullFrameBytes(), m_nBufferTail - m_nBufferHead);
|
||||||
|
|
||||||
if (nFrameBytes == 0)
|
if (nFrameBytes == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int nRetVal = m_spAPECompressCreate->EncodeFrame(&m_pBuffer[m_nBufferHead], nFrameBytes);
|
int nRetVal = m_spAPECompressCreate->EncodeFrame(&m_pBuffer[m_nBufferHead], nFrameBytes);
|
||||||
if (nRetVal != 0) { return nRetVal; }
|
if (nRetVal != 0) { return nRetVal; }
|
||||||
|
|
||||||
m_nBufferHead += nFrameBytes;
|
m_nBufferHead += nFrameBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shift the buffer
|
// shift the buffer
|
||||||
if (m_nBufferHead != 0)
|
if (m_nBufferHead != 0)
|
||||||
{
|
{
|
||||||
int nBytesLeft = m_nBufferTail - m_nBufferHead;
|
int nBytesLeft = m_nBufferTail - m_nBufferHead;
|
||||||
|
|
||||||
if (nBytesLeft != 0)
|
if (nBytesLeft != 0)
|
||||||
memmove(m_pBuffer, &m_pBuffer[m_nBufferHead], nBytesLeft);
|
memmove(m_pBuffer, &m_pBuffer[m_nBufferHead], nBytesLeft);
|
||||||
|
|
||||||
m_nBufferTail -= m_nBufferHead;
|
m_nBufferTail -= m_nBufferHead;
|
||||||
m_nBufferHead = 0;
|
m_nBufferHead = 0;
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ int CAPECompress::ProcessBuffer(BOOL bFinalize)
|
|||||||
{
|
{
|
||||||
return ERROR_UNDEFINED;
|
return ERROR_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,13 +192,13 @@ int CAPECompress::AddDataFromInputSource(CInputSource * pInputSource, int nMaxBy
|
|||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
if (pBytesAdded) *pBytesAdded = 0;
|
if (pBytesAdded) *pBytesAdded = 0;
|
||||||
|
|
||||||
// lock the buffer
|
// lock the buffer
|
||||||
int nBytesAvailable = 0;
|
int nBytesAvailable = 0;
|
||||||
unsigned char * pBuffer = LockBuffer(&nBytesAvailable);
|
unsigned char * pBuffer = LockBuffer(&nBytesAvailable);
|
||||||
if ((pBuffer == NULL) || (nBytesAvailable == 0))
|
if ((pBuffer == NULL) || (nBytesAvailable == 0))
|
||||||
return ERROR_INSUFFICIENT_MEMORY;
|
return ERROR_INSUFFICIENT_MEMORY;
|
||||||
|
|
||||||
// calculate the 'ideal' number of bytes
|
// calculate the 'ideal' number of bytes
|
||||||
unsigned int nBytesRead = 0;
|
unsigned int nBytesRead = 0;
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ int CAPECompress::AddDataFromInputSource(CInputSource * pInputSource, int nMaxBy
|
|||||||
{
|
{
|
||||||
// get the data
|
// get the data
|
||||||
int nBytesToAdd = nBytesAvailable;
|
int nBytesToAdd = nBytesAvailable;
|
||||||
|
|
||||||
if (nMaxBytes > 0)
|
if (nMaxBytes > 0)
|
||||||
{
|
{
|
||||||
if (nBytesToAdd > nMaxBytes) nBytesToAdd = nMaxBytes;
|
if (nBytesToAdd > nMaxBytes) nBytesToAdd = nMaxBytes;
|
||||||
@@ -228,19 +228,19 @@ int CAPECompress::AddDataFromInputSource(CInputSource * pInputSource, int nMaxBy
|
|||||||
return ERROR_IO_READ;
|
return ERROR_IO_READ;
|
||||||
else
|
else
|
||||||
nBytesRead = (nBlocksAdded * m_wfeInput.nBlockAlign);
|
nBytesRead = (nBlocksAdded * m_wfeInput.nBlockAlign);
|
||||||
|
|
||||||
// store the bytes read
|
// store the bytes read
|
||||||
if (pBytesAdded)
|
if (pBytesAdded)
|
||||||
*pBytesAdded = nBytesRead;
|
*pBytesAdded = nBytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlock the data and process
|
// unlock the data and process
|
||||||
int nRetVal = UnlockBuffer(nBytesRead, TRUE);
|
int nRetVal = UnlockBuffer(nBytesRead, TRUE);
|
||||||
if (nRetVal != 0)
|
if (nRetVal != 0)
|
||||||
{
|
{
|
||||||
return nRetVal;
|
return nRetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,30 +15,30 @@ public:
|
|||||||
~CAPECompress();
|
~CAPECompress();
|
||||||
|
|
||||||
// start encoding
|
// start encoding
|
||||||
int Start(const wchar_t * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
|
int Start(const char* pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
|
||||||
int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
|
int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
|
||||||
|
|
||||||
// add data / compress data
|
// add data / compress data
|
||||||
|
|
||||||
// allows linear, immediate access to the buffer (fast)
|
// allows linear, immediate access to the buffer (fast)
|
||||||
int GetBufferBytesAvailable();
|
int GetBufferBytesAvailable();
|
||||||
int UnlockBuffer(int nBytesAdded, BOOL bProcess = TRUE);
|
int UnlockBuffer(int nBytesAdded, BOOL bProcess = TRUE);
|
||||||
unsigned char * LockBuffer(int * pBytesAvailable);
|
unsigned char * LockBuffer(int * pBytesAvailable);
|
||||||
|
|
||||||
// slower, but easier than locking and unlocking (copies data)
|
// slower, but easier than locking and unlocking (copies data)
|
||||||
int AddData(unsigned char * pData, int nBytes);
|
int AddData(unsigned char * pData, int nBytes);
|
||||||
|
|
||||||
// use a CIO (input source) to add data
|
// use a CIO (input source) to add data
|
||||||
int AddDataFromInputSource(CInputSource * pInputSource, int nMaxBytes = -1, int * pBytesAdded = NULL);
|
int AddDataFromInputSource(CInputSource * pInputSource, int nMaxBytes = -1, int * pBytesAdded = NULL);
|
||||||
|
|
||||||
// finish / kill
|
// finish / kill
|
||||||
int Finish(unsigned char * pTerminatingData, int nTerminatingBytes, int nWAVTerminatingBytes);
|
int Finish(unsigned char * pTerminatingData, int nTerminatingBytes, int nWAVTerminatingBytes);
|
||||||
int Kill();
|
int Kill();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int ProcessBuffer(BOOL bFinalize = FALSE);
|
int ProcessBuffer(BOOL bFinalize = FALSE);
|
||||||
|
|
||||||
CSmartPtr<CAPECompressCreate> m_spAPECompressCreate;
|
CSmartPtr<CAPECompressCreate> m_spAPECompressCreate;
|
||||||
|
|
||||||
int m_nBufferHead;
|
int m_nBufferHead;
|
||||||
|
|||||||
@@ -9,11 +9,6 @@
|
|||||||
|
|
||||||
#define DECODE_BLOCK_SIZE 4096
|
#define DECODE_BLOCK_SIZE 4096
|
||||||
|
|
||||||
#if __GNUC__ != 2
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CAPEDecompress::CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStartBlock, int nFinishBlock)
|
CAPEDecompress::CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStartBlock, int nFinishBlock)
|
||||||
{
|
{
|
||||||
*pErrorCode = ERROR_SUCCESS;
|
*pErrorCode = ERROR_SUCCESS;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ CAPEInfo:
|
|||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
Construction
|
Construction
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
CAPEInfo::CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag)
|
CAPEInfo::CAPEInfo(int * pErrorCode, const char* pFilename, CAPETag * pTag)
|
||||||
{
|
{
|
||||||
*pErrorCode = ERROR_SUCCESS;
|
*pErrorCode = ERROR_SUCCESS;
|
||||||
CloseFile();
|
CloseFile();
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class CAPEInfo
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
// construction and destruction
|
// construction and destruction
|
||||||
CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag = NULL);
|
CAPEInfo(int * pErrorCode, const char* pFilename, CAPETag * pTag = NULL);
|
||||||
CAPEInfo(int * pErrorCode, CIO * pIO, CAPETag * pTag = NULL);
|
CAPEInfo(int * pErrorCode, CIO * pIO, CAPETag * pTag = NULL);
|
||||||
virtual ~CAPEInfo();
|
virtual ~CAPEInfo();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
BOOL GetIsLinkFile();
|
BOOL GetIsLinkFile();
|
||||||
int GetStartBlock();
|
int GetStartBlock();
|
||||||
int GetFinishBlock();
|
int GetFinishBlock();
|
||||||
const wchar_t * GetImageFilename();
|
const char* GetImageFilename();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,6 @@
|
|||||||
|
|
||||||
#define BLOCKS_PER_DECODE 9216
|
#define BLOCKS_PER_DECODE 9216
|
||||||
|
|
||||||
#if __GNUC__ != 2
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int DecompressCore(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nOutputMode, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
int DecompressCore(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nOutputMode, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include IO_HEADER_FILE
|
#include IO_HEADER_FILE
|
||||||
|
|
||||||
#if __GNUC__ != 2
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
CAPETagField
|
CAPETagField
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
|
|||||||
@@ -42,6 +42,12 @@ Global includes
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "SmartPtr.h"
|
#include "SmartPtr.h"
|
||||||
|
|
||||||
|
#if __GNUC__ != 2
|
||||||
|
#include <algorithm>
|
||||||
|
using std::min;
|
||||||
|
using std::max;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
Global compiler settings (useful for porting)
|
Global compiler settings (useful for porting)
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ CBitArray::CBitArray(CIO *pIO)
|
|||||||
// allocate memory for the bit array
|
// allocate memory for the bit array
|
||||||
m_pBitArray = new uint32 [BIT_ARRAY_ELEMENTS];
|
m_pBitArray = new uint32 [BIT_ARRAY_ELEMENTS];
|
||||||
memset(m_pBitArray, 0, BIT_ARRAY_BYTES);
|
memset(m_pBitArray, 0, BIT_ARRAY_BYTES);
|
||||||
|
|
||||||
// initialize other variables
|
// initialize other variables
|
||||||
m_nCurrentBitIndex = 0;
|
m_nCurrentBitIndex = 0;
|
||||||
m_pIO = pIO;
|
m_pIO = pIO;
|
||||||
@@ -73,7 +73,7 @@ int CBitArray::OutputBitArray(BOOL bFinalize)
|
|||||||
unsigned int nBytesWritten = 0;
|
unsigned int nBytesWritten = 0;
|
||||||
unsigned int nBytesToWrite = 0;
|
unsigned int nBytesToWrite = 0;
|
||||||
// unsigned int nRetVal = 0;
|
// unsigned int nRetVal = 0;
|
||||||
|
|
||||||
if (bFinalize)
|
if (bFinalize)
|
||||||
{
|
{
|
||||||
nBytesToWrite = ((m_nCurrentBitIndex >> 5) * 4) + 4;
|
nBytesToWrite = ((m_nCurrentBitIndex >> 5) * 4) + 4;
|
||||||
@@ -83,7 +83,7 @@ int CBitArray::OutputBitArray(BOOL bFinalize)
|
|||||||
RETURN_ON_ERROR(m_pIO->Write(m_pBitArray, nBytesToWrite, &nBytesWritten))
|
RETURN_ON_ERROR(m_pIO->Write(m_pBitArray, nBytesToWrite, &nBytesWritten))
|
||||||
|
|
||||||
// reset the bit pointer
|
// reset the bit pointer
|
||||||
m_nCurrentBitIndex = 0;
|
m_nCurrentBitIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -92,15 +92,15 @@ int CBitArray::OutputBitArray(BOOL bFinalize)
|
|||||||
m_MD5.AddData(m_pBitArray, nBytesToWrite);
|
m_MD5.AddData(m_pBitArray, nBytesToWrite);
|
||||||
|
|
||||||
RETURN_ON_ERROR(m_pIO->Write(m_pBitArray, nBytesToWrite, &nBytesWritten))
|
RETURN_ON_ERROR(m_pIO->Write(m_pBitArray, nBytesToWrite, &nBytesWritten))
|
||||||
|
|
||||||
// move the last value to the front of the bit array
|
// move the last value to the front of the bit array
|
||||||
m_pBitArray[0] = m_pBitArray[m_nCurrentBitIndex >> 5];
|
m_pBitArray[0] = m_pBitArray[m_nCurrentBitIndex >> 5];
|
||||||
m_nCurrentBitIndex = (m_nCurrentBitIndex & 31);
|
m_nCurrentBitIndex = (m_nCurrentBitIndex & 31);
|
||||||
|
|
||||||
// zero the rest of the memory (may not need the +1 because of frame byte alignment)
|
// zero the rest of the memory (may not need the +1 because of frame byte alignment)
|
||||||
memset(&m_pBitArray[1], 0, min(nBytesToWrite + 1, BIT_ARRAY_BYTES - 1));
|
memset(&m_pBitArray[1], 0, min((int)nBytesToWrite + 1, BIT_ARRAY_BYTES - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// return a success
|
// return a success
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -134,13 +134,13 @@ Range coding macros -- ugly, but outperform inline's (every cycle counts here)
|
|||||||
\
|
\
|
||||||
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8) & (TOP_VALUE - 1); \
|
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8) & (TOP_VALUE - 1); \
|
||||||
m_RangeCoderInfo.range <<= 8; \
|
m_RangeCoderInfo.range <<= 8; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ENCODE_FAST(RANGE_WIDTH, RANGE_TOTAL, SHIFT) \
|
#define ENCODE_FAST(RANGE_WIDTH, RANGE_TOTAL, SHIFT) \
|
||||||
NORMALIZE_RANGE_CODER \
|
NORMALIZE_RANGE_CODER \
|
||||||
const int nTemp = m_RangeCoderInfo.range >> (SHIFT); \
|
const int nTemp = m_RangeCoderInfo.range >> (SHIFT); \
|
||||||
m_RangeCoderInfo.range = nTemp * (RANGE_WIDTH); \
|
m_RangeCoderInfo.range = nTemp * (RANGE_WIDTH); \
|
||||||
m_RangeCoderInfo.low += nTemp * (RANGE_TOTAL);
|
m_RangeCoderInfo.low += nTemp * (RANGE_TOTAL);
|
||||||
|
|
||||||
#define ENCODE_DIRECT(VALUE, SHIFT) \
|
#define ENCODE_DIRECT(VALUE, SHIFT) \
|
||||||
NORMALIZE_RANGE_CODER \
|
NORMALIZE_RANGE_CODER \
|
||||||
@@ -158,7 +158,7 @@ int CBitArray::EncodeBits(unsigned int nValue, int nBits)
|
|||||||
{
|
{
|
||||||
RETURN_ON_ERROR(OutputBitArray())
|
RETURN_ON_ERROR(OutputBitArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
ENCODE_DIRECT(nValue, nBits);
|
ENCODE_DIRECT(nValue, nBits);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ int CBitArray::EncodeBits(unsigned int nValue, int nBits)
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
Encodes an unsigned int to the bit array (no rice coding)
|
Encodes an unsigned int to the bit array (no rice coding)
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
int CBitArray::EncodeUnsignedLong(unsigned int n)
|
int CBitArray::EncodeUnsignedLong(unsigned int n)
|
||||||
{
|
{
|
||||||
// make sure there are at least 8 bytes in the buffer
|
// make sure there are at least 8 bytes in the buffer
|
||||||
if (m_nCurrentBitIndex > (BIT_ARRAY_BYTES - 8))
|
if (m_nCurrentBitIndex > (BIT_ARRAY_BYTES - 8))
|
||||||
@@ -177,16 +177,16 @@ int CBitArray::EncodeUnsignedLong(unsigned int n)
|
|||||||
// encode the value
|
// encode the value
|
||||||
uint32 nBitArrayIndex = m_nCurrentBitIndex >> 5;
|
uint32 nBitArrayIndex = m_nCurrentBitIndex >> 5;
|
||||||
int nBitIndex = m_nCurrentBitIndex & 31;
|
int nBitIndex = m_nCurrentBitIndex & 31;
|
||||||
|
|
||||||
if (nBitIndex == 0)
|
if (nBitIndex == 0)
|
||||||
{
|
{
|
||||||
m_pBitArray[nBitArrayIndex] = n;
|
m_pBitArray[nBitArrayIndex] = n;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_pBitArray[nBitArrayIndex] |= n >> nBitIndex;
|
m_pBitArray[nBitArrayIndex] |= n >> nBitIndex;
|
||||||
m_pBitArray[nBitArrayIndex + 1] = n << (32 - nBitIndex);
|
m_pBitArray[nBitArrayIndex + 1] = n << (32 - nBitIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nCurrentBitIndex += 32;
|
m_nCurrentBitIndex += 32;
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ int CBitArray::EncodeUnsignedLong(unsigned int n)
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
Advance to a byte boundary (for frame alignment)
|
Advance to a byte boundary (for frame alignment)
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
void CBitArray::AdvanceToByteBoundary()
|
void CBitArray::AdvanceToByteBoundary()
|
||||||
{
|
{
|
||||||
while (m_nCurrentBitIndex % 8)
|
while (m_nCurrentBitIndex % 8)
|
||||||
m_nCurrentBitIndex++;
|
m_nCurrentBitIndex++;
|
||||||
@@ -213,22 +213,22 @@ int CBitArray::EncodeValue(int nEncode, BIT_ARRAY_STATE & BitArrayState)
|
|||||||
{
|
{
|
||||||
RETURN_ON_ERROR(OutputBitArray())
|
RETURN_ON_ERROR(OutputBitArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to unsigned
|
// convert to unsigned
|
||||||
nEncode = (nEncode > 0) ? nEncode * 2 - 1 : -nEncode * 2;
|
nEncode = (nEncode > 0) ? nEncode * 2 - 1 : -nEncode * 2;
|
||||||
|
|
||||||
int nOriginalKSum = BitArrayState.nKSum;
|
int nOriginalKSum = BitArrayState.nKSum;
|
||||||
|
|
||||||
// get the working k
|
// get the working k
|
||||||
// int nTempK = (BitArrayState.k) ? BitArrayState.k - 1 : 0;
|
// int nTempK = (BitArrayState.k) ? BitArrayState.k - 1 : 0;
|
||||||
|
|
||||||
// update nKSum
|
// update nKSum
|
||||||
BitArrayState.nKSum += ((nEncode + 1) / 2) - ((BitArrayState.nKSum + 16) >> 5);
|
BitArrayState.nKSum += ((nEncode + 1) / 2) - ((BitArrayState.nKSum + 16) >> 5);
|
||||||
|
|
||||||
// update k
|
// update k
|
||||||
if (BitArrayState.nKSum < K_SUM_MIN_BOUNDARY[BitArrayState.k])
|
if (BitArrayState.nKSum < K_SUM_MIN_BOUNDARY[BitArrayState.k])
|
||||||
BitArrayState.k--;
|
BitArrayState.k--;
|
||||||
else if (BitArrayState.nKSum >= K_SUM_MIN_BOUNDARY[BitArrayState.k + 1])
|
else if (BitArrayState.nKSum >= K_SUM_MIN_BOUNDARY[BitArrayState.k + 1])
|
||||||
BitArrayState.k++;
|
BitArrayState.k++;
|
||||||
|
|
||||||
// figure the pivot value
|
// figure the pivot value
|
||||||
@@ -324,7 +324,7 @@ void CBitArray::FlushBitArray()
|
|||||||
m_RangeCoderInfo.help = 0; // no bytes to follow
|
m_RangeCoderInfo.help = 0; // no bytes to follow
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBitArray::FlushState(BIT_ARRAY_STATE & BitArrayState)
|
void CBitArray::FlushState(BIT_ARRAY_STATE & BitArrayState)
|
||||||
{
|
{
|
||||||
// k and ksum
|
// k and ksum
|
||||||
BitArrayState.k = 10;
|
BitArrayState.k = 10;
|
||||||
@@ -347,7 +347,7 @@ void CBitArray::Finalize()
|
|||||||
{
|
{
|
||||||
PUTC(0);
|
PUTC(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // no carry
|
else // no carry
|
||||||
{
|
{
|
||||||
PUTC(m_RangeCoderInfo.buffer);
|
PUTC(m_RangeCoderInfo.buffer);
|
||||||
@@ -371,9 +371,9 @@ Build a range table (for development / debugging)
|
|||||||
void CBitArray::OutputRangeTable()
|
void CBitArray::OutputRangeTable()
|
||||||
{
|
{
|
||||||
int z;
|
int z;
|
||||||
|
|
||||||
if (g_nTotalOverflow == 0) return;
|
if (g_nTotalOverflow == 0) return;
|
||||||
|
|
||||||
int nTotal = 0;
|
int nTotal = 0;
|
||||||
int aryWidth[256]; ZeroMemory(aryWidth, 256 * 4);
|
int aryWidth[256]; ZeroMemory(aryWidth, 256 * 4);
|
||||||
for (z = 0; z < MODEL_ELEMENTS; z++)
|
for (z = 0; z < MODEL_ELEMENTS; z++)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ CCircleBuffer::~CCircleBuffer()
|
|||||||
void CCircleBuffer::CreateBuffer(int nBytes, int nMaxDirectWriteBytes)
|
void CCircleBuffer::CreateBuffer(int nBytes, int nMaxDirectWriteBytes)
|
||||||
{
|
{
|
||||||
SAFE_ARRAY_DELETE(m_pBuffer)
|
SAFE_ARRAY_DELETE(m_pBuffer)
|
||||||
|
|
||||||
m_nMaxDirectWriteBytes = nMaxDirectWriteBytes;
|
m_nMaxDirectWriteBytes = nMaxDirectWriteBytes;
|
||||||
m_nTotal = nBytes + 1 + nMaxDirectWriteBytes;
|
m_nTotal = nBytes + 1 + nMaxDirectWriteBytes;
|
||||||
m_pBuffer = new unsigned char [m_nTotal];
|
m_pBuffer = new unsigned char [m_nTotal];
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ int WriteSafe(CIO * pIO, void * pBuffer, int nBytes)
|
|||||||
return nRetVal;
|
return nRetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL FileExists(wchar_t * pFilename)
|
BOOL FileExists(char* pFilename)
|
||||||
{
|
{
|
||||||
if (0 == wcscmp(pFilename, "-") || 0 == wcscmp(pFilename, "/dev/stdin"))
|
if (0 == wcscmp(pFilename, "-") || 0 == wcscmp(pFilename, "/dev/stdin"))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ int WriteSafe(CIO * pIO, void * pBuffer, int nBytes);
|
|||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
Checks for the existence of a file
|
Checks for the existence of a file
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
BOOL FileExists(wchar_t * pFilename);
|
BOOL FileExists(char* pFilename);
|
||||||
|
|
||||||
#endif // #ifndef APE_GLOBALFUNCTIONS_H
|
#endif // #ifndef APE_GLOBALFUNCTIONS_H
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
virtual ~CIO() { };
|
virtual ~CIO() { };
|
||||||
|
|
||||||
// open / close
|
// open / close
|
||||||
virtual int Open(const wchar_t * pName) = 0;
|
virtual int Open(const char* pName) = 0;
|
||||||
virtual int Close() = 0;
|
virtual int Close() = 0;
|
||||||
|
|
||||||
// read / write
|
// read / write
|
||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
virtual int Seek(int nDistance, unsigned int nMoveMode) = 0;
|
virtual int Seek(int nDistance, unsigned int nMoveMode) = 0;
|
||||||
|
|
||||||
// creation / destruction
|
// creation / destruction
|
||||||
virtual int Create(const wchar_t * pName) = 0;
|
virtual int Create(const char* pName) = 0;
|
||||||
virtual int Delete() = 0;
|
virtual int Delete() = 0;
|
||||||
|
|
||||||
// other functions
|
// other functions
|
||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
// attributes
|
// attributes
|
||||||
virtual int GetPosition() = 0;
|
virtual int GetPosition() = 0;
|
||||||
virtual int GetSize() = 0;
|
virtual int GetSize() = 0;
|
||||||
virtual int GetName(wchar_t * pBuffer) = 0;
|
virtual int GetName(char* pBuffer) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef APE_IO_H
|
#endif // #ifndef APE_IO_H
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ int __stdcall FillWaveHeader(WAVE_HEADER * pWAVHeader, int nAudioBytes, WAVEFORM
|
|||||||
// format header
|
// format header
|
||||||
memcpy(pWAVHeader->cDataTypeID, "WAVE", 4);
|
memcpy(pWAVHeader->cDataTypeID, "WAVE", 4);
|
||||||
memcpy(pWAVHeader->cFormatHeader, "fmt ", 4);
|
memcpy(pWAVHeader->cFormatHeader, "fmt ", 4);
|
||||||
|
|
||||||
// the format chunk is the first 16 bytes of a waveformatex
|
// the format chunk is the first 16 bytes of a waveformatex
|
||||||
pWAVHeader->nFormatBytes = 16;
|
pWAVHeader->nFormatBytes = 16;
|
||||||
memcpy(&pWAVHeader->nFormatTag, pWaveFormatEx, 16);
|
memcpy(&pWAVHeader->nFormatTag, pWaveFormatEx, 16);
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ There are two main interfaces... create one (using CreateIAPExxx) and go to town
|
|||||||
|
|
||||||
Note(s):
|
Note(s):
|
||||||
|
|
||||||
Unless otherwise specified, functions return ERROR_SUCCESS (0) on success and an
|
Unless otherwise specified, functions return ERROR_SUCCESS (0) on success and an
|
||||||
error code on failure.
|
error code on failure.
|
||||||
|
|
||||||
The terminology "Sample" refers to a single sample value, and "Block" refers
|
The terminology "Sample" refers to a single sample value, and "Block" refers
|
||||||
to a collection of "Channel" samples. For simplicity, MAC typically uses blocks
|
to a collection of "Channel" samples. For simplicity, MAC typically uses blocks
|
||||||
everywhere so that channel mis-alignment cannot happen. (i.e. on a CD, a sample is
|
everywhere so that channel mis-alignment cannot happen. (i.e. on a CD, a sample is
|
||||||
2 bytes and a block is 4 bytes ([2 bytes per sample] * [2 channels] = 4 bytes))
|
2 bytes and a block is 4 bytes ([2 bytes per sample] * [2 channels] = 4 bytes))
|
||||||
@@ -50,7 +50,7 @@ Notes:
|
|||||||
|
|
||||||
Seek Table:
|
Seek Table:
|
||||||
|
|
||||||
A 32-bit unsigned integer array of offsets from the header to the frame data. May become "delta"
|
A 32-bit unsigned integer array of offsets from the header to the frame data. May become "delta"
|
||||||
values someday to better suit huge files.
|
values someday to better suit huge files.
|
||||||
|
|
||||||
MD5 Hash:
|
MD5 Hash:
|
||||||
@@ -58,7 +58,7 @@ Notes:
|
|||||||
Since the header is the last part written to an APE file, you must calculate the MD5 checksum out of order.
|
Since the header is the last part written to an APE file, you must calculate the MD5 checksum out of order.
|
||||||
So, you first calculate from the tail of the seek table to the end of the terminating data.
|
So, you first calculate from the tail of the seek table to the end of the terminating data.
|
||||||
Then, go back and do from the end of the descriptor to the tail of the seek table.
|
Then, go back and do from the end of the descriptor to the tail of the seek table.
|
||||||
You may wish to just cache the header data when starting and run it last, so you don't
|
You may wish to just cache the header data when starting and run it last, so you don't
|
||||||
need to seek back in the I/O.
|
need to seek back in the I/O.
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ struct WAVE_HEADER
|
|||||||
unsigned int nAvgBytesPerSec;
|
unsigned int nAvgBytesPerSec;
|
||||||
unsigned short nBlockAlign;
|
unsigned short nBlockAlign;
|
||||||
unsigned short nBitsPerSample;
|
unsigned short nBitsPerSample;
|
||||||
|
|
||||||
// data chunk header
|
// data chunk header
|
||||||
char cDataHeader[4];
|
char cDataHeader[4];
|
||||||
unsigned int nDataBytes;
|
unsigned int nDataBytes;
|
||||||
@@ -164,7 +164,7 @@ Note(s):
|
|||||||
-the distinction between APE_INFO_XXXX and APE_DECOMPRESS_XXXX is that the first is querying the APE
|
-the distinction between APE_INFO_XXXX and APE_DECOMPRESS_XXXX is that the first is querying the APE
|
||||||
information engine, and the other is querying the decompressor, and since the decompressor can be
|
information engine, and the other is querying the decompressor, and since the decompressor can be
|
||||||
a range of an APE file (for APL), differences will arise. Typically, use the APE_DECOMPRESS_XXXX
|
a range of an APE file (for APL), differences will arise. Typically, use the APE_DECOMPRESS_XXXX
|
||||||
fields when querying for info about the length, etc. so APL will work properly.
|
fields when querying for info about the length, etc. so APL will work properly.
|
||||||
(i.e. (APE_INFO_TOTAL_BLOCKS != APE_DECOMPRESS_TOTAL_BLOCKS) for APL files)
|
(i.e. (APE_INFO_TOTAL_BLOCKS != APE_DECOMPRESS_TOTAL_BLOCKS) for APL files)
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
enum APE_DECOMPRESS_FIELDS
|
enum APE_DECOMPRESS_FIELDS
|
||||||
@@ -200,7 +200,7 @@ enum APE_DECOMPRESS_FIELDS
|
|||||||
APE_INFO_FRAME_BYTES = 1028, // bytes (compressed) of the frame [frame index, ignored]
|
APE_INFO_FRAME_BYTES = 1028, // bytes (compressed) of the frame [frame index, ignored]
|
||||||
APE_INFO_FRAME_BLOCKS = 1029, // blocks in a given frame [frame index, ignored]
|
APE_INFO_FRAME_BLOCKS = 1029, // blocks in a given frame [frame index, ignored]
|
||||||
APE_INFO_TAG = 1030, // point to tag (CAPETag *) [ignored, ignored]
|
APE_INFO_TAG = 1030, // point to tag (CAPETag *) [ignored, ignored]
|
||||||
|
|
||||||
APE_DECOMPRESS_CURRENT_BLOCK = 2000, // current block location [ignored, ignored]
|
APE_DECOMPRESS_CURRENT_BLOCK = 2000, // current block location [ignored, ignored]
|
||||||
APE_DECOMPRESS_CURRENT_MS = 2001, // current millisecond location [ignored, ignored]
|
APE_DECOMPRESS_CURRENT_MS = 2001, // current millisecond location [ignored, ignored]
|
||||||
APE_DECOMPRESS_TOTAL_BLOCKS = 2002, // total blocks in the decompressors range [ignored, ignored]
|
APE_DECOMPRESS_TOTAL_BLOCKS = 2002, // total blocks in the decompressors range [ignored, ignored]
|
||||||
@@ -220,14 +220,14 @@ public:
|
|||||||
|
|
||||||
// destructor (needed so implementation's destructor will be called)
|
// destructor (needed so implementation's destructor will be called)
|
||||||
virtual ~IAPEDecompress() {}
|
virtual ~IAPEDecompress() {}
|
||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
* Decompress / Seek
|
* Decompress / Seek
|
||||||
*********************************************************************************************/
|
*********************************************************************************************/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// GetData(...) - gets raw decompressed audio
|
// GetData(...) - gets raw decompressed audio
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// char * pBuffer
|
// char * pBuffer
|
||||||
// a pointer to a buffer to put the data into
|
// a pointer to a buffer to put the data into
|
||||||
@@ -240,7 +240,7 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Seek(...) - seeks
|
// Seek(...) - seeks
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// int nBlockOffset
|
// int nBlockOffset
|
||||||
// the block to seek to (see note at intro about blocks vs. samples)
|
// the block to seek to (see note at intro about blocks vs. samples)
|
||||||
@@ -253,7 +253,7 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// GetInfo(...) - get information about the APE file or the state of the decompressor
|
// GetInfo(...) - get information about the APE file or the state of the decompressor
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// APE_DECOMPRESS_FIELDS Field
|
// APE_DECOMPRESS_FIELDS Field
|
||||||
// the field we're querying (see APE_DECOMPRESS_FIELDS above for more info)
|
// the field we're querying (see APE_DECOMPRESS_FIELDS above for more info)
|
||||||
@@ -278,14 +278,14 @@ public:
|
|||||||
|
|
||||||
// destructor (needed so implementation's destructor will be called)
|
// destructor (needed so implementation's destructor will be called)
|
||||||
virtual ~IAPECompress() {}
|
virtual ~IAPECompress() {}
|
||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
* Start
|
* Start
|
||||||
*********************************************************************************************/
|
*********************************************************************************************/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Start(...) / StartEx(...) - starts encoding
|
// Start(...) / StartEx(...) - starts encoding
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// CIO * pioOutput / const str_utf16 * pFilename
|
// CIO * pioOutput / const str_utf16 * pFilename
|
||||||
// the output... either a filename or an I/O source
|
// the output... either a filename or an I/O source
|
||||||
@@ -309,14 +309,14 @@ public:
|
|||||||
// on decompression)
|
// on decompression)
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
virtual int Start(const str_utf16 * pOutputFilename, const WAVEFORMATEX * pwfeInput,
|
virtual int Start(const str_utf16 * pOutputFilename, const WAVEFORMATEX * pwfeInput,
|
||||||
int nMaxAudioBytes = MAX_AUDIO_BYTES_UNKNOWN, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL,
|
int nMaxAudioBytes = MAX_AUDIO_BYTES_UNKNOWN, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL,
|
||||||
const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION) = 0;
|
const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION) = 0;
|
||||||
|
|
||||||
virtual int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput,
|
virtual int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput,
|
||||||
int nMaxAudioBytes = MAX_AUDIO_BYTES_UNKNOWN, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL,
|
int nMaxAudioBytes = MAX_AUDIO_BYTES_UNKNOWN, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL,
|
||||||
const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION) = 0;
|
const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION) = 0;
|
||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
* Add / Compress Data
|
* Add / Compress Data
|
||||||
* - there are 3 ways to add data:
|
* - there are 3 ways to add data:
|
||||||
@@ -327,7 +327,7 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// AddData(...) - adds data to the encoder
|
// AddData(...) - adds data to the encoder
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// unsigned char * pData
|
// unsigned char * pData
|
||||||
// a pointer to a buffer containing the raw audio data
|
// a pointer to a buffer containing the raw audio data
|
||||||
@@ -335,7 +335,7 @@ public:
|
|||||||
// the number of bytes in the buffer
|
// the number of bytes in the buffer
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
virtual int AddData(unsigned char * pData, int nBytes) = 0;
|
virtual int AddData(unsigned char * pData, int nBytes) = 0;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// GetBufferBytesAvailable(...) - returns the number of bytes available in the buffer
|
// GetBufferBytesAvailable(...) - returns the number of bytes available in the buffer
|
||||||
// (helpful when locking)
|
// (helpful when locking)
|
||||||
@@ -344,7 +344,7 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// LockBuffer(...) - locks MAC's buffer so we can copy into it
|
// LockBuffer(...) - locks MAC's buffer so we can copy into it
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// int * pBytesAvailable
|
// int * pBytesAvailable
|
||||||
// returns the number of bytes available in the buffer (DO NOT COPY MORE THAN THIS IN)
|
// returns the number of bytes available in the buffer (DO NOT COPY MORE THAN THIS IN)
|
||||||
@@ -356,7 +356,7 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// UnlockBuffer(...) - releases the buffer
|
// UnlockBuffer(...) - releases the buffer
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// int nBytesAdded
|
// int nBytesAdded
|
||||||
// the number of bytes copied into the buffer
|
// the number of bytes copied into the buffer
|
||||||
@@ -364,7 +364,7 @@ public:
|
|||||||
// whether MAC should process as much as possible of the buffer
|
// whether MAC should process as much as possible of the buffer
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
virtual int UnlockBuffer(int nBytesAdded, BOOL bProcess = TRUE) = 0;
|
virtual int UnlockBuffer(int nBytesAdded, BOOL bProcess = TRUE) = 0;
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// AddDataFromInputSource(...) - use a CInputSource (input source) to add data
|
// AddDataFromInputSource(...) - use a CInputSource (input source) to add data
|
||||||
@@ -378,14 +378,14 @@ public:
|
|||||||
// returns the number of bytes added from the I/O source
|
// returns the number of bytes added from the I/O source
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
virtual int AddDataFromInputSource(CInputSource * pInputSource, int nMaxBytes = -1, int * pBytesAdded = NULL) = 0;
|
virtual int AddDataFromInputSource(CInputSource * pInputSource, int nMaxBytes = -1, int * pBytesAdded = NULL) = 0;
|
||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
* Finish / Kill
|
* Finish / Kill
|
||||||
*********************************************************************************************/
|
*********************************************************************************************/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Finish(...) - ends encoding and finalizes the file
|
// Finish(...) - ends encoding and finalizes the file
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// unsigned char * pTerminatingData
|
// unsigned char * pTerminatingData
|
||||||
// a pointer to a buffer containing the information to place at the end of the APE file
|
// a pointer to a buffer containing the information to place at the end of the APE file
|
||||||
@@ -438,12 +438,12 @@ extern "C"
|
|||||||
DLLEXPORT int __stdcall CompressFile(const str_ansi * pInputFilename, const str_ansi * pOutputFilename, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, int * pPercentageDone = NULL, APE_PROGRESS_CALLBACK ProgressCallback = 0, int * pKillFlag = NULL);
|
DLLEXPORT int __stdcall CompressFile(const str_ansi * pInputFilename, const str_ansi * pOutputFilename, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, int * pPercentageDone = NULL, APE_PROGRESS_CALLBACK ProgressCallback = 0, int * pKillFlag = NULL);
|
||||||
DLLEXPORT int __stdcall DecompressFile(const str_ansi * pInputFilename, const str_ansi * pOutputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
DLLEXPORT int __stdcall DecompressFile(const str_ansi * pInputFilename, const str_ansi * pOutputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
||||||
DLLEXPORT int __stdcall ConvertFile(const str_ansi * pInputFilename, const str_ansi * pOutputFilename, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
DLLEXPORT int __stdcall ConvertFile(const str_ansi * pInputFilename, const str_ansi * pOutputFilename, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
||||||
DLLEXPORT int __stdcall VerifyFile(const str_ansi * pInputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag, BOOL bQuickVerifyIfPossible);
|
DLLEXPORT int __stdcall VerifyFile(const str_ansi * pInputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag, BOOL bQuickVerifyIfPossible);
|
||||||
|
|
||||||
DLLEXPORT int __stdcall CompressFileW(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, int * pPercentageDone = NULL, APE_PROGRESS_CALLBACK ProgressCallback = 0, int * pKillFlag = NULL);
|
DLLEXPORT int __stdcall CompressFileW(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, int * pPercentageDone = NULL, APE_PROGRESS_CALLBACK ProgressCallback = 0, int * pKillFlag = NULL);
|
||||||
DLLEXPORT int __stdcall DecompressFileW(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
DLLEXPORT int __stdcall DecompressFileW(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
||||||
DLLEXPORT int __stdcall ConvertFileW(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
DLLEXPORT int __stdcall ConvertFileW(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
|
||||||
DLLEXPORT int __stdcall VerifyFileW(const str_utf16 * pInputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag, BOOL bQuickVerifyIfPossible = FALSE);
|
DLLEXPORT int __stdcall VerifyFileW(const str_utf16 * pInputFilename, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag, BOOL bQuickVerifyIfPossible = FALSE);
|
||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
DLLEXPORT int __stdcall FillWaveFormatEx(WAVEFORMATEX * pWaveFormatEx, int nSampleRate = 44100, int nBitsPerSample = 16, int nChannels = 2);
|
DLLEXPORT int __stdcall FillWaveFormatEx(WAVEFORMATEX * pWaveFormatEx, int nSampleRate = 44100, int nBitsPerSample = 16, int nChannels = 2);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
//typedef char int8;
|
//typedef char int8;
|
||||||
typedef char str_ansi;
|
typedef char str_ansi;
|
||||||
typedef unsigned char str_utf8;
|
typedef unsigned char str_utf8;
|
||||||
typedef wchar_t str_utf16;
|
typedef char str_utf16;
|
||||||
|
|
||||||
typedef unsigned long DWORD;
|
typedef unsigned long DWORD;
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
@@ -31,8 +31,8 @@ typedef unsigned int UINT;
|
|||||||
typedef unsigned int WPARAM;
|
typedef unsigned int WPARAM;
|
||||||
typedef long LPARAM;
|
typedef long LPARAM;
|
||||||
typedef const char * LPCSTR;
|
typedef const char * LPCSTR;
|
||||||
typedef const wchar_t * LPCTSTR; // ?? SHINTA
|
typedef const char* LPCTSTR; // ?? SHINTA
|
||||||
typedef const wchar_t * LPCWSTR; // ?? SHINTA
|
typedef const char* LPCWSTR; // ?? SHINTA
|
||||||
typedef char * LPSTR;
|
typedef char * LPSTR;
|
||||||
typedef long LRESULT;
|
typedef long LRESULT;
|
||||||
typedef unsigned char UCHAR;
|
typedef unsigned char UCHAR;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ int CStdLibFileIO::GetName(char * pBuffer)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CStdLibFileIO::Create(const wchar_t * pName)
|
int CStdLibFileIO::Create(const char* pName)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ public:
|
|||||||
int SetEOF();
|
int SetEOF();
|
||||||
|
|
||||||
// creation / destruction
|
// creation / destruction
|
||||||
int Create(const wchar_t * pName);
|
int Create(const char* pName);
|
||||||
int Delete();
|
int Delete();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
int GetPosition();
|
int GetPosition();
|
||||||
int GetSize();
|
int GetSize();
|
||||||
int GetName(wchar_t * pBuffer);
|
int GetName(char* pBuffer);
|
||||||
int GetHandle();
|
int GetHandle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const uint32 RANGE_TOTAL_1[65] = {0u,14824u,28224u,39348u,47855u,53994u,58171u,
|
|||||||
65509u,65510u,65511u,65512u,65513u,65514u,65515u,65516u,65517u,65518u,
|
65509u,65510u,65511u,65512u,65513u,65514u,65515u,65516u,65517u,65518u,
|
||||||
65519u,65520u,65521u,65522u,65523u,65524u,65525u,65526u,65527u,65528u,
|
65519u,65520u,65521u,65522u,65523u,65524u,65525u,65526u,65527u,65528u,
|
||||||
65529u,65530u,65531u,65532u,65533u,65534u,65535u,65536u};
|
65529u,65530u,65531u,65532u,65533u,65534u,65535u,65536u};
|
||||||
|
|
||||||
const uint32 RANGE_WIDTH_1[64] = {14824u,13400u,11124u,8507u,6139u,4177u,2755u,
|
const uint32 RANGE_WIDTH_1[64] = {14824u,13400u,11124u,8507u,6139u,4177u,2755u,
|
||||||
1756u,1104u,677u,415u,248u,150u,89u,54u,31u,19u,11u,7u,4u,2u,1u,1u,1u,1u,1u,
|
1756u,1104u,677u,415u,248u,150u,89u,54u,31u,19u,11u,7u,4u,2u,1u,1u,1u,1u,1u,
|
||||||
1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,
|
1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,1u,
|
||||||
@@ -54,11 +54,6 @@ const uint32 RANGE_WIDTH_2[64] = {19578u,16582u,12257u,7906u,4576u,2366u,1170u,
|
|||||||
|
|
||||||
#define MODEL_ELEMENTS 64
|
#define MODEL_ELEMENTS 64
|
||||||
|
|
||||||
#if __GNUC__ != 2
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
CUnBitArray::CUnBitArray(CIO * pIO, int nVersion)
|
CUnBitArray::CUnBitArray(CIO * pIO, int nVersion)
|
||||||
{
|
{
|
||||||
@@ -112,7 +107,7 @@ CUnBitArray::RangeDecodeFast(int nShift)
|
|||||||
{
|
{
|
||||||
while (m_RangeCoderInfo.range <= BOTTOM_VALUE) {
|
while (m_RangeCoderInfo.range <= BOTTOM_VALUE) {
|
||||||
m_RangeCoderInfo.buffer = (m_RangeCoderInfo.buffer << 8)
|
m_RangeCoderInfo.buffer = (m_RangeCoderInfo.buffer << 8)
|
||||||
| ((m_pBitArray[m_nCurrentBitIndex >> 5]
|
| ((m_pBitArray[m_nCurrentBitIndex >> 5]
|
||||||
>> (24 - (m_nCurrentBitIndex & 31))) & 0xFF);
|
>> (24 - (m_nCurrentBitIndex & 31))) & 0xFF);
|
||||||
m_nCurrentBitIndex += 8;
|
m_nCurrentBitIndex += 8;
|
||||||
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8)
|
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8)
|
||||||
@@ -172,9 +167,9 @@ CUnBitArray::DecodeValueRange(UNBIT_ARRAY_STATE & BitArrayState)
|
|||||||
nOverflow++;
|
nOverflow++;
|
||||||
|
|
||||||
// update
|
// update
|
||||||
m_RangeCoderInfo.low -= m_RangeCoderInfo.range
|
m_RangeCoderInfo.low -= m_RangeCoderInfo.range
|
||||||
* RANGE_TOTAL_2[nOverflow];
|
* RANGE_TOTAL_2[nOverflow];
|
||||||
m_RangeCoderInfo.range = m_RangeCoderInfo.range
|
m_RangeCoderInfo.range = m_RangeCoderInfo.range
|
||||||
* RANGE_WIDTH_2[nOverflow];
|
* RANGE_WIDTH_2[nOverflow];
|
||||||
|
|
||||||
// get the working k
|
// get the working k
|
||||||
@@ -191,14 +186,14 @@ CUnBitArray::DecodeValueRange(UNBIT_ARRAY_STATE & BitArrayState)
|
|||||||
int nPivotValueBits = 0;
|
int nPivotValueBits = 0;
|
||||||
while ((nPivotValue >> nPivotValueBits) > 0)
|
while ((nPivotValue >> nPivotValueBits) > 0)
|
||||||
nPivotValueBits++;
|
nPivotValueBits++;
|
||||||
|
|
||||||
int nSplitFactor = 1 << (nPivotValueBits - 16);
|
int nSplitFactor = 1 << (nPivotValueBits - 16);
|
||||||
int nPivotValueA = (nPivotValue / nSplitFactor) + 1;
|
int nPivotValueA = (nPivotValue / nSplitFactor) + 1;
|
||||||
int nPivotValueB = nSplitFactor;
|
int nPivotValueB = nSplitFactor;
|
||||||
|
|
||||||
while (m_RangeCoderInfo.range <= BOTTOM_VALUE) {
|
while (m_RangeCoderInfo.range <= BOTTOM_VALUE) {
|
||||||
m_RangeCoderInfo.buffer = (m_RangeCoderInfo.buffer << 8)
|
m_RangeCoderInfo.buffer = (m_RangeCoderInfo.buffer << 8)
|
||||||
| ((m_pBitArray[m_nCurrentBitIndex >> 5]
|
| ((m_pBitArray[m_nCurrentBitIndex >> 5]
|
||||||
>> (24 - (m_nCurrentBitIndex & 31))) & 0xFF);
|
>> (24 - (m_nCurrentBitIndex & 31))) & 0xFF);
|
||||||
m_nCurrentBitIndex += 8;
|
m_nCurrentBitIndex += 8;
|
||||||
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8)
|
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8)
|
||||||
@@ -211,7 +206,7 @@ CUnBitArray::DecodeValueRange(UNBIT_ARRAY_STATE & BitArrayState)
|
|||||||
|
|
||||||
while (m_RangeCoderInfo.range <= BOTTOM_VALUE) {
|
while (m_RangeCoderInfo.range <= BOTTOM_VALUE) {
|
||||||
m_RangeCoderInfo.buffer = (m_RangeCoderInfo.buffer << 8)
|
m_RangeCoderInfo.buffer = (m_RangeCoderInfo.buffer << 8)
|
||||||
| ((m_pBitArray[m_nCurrentBitIndex >> 5]
|
| ((m_pBitArray[m_nCurrentBitIndex >> 5]
|
||||||
>> (24 - (m_nCurrentBitIndex & 31))) & 0xFF);
|
>> (24 - (m_nCurrentBitIndex & 31))) & 0xFF);
|
||||||
m_nCurrentBitIndex += 8;
|
m_nCurrentBitIndex += 8;
|
||||||
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8)
|
m_RangeCoderInfo.low = (m_RangeCoderInfo.low << 8)
|
||||||
@@ -281,7 +276,7 @@ CUnBitArray::DecodeValueRange(UNBIT_ARRAY_STATE & BitArrayState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update nKSum
|
// update nKSum
|
||||||
BitArrayState.nKSum += ((nValue + 1) / 2)
|
BitArrayState.nKSum += ((nValue + 1) / 2)
|
||||||
- ((BitArrayState.nKSum + 16) >> 5);
|
- ((BitArrayState.nKSum + 16) >> 5);
|
||||||
|
|
||||||
// update k
|
// update k
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ struct RIFF_CHUNK_HEADER
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CInputSource * __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode)
|
CInputSource * __stdcall CreateInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode)
|
||||||
{
|
{
|
||||||
// error check the parameters
|
// error check the parameters
|
||||||
if ((pSourceName == NULL) || (wcslen(pSourceName) == 0))
|
if ((pSourceName == NULL) || (wcslen(pSourceName) == 0))
|
||||||
@@ -42,7 +42,7 @@ CInputSource * __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the extension
|
// get the extension
|
||||||
const wchar_t * pExtension = &pSourceName[wcslen(pSourceName)];
|
const char* pExtension = &pSourceName[wcslen(pSourceName)];
|
||||||
while ((pExtension > pSourceName) && (*pExtension != '.'))
|
while ((pExtension > pSourceName) && (*pExtension != '.'))
|
||||||
pExtension--;
|
pExtension--;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ CWAVInputSource::CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTo
|
|||||||
if (pErrorCode) *pErrorCode = nRetVal;
|
if (pErrorCode) *pErrorCode = nRetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWAVInputSource::CWAVInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode)
|
CWAVInputSource::CWAVInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode)
|
||||||
: CInputSource(pSourceName, pwfeSource, pTotalBlocks, pHeaderBytes, pTerminatingBytes, pErrorCode)
|
: CInputSource(pSourceName, pwfeSource, pTotalBlocks, pHeaderBytes, pTerminatingBytes, pErrorCode)
|
||||||
{
|
{
|
||||||
m_bIsValid = FALSE;
|
m_bIsValid = FALSE;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
|
|
||||||
// construction / destruction
|
// construction / destruction
|
||||||
CInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
|
CInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
|
||||||
CInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
|
CInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
|
||||||
virtual ~CInputSource() { }
|
virtual ~CInputSource() { }
|
||||||
|
|
||||||
// get data
|
// get data
|
||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
// construction / destruction
|
// construction / destruction
|
||||||
CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
|
CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
|
||||||
CWAVInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
|
CWAVInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
|
||||||
~CWAVInputSource();
|
~CWAVInputSource();
|
||||||
|
|
||||||
// get data
|
// get data
|
||||||
@@ -63,7 +63,7 @@ private:
|
|||||||
Input souce creation
|
Input souce creation
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
extern "C" { // SHINTA: export
|
extern "C" { // SHINTA: export
|
||||||
DLLEXPORT CInputSource* __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
|
DLLEXPORT CInputSource* __stdcall CreateInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifndef APE_WAVINPUTSOURCE_H
|
#endif // #ifndef APE_WAVINPUTSOURCE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user