Skip to content

Commit 0354acf

Browse files
author
Clement Champetier
committed
Encoders: set threads before any other options
Add constants 'avProfileThreads' in ProfileLoader.
1 parent d7b0296 commit 0354acf

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/AvTranscoder/ProfileLoader.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace constants
2828
const std::string avProfileHeight = "height";
2929
const std::string avProfileSampleRate = "ar";
3030
const std::string avProfileChannel = "ac";
31+
const std::string avProfileThreads = "threads";
3132
}
3233

3334
class AvExport ProfileLoader

src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ void AudioEncoder::setProfile( const ProfileLoader::Profile& profile, const Audi
146146
// set sampleRate, number of channels, sample format
147147
_codec.setAudioParameters( frameDesc );
148148

149-
// set threads if not in profile
150-
if( ! profile.count( "threads" ) )
151-
_codec.getOption( "threads" ).setString( "auto" );
149+
// set threads before any other options
150+
if( profile.count( constants::avProfileThreads ) )
151+
_codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
152+
else
153+
_codec.getOption( constants::avProfileThreads ).setString( "auto" );
154+
152155

153156
// set encoder options
154157
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
@@ -157,7 +160,8 @@ void AudioEncoder::setProfile( const ProfileLoader::Profile& profile, const Audi
157160
(*it).first == constants::avProfileIdentificatorHuman ||
158161
(*it).first == constants::avProfileType ||
159162
(*it).first == constants::avProfileCodec ||
160-
(*it).first == constants::avProfileSampleFormat )
163+
(*it).first == constants::avProfileSampleFormat ||
164+
(*it).first == constants::avProfileThreads )
161165
continue;
162166

163167
try
@@ -177,7 +181,8 @@ void AudioEncoder::setProfile( const ProfileLoader::Profile& profile, const Audi
177181
(*it).first == constants::avProfileIdentificatorHuman ||
178182
(*it).first == constants::avProfileType ||
179183
(*it).first == constants::avProfileCodec ||
180-
(*it).first == constants::avProfileSampleFormat )
184+
(*it).first == constants::avProfileSampleFormat ||
185+
(*it).first == constants::avProfileThreads )
181186
continue;
182187

183188
try

src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ void VideoEncoder::setProfile( const ProfileLoader::Profile& profile, const avtr
137137
// set width, height, pixel format, fps
138138
_codec.setImageParameters( frameDesc );
139139

140-
// set threads if not in profile
141-
if( ! profile.count( "threads" ) )
142-
_codec.getOption( "threads" ).setString( "auto" );
140+
// set threads before any other options
141+
if( profile.count( constants::avProfileThreads ) )
142+
_codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
143+
else
144+
_codec.getOption( constants::avProfileThreads ).setString( "auto" );
143145

144146
// set encoder options
145147
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
@@ -151,7 +153,8 @@ void VideoEncoder::setProfile( const ProfileLoader::Profile& profile, const avtr
151153
(*it).first == constants::avProfileWidth ||
152154
(*it).first == constants::avProfileHeight ||
153155
(*it).first == constants::avProfilePixelFormat ||
154-
(*it).first == constants::avProfileFrameRate )
156+
(*it).first == constants::avProfileFrameRate ||
157+
(*it).first == constants::avProfileThreads )
155158
continue;
156159

157160
try
@@ -174,7 +177,8 @@ void VideoEncoder::setProfile( const ProfileLoader::Profile& profile, const avtr
174177
(*it).first == constants::avProfileWidth ||
175178
(*it).first == constants::avProfileHeight ||
176179
(*it).first == constants::avProfilePixelFormat ||
177-
(*it).first == constants::avProfileFrameRate )
180+
(*it).first == constants::avProfileFrameRate ||
181+
(*it).first == constants::avProfileThreads )
178182
continue;
179183

180184
try

0 commit comments

Comments
 (0)