Skip to content

Commit 5c08d96

Browse files
author
Clement Champetier
committed
Merge branch 'develop' of https://github.com/mikrosimage/avTranscoder into develop
2 parents 49d3554 + 8b4a5cc commit 5c08d96

File tree

9 files changed

+75
-71
lines changed

9 files changed

+75
-71
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ bool AudioDecoder::decodeNextFrame()
147147

148148
void AudioDecoder::setProfile( const ProfileLoader::Profile& profile )
149149
{
150+
LOG_DEBUG( "Set profile of audio decoder with:\n" << profile )
151+
150152
AudioCodec& codec = _inputStream->getAudioCodec();
151153

152154
// set threads before any other options

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ void VideoDecoder::flushDecoder()
105105
}
106106

107107
void VideoDecoder::setProfile( const ProfileLoader::Profile& profile )
108-
{
108+
{
109+
LOG_DEBUG( "Set profile of video decoder with:\n" << profile )
110+
109111
VideoCodec& codec = _inputStream->getVideoCodec();
110112

111113
// set threads before any other options

src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ bool AudioEncoder::encodeFrame( Frame& codedFrame )
135135

136136
void AudioEncoder::setProfile( const ProfileLoader::Profile& profile, const AudioFrameDesc& frameDesc )
137137
{
138+
LOG_DEBUG( "Set profile of audio encoder with:\n" << profile )
139+
138140
// set sampleRate, number of channels, sample format
139141
_codec.setAudioParameters( frameDesc );
140142

src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ bool VideoEncoder::encodeFrame( Frame& codedFrame )
128128

129129
void VideoEncoder::setProfile( const ProfileLoader::Profile& profile, const avtranscoder::VideoFrameDesc& frameDesc )
130130
{
131+
LOG_DEBUG( "Set profile of video encoder with:\n" << profile )
132+
131133
// set width, height, pixel format, fps
132134
_codec.setImageParameters( frameDesc );
133135

src/AvTranscoder/file/InputFile.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ double InputFile::getFps()
199199
}
200200

201201
void InputFile::setProfile( const ProfileLoader::Profile& profile )
202-
{
202+
{
203+
LOG_DEBUG( "Set profile of input file with:\n" << profile )
204+
203205
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
204206
{
205207
if( (*it).first == constants::avProfileIdentificator ||

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ void OutputFile::addMetadata( const std::string& key, const std::string& value )
147147

148148
void OutputFile::setProfile( const ProfileLoader::Profile& profile )
149149
{
150+
LOG_DEBUG( "Set profile of output file with:\n" << profile )
151+
150152
// check if output format indicated is valid with the filename extension
151153
if( ! matchFormat( profile.find( constants::avProfileFormat )->second, _filename ) )
152154
{

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ class AvExport StreamTranscoder
6969
*/
7070
double getDuration() const;
7171

72-
/// Returns a reference to the current decoder used by the streamTranscoder (from input file or from generator)
72+
/// Returns a reference to the current decoder (from input file or from generator)
7373
IDecoder& getCurrentDecoder() const { return *_currentDecoder; }
74+
/// Returns a reference to the encoder
75+
IEncoder& getEncoder() const { return *_outputEncoder; }
76+
77+
/// Returns a reference to the object which transforms the decoded data
78+
ITransform& getTransform() const { return *_transform; }
79+
80+
/// Returns a reference to the stream which unwraps data
81+
IInputStream& getInputStream() const { return *_inputStream; }
82+
/// Returns a reference to the stream which wraps data
83+
IOutputStream& getOutputStream() const { return *_outputStream; }
7484

7585
/**
7686
* @brief Returns if the stream can switch to a generator when ended

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,23 @@ class AvExport Transcoder
122122
void process( IProgress& progress );
123123
void process(); ///< Call process with no display of progression
124124

125+
/**
126+
* @brief Return the list of streams added to the transcoder.
127+
*/
128+
std::vector< StreamTranscoder* >& getStreamTranscoders() { return _streamTranscoders; }
129+
125130
/**
126131
* @param streamIndex: careful about the order of stream insertion of the Transcoder.
127132
* @return a reference to a stream manage by the Transcoder.
128133
*/
129134
StreamTranscoder& getStreamTranscoder( size_t streamIndex ) const { return *_streamTranscoders.at( streamIndex ); }
130135

136+
/**
137+
* @brief Get current processMethod
138+
* @see EProcessMethod
139+
*/
140+
EProcessMethod getProcessMethod() const { return _eProcessMethod; }
141+
131142
/**
132143
* @brief Set the transcoding policy.
133144
* @note By default eProcessMethodBasedOnStream at index 0.

src/AvTranscoder/util.cpp

Lines changed: 39 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern "C" {
77
}
88

99
#include <utility>
10+
#include <algorithm>
1011

1112
namespace avtranscoder
1213
{
@@ -144,25 +145,18 @@ NamesArray getVideoCodecsNames()
144145
AVCodec* c = NULL;
145146
while( ( c = av_codec_next( c ) ) != NULL )
146147
{
147-
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
148-
if( ! c->encode )
149-
continue;
150-
#else
151-
if( ! c->encode2 )
152-
continue;
153-
#endif
154-
switch( c->type )
148+
if( c->type == AVMEDIA_TYPE_VIDEO)
155149
{
156-
case AVMEDIA_TYPE_VIDEO:
157-
{
158-
if( ! c->name && ! c->long_name )
159-
continue;
150+
if( ! c->name && ! c->long_name )
151+
continue;
160152

161-
videoCodecsNames.push_back( std::make_pair( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) ) );
162-
break;
163-
}
164-
default:
165-
break;
153+
std::pair< std::string, std::string > codecNames( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) );
154+
155+
// skip duplicates
156+
if( std::find( videoCodecsNames.begin(), videoCodecsNames.end(), codecNames ) != videoCodecsNames.end() )
157+
continue;
158+
159+
videoCodecsNames.push_back( codecNames );
166160
}
167161
}
168162
return videoCodecsNames;
@@ -175,35 +169,26 @@ NamesArray getAudioCodecsNames()
175169
AVCodec* c = NULL;
176170
while( ( c = av_codec_next( c ) ) != NULL )
177171
{
178-
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
179-
if( ! c->encode )
180-
continue;
181-
#else
182-
if( ! c->encode2 )
183-
continue;
184-
#endif
185-
switch( c->type )
172+
if( c->type == AVMEDIA_TYPE_AUDIO )
186173
{
187-
case AVMEDIA_TYPE_AUDIO:
188-
{
189-
if( ! c->name && ! c->long_name )
190-
continue;
174+
if( ! c->name && ! c->long_name )
175+
continue;
191176

192-
audioCodecsNames.push_back( std::make_pair( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) ) );
193-
break;
194-
}
195-
default:
196-
break;
177+
std::pair< std::string, std::string > codecNames( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) );
178+
179+
// skip duplicates
180+
if( std::find( audioCodecsNames.begin(), audioCodecsNames.end(), codecNames ) != audioCodecsNames.end() )
181+
continue;
182+
183+
audioCodecsNames.push_back( codecNames );
197184
}
198185
}
199186
return audioCodecsNames;
200187
}
201188

202189
OptionArrayMap getOutputFormatOptions()
203190
{
204-
av_register_all();
205-
206-
std::map< std::string, std::vector<Option> > optionsPerFormat;
191+
OptionArrayMap optionsPerFormat;
207192

208193
AVOutputFormat* outputFormat = av_oformat_next( NULL );
209194

@@ -216,7 +201,7 @@ OptionArrayMap getOutputFormatOptions()
216201
{
217202
if( outputFormat->priv_class )
218203
{
219-
std::string outputFormatName( outputFormat->name );
204+
const std::string outputFormatName( outputFormat->name );
220205
OptionArray options;
221206
loadOptions( options, (void*)&outputFormat->priv_class, 0 );
222207
optionsPerFormat.insert( std::make_pair( outputFormatName, options ) );
@@ -229,29 +214,22 @@ OptionArrayMap getOutputFormatOptions()
229214

230215
OptionArrayMap getVideoCodecOptions()
231216
{
232-
std::map< std::string, std::vector<Option> > videoCodecOptions;
217+
OptionArrayMap videoCodecOptions;
233218

234219
AVCodec* codec = av_codec_next( NULL );
235220

236221
// iterate on codecs
237222
while( codec )
238223
{
239-
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
240-
if( codec->encode )
241-
#else
242-
if( codec->encode2 )
243-
#endif
224+
// add only video codec
225+
if( codec->type == AVMEDIA_TYPE_VIDEO )
244226
{
245-
// add only video codec
246-
if( codec->type == AVMEDIA_TYPE_VIDEO )
227+
if( codec->priv_class )
247228
{
248-
if( codec->priv_class )
249-
{
250-
std::string videoCodecName( codec->name );
251-
OptionArray options;
252-
loadOptions( options, (void*)&codec->priv_class, 0 );
253-
videoCodecOptions.insert( std::make_pair( videoCodecName, options ) );
254-
}
229+
std::string videoCodecName( codec->name );
230+
OptionArray options;
231+
loadOptions( options, (void*)&codec->priv_class, 0 );
232+
videoCodecOptions.insert( std::make_pair( videoCodecName, options ) );
255233
}
256234
}
257235
codec = av_codec_next( codec );
@@ -261,29 +239,22 @@ OptionArrayMap getVideoCodecOptions()
261239

262240
OptionArrayMap getAudioCodecOptions()
263241
{
264-
std::map< std::string, std::vector<Option> > audioCodecOptions;
242+
OptionArrayMap audioCodecOptions;
265243

266244
AVCodec* codec = av_codec_next( NULL );
267245

268246
// iterate on codecs
269247
while( codec )
270248
{
271-
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
272-
if( codec->encode )
273-
#else
274-
if( codec->encode2 )
275-
#endif
249+
// add only audio codec
250+
if( codec->type == AVMEDIA_TYPE_AUDIO )
276251
{
277-
// add only audio codec
278-
if( codec->type == AVMEDIA_TYPE_AUDIO )
252+
if( codec->priv_class )
279253
{
280-
if( codec->priv_class )
281-
{
282-
std::string audioCodecName( codec->name );
283-
OptionArray options;
284-
loadOptions( options, (void*)&codec->priv_class, 0 );
285-
audioCodecOptions.insert( std::make_pair( audioCodecName, options ) );
286-
}
254+
std::string audioCodecName( codec->name );
255+
OptionArray options;
256+
loadOptions( options, (void*)&codec->priv_class, 0 );
257+
audioCodecOptions.insert( std::make_pair( audioCodecName, options ) );
287258
}
288259
}
289260
codec = av_codec_next( codec );

0 commit comments

Comments
 (0)