Skip to content

Commit 07582b2

Browse files
author
Clement Champetier
committed
Decoders: set threads before any other options
1 parent 0354acf commit 07582b2

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,26 @@ bool AudioDecoder::decodeNextFrame()
151151

152152
void AudioDecoder::setProfile( const ProfileLoader::Profile& profile )
153153
{
154-
// set threads if not in profile
155-
if( ! profile.count( "threads" ) )
156-
_inputStream->getAudioCodec().getOption( "threads" ).setString( "auto" );
154+
AudioCodec& codec = _inputStream->getAudioCodec();
157155

156+
// set threads before any other options
157+
if( profile.count( constants::avProfileThreads ) )
158+
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
159+
else
160+
codec.getOption( constants::avProfileThreads ).setString( "auto" );
161+
162+
// set decoder options
158163
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
159164
{
160165
if( (*it).first == constants::avProfileIdentificator ||
161166
(*it).first == constants::avProfileIdentificatorHuman ||
162-
(*it).first == constants::avProfileType )
167+
(*it).first == constants::avProfileType ||
168+
(*it).first == constants::avProfileThreads )
163169
continue;
164170

165171
try
166172
{
167-
Option& decodeOption = _inputStream->getAudioCodec().getOption( (*it).first );
173+
Option& decodeOption = codec.getOption( (*it).first );
168174
decodeOption.setString( (*it).second );
169175
}
170176
catch( std::exception& e )

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,26 @@ void VideoDecoder::flushDecoder()
110110

111111
void VideoDecoder::setProfile( const ProfileLoader::Profile& profile )
112112
{
113-
// set threads if not in profile
114-
if( ! profile.count( "threads" ) )
115-
_inputStream->getVideoCodec().getOption( "threads" ).setString( "auto" );
113+
VideoCodec& codec = _inputStream->getVideoCodec();
116114

115+
// set threads before any other options
116+
if( profile.count( constants::avProfileThreads ) )
117+
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
118+
else
119+
codec.getOption( constants::avProfileThreads ).setString( "auto" );
120+
121+
// set decoder options
117122
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
118123
{
119124
if( (*it).first == constants::avProfileIdentificator ||
120125
(*it).first == constants::avProfileIdentificatorHuman ||
121-
(*it).first == constants::avProfileType )
126+
(*it).first == constants::avProfileType ||
127+
(*it).first == constants::avProfileThreads )
122128
continue;
123129

124130
try
125131
{
126-
Option& decodeOption = _inputStream->getVideoCodec().getOption( (*it).first );
132+
Option& decodeOption = codec.getOption( (*it).first );
127133
decodeOption.setString( (*it).second );
128134
}
129135
catch( std::exception& e )

0 commit comments

Comments
 (0)