File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ void AudioFrame::allocateData()
103
103
av_frame_set_channels (_frame, _desc._nbChannels );
104
104
av_frame_set_channel_layout (_frame, av_get_default_channel_layout (_desc._nbChannels ));
105
105
_frame->format = _desc._sampleFormat ;
106
- _frame->nb_samples = getDefaultNbSamples ();
106
+ if (_frame->nb_samples == 0 )
107
+ _frame->nb_samples = getDefaultNbSamples ();
107
108
108
109
// Allocate data
109
110
const int align = 0 ;
Original file line number Diff line number Diff line change @@ -547,6 +547,26 @@ bool StreamTranscoder::processTranscode()
547
547
decodingStatus = decodingStatus && _currentDecoder->decodeNextFrame (*_decodedData.at (index));
548
548
}
549
549
550
+ // check the next data buffers in case of audio frames
551
+ if (_decodedData.at (0 )->isAudioFrame ())
552
+ {
553
+ const int nbInputSamplesPerChannel = _decodedData.at (0 )->getAVFrame ().nb_samples ;
554
+ if (nbInputSamplesPerChannel > _filteredData->getAVFrame ().nb_samples )
555
+ {
556
+ LOG_WARN (" The buffer of filtered data is too small: reallocate it." )
557
+ _filteredData->freeData ();
558
+ _filteredData->getAVFrame ().nb_samples = nbInputSamplesPerChannel;
559
+ _filteredData->allocateData ();
560
+ }
561
+ if (nbInputSamplesPerChannel > _transformedData->getAVFrame ().nb_samples )
562
+ {
563
+ LOG_WARN (" The buffer of transformed data is too small: reallocate it." )
564
+ _transformedData->freeData ();
565
+ _transformedData->getAVFrame ().nb_samples = nbInputSamplesPerChannel;
566
+ _transformedData->allocateData ();
567
+ }
568
+ }
569
+
550
570
// Transform
551
571
CodedData data;
552
572
if (decodingStatus)
You can’t perform that action at this time.
0 commit comments