Skip to content

Commit 1ec6ff0

Browse files
committed
Merge pull request #71 from cchampet/fix_memory_leaks
Fix memory leaks
2 parents f9ad8b2 + 71f1d0d commit 1ec6ff0

File tree

6 files changed

+23
-2
lines changed

6 files changed

+23
-2
lines changed

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ OutputFile::OutputFile( const std::string& filename )
1717
, _verbose( false )
1818
{}
1919

20+
OutputFile::~OutputFile()
21+
{
22+
for( std::vector< OutputStream* >::iterator it = _outputStreams.begin(); it != _outputStreams.end(); ++it )
23+
{
24+
delete (*it);
25+
}
26+
}
27+
2028
bool OutputFile::setup()
2129
{
2230
_formatContext.setOutputFormat( _filename );

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class AvExport OutputFile : public IOutputFile
2323
**/
2424
OutputFile( const std::string& filename = "" );
2525

26+
~OutputFile();
27+
2628
/**
2729
* @brief Initialize the OutputFile, create format context to wrap essences into output file.
2830
* @note call this before adding streams using addVideoStream() or addAudioStream()

src/AvTranscoder/transform/AudioTransform.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ AudioTransform::AudioTransform()
3737
{
3838
}
3939

40+
AudioTransform::~AudioTransform()
41+
{
42+
FreeResampleContext( &_audioConvertContext );
43+
}
44+
4045
bool AudioTransform::init( const Frame& srcFrame, const Frame& dstFrame )
4146
{
4247
const AudioFrame& src = static_cast<const AudioFrame&>( srcFrame );

src/AvTranscoder/transform/AudioTransform.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AvExport AudioTransform : public ITransform
2121
{
2222
public:
2323
AudioTransform();
24+
~AudioTransform();
2425

2526
void convert( const Frame& srcFrame, Frame& dstFrame );
2627

src/AvTranscoder/transform/VideoTransform.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ VideoTransform::VideoTransform()
3131
{
3232
}
3333

34+
VideoTransform::~VideoTransform()
35+
{
36+
sws_freeContext( _imageConvertContext );
37+
}
38+
3439
bool VideoTransform::init( const Frame& srcFrame, const Frame& dstFrame )
3540
{
3641
const VideoFrame& src = static_cast<const VideoFrame&>( srcFrame );
3742
const VideoFrame& dst = static_cast<const VideoFrame&>( dstFrame );
3843

39-
4044
const AVPixelFormat srcPixelFormat = src.desc().getPixelFormat();
4145
const AVPixelFormat dstPixelFormat = dst.desc().getPixelFormat();
4246

43-
_imageConvertContext = sws_getContext(
47+
_imageConvertContext = sws_getCachedContext( _imageConvertContext,
4448
src.desc().getWidth(), src.desc().getHeight(), srcPixelFormat,
4549
dst.desc().getWidth(), dst.desc().getHeight(), dstPixelFormat,
4650
SWS_POINT, NULL, NULL, NULL);

src/AvTranscoder/transform/VideoTransform.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class AvExport VideoTransform : public ITransform
1616
{
1717
public:
1818
VideoTransform();
19+
~VideoTransform();
1920

2021
void convert( const Frame& srcFrame, Frame& dstFrame );
2122

0 commit comments

Comments
 (0)