Improve buffering and fix memory leaks

Use a dedicated class to handle frame buffer
Fix memory leak in stream handler and frame allocation
This commit is contained in:
jfmcarreira committed 2017-09-22 00:54:46 +01:00
1 parent 58146a6b06
commit 1d07dd6b38
12 files changed
+159 -160

No files matched your search

+4
View File
@@ -48,6 +48,8 @@ Void StreamHandlerRaw::closeHandler()
{
if( m_pFile )
fclose( m_pFile );
if( m_pStreamBuffer )
freeMem1D( m_pStreamBuffer );
}
Bool StreamHandlerRaw::configureBuffer( PlaYUVerFrame* pcFrame )
@@ -70,6 +72,7 @@ Bool StreamHandlerRaw::seek( UInt64 iFrameNum )
if( m_bIsInput && m_pFile )
{
fseek( m_pFile, iFrameNum >= 0 ? iFrameNum * m_uiNBytesPerFrame : 0, SEEK_SET );
m_uiCurrFrameFileIdx = iFrameNum;
return true;
}
return false;
@@ -80,6 +83,7 @@ Bool StreamHandlerRaw::read( PlaYUVerFrame* pcFrame )
UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile );
if( processed_bytes != m_uiNBytesPerFrame )
return false;
m_uiCurrFrameFileIdx++;
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
return true;
}