Skip to content

Commit c8f5fe1

Browse files
author
Valentin NOEL
committed
StreamTranscoder: fix filter graph memory usage
1 parent 36e222f commit c8f5fe1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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)