mirror of
https://github.com/openharmony/third_party_lame.git
synced 2026-07-01 05:53:58 -04:00
fixing some issues found by the cppcheck tool
This commit is contained in:
@@ -44,7 +44,7 @@ void TiXmlBase::PutString( const std::string& str, std::ostream* stream )
|
||||
{
|
||||
stream->write( &str.at( i ), str.length() - i );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// We found an entity.
|
||||
if ( next - i > 0 )
|
||||
@@ -52,8 +52,8 @@ void TiXmlBase::PutString( const std::string& str, std::ostream* stream )
|
||||
i = next;
|
||||
|
||||
// Check for the special "&#x" entitity
|
||||
if ( i < str.length() - 2
|
||||
&& str[i] == '&'
|
||||
if ( i < str.length() - 2
|
||||
&& str[i] == '&'
|
||||
&& str[i+1] == '#'
|
||||
&& str[i+2] == 'x' )
|
||||
{
|
||||
@@ -862,10 +862,10 @@ TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
|
||||
const std::string& _encoding,
|
||||
const std::string& _standalone )
|
||||
: TiXmlNode( TiXmlNode::DECLARATION )
|
||||
, version( _version )
|
||||
, encoding( _encoding )
|
||||
, standalone( _standalone )
|
||||
{
|
||||
version = _version;
|
||||
encoding = _encoding;
|
||||
standalone = _standalone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -699,16 +699,12 @@ const char* TiXmlUnknown::Parse( const char* p )
|
||||
++p;
|
||||
value = "";
|
||||
|
||||
while ( p && *p && *p != '>' )
|
||||
while ( *p && *p != '>' )
|
||||
{
|
||||
value += *p;
|
||||
++p;
|
||||
}
|
||||
|
||||
if ( !p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN );
|
||||
}
|
||||
if ( *p == '>' )
|
||||
return p+1;
|
||||
return p;
|
||||
|
||||
+67
-58
@@ -35,13 +35,46 @@ BEVERSION beVersion=NULL;
|
||||
BEWRITEVBRHEADER beWriteVBRHeader=NULL;
|
||||
BEWRITEINFOTAG beWriteInfoTag=NULL;
|
||||
|
||||
struct Resources
|
||||
{
|
||||
HINSTANCE hDLL;
|
||||
FILE* pFileIn;
|
||||
FILE* pFileOut;
|
||||
HBE_STREAM hbeStream;
|
||||
PBYTE pMP3Buffer;
|
||||
PSHORT pWAVBuffer;
|
||||
|
||||
Resources()
|
||||
{
|
||||
hDLL =NULL;
|
||||
pFileIn =NULL;
|
||||
pFileOut =NULL;
|
||||
hbeStream =0;
|
||||
pMP3Buffer =NULL;
|
||||
pWAVBuffer =NULL;
|
||||
}
|
||||
|
||||
~Resources()
|
||||
{
|
||||
// close the MP3 Stream
|
||||
if (hbeStream) beCloseStream(hbeStream);
|
||||
// Delete WAV buffer
|
||||
if (pWAVBuffer) delete [] pWAVBuffer;
|
||||
// Delete MP3 Buffer
|
||||
if (pMP3Buffer) delete [] pMP3Buffer;
|
||||
// Close input file
|
||||
if (pFileIn) fclose(pFileIn);
|
||||
// Close output file
|
||||
if (pFileOut) fclose(pFileOut);
|
||||
// Were done, return OK result
|
||||
if (hDLL) FreeLibrary(hDLL);
|
||||
}
|
||||
};
|
||||
|
||||
// Main program
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
HINSTANCE hDLL =NULL;
|
||||
FILE* pFileIn =NULL;
|
||||
FILE* pFileOut =NULL;
|
||||
Resources r; // frees Resources on destruction at block scope end
|
||||
BE_VERSION Version ={0,};
|
||||
BE_CONFIG beConfig ={0,};
|
||||
|
||||
@@ -50,12 +83,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
DWORD dwSamples =0;
|
||||
DWORD dwMP3Buffer =0;
|
||||
HBE_STREAM hbeStream =0;
|
||||
BE_ERR err =0;
|
||||
|
||||
PBYTE pMP3Buffer =NULL;
|
||||
PSHORT pWAVBuffer =NULL;
|
||||
|
||||
// check number of arguments
|
||||
if(argc != 2)
|
||||
{
|
||||
@@ -76,27 +105,27 @@ int main(int argc, char *argv[])
|
||||
// Load lame_enc.dll library (Make sure though that you set the
|
||||
// project/settings/debug Working Directory correctly, otherwhise the DLL can't be loaded
|
||||
|
||||
hDLL = LoadLibrary("lame_enc.dll");
|
||||
r.hDLL = LoadLibrary("lame_enc.dll");
|
||||
|
||||
if ( NULL == hDLL )
|
||||
{
|
||||
hDLL = LoadLibrary("..\\..\\output\\lame_enc.dll");
|
||||
}
|
||||
if ( NULL == r.hDLL )
|
||||
{
|
||||
r.hDLL = LoadLibrary("..\\..\\output\\lame_enc.dll");
|
||||
}
|
||||
|
||||
if( NULL == hDLL )
|
||||
if( NULL == r.hDLL )
|
||||
{
|
||||
fprintf(stderr,"Error loading lame_enc.DLL");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get Interface functions from the DLL
|
||||
beInitStream = (BEINITSTREAM) GetProcAddress(hDLL, TEXT_BEINITSTREAM);
|
||||
beEncodeChunk = (BEENCODECHUNK) GetProcAddress(hDLL, TEXT_BEENCODECHUNK);
|
||||
beDeinitStream = (BEDEINITSTREAM) GetProcAddress(hDLL, TEXT_BEDEINITSTREAM);
|
||||
beCloseStream = (BECLOSESTREAM) GetProcAddress(hDLL, TEXT_BECLOSESTREAM);
|
||||
beVersion = (BEVERSION) GetProcAddress(hDLL, TEXT_BEVERSION);
|
||||
beWriteVBRHeader= (BEWRITEVBRHEADER) GetProcAddress(hDLL,TEXT_BEWRITEVBRHEADER);
|
||||
beWriteInfoTag = (BEWRITEINFOTAG) GetProcAddress(hDLL,TEXT_BEWRITEINFOTAG);
|
||||
beInitStream = (BEINITSTREAM) GetProcAddress(r.hDLL, TEXT_BEINITSTREAM);
|
||||
beEncodeChunk = (BEENCODECHUNK) GetProcAddress(r.hDLL, TEXT_BEENCODECHUNK);
|
||||
beDeinitStream = (BEDEINITSTREAM) GetProcAddress(r.hDLL, TEXT_BEDEINITSTREAM);
|
||||
beCloseStream = (BECLOSESTREAM) GetProcAddress(r.hDLL, TEXT_BECLOSESTREAM);
|
||||
beVersion = (BEVERSION) GetProcAddress(r.hDLL, TEXT_BEVERSION);
|
||||
beWriteVBRHeader= (BEWRITEVBRHEADER) GetProcAddress(r.hDLL,TEXT_BEWRITEVBRHEADER);
|
||||
beWriteInfoTag = (BEWRITEINFOTAG) GetProcAddress(r.hDLL,TEXT_BEWRITEINFOTAG);
|
||||
|
||||
// Check if all interfaces are present
|
||||
if(!beInitStream || !beEncodeChunk || !beDeinitStream || !beCloseStream || !beVersion || !beWriteVBRHeader)
|
||||
@@ -118,23 +147,22 @@ int main(int argc, char *argv[])
|
||||
Version.zHomepage);
|
||||
|
||||
// Try to open the WAV file, be sure to open it as a binary file!
|
||||
pFileIn = fopen( strFileIn, "rb" );
|
||||
r.pFileIn = fopen( strFileIn, "rb" );
|
||||
|
||||
// Check file open result
|
||||
if(pFileIn == NULL)
|
||||
if(r.pFileIn == NULL)
|
||||
{
|
||||
fprintf(stderr,"Error opening %s", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Open MP3 file
|
||||
pFileOut= fopen(strFileOut,"wb+");
|
||||
r.pFileOut= fopen(strFileOut,"wb+");
|
||||
|
||||
// Check file open result
|
||||
if(pFileOut == NULL)
|
||||
if(r.pFileOut == NULL)
|
||||
{
|
||||
fprintf(stderr,"Error creating file %s", strFileOut);
|
||||
fclose(pFileIn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -170,30 +198,26 @@ int main(int argc, char *argv[])
|
||||
// beConfig.format.LHV1.nPreset = LQP_PHONE;
|
||||
|
||||
// Init the MP3 Stream
|
||||
err = beInitStream(&beConfig, &dwSamples, &dwMP3Buffer, &hbeStream);
|
||||
err = beInitStream(&beConfig, &dwSamples, &dwMP3Buffer, &r.hbeStream);
|
||||
|
||||
// Check result
|
||||
if(err != BE_ERR_SUCCESSFUL)
|
||||
{
|
||||
fprintf(stderr,"Error opening encoding stream (%lu)", err);
|
||||
fclose(pFileIn);
|
||||
fclose(pFileOut);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Allocate MP3 buffer
|
||||
pMP3Buffer = new BYTE[dwMP3Buffer];
|
||||
r.pMP3Buffer = new BYTE[dwMP3Buffer];
|
||||
|
||||
// Allocate WAV buffer
|
||||
pWAVBuffer = new SHORT[dwSamples];
|
||||
r.pWAVBuffer = new SHORT[dwSamples];
|
||||
|
||||
// Check if Buffer are allocated properly
|
||||
if(!pMP3Buffer || !pWAVBuffer)
|
||||
if(!r.pMP3Buffer || !r.pWAVBuffer)
|
||||
{
|
||||
printf("Out of memory");
|
||||
fclose(pFileIn);
|
||||
fclose(pFileOut);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -203,32 +227,31 @@ int main(int argc, char *argv[])
|
||||
DWORD dwFileSize=0;
|
||||
|
||||
// Seek to end of file
|
||||
fseek(pFileIn,0,SEEK_END);
|
||||
fseek(r.pFileIn,0,SEEK_END);
|
||||
|
||||
// Get the file size
|
||||
dwFileSize=ftell(pFileIn);
|
||||
dwFileSize=ftell(r.pFileIn);
|
||||
|
||||
// Seek back to start of WAV file,
|
||||
// but skip the first 44 bytes, since that's the WAV header
|
||||
fseek(pFileIn,44,SEEK_SET);
|
||||
fseek(r.pFileIn,44,SEEK_SET);
|
||||
|
||||
|
||||
// Convert All PCM samples
|
||||
while ( (dwRead=fread(pWAVBuffer,sizeof(SHORT),dwSamples,pFileIn)) >0 )
|
||||
while ( (dwRead=fread(r.pWAVBuffer,sizeof(SHORT),dwSamples,r.pFileIn)) >0 )
|
||||
{
|
||||
// Encode samples
|
||||
err = beEncodeChunk(hbeStream, dwRead, pWAVBuffer, pMP3Buffer, &dwWrite);
|
||||
err = beEncodeChunk(r.hbeStream, dwRead, r.pWAVBuffer, r.pMP3Buffer, &dwWrite);
|
||||
|
||||
// Check result
|
||||
if(err != BE_ERR_SUCCESSFUL)
|
||||
{
|
||||
beCloseStream(hbeStream);
|
||||
fprintf(stderr,"beEncodeChunk() failed (%lu)", err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// write dwWrite bytes that are returned in tehe pMP3Buffer to disk
|
||||
if(fwrite(pMP3Buffer,1,dwWrite,pFileOut) != dwWrite)
|
||||
if(fwrite(r.pMP3Buffer,1,dwWrite,r.pFileOut) != dwWrite)
|
||||
{
|
||||
fprintf(stderr,"Output file write error");
|
||||
return -1;
|
||||
@@ -240,13 +263,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Deinit the stream
|
||||
err = beDeinitStream(hbeStream, pMP3Buffer, &dwWrite);
|
||||
err = beDeinitStream(r.hbeStream, r.pMP3Buffer, &dwWrite);
|
||||
|
||||
// Check result
|
||||
if(err != BE_ERR_SUCCESSFUL)
|
||||
{
|
||||
|
||||
beCloseStream(hbeStream);
|
||||
fprintf(stderr,"beExitStream failed (%lu)", err);
|
||||
return -1;
|
||||
}
|
||||
@@ -255,32 +276,20 @@ int main(int argc, char *argv[])
|
||||
// If so, write them to disk
|
||||
if( dwWrite )
|
||||
{
|
||||
if( fwrite( pMP3Buffer, 1, dwWrite, pFileOut ) != dwWrite )
|
||||
if( fwrite( r.pMP3Buffer, 1, dwWrite, r.pFileOut ) != dwWrite )
|
||||
{
|
||||
fprintf(stderr,"Output file write error");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// close the MP3 Stream
|
||||
beCloseStream( hbeStream );
|
||||
|
||||
// Delete WAV buffer
|
||||
delete [] pWAVBuffer;
|
||||
|
||||
// Delete MP3 Buffer
|
||||
delete [] pMP3Buffer;
|
||||
|
||||
// Close input file
|
||||
fclose( pFileIn );
|
||||
|
||||
// Close output file
|
||||
fclose( pFileOut );
|
||||
fclose( r.pFileOut );
|
||||
|
||||
if ( beWriteInfoTag )
|
||||
{
|
||||
// Write the INFO Tag
|
||||
beWriteInfoTag( hbeStream, strFileOut );
|
||||
beWriteInfoTag( r.hbeStream, strFileOut );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+3
-3
@@ -28,13 +28,13 @@
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CEncoder::CEncoder() :
|
||||
pgf(NULL),
|
||||
m_bInpuTypeSet(FALSE),
|
||||
m_bOutpuTypeSet(FALSE),
|
||||
m_bFinished(FALSE),
|
||||
m_outOffset(0),
|
||||
m_outReadOffset(0),
|
||||
m_frameCount(0),
|
||||
pgf(NULL)
|
||||
m_outOffset(0),
|
||||
m_outReadOffset(0)
|
||||
{
|
||||
m_outFrameBuf = new unsigned char[OUT_BUFFER_SIZE];
|
||||
}
|
||||
|
||||
+6
-6
@@ -134,16 +134,16 @@ public:
|
||||
// Encode media sample data
|
||||
int Encode(const short * pdata, int data_size);
|
||||
int GetFrame(const unsigned char ** pframe);
|
||||
|
||||
// Returns block of a mp3 file, witch size integer multiples of cbAlign
|
||||
int GetBlockAligned(const unsigned char ** pblock, int* piBufferSize, const long& cbAlign);
|
||||
|
||||
// Returns block of a mp3 file, witch size integer multiples of cbAlign
|
||||
int GetBlockAligned(const unsigned char ** pblock, int* piBufferSize, const long& cbAlign);
|
||||
|
||||
HRESULT Finish();
|
||||
|
||||
protected:
|
||||
HRESULT updateLameTagFrame(IStream* pStream);
|
||||
HRESULT skipId3v2(IStream *pStream, size_t lametag_frame_size);
|
||||
HRESULT maybeSyncWord(IStream *pStream);
|
||||
HRESULT updateLameTagFrame(IStream* pStream);
|
||||
static HRESULT skipId3v2(IStream *pStream, size_t lametag_frame_size);
|
||||
static HRESULT maybeSyncWord(IStream *pStream);
|
||||
HRESULT SetDefaultOutputType(LPWAVEFORMATEX lpwfex);
|
||||
|
||||
// Input media type
|
||||
|
||||
+155
-161
@@ -159,7 +159,7 @@ AMOVIESETUP_PIN sudMpgPins[] =
|
||||
|
||||
AMOVIESETUP_FILTER sudMpgAEnc =
|
||||
{
|
||||
&CLSID_LAMEDShowFilter,
|
||||
&CLSID_LAMEDShowFilter,
|
||||
L"LAME Audio Encoder",
|
||||
DEFAULT_FILTER_MERIT, // Standard compressor merit value
|
||||
NUMELMS(sudMpgPins), // 2 pins
|
||||
@@ -380,34 +380,33 @@ HRESULT CMpegAudEnc::FlushEncodedSamples()
|
||||
IMediaSample * pOutSample = NULL;
|
||||
BYTE * pDst = NULL;
|
||||
|
||||
if(m_bStreamOutput)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
const unsigned char * pblock = NULL;
|
||||
int iBufferSize;
|
||||
int iBlockLength = m_Encoder.GetBlockAligned(&pblock, &iBufferSize, m_cbStreamAlignment);
|
||||
|
||||
if(!iBlockLength)
|
||||
return S_OK;
|
||||
if(m_bStreamOutput)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
const unsigned char * pblock = NULL;
|
||||
int iBufferSize;
|
||||
int iBlockLength = m_Encoder.GetBlockAligned(&pblock, &iBufferSize, m_cbStreamAlignment);
|
||||
|
||||
hr = m_pOutput->GetDeliveryBuffer(&pOutSample, NULL, NULL, 0);
|
||||
if (hr == S_OK && pOutSample)
|
||||
{
|
||||
hr = pOutSample->GetPointer(&pDst);
|
||||
if (hr == S_OK && pDst)
|
||||
{
|
||||
CopyMemory(pDst, pblock, iBlockLength);
|
||||
REFERENCE_TIME rtEndPos = m_rtBytePos + iBufferSize;
|
||||
EXECUTE_ASSERT(S_OK == pOutSample->SetTime(&m_rtBytePos, &rtEndPos));
|
||||
pOutSample->SetActualDataLength(iBufferSize);
|
||||
m_rtBytePos += iBlockLength;
|
||||
m_pOutput->Deliver(pOutSample);
|
||||
}
|
||||
if(!iBlockLength)
|
||||
return S_OK;
|
||||
|
||||
pOutSample->Release();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
hr = m_pOutput->GetDeliveryBuffer(&pOutSample, NULL, NULL, 0);
|
||||
if (hr == S_OK && pOutSample)
|
||||
{
|
||||
hr = pOutSample->GetPointer(&pDst);
|
||||
if (hr == S_OK && pDst)
|
||||
{
|
||||
CopyMemory(pDst, pblock, iBlockLength);
|
||||
REFERENCE_TIME rtEndPos = m_rtBytePos + iBufferSize;
|
||||
EXECUTE_ASSERT(S_OK == pOutSample->SetTime(&m_rtBytePos, &rtEndPos));
|
||||
pOutSample->SetActualDataLength(iBufferSize);
|
||||
m_rtBytePos += iBlockLength;
|
||||
m_pOutput->Deliver(pOutSample);
|
||||
}
|
||||
pOutSample->Release();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (m_rtStreamTime < 0)
|
||||
m_rtStreamTime = 0;
|
||||
@@ -434,28 +433,20 @@ HRESULT CMpegAudEnc::FlushEncodedSamples()
|
||||
REFERENCE_TIME rtStart = m_rtStreamTime;
|
||||
REFERENCE_TIME rtStop = rtStart + m_rtFrameTime;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
hr = m_pOutput->GetDeliveryBuffer(&pOutSample, NULL, NULL, 0);
|
||||
if (hr == S_OK && pOutSample)
|
||||
{
|
||||
hr = pOutSample->GetPointer(&pDst);
|
||||
if (hr == S_OK && pDst)
|
||||
{
|
||||
CopyMemory(pDst, pframe, frame_size);
|
||||
pOutSample->SetActualDataLength(frame_size);
|
||||
|
||||
pOutSample->SetSyncPoint(TRUE);
|
||||
pOutSample->SetTime(&rtStart, m_setDuration ? &rtStop : NULL);
|
||||
|
||||
|
||||
m_pOutput->Deliver(pOutSample);
|
||||
}
|
||||
|
||||
pOutSample->Release();
|
||||
}
|
||||
|
||||
|
||||
HRESULT hr = m_pOutput->GetDeliveryBuffer(&pOutSample, NULL, NULL, 0);
|
||||
if (hr == S_OK && pOutSample)
|
||||
{
|
||||
hr = pOutSample->GetPointer(&pDst);
|
||||
if (hr == S_OK && pDst)
|
||||
{
|
||||
CopyMemory(pDst, pframe, frame_size);
|
||||
pOutSample->SetActualDataLength(frame_size);
|
||||
pOutSample->SetSyncPoint(TRUE);
|
||||
pOutSample->SetTime(&rtStart, m_setDuration ? &rtStop : NULL);
|
||||
m_pOutput->Deliver(pOutSample);
|
||||
}
|
||||
pOutSample->Release();
|
||||
}
|
||||
m_samplesOut += m_samplesPerFrame;
|
||||
m_rtStreamTime = rtStop;
|
||||
}
|
||||
@@ -472,26 +463,23 @@ HRESULT CMpegAudEnc::StartStreaming()
|
||||
WAVEFORMATEX * pwfxIn = (WAVEFORMATEX *) m_pInput->CurrentMediaType().Format();
|
||||
|
||||
m_bytesPerSample = pwfxIn->nChannels * sizeof(short);
|
||||
DWORD dwOutSampleRate;
|
||||
if(MEDIATYPE_Stream == m_pOutput->CurrentMediaType().majortype)
|
||||
{
|
||||
MPEG_ENCODER_CONFIG mcfg;
|
||||
if(FAILED(m_Encoder.GetOutputType(&mcfg)))
|
||||
return E_FAIL;
|
||||
|
||||
dwOutSampleRate = mcfg.dwSampleRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwOutSampleRate = ((WAVEFORMATEX *) m_pOutput->CurrentMediaType().Format())->nSamplesPerSec;
|
||||
}
|
||||
m_samplesPerFrame = (dwOutSampleRate >= 32000) ? 1152 : 576;
|
||||
|
||||
DWORD dwOutSampleRate;
|
||||
if(MEDIATYPE_Stream == m_pOutput->CurrentMediaType().majortype)
|
||||
{
|
||||
MPEG_ENCODER_CONFIG mcfg;
|
||||
if(FAILED(m_Encoder.GetOutputType(&mcfg)))
|
||||
return E_FAIL;
|
||||
dwOutSampleRate = mcfg.dwSampleRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwOutSampleRate = ((WAVEFORMATEX *) m_pOutput->CurrentMediaType().Format())->nSamplesPerSec;
|
||||
}
|
||||
m_samplesPerFrame = (dwOutSampleRate >= 32000) ? 1152 : 576;
|
||||
m_rtFrameTime = MulDiv(10000000, m_samplesPerFrame, dwOutSampleRate);
|
||||
|
||||
m_samplesIn = m_samplesOut = 0;
|
||||
m_rtStreamTime = -1;
|
||||
m_rtBytePos = 0;
|
||||
m_rtBytePos = 0;
|
||||
|
||||
// initialize encoder
|
||||
m_Encoder.Init();
|
||||
@@ -511,27 +499,27 @@ HRESULT CMpegAudEnc::StartStreaming()
|
||||
get_SetDuration(&m_setDuration);
|
||||
get_SampleOverlap(&m_allowOverlap);
|
||||
|
||||
return S_OK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CMpegAudEnc::StopStreaming()
|
||||
{
|
||||
IStream *pStream = NULL;
|
||||
if(m_bStreamOutput && m_pOutput->IsConnected() != FALSE)
|
||||
{
|
||||
IPin * pDwnstrmInputPin = m_pOutput->GetConnected();
|
||||
if(pDwnstrmInputPin && FAILED(pDwnstrmInputPin->QueryInterface(IID_IStream, (LPVOID*)(&pStream))))
|
||||
{
|
||||
pStream = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
IStream *pStream = NULL;
|
||||
if(m_bStreamOutput && m_pOutput->IsConnected() != FALSE)
|
||||
{
|
||||
IPin * pDwnstrmInputPin = m_pOutput->GetConnected();
|
||||
if(pDwnstrmInputPin && FAILED(pDwnstrmInputPin->QueryInterface(IID_IStream, (LPVOID*)(&pStream))))
|
||||
{
|
||||
pStream = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_Encoder.Close(pStream);
|
||||
m_Encoder.Close(pStream);
|
||||
|
||||
if(pStream)
|
||||
pStream->Release();
|
||||
if(pStream)
|
||||
pStream->Release();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -548,30 +536,30 @@ HRESULT CMpegAudEnc::EndOfStream()
|
||||
m_Encoder.Finish();
|
||||
FlushEncodedSamples();
|
||||
|
||||
IStream *pStream = NULL;
|
||||
IStream *pStream = NULL;
|
||||
if(m_bStreamOutput && m_pOutput->IsConnected() != FALSE)
|
||||
{
|
||||
IPin * pDwnstrmInputPin = m_pOutput->GetConnected();
|
||||
if(pDwnstrmInputPin)
|
||||
{
|
||||
if(FAILED(pDwnstrmInputPin->QueryInterface(IID_IStream, (LPVOID*)(&pStream))))
|
||||
{
|
||||
pStream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
IPin * pDwnstrmInputPin = m_pOutput->GetConnected();
|
||||
if(pDwnstrmInputPin)
|
||||
{
|
||||
if(FAILED(pDwnstrmInputPin->QueryInterface(IID_IStream, (LPVOID*)(&pStream))))
|
||||
{
|
||||
pStream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(pStream)
|
||||
{
|
||||
ULARGE_INTEGER size;
|
||||
size.QuadPart = m_rtBytePos;
|
||||
pStream->SetSize(size);
|
||||
}
|
||||
if(pStream)
|
||||
{
|
||||
ULARGE_INTEGER size;
|
||||
size.QuadPart = m_rtBytePos;
|
||||
pStream->SetSize(size);
|
||||
}
|
||||
|
||||
m_Encoder.Close(pStream);
|
||||
m_Encoder.Close(pStream);
|
||||
|
||||
if(pStream)
|
||||
pStream->Release();
|
||||
if(pStream)
|
||||
pStream->Release();
|
||||
|
||||
m_hasFinished = TRUE;
|
||||
|
||||
@@ -596,20 +584,20 @@ HRESULT CMpegAudEnc::BeginFlush()
|
||||
m_Encoder.Finish();
|
||||
FlushEncodedSamples();
|
||||
|
||||
IStream *pStream = NULL;
|
||||
if(m_bStreamOutput && m_pOutput->IsConnected() != FALSE)
|
||||
{
|
||||
IPin * pDwnstrmInputPin = m_pOutput->GetConnected();
|
||||
if(pDwnstrmInputPin && SUCCEEDED(pDwnstrmInputPin->QueryInterface(IID_IStream, (LPVOID*)(&pStream))))
|
||||
{
|
||||
ULARGE_INTEGER size;
|
||||
size.QuadPart = m_rtBytePos;
|
||||
pStream->SetSize(size);
|
||||
pStream->Release();
|
||||
}
|
||||
}
|
||||
m_rtStreamTime = -1;
|
||||
m_rtBytePos = 0;
|
||||
IStream *pStream = NULL;
|
||||
if(m_bStreamOutput && m_pOutput->IsConnected() != FALSE)
|
||||
{
|
||||
IPin * pDwnstrmInputPin = m_pOutput->GetConnected();
|
||||
if(pDwnstrmInputPin && SUCCEEDED(pDwnstrmInputPin->QueryInterface(IID_IStream, (LPVOID*)(&pStream))))
|
||||
{
|
||||
ULARGE_INTEGER size;
|
||||
size.QuadPart = m_rtBytePos;
|
||||
pStream->SetSize(size);
|
||||
pStream->Release();
|
||||
}
|
||||
}
|
||||
m_rtStreamTime = -1;
|
||||
m_rtBytePos = 0;
|
||||
}
|
||||
|
||||
return hr;
|
||||
@@ -622,15 +610,18 @@ HRESULT CMpegAudEnc::BeginFlush()
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
HRESULT CMpegAudEnc::SetMediaType(PIN_DIRECTION direction, const CMediaType * pmt)
|
||||
{
|
||||
if (pmt == NULL)
|
||||
return E_POINTER;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (direction == PINDIR_INPUT)
|
||||
{
|
||||
if (*pmt->FormatType() != FORMAT_WaveFormatEx)
|
||||
if (*pmt->FormatType() != FORMAT_WaveFormatEx)
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
|
||||
if (pmt->FormatLength() < sizeof(WAVEFORMATEX))
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
if (pmt->FormatLength() < sizeof(WAVEFORMATEX))
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
|
||||
DbgLog((LOG_TRACE,1,TEXT("CMpegAudEnc::SetMediaType(), direction = PINDIR_INPUT")));
|
||||
|
||||
@@ -638,15 +629,17 @@ HRESULT CMpegAudEnc::SetMediaType(PIN_DIRECTION direction, const CMediaType * pm
|
||||
m_Encoder.SetInputType((LPWAVEFORMATEX)pmt->Format());
|
||||
|
||||
WAVEFORMATEX * pwfx = (WAVEFORMATEX *)pmt->Format();
|
||||
DWORD sample_rate = 44100;
|
||||
|
||||
if (pwfx)
|
||||
if (pwfx) {
|
||||
sample_rate = pwfx->nSamplesPerSec;
|
||||
m_bytesToDuration = (float)1.e7 / (float)(pwfx->nChannels * sizeof(short) * pwfx->nSamplesPerSec);
|
||||
else
|
||||
} else {
|
||||
m_bytesToDuration = 0.0;
|
||||
|
||||
}
|
||||
// Parse the encoder output capabilities into the subset of capabilities that are supported
|
||||
// for the current input format. This listing will be utilized by the IAMStreamConfig Interface.
|
||||
LoadOutputCapabilities(pwfx->nSamplesPerSec);
|
||||
LoadOutputCapabilities(sample_rate);
|
||||
|
||||
Reconnect();
|
||||
}
|
||||
@@ -695,30 +688,30 @@ HRESULT CMpegAudEnc::CheckInputType(const CMediaType* mtIn)
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
HRESULT CMpegAudEnc::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
|
||||
{
|
||||
if(MEDIATYPE_Stream != mtOut->majortype)
|
||||
{
|
||||
if (*mtOut->FormatType() != FORMAT_WaveFormatEx)
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
if(MEDIATYPE_Stream != mtOut->majortype)
|
||||
{
|
||||
if (*mtOut->FormatType() != FORMAT_WaveFormatEx)
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
|
||||
if (mtOut->FormatLength() < sizeof(WAVEFORMATEX))
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
if (mtOut->FormatLength() < sizeof(WAVEFORMATEX))
|
||||
return VFW_E_INVALIDMEDIATYPE;
|
||||
|
||||
MPEG_ENCODER_CONFIG mec;
|
||||
if(FAILED(m_Encoder.GetOutputType(&mec)))
|
||||
return S_OK;
|
||||
MPEG_ENCODER_CONFIG mec;
|
||||
if(FAILED(m_Encoder.GetOutputType(&mec)))
|
||||
return S_OK;
|
||||
|
||||
if (((LPWAVEFORMATEX)mtIn->Format())->nSamplesPerSec % mec.dwSampleRate != 0)
|
||||
return S_OK;
|
||||
if (((LPWAVEFORMATEX)mtIn->Format())->nSamplesPerSec % mec.dwSampleRate != 0)
|
||||
return S_OK;
|
||||
|
||||
if (mec.dwSampleRate != ((LPWAVEFORMATEX)mtOut->Format())->nSamplesPerSec)
|
||||
return VFW_E_TYPE_NOT_ACCEPTED;
|
||||
if (mec.dwSampleRate != ((LPWAVEFORMATEX)mtOut->Format())->nSamplesPerSec)
|
||||
return VFW_E_TYPE_NOT_ACCEPTED;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
else if(mtOut->subtype == MEDIASUBTYPE_MPEG1Audio)
|
||||
return S_OK;
|
||||
return S_OK;
|
||||
}
|
||||
else if(mtOut->subtype == MEDIASUBTYPE_MPEG1Audio)
|
||||
return S_OK;
|
||||
|
||||
return VFW_E_TYPE_NOT_ACCEPTED;
|
||||
return VFW_E_TYPE_NOT_ACCEPTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -730,16 +723,16 @@ HRESULT CMpegAudEnc::DecideBufferSize(
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if(m_bStreamOutput)
|
||||
m_cbStreamAlignment = pProperties->cbAlign;
|
||||
if(m_bStreamOutput)
|
||||
m_cbStreamAlignment = pProperties->cbAlign;
|
||||
|
||||
///
|
||||
if (pProperties->cBuffers == 0) pProperties->cBuffers = 1; // If downstream filter didn't suggest a buffer count then default to 1
|
||||
pProperties->cbBuffer = OUT_BUFFER_SIZE;
|
||||
//
|
||||
|
||||
ASSERT(pProperties->cbBuffer);
|
||||
|
||||
//
|
||||
|
||||
ASSERT(pProperties->cbBuffer);
|
||||
|
||||
ALLOCATOR_PROPERTIES Actual;
|
||||
hr = pAllocator->SetProperties(pProperties,&Actual);
|
||||
if(FAILED(hr))
|
||||
@@ -781,7 +774,7 @@ HRESULT CMpegAudEnc::Reconnect()
|
||||
{
|
||||
// Create an updated output MediaType using the current encoder settings
|
||||
CMediaType cmt;
|
||||
cmt.InitMediaType();
|
||||
cmt.InitMediaType();
|
||||
m_pOutput->GetMediaType(m_currentMediaTypeIndex, &cmt);
|
||||
|
||||
// If the updated MediaType matches the current output MediaType no reconnect is needed
|
||||
@@ -893,7 +886,7 @@ STDMETHODIMP CMpegAudEnc::NonDelegatingQueryInterface(REFIID riid, void ** ppv)
|
||||
|
||||
if (riid == IID_ISpecifyPropertyPages)
|
||||
return GetInterface((ISpecifyPropertyPages *) this, ppv);
|
||||
else if(riid == IID_IPersistStream)
|
||||
else if(riid == IID_IPersistStream)
|
||||
return GetInterface((IPersistStream *)this, ppv);
|
||||
// else if (riid == IID_IVAudioEncSettings)
|
||||
// return GetInterface((IVAudioEncSettings*) this, ppv);
|
||||
@@ -1400,9 +1393,8 @@ STDMETHODIMP CMpegAudEnc::set_ModeFixed(DWORD dwModeFixed)
|
||||
|
||||
STDMETHODIMP CMpegAudEnc::get_ParameterBlockSize(BYTE *pcBlock, DWORD *pdwSize)
|
||||
{
|
||||
DbgLog((LOG_TRACE, 1, TEXT("get_ParameterBlockSize -> %d%d"), *pcBlock, *pdwSize));
|
||||
|
||||
if (pcBlock != NULL) {
|
||||
if (pcBlock != NULL && pdwSize != NULL) {
|
||||
DbgLog((LOG_TRACE, 1, TEXT("get_ParameterBlockSize -> %d%d"), *pcBlock, *pdwSize));
|
||||
if (*pdwSize >= sizeof(MPEG_ENCODER_CONFIG)) {
|
||||
m_Encoder.GetOutputType((MPEG_ENCODER_CONFIG*)pcBlock);
|
||||
return S_OK;
|
||||
@@ -1422,12 +1414,14 @@ STDMETHODIMP CMpegAudEnc::get_ParameterBlockSize(BYTE *pcBlock, DWORD *pdwSize)
|
||||
|
||||
STDMETHODIMP CMpegAudEnc::set_ParameterBlockSize(BYTE *pcBlock, DWORD dwSize)
|
||||
{
|
||||
DbgLog((LOG_TRACE, 1, TEXT("get_ParameterBlockSize(%d, %d)"), *pcBlock, dwSize));
|
||||
if (sizeof(MPEG_ENCODER_CONFIG) == dwSize){
|
||||
m_Encoder.SetOutputType(*(MPEG_ENCODER_CONFIG*)pcBlock);
|
||||
return S_OK;
|
||||
if (pcBlock != NULL) {
|
||||
DbgLog((LOG_TRACE, 1, TEXT("get_ParameterBlockSize(%d, %d)"), *pcBlock, dwSize));
|
||||
if (sizeof(MPEG_ENCODER_CONFIG) == dwSize){
|
||||
m_Encoder.SetOutputType(*(MPEG_ENCODER_CONFIG*)pcBlock);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
else return E_FAIL;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1565,10 +1559,10 @@ HRESULT CMpegAudEnc::WriteToStream(IStream *pStream)
|
||||
{
|
||||
DbgLog((LOG_TRACE,1,TEXT("WriteToStream()")));
|
||||
|
||||
MPEG_ENCODER_CONFIG mec;
|
||||
MPEG_ENCODER_CONFIG mec;
|
||||
|
||||
if(m_Encoder.GetOutputType(&mec) == S_FALSE)
|
||||
return E_FAIL;
|
||||
if(m_Encoder.GetOutputType(&mec) == S_FALSE)
|
||||
return E_FAIL;
|
||||
|
||||
return pStream->Write(&mec, sizeof(mec), 0);
|
||||
}
|
||||
@@ -1578,14 +1572,14 @@ HRESULT CMpegAudEnc::WriteToStream(IStream *pStream)
|
||||
// are in
|
||||
HRESULT CMpegAudEnc::ReadFromStream(IStream *pStream)
|
||||
{
|
||||
MPEG_ENCODER_CONFIG mec;
|
||||
MPEG_ENCODER_CONFIG mec;
|
||||
|
||||
HRESULT hr = pStream->Read(&mec, sizeof(mec), 0);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if(m_Encoder.SetOutputType(mec) == S_FALSE)
|
||||
return S_FALSE;
|
||||
if(m_Encoder.SetOutputType(mec) == S_FALSE)
|
||||
return S_FALSE;
|
||||
|
||||
DbgLog((LOG_TRACE,1,TEXT("ReadFromStream() succeeded")));
|
||||
|
||||
|
||||
+3
-3
@@ -107,7 +107,7 @@ public:
|
||||
|
||||
HRESULT CheckInputType(const CMediaType* mtIn);
|
||||
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
|
||||
HRESULT DecideBufferSize(IMemAllocator * pAllocator, ALLOCATOR_PROPERTIES *pprop);
|
||||
HRESULT DecideBufferSize(IMemAllocator * pAllocator, ALLOCATOR_PROPERTIES *pProperties);
|
||||
|
||||
HRESULT GetMediaType (int iPosition, CMediaType *pMediaType);
|
||||
HRESULT SetMediaType (PIN_DIRECTION direction,const CMediaType *pmt);
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
|
||||
// ISpecifyPropertyPages
|
||||
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
|
||||
STDMETHODIMP GetPages(CAUUID *pPages);
|
||||
STDMETHODIMP GetPages(CAUUID *pcauuid);
|
||||
|
||||
// IAudioEncoderProperties
|
||||
STDMETHODIMP get_PESOutputEnabled(DWORD *dwEnabled); // PES header. Obsolete
|
||||
@@ -204,7 +204,7 @@ private:
|
||||
|
||||
HRESULT FlushEncodedSamples();
|
||||
|
||||
void ReadPresetSettings(MPEG_ENCODER_CONFIG *pmabsi);
|
||||
void ReadPresetSettings(MPEG_ENCODER_CONFIG *pmec);
|
||||
|
||||
void LoadOutputCapabilities(DWORD sample_rate);
|
||||
|
||||
|
||||
+10
-9
@@ -290,7 +290,7 @@ addPcmBuffer(PcmBuffer * b, void *a0, void *a1, int read)
|
||||
}
|
||||
a_n = read - b->skip_start;
|
||||
|
||||
if (b != 0 && a_n > 0) {
|
||||
if (a_n > 0) {
|
||||
int const a_skip = b->w * b->skip_start;
|
||||
int const a_want = b->w * a_n;
|
||||
int const b_used = b->w * b->u;
|
||||
@@ -368,7 +368,7 @@ static get_audio_global_data global;
|
||||
|
||||
|
||||
#ifdef AMIGA_MPEGA
|
||||
int lame_decode_initfile(const char *fullname, mp3data_struct * const mp3data);
|
||||
int lame_decode_initfile_amiga(const char *fullname, mp3data_struct * const mp3data);
|
||||
#else
|
||||
int lame_decode_initfile(FILE * fd, mp3data_struct * mp3data, int *enc_delay, int *enc_padding);
|
||||
#endif
|
||||
@@ -752,9 +752,7 @@ get_audio_common(lame_t gfp, int buffer[2][1152], short buffer16[2][1152])
|
||||
short buf_tmp16[2][1152];
|
||||
int samples_read;
|
||||
int samples_to_read;
|
||||
unsigned int remaining;
|
||||
int i;
|
||||
int *p;
|
||||
|
||||
/* sanity checks, that's what we expect to be true */
|
||||
if ((num_channels < 1 || 2 < num_channels)
|
||||
@@ -780,7 +778,7 @@ get_audio_common(lame_t gfp, int buffer[2][1152], short buffer16[2][1152])
|
||||
* are using LIBSNDFILE, this is not necessary
|
||||
*/
|
||||
if (global.count_samples_carefully) {
|
||||
unsigned int tmp_num_samples;
|
||||
unsigned int tmp_num_samples, remaining;
|
||||
/* get num_samples */
|
||||
if (is_mpeg_file_format(global_reader.input_format)) {
|
||||
tmp_num_samples = global_decoder.mp3input_data.nsamp;
|
||||
@@ -812,6 +810,7 @@ get_audio_common(lame_t gfp, int buffer[2][1152], short buffer16[2][1152])
|
||||
}
|
||||
}
|
||||
else {
|
||||
int *p;
|
||||
if (global.snd_file) {
|
||||
#ifdef LIBSNDFILE
|
||||
samples_read = sf_read_int(global.snd_file, insamp, num_channels * samples_to_read);
|
||||
@@ -1416,12 +1415,10 @@ static int
|
||||
parse_wave_header(lame_global_flags * gfp, FILE * sf)
|
||||
{
|
||||
uint32_t ui32_nSamplesPerSec = 0;
|
||||
uint32_t ui32_nAvgBytesPerSec = 0;
|
||||
uint32_t ui32_DataChunkSize = 0;
|
||||
uint16_t ui16_wFormatTag = 0;
|
||||
uint16_t ui16_nChannels = 0;
|
||||
uint16_t ui16_wBitsPerSample = 0;
|
||||
uint16_t ui16_nBlockAlign = 0;
|
||||
|
||||
int is_wav = 0;
|
||||
int loop_sanity = 0;
|
||||
@@ -1434,7 +1431,11 @@ parse_wave_header(lame_global_flags * gfp, FILE * sf)
|
||||
for (loop_sanity = 0; loop_sanity < 20; ++loop_sanity) {
|
||||
uint32_t ui32_ckID = read_32_bits_high_low(sf);
|
||||
if (ui32_ckID == WAV_ID_FMT) {
|
||||
uint32_t ui32_cksize = read_32_bits_low_high(sf);
|
||||
uint32_t ui32_nAvgBytesPerSec = 0;
|
||||
uint32_t ui32_cksize = 0;
|
||||
uint16_t ui16_nBlockAlign = 0;
|
||||
|
||||
ui32_cksize = read_32_bits_low_high(sf);
|
||||
ui32_cksize = make_even_number_of_bytes_in_length(ui32_cksize);
|
||||
if (ui32_cksize < 16u) {
|
||||
/*DEBUGF("'fmt' chunk too short (only %ld bytes)!", ui32_cksize);*/
|
||||
@@ -1898,7 +1899,7 @@ open_mpeg_file(lame_t gfp, char const *inPath, int *enc_delay, int *enc_padding)
|
||||
}
|
||||
}
|
||||
#ifdef AMIGA_MPEGA
|
||||
if (-1 == lame_decode_initfile(inPath, &global_decoder.mp3input_data)) {
|
||||
if (-1 == lame_decode_initfile_amiga(inPath, &global_decoder.mp3input_data)) {
|
||||
if (global_ui_config.silent < 10) {
|
||||
error_printf("Error reading headers in mp3 input file %s.\n", inPath);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ typedef enum sound_file_format_e {
|
||||
sf_ogg
|
||||
} sound_file_format;
|
||||
|
||||
int is_mpeg_file_format( int input_format );
|
||||
int is_mpeg_file_format( int input_file_format );
|
||||
|
||||
int init_infile(lame_t gfp, char const * inPath);
|
||||
int samples_to_skip_at_start(void);
|
||||
@@ -83,7 +83,7 @@ int aw_write(AudioWriter aw, float buffer[2][1152], int n);
|
||||
extern size_t sizeOfOldTag(lame_t gf);
|
||||
extern unsigned char* getOldTag(lame_t gf);
|
||||
|
||||
#ifdef _cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ write_xing_frame(lame_global_flags * gf, FILE * outf, size_t offset)
|
||||
size_t imp3, owrite;
|
||||
|
||||
imp3 = lame_get_lametag_frame(gf, mp3buffer, sizeof(mp3buffer));
|
||||
if (imp3 <= 0) {
|
||||
if (imp3 == 0) {
|
||||
return 0; /* nothing to do */
|
||||
}
|
||||
if (global_ui_config.silent <= 0) {
|
||||
@@ -368,7 +368,7 @@ write_id3v1_tag(lame_t gf, FILE * outf)
|
||||
size_t imp3, owrite;
|
||||
|
||||
imp3 = lame_get_id3v1_tag(gf, mp3buffer, sizeof(mp3buffer));
|
||||
if (imp3 <= 0) {
|
||||
if (imp3 == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (imp3 > sizeof(mp3buffer)) {
|
||||
|
||||
+11
-11
@@ -141,11 +141,11 @@ set_process_affinity()
|
||||
*/
|
||||
|
||||
void
|
||||
dosToLongFileName(char *fn)
|
||||
dosToLongFileName(char *filename)
|
||||
{
|
||||
const size_t MSIZE = PATH_MAX + 1 - 4; /* we wanna add ".mp3" later */
|
||||
WIN32_FIND_DATAA lpFindFileData;
|
||||
HANDLE h = FindFirstFileA(fn, &lpFindFileData);
|
||||
HANDLE h = FindFirstFileA(filename, &lpFindFileData);
|
||||
if (h != INVALID_HANDLE_VALUE) {
|
||||
size_t a;
|
||||
char *q, *p;
|
||||
@@ -156,16 +156,16 @@ dosToLongFileName(char *fn)
|
||||
}
|
||||
if (a >= MSIZE || a == 0)
|
||||
return;
|
||||
q = strrchr(fn, '\\');
|
||||
p = strrchr(fn, '/');
|
||||
q = strrchr(filename, '\\');
|
||||
p = strrchr(filename, '/');
|
||||
if (p - q > 0)
|
||||
q = p;
|
||||
if (q == NULL)
|
||||
q = strrchr(fn, ':');
|
||||
q = strrchr(filename, ':');
|
||||
if (q == NULL)
|
||||
strncpy(fn, lpFindFileData.cFileName, a);
|
||||
strncpy(filename, lpFindFileData.cFileName, a);
|
||||
else {
|
||||
a += q - fn + 1;
|
||||
a += q - filename + 1;
|
||||
if (a >= MSIZE)
|
||||
return;
|
||||
strncpy(++q, lpFindFileData.cFileName, MSIZE - a);
|
||||
@@ -181,9 +181,9 @@ SetPriorityClassMacro(DWORD p)
|
||||
}
|
||||
|
||||
void
|
||||
setProcessPriority(int Priority)
|
||||
setProcessPriority(int priority)
|
||||
{
|
||||
switch (Priority) {
|
||||
switch (priority) {
|
||||
case 0:
|
||||
case 1:
|
||||
SetPriorityClassMacro(IDLE_PRIORITY_CLASS);
|
||||
@@ -207,11 +207,11 @@ setProcessPriority(int Priority)
|
||||
#if defined(__OS2__)
|
||||
/* OS/2 priority functions */
|
||||
void
|
||||
setProcessPriority(int Priority)
|
||||
setProcessPriority(int priority)
|
||||
{
|
||||
int rc;
|
||||
|
||||
switch (Priority) {
|
||||
switch (priority) {
|
||||
|
||||
case 0:
|
||||
rc = DosSetPriority(0, /* Scope: only one process */
|
||||
|
||||
+3
-2
@@ -91,10 +91,11 @@ extern RawPCMConfig global_raw_pcm;
|
||||
extern FILE* lame_fopen(char const* file, char const* mode);
|
||||
extern char* utf8ToConsole8Bit(const char* str);
|
||||
extern char* utf8ToLocal8Bit(const char* str);
|
||||
extern unsigned short* utf8ToUtf16(char const* str);
|
||||
extern unsigned short* utf8ToUtf16(char const* mbstr);
|
||||
extern char* utf8ToLatin1(char const* str);
|
||||
#ifdef _WIN32
|
||||
extern wchar_t* utf8ToUnicode(char const* str);
|
||||
extern wchar_t* utf8ToUnicode(char const* mbstr);
|
||||
extern char *unicodeToUtf8(const wchar_t *wstr);
|
||||
#endif
|
||||
|
||||
extern void dosToLongFileName(char* filename);
|
||||
|
||||
+9
-10
@@ -170,9 +170,9 @@ strlenMultiByte(char const* str, size_t w)
|
||||
{
|
||||
size_t n = 0;
|
||||
if (str != 0) {
|
||||
size_t i, x = 0;
|
||||
size_t i;
|
||||
for (n = 0; ; ++n) {
|
||||
x = 0;
|
||||
size_t x = 0;
|
||||
for (i = 0; i < w; ++i) {
|
||||
x += *str++ == 0 ? 1 : 0;
|
||||
}
|
||||
@@ -1461,7 +1461,6 @@ set_id3_albumart(lame_t gfp, char const* file_name)
|
||||
{
|
||||
int ret = -1;
|
||||
FILE *fpi = 0;
|
||||
char *albumart = 0;
|
||||
|
||||
if (file_name == 0) {
|
||||
return 0;
|
||||
@@ -1472,6 +1471,7 @@ set_id3_albumart(lame_t gfp, char const* file_name)
|
||||
}
|
||||
else {
|
||||
size_t size;
|
||||
char *albumart = 0;
|
||||
|
||||
fseek(fpi, 0, SEEK_END);
|
||||
size = ftell(fpi);
|
||||
@@ -1579,18 +1579,14 @@ parse_args_(lame_global_flags * gfp, int argc, char **argv,
|
||||
|
||||
/* process args */
|
||||
for (i = 0; ++i < argc;) {
|
||||
char c;
|
||||
char *token;
|
||||
char *arg;
|
||||
char *nextArg;
|
||||
int argUsed;
|
||||
int argIgnored=0;
|
||||
|
||||
token = argv[i];
|
||||
if (*token++ == '-') {
|
||||
char *nextArg = i + 1 < argc ? argv[i + 1] : "";
|
||||
argUsed = 0;
|
||||
nextArg = i + 1 < argc ? argv[i + 1] : "";
|
||||
|
||||
if (!*token) { /* The user wants to use stdin and/or stdout. */
|
||||
input_file = 1;
|
||||
if (inPath[0] == '\0')
|
||||
@@ -2258,10 +2254,11 @@ parse_args_(lame_global_flags * gfp, int argc, char **argv,
|
||||
|
||||
}
|
||||
else {
|
||||
char c;
|
||||
while ((c = *token++) != '\0') {
|
||||
double double_value = 0;
|
||||
int int_value = 0;
|
||||
arg = *token ? token : nextArg;
|
||||
char const *arg = *token ? token : nextArg;
|
||||
switch (c) {
|
||||
case 'm':
|
||||
argUsed = 1;
|
||||
@@ -2480,7 +2477,9 @@ parse_args_(lame_global_flags * gfp, int argc, char **argv,
|
||||
error_printf
|
||||
("Error: 'nogap option'. Calling program does not allow nogap option, or\n"
|
||||
"you have exceeded maximum number of input files for the nogap option\n");
|
||||
*num_nogap = -1;
|
||||
if (num_nogap) {
|
||||
*num_nogap = -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ int long_help(const lame_global_flags * gfp, FILE * const fp, const char *Pr
|
||||
int display_bitrates(FILE * const fp);
|
||||
|
||||
int parse_args(lame_global_flags * gfp, int argc, char **argv, char *const inPath,
|
||||
char *const outPath, char **nogap_inPath, int *max_nogap);
|
||||
char *const outPath, char **nogap_inPath, int *num_nogap);
|
||||
|
||||
void parse_close();
|
||||
|
||||
int generateOutPath(char const* inPath, char const* outDir, char const* suffix, char* outPath);
|
||||
int generateOutPath(char const* inPath, char const* outDir, char const* s_ext, char* outPath);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ rtp_socket(char const *address, unsigned int port, unsigned int TTL)
|
||||
iRet = setsockopt(iSocket, SOL_SOCKET, SO_REUSEADDR, &iLoop, sizeof(int));
|
||||
if (iRet < 0) {
|
||||
error_printf("setsockopt SO_REUSEADDR failed\n");
|
||||
close(iSocket);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -125,6 +126,7 @@ rtp_socket(char const *address, unsigned int port, unsigned int TTL)
|
||||
iRet = setsockopt(iSocket, IPPROTO_IP, IP_MULTICAST_TTL, &cTtl, sizeof(char));
|
||||
if (iRet < 0) {
|
||||
error_printf("setsockopt IP_MULTICAST_TTL failed. multicast in kernel?\n");
|
||||
close(iSocket);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -132,12 +134,14 @@ rtp_socket(char const *address, unsigned int port, unsigned int TTL)
|
||||
iRet = setsockopt(iSocket, IPPROTO_IP, IP_MULTICAST_LOOP, &cLoop, sizeof(char));
|
||||
if (iRet < 0) {
|
||||
error_printf("setsockopt IP_MULTICAST_LOOP failed. multicast in kernel?\n");
|
||||
close(iSocket);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
iRet = connect(iSocket, (struct sockaddr *) &sin, sizeof(struct sockaddr_in));
|
||||
if (iRet < 0) {
|
||||
error_printf("connect IP_MULTICAST_LOOP failed. multicast in kernel?\n");
|
||||
close(iSocket);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1497,7 +1497,7 @@ VBR_old_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
|
||||
|
||||
FLOAT xrpow[576];
|
||||
int bands[2][2];
|
||||
int frameBits[15];
|
||||
int frameBits[16];
|
||||
int used_bits;
|
||||
int bits;
|
||||
int min_bits[2][2], max_bits[2][2];
|
||||
@@ -1651,7 +1651,7 @@ VBR_new_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
|
||||
FLOAT l3_xmin[2][2][SFBMAX];
|
||||
|
||||
FLOAT xrpow[2][2][576];
|
||||
int frameBits[15];
|
||||
int frameBits[16];
|
||||
int used_bits;
|
||||
int max_bits[2][2];
|
||||
int ch, gr, analog_silence, pad;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#define LAME_RESERVOIR_H
|
||||
|
||||
int ResvFrameBegin(lame_internal_flags * gfc, int *mean_bits);
|
||||
void ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *max_bits,
|
||||
void ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *extra_bits,
|
||||
int cbr);
|
||||
void ResvAdjust(lame_internal_flags * gfc, gr_info const *gi);
|
||||
void ResvFrameEnd(lame_internal_flags * gfc, int mean_bits);
|
||||
|
||||
@@ -2131,7 +2131,7 @@ lame_get_totalframes(const lame_global_flags * gfp)
|
||||
lame_internal_flags const *const gfc = gfp->internal_flags;
|
||||
if (is_lame_internal_flags_valid(gfc)) {
|
||||
SessionConfig_t const *const cfg = &gfc->cfg;
|
||||
unsigned long const pcm_samples_per_frame = 576 * cfg->mode_gr;
|
||||
unsigned long const pcm_samples_per_frame = 576ul * cfg->mode_gr;
|
||||
unsigned long pcm_samples_to_encode = gfp->num_samples;
|
||||
unsigned long end_padding = 0;
|
||||
int frames = 0;
|
||||
|
||||
+10
-9
@@ -247,30 +247,30 @@ bitrate is more balanced according to the -V value.*/
|
||||
|
||||
|
||||
FLOAT
|
||||
ATHformula(SessionConfig_t const *cfg, FLOAT f)
|
||||
ATHformula(SessionConfig_t const *cfg, FLOAT freq)
|
||||
{
|
||||
FLOAT ath;
|
||||
switch (cfg->ATHtype) {
|
||||
case 0:
|
||||
ath = ATHformula_GB(f, 9, 0.1f, 24.0f);
|
||||
ath = ATHformula_GB(freq, 9, 0.1f, 24.0f);
|
||||
break;
|
||||
case 1:
|
||||
ath = ATHformula_GB(f, -1, 0.1f, 24.0f); /*over sensitive, should probably be removed */
|
||||
ath = ATHformula_GB(freq, -1, 0.1f, 24.0f); /*over sensitive, should probably be removed */
|
||||
break;
|
||||
case 2:
|
||||
ath = ATHformula_GB(f, 0, 0.1f, 24.0f);
|
||||
ath = ATHformula_GB(freq, 0, 0.1f, 24.0f);
|
||||
break;
|
||||
case 3:
|
||||
ath = ATHformula_GB(f, 1, 0.1f, 24.0f) + 6; /*modification of GB formula by Roel */
|
||||
ath = ATHformula_GB(freq, 1, 0.1f, 24.0f) + 6; /*modification of GB formula by Roel */
|
||||
break;
|
||||
case 4:
|
||||
ath = ATHformula_GB(f, cfg->ATHcurve, 0.1f, 24.0f);
|
||||
ath = ATHformula_GB(freq, cfg->ATHcurve, 0.1f, 24.0f);
|
||||
break;
|
||||
case 5:
|
||||
ath = ATHformula_GB(f, cfg->ATHcurve, 3.41f, 16.1f);
|
||||
ath = ATHformula_GB(freq, cfg->ATHcurve, 3.41f, 16.1f);
|
||||
break;
|
||||
default:
|
||||
ath = ATHformula_GB(f, 0, 0.1f, 24.0f);
|
||||
ath = ATHformula_GB(freq, 0, 0.1f, 24.0f);
|
||||
break;
|
||||
}
|
||||
return ath;
|
||||
@@ -543,7 +543,7 @@ fill_buffer_resample(lame_internal_flags * gfc,
|
||||
EncStateVar_t *esv = &gfc->sv_enc;
|
||||
double resample_ratio = (double)cfg->samplerate_in / (double)cfg->samplerate_out;
|
||||
int BLACKSIZE;
|
||||
FLOAT offset, xvalue;
|
||||
FLOAT offset;
|
||||
int i, j = 0, k;
|
||||
int filter_l;
|
||||
FLOAT fcn, intratio;
|
||||
@@ -590,6 +590,7 @@ fill_buffer_resample(lame_internal_flags * gfc,
|
||||
/* time of k'th element in outbuf = j/ofreq */
|
||||
for (k = 0; k < desired_len; k++) {
|
||||
double time0 = k * resample_ratio; /* time of k'th output sample */
|
||||
FLOAT xvalue;
|
||||
int joff;
|
||||
|
||||
j = floor(time0 - esv->itime[ch]);
|
||||
|
||||
+1
-1
@@ -560,7 +560,7 @@ extern "C" {
|
||||
extern int FindNearestBitrate(int, int, int);
|
||||
extern int map2MP3Frequency(int freq);
|
||||
extern int SmpFrqIndex(int, int *const);
|
||||
extern int nearestBitrateFullIndex(uint16_t brate);
|
||||
extern int nearestBitrateFullIndex(uint16_t bitrate);
|
||||
extern FLOAT ATHformula(SessionConfig_t const *cfg, FLOAT freq);
|
||||
extern FLOAT freq2bark(FLOAT freq);
|
||||
void disable_FPE(void);
|
||||
|
||||
+5
-5
@@ -370,7 +370,7 @@ void eval ( int right )
|
||||
|
||||
val = 1.L / prob ( okay, count );
|
||||
|
||||
fprintf (stderr, " %s %5u/%-5u ", right ? "OK" : "- " , okay, count );
|
||||
fprintf (stderr, " %s %5d/%-5d ", right ? "OK" : "- " , okay, count );
|
||||
printnumber (val);
|
||||
if ( count > 1 )
|
||||
fprintf (stderr, " %4.2f bit", 0.01 * (int)(logdual(val) / (count-1) * 100.) );
|
||||
@@ -535,7 +535,7 @@ void setup ( int fdd, int samples, long freq )
|
||||
perror ("SOUND_PCM_WRITE_CHANNELS ioctl failed");
|
||||
if (arg != org)
|
||||
perror ("unable to set number of channels");
|
||||
fprintf (stderr, "%1u*", arg);
|
||||
fprintf (stderr, "%1d*", arg);
|
||||
|
||||
org = arg = AFMT_S16_LE;
|
||||
if ( -1 == ioctl (fdd, SNDCTL_DSP_SETFMT, &arg) )
|
||||
@@ -546,7 +546,7 @@ void setup ( int fdd, int samples, long freq )
|
||||
org = arg = freq;
|
||||
if ( -1 == (status = ioctl (fdd, SNDCTL_DSP_SPEED, &arg)) )
|
||||
perror ("SNDCTL_DSP_SPEED ioctl failed");
|
||||
fprintf (stderr, "%5u Hz*%.3f sec\n", arg, (double)samples/arg );
|
||||
fprintf (stderr, "%5d Hz*%.3f sec\n", arg, (double)samples/arg );
|
||||
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ void testing ( const stereo_t* A, const stereo_t* B, size_t len, long freq )
|
||||
fprintf (stderr, " Vote for X:=A" );
|
||||
eval ( rnd == 0 );
|
||||
rnd = random_number ();
|
||||
if ( state == 6 && state == 7 )
|
||||
if ( state == 6 || state == 7 )
|
||||
state = 6 + rnd;
|
||||
else if ( state != rnd )
|
||||
state = rnd + 2;
|
||||
@@ -756,7 +756,7 @@ void testing ( const stereo_t* A, const stereo_t* B, size_t len, long freq )
|
||||
fprintf (stderr, " Vote for X:=B" );
|
||||
eval ( rnd == 1 );
|
||||
rnd = random_number ();
|
||||
if ( state == 6 && state == 7 )
|
||||
if ( state == 6 || state == 7 )
|
||||
state = 6 + rnd;
|
||||
else if ( state != rnd )
|
||||
state = rnd + 2;
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ void init ( void )
|
||||
}
|
||||
}
|
||||
|
||||
void test ( int no, scalar_t f )
|
||||
void test ( unsigned int no, scalar_t f )
|
||||
{
|
||||
unsigned long long t1;
|
||||
unsigned long long t2;
|
||||
@@ -67,7 +67,7 @@ void testn ( scalarn_t f )
|
||||
double curr = 0;
|
||||
|
||||
for ( i = 1; i <= 64; i += i<6 ? 1 : i<8 ? 2 : i ) {
|
||||
printf ( "[%3u] %22.14f\t\t", 4*i, (double)f (a1,a2,i) );
|
||||
printf ( "[%3u] %22.14f\t\t", 4u*i, (double)f (a1,a2,i) );
|
||||
fflush ( stdout );
|
||||
|
||||
do {
|
||||
|
||||
+8
-4
@@ -30,12 +30,16 @@ class PcmGenerator
|
||||
float m_a;
|
||||
float m_b;
|
||||
|
||||
double random()
|
||||
static double random()
|
||||
{
|
||||
int const range_max = 32768;
|
||||
int const range_min = -32767;
|
||||
return (double)rand() / (RAND_MAX + 1) * (range_max - range_min) + range_min;
|
||||
}
|
||||
|
||||
PcmGenerator( PcmGenerator const& );
|
||||
PcmGenerator& operator = ( PcmGenerator const& );
|
||||
|
||||
public:
|
||||
|
||||
explicit PcmGenerator(int size)
|
||||
@@ -146,9 +150,6 @@ public:
|
||||
return m_gf != 0;
|
||||
}
|
||||
|
||||
operator lame_t () {
|
||||
return m_gf;
|
||||
}
|
||||
operator lame_t () const {
|
||||
return m_gf;
|
||||
}
|
||||
@@ -188,6 +189,9 @@ class OutBuffer
|
||||
int m_size;
|
||||
int m_used;
|
||||
|
||||
OutBuffer( OutBuffer const& );
|
||||
OutBuffer& operator = ( OutBuffer const& );
|
||||
|
||||
public:
|
||||
|
||||
OutBuffer()
|
||||
|
||||
Reference in New Issue
Block a user