Skip to content

Commit 1c318c2

Browse files
authored
Merge pull request avTranscoder#305 from valnoel/fix_filtering_memory_usage
Fix filter graph memory usage
2 parents 36e222f + 30b7385 commit 1c318c2

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/AvTranscoder/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define AVTRANSCODER_VERSION_MAJOR 0
55
#define AVTRANSCODER_VERSION_MINOR 14
6-
#define AVTRANSCODER_VERSION_MICRO 0
6+
#define AVTRANSCODER_VERSION_MICRO 1
77

88
#include <AvTranscoder/system.hpp>
99

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ StreamTranscoder::~StreamTranscoder()
435435
{
436436
delete(*it);
437437
}
438-
delete _filteredData;
438+
439+
if(_filteredData != NULL && _filteredData->isDataAllocated())
440+
delete _filteredData;
441+
439442
delete _transformedData;
440443

441444
for(std::vector<IDecoder*>::iterator it = _inputDecoders.begin(); it != _inputDecoders.end(); ++it)
@@ -620,13 +623,17 @@ bool StreamTranscoder::processTranscode()
620623
const int nbInputSamplesPerChannel = _decodedData.at(_firstInputStreamIndex)->getAVFrame().nb_samples;
621624

622625
// Reallocate output frame
623-
if(nbInputSamplesPerChannel > _filteredData->getAVFrame().nb_samples)
626+
if(_filterGraph->hasFilters())
624627
{
625-
LOG_WARN("The buffer of filtered data corresponds to a frame of " << _filteredData->getAVFrame().nb_samples << " samples. The decoded buffer contains " << nbInputSamplesPerChannel << " samples. Reallocate it.")
626628
_filteredData->freeData();
627-
_filteredData->getAVFrame().nb_samples = nbInputSamplesPerChannel;
628-
_filteredData->allocateData();
629+
if(nbInputSamplesPerChannel > _filteredData->getAVFrame().nb_samples)
630+
{
631+
LOG_WARN("The buffer of filtered data corresponds to a frame of " << _filteredData->getAVFrame().nb_samples << " samples. The decoded buffer contains " << nbInputSamplesPerChannel << " samples. Reallocate it.")
632+
_filteredData->getAVFrame().nb_samples = nbInputSamplesPerChannel;
633+
_filteredData->allocateData();
634+
}
629635
}
636+
630637
if(nbInputSamplesPerChannel > _transformedData->getAVFrame().nb_samples)
631638
{
632639
LOG_WARN("The buffer of transformed data corresponds to a frame of " << _transformedData->getAVFrame().nb_samples << " samples. The decoded buffer contains " << nbInputSamplesPerChannel << " samples. Reallocate it.")

0 commit comments

Comments
 (0)