Commit 7f4ff861 authored by Eric Petit's avatar Eric Petit

src/modules/raw2ts/raw2ts.cpp: fixed a memory leak I introduced

parent e4eb1065
......@@ -2,7 +2,7 @@
* raw2ts.cpp: raw -> ES ffmpeg encoder -> TS
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: raw2ts.cpp,v 1.7 2003/02/20 05:57:23 titer Exp $
* $Id: raw2ts.cpp,v 1.8 2003/02/20 19:38:59 titer Exp $
*
* Authors: Tristan Leteurtre <tooney@videolan.org>
* (inspirated from Fabrice Bellard...)
......@@ -281,18 +281,28 @@ void C_Raw2TsMpegConverter::DoWork()
TSPacketization(PesPacket, TimeStamp, 0xE0, &iVideoContinuityCounter);
// Get and encode the sound
// FIXME: we currently encode a arbitraty size of data without
// thinking about his time length
m_pReader->GetAudioFrame(&m_AudioSampleBuf, m_iAudioSampleBufSize);
int outSize;
outSize = avcodec_encode_audio( m_AudioCodecContext, m_AudioOutBuf,
m_iAudioSampleBufSize, (short*)m_AudioSampleBuf );
// Get and encode the sound: time needed = ( 1 / m_iFrameRate ) second
int iLeft = 2 * 44100 / m_iFrameRate; // 16 bits samples
while( iLeft > 0 )
{
int inSize;
int outSize;
if( iLeft < m_iAudioSampleBufSize )
inSize = iLeft;
else
inSize = m_iAudioSampleBufSize;
PesPacket = new C_PesPacket();
PesPacket->BuildPacket(TimeStamp, 0xC0, m_AudioOutBuf, outSize );
TSPacketization(PesPacket, TimeStamp, 0xC0, &iAudioContinuityCounter);
m_pReader->GetAudioFrame(&m_AudioSampleBuf, m_iAudioSampleBufSize);
outSize = avcodec_encode_audio( m_AudioCodecContext, m_AudioOutBuf,
m_iAudioSampleBufSize, (short*)m_AudioSampleBuf );
PesPacket->BuildPacket(TimeStamp, 0xC0, m_AudioOutBuf, outSize );
TSPacketization(PesPacket, TimeStamp, 0xC0, &iAudioContinuityCounter);
iLeft -= inSize;
}
if(iRc == MPEG_ENDOFSTREAM)
{
......@@ -382,6 +392,3 @@ u64 C_Raw2TsMpegConverter::GetTime(void)
return( (u64)tmp.tv_sec * 1000000 + (u64)tmp.tv_usec );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment