Skip to content

Commit 1082844

Browse files
author
Clement Champetier
committed
Video/AudioDecoder: set threads options to auto if no set by the user
1 parent 816e102 commit 1082844

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,29 @@ bool AudioDecoder::decodeNextFrame()
161161
return true;
162162
}
163163

164+
void AudioDecoder::setProfile( const ProfileLoader::Profile& profile )
165+
{
166+
// set threads if not in profile
167+
if( ! profile.count( "threads" ) )
168+
_inputStream->getAudioCodec().getOption( "threads" ).setString( "auto" );
169+
170+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
171+
{
172+
if( (*it).first == constants::avProfileIdentificator ||
173+
(*it).first == constants::avProfileIdentificatorHuman ||
174+
(*it).first == constants::avProfileType )
175+
continue;
176+
177+
try
178+
{
179+
Option& decodeOption = _inputStream->getAudioCodec().getOption( (*it).first );
180+
decodeOption.setString( (*it).second );
181+
}
182+
catch( std::exception& e )
183+
{
184+
std::cout << "[AudioDecoder] warning - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() << std::endl;
185+
}
186+
}
187+
}
188+
164189
}

src/AvTranscoder/decoder/AudioDecoder.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _AV_TRANSCODER_ESSENCE_STREAM_AV_INPUT_AUDIO_HPP_
33

44
#include "IDecoder.hpp"
5+
#include <AvTranscoder/ProfileLoader.hpp>
56

67
struct AVFrame;
78

@@ -21,6 +22,8 @@ class AvExport AudioDecoder : public IDecoder
2122
bool decodeNextFrame( Frame& frameBuffer );
2223
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );
2324

25+
void setProfile( const ProfileLoader::Profile& profile );
26+
2427
private:
2528
bool decodeNextFrame();
2629

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ void VideoDecoder::flushDecoder()
119119

120120
void VideoDecoder::setProfile( const ProfileLoader::Profile& profile )
121121
{
122+
// set threads if not in profile
123+
if( ! profile.count( "threads" ) )
124+
_inputStream->getVideoCodec().getOption( "threads" ).setString( "auto" );
125+
122126
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
123127
{
124128
if( (*it).first == constants::avProfileIdentificator ||

0 commit comments

Comments
 (0)