@@ -33,6 +33,7 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
33
33
, _outputEncoder(NULL )
34
34
, _transform(NULL )
35
35
, _filterGraph(NULL )
36
+ , _firstInputStreamIndex(0 )
36
37
, _offset(offset)
37
38
, _needToSwitchToGenerator(false )
38
39
{
@@ -140,6 +141,7 @@ StreamTranscoder::StreamTranscoder(const std::vector<InputStreamDesc>& inputStre
140
141
, _outputEncoder(NULL )
141
142
, _transform(NULL )
142
143
, _filterGraph(NULL )
144
+ , _firstInputStreamIndex(std::numeric_limits<size_t >::max())
143
145
, _offset(offset)
144
146
, _needToSwitchToGenerator(false )
145
147
{
@@ -152,17 +154,19 @@ StreamTranscoder::StreamTranscoder(const std::vector<InputStreamDesc>& inputStre
152
154
LOG_INFO (" add decoder for input stream " << index);
153
155
addDecoder (_inputStreamDesc.at (index), *_inputStreams.at (index));
154
156
nbOutputChannels += _inputStreamDesc.at (index)._channelIndexArray .size ();
157
+ if (_firstInputStreamIndex == std::numeric_limits<size_t >::max ())
158
+ _firstInputStreamIndex = index;
155
159
}
156
160
else
157
161
{
158
162
LOG_INFO (" add generator for empty input " << index);
159
163
addGenerator (_inputStreamDesc.at (index), profile);
164
+ nbOutputChannels++;
160
165
}
161
166
}
162
167
163
- const size_t firstInputStreamIndex = getFirstInputStreamIndex ();
164
- IInputStream& inputStream = *_inputStreams.at (firstInputStreamIndex);
165
- const InputStreamDesc& inputStreamDesc = inputStreamsDesc.at (firstInputStreamIndex);
168
+ IInputStream& inputStream = *_inputStreams.at (_firstInputStreamIndex);
169
+ const InputStreamDesc& inputStreamDesc = inputStreamsDesc.at (_firstInputStreamIndex);
166
170
167
171
// create a transcode case
168
172
switch (inputStream.getProperties ().getStreamType ())
@@ -239,16 +243,6 @@ StreamTranscoder::StreamTranscoder(const std::vector<InputStreamDesc>& inputStre
239
243
setOffset (offset);
240
244
}
241
245
242
- size_t StreamTranscoder::getFirstInputStreamIndex ()
243
- {
244
- for (size_t index = 0 ; index < _inputStreams.size (); ++index)
245
- {
246
- if (_inputStreams.at (index) != NULL )
247
- return index;
248
- }
249
- throw std::runtime_error (" Cannot handle only null input streams" );
250
- }
251
-
252
246
void StreamTranscoder::addDecoder (const InputStreamDesc& inputStreamDesc, IInputStream& inputStream)
253
247
{
254
248
// create a transcode case
@@ -358,6 +352,7 @@ StreamTranscoder::StreamTranscoder(IOutputFile& outputFile, const ProfileLoader:
358
352
, _outputEncoder(NULL )
359
353
, _transform(NULL )
360
354
, _filterGraph(NULL )
355
+ , _firstInputStreamIndex(0 )
361
356
, _offset(0 )
362
357
, _needToSwitchToGenerator(false )
363
358
{
@@ -617,10 +612,9 @@ bool StreamTranscoder::processTranscode()
617
612
}
618
613
619
614
// check the next data buffers in case of audio frames
620
- const size_t firstInputStreamIndex = getFirstInputStreamIndex ();
621
- if (_decodedData.at (firstInputStreamIndex)->isAudioFrame ())
615
+ if (_decodedData.at (_firstInputStreamIndex)->isAudioFrame ())
622
616
{
623
- const int nbInputSamplesPerChannel = _decodedData.at (firstInputStreamIndex )->getAVFrame ().nb_samples ;
617
+ const int nbInputSamplesPerChannel = _decodedData.at (_firstInputStreamIndex )->getAVFrame ().nb_samples ;
624
618
625
619
// Reallocate output frame
626
620
if (nbInputSamplesPerChannel > _filteredData->getAVFrame ().nb_samples )
0 commit comments