Skip to content

Commit 743c148

Browse files
Merge branch 'cchampet-dev_OptionLoader'
2 parents 2656857 + 4707e9c commit 743c148

File tree

10 files changed

+47
-40
lines changed

10 files changed

+47
-40
lines changed

src/AvTranscoder/EssenceStream/OutputAudio.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,27 @@ OutputAudio::OutputAudio()
2424
{
2525
}
2626

27-
bool OutputAudio::setup()
27+
void OutputAudio::setup()
2828
{
2929
av_register_all(); // Warning: should be called only once
3030

3131
AVCodecContext* codecContext( _audioDesc.getCodecContext() );
3232

3333
if( codecContext == NULL )
34-
return false;
34+
{
35+
throw std::runtime_error( "could not allocate audio codec context" );
36+
}
3537

3638
// try to open encoder with parameters.
37-
if( avcodec_open2( codecContext, _audioDesc.getCodec(), NULL ) < 0 )
38-
return false;
39-
40-
return true;
39+
int ret = avcodec_open2( codecContext, _audioDesc.getCodec(), NULL );
40+
if( ret < 0 )
41+
{
42+
char err[250];
43+
av_strerror( ret, err, 250);
44+
std::string msg = "could not open audio encoder: ";
45+
msg += err;
46+
throw std::runtime_error( msg );
47+
}
4148
}
4249

4350
bool OutputAudio::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame )
@@ -174,22 +181,11 @@ void OutputAudio::setProfile( Profile::ProfileDesc& desc, const AudioFrameDesc&
174181
if( ! desc.count( Profile::avProfileCodec ) ||
175182
! desc.count( Profile::avProfileSampleFormat ) ||
176183
! desc.count( Profile::avProfileSampleRate ) ||
177-
! desc.count( Profile::avProfileChannel ) ||
178-
! desc.count( Profile::avProfileChannelLayout ) )
184+
! desc.count( Profile::avProfileChannel ) )
179185
{
180186
throw std::runtime_error( "The profile " + desc[ Profile::avProfileIdentificatorHuman ] + " is invalid." );
181187
}
182188

183-
// check some values of the profile
184-
if( desc[ Profile::avProfileSampleRate ] == "0" )
185-
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad sample rate." );
186-
187-
if( desc[ Profile::avProfileChannel ] == "0" )
188-
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad audio channel." );
189-
190-
if( desc[ Profile::avProfileChannelLayout ] == "0" )
191-
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad audio channel layout." );
192-
193189
_audioDesc.setAudioCodec( desc[ Profile::avProfileCodec ] );
194190

195191
size_t sample_rate = std::strtoul( desc[ Profile::avProfileSampleRate ].c_str(), NULL, 0 );

src/AvTranscoder/EssenceStream/OutputAudio.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class OutputAudio : public OutputEssence
1717
public:
1818
OutputAudio();
1919

20-
bool setup();
20+
void setup();
2121

2222
/**
2323
* @param[out] codedFrame

src/AvTranscoder/EssenceStream/OutputEssence.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ class AvExport OutputEssence
3030

3131
/**
3232
* @brief Setup the encoder
33-
* @return status of setup
3433
*/
35-
virtual bool setup() = 0;
34+
virtual void setup() = 0;
3635

3736
/**
3837
* @brief Encode a new frame, and get coded frame

src/AvTranscoder/EssenceStream/OutputVideo.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,27 @@ OutputVideo::OutputVideo( )
2727
{
2828
}
2929

30-
bool OutputVideo::setup( )
30+
void OutputVideo::setup( )
3131
{
3232
av_register_all(); // Warning: should be called only once
3333

3434
AVCodecContext* codecContext( _videoDesc.getCodecContext() );
3535

3636
if( codecContext == NULL )
37-
return false;
37+
{
38+
throw std::runtime_error( "could not allocate video codec context" );
39+
}
3840

3941
// try to open encoder with parameters
40-
if( avcodec_open2( codecContext, _videoDesc.getCodec(), NULL ) < 0 )
41-
return false;
42-
43-
return true;
42+
int ret = avcodec_open2( codecContext, _videoDesc.getCodec(), NULL );
43+
if( ret < 0 )
44+
{
45+
char err[250];
46+
av_strerror( ret, err, 250);
47+
std::string msg = "could not open video encoder: ";
48+
msg += err;
49+
throw std::runtime_error( msg );
50+
}
4451
}
4552

4653

@@ -195,8 +202,10 @@ void OutputVideo::setProfile( Profile::ProfileDesc& desc, const avtranscoder::Im
195202
}
196203

197204
_videoDesc.setVideoCodec( desc[ Profile::avProfileCodec ] );
205+
198206
const size_t frameRate = std::strtoul( desc[ Profile::avProfileFrameRate ].c_str(), NULL, 0 );
199207
_videoDesc.setTimeBase( 1, frameRate );
208+
200209
_videoDesc.setImageParameters( imageDesc );
201210

202211
for( Profile::ProfileDesc::iterator it = desc.begin(); it != desc.end(); ++it )
@@ -207,8 +216,8 @@ void OutputVideo::setProfile( Profile::ProfileDesc& desc, const avtranscoder::Im
207216
(*it).first == Profile::avProfileCodec ||
208217
(*it).first == Profile::avProfilePixelFormat ||
209218
(*it).first == Profile::avProfileWidth ||
210-
(*it).first == Profile::avProfileHeight||
211-
(*it).first == Profile::avProfileFrameRate)
219+
(*it).first == Profile::avProfileHeight ||
220+
(*it).first == Profile::avProfileFrameRate )
212221
continue;
213222

214223
try
@@ -231,8 +240,8 @@ void OutputVideo::setProfile( Profile::ProfileDesc& desc, const avtranscoder::Im
231240
(*it).first == Profile::avProfileCodec ||
232241
(*it).first == Profile::avProfilePixelFormat ||
233242
(*it).first == Profile::avProfileWidth ||
234-
(*it).first == Profile::avProfileHeight||
235-
(*it).first == Profile::avProfileFrameRate)
243+
(*it).first == Profile::avProfileHeight ||
244+
(*it).first == Profile::avProfileFrameRate )
236245
continue;
237246

238247
try

src/AvTranscoder/EssenceStream/OutputVideo.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AvExport OutputVideo : public OutputEssence
3030
public:
3131
OutputVideo();
3232

33-
bool setup();
33+
void setup();
3434

3535
//void setVideoDesc( const VideoDesc& videoDesc );
3636

src/AvTranscoder/OptionLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
277277
return options;
278278
}
279279

280-
std::vector<std::string> OptionLoader::getPixelFormats( const std::string& videoCodecName ) const
280+
std::vector<std::string> OptionLoader::getPixelFormats( const std::string& videoCodecName )
281281
{
282282
std::vector<std::string> pixelFormats;
283283

@@ -323,7 +323,7 @@ std::vector<std::string> OptionLoader::getPixelFormats( const std::string& video
323323
return pixelFormats;
324324
}
325325

326-
std::vector<std::string> OptionLoader::getSampleFormats( const std::string& audioCodecName ) const
326+
std::vector<std::string> OptionLoader::getSampleFormats( const std::string& audioCodecName )
327327
{
328328
std::vector<std::string> sampleFormats;
329329

src/AvTranscoder/OptionLoader.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,19 @@ class OptionLoader
6060

6161
std::vector<std::string>& getAudioCodecsLongNames() { return _audioCodecsLongNames; }
6262
std::vector<std::string>& getAudioCodecsShortNames() { return _audioCodecsShortNames; }
63-
63+
64+
public:
6465
/**
6566
* Get array of pixel format supported by a video codec.
6667
* @param videoCodecName: the video codec name (empty if not indicated, and so get all pixel formats supported by all video codecs).
6768
*/
68-
std::vector<std::string> getPixelFormats( const std::string& videoCodecName = "" ) const;
69+
static std::vector<std::string> getPixelFormats( const std::string& videoCodecName = "" );
70+
71+
/**
72+
* Get array of sample format supported by an audio codec.
73+
* @param audioCodecName: the audio codec name (empty if not indicated, and so get all sample formats supported by all audio codecs).
74+
*/
75+
static std::vector<std::string> getSampleFormats( const std::string& audioCodecName = "" );
6976

7077
/**
7178
* Get array of sample format supported by an audio codec.

src/AvTranscoder/Profile.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const std::string Profile::avProfileSampleFormat( "sample_fmt" );
2525
const std::string Profile::avProfileFrameRate( "r" );
2626
const std::string Profile::avProfileSampleRate( "ar" );
2727
const std::string Profile::avProfileChannel( "ac" );
28-
const std::string Profile::avProfileChannelLayout( "channel_layout" );
2928
const std::string Profile::avProfileWidth( "width" );
3029
const std::string Profile::avProfileHeight( "height" );
3130

src/AvTranscoder/Profile.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class Profile
2525
static const std::string avProfileFrameRate;
2626
static const std::string avProfileSampleRate;
2727
static const std::string avProfileChannel;
28-
static const std::string avProfileChannelLayout;
2928

3029
static const std::string avProfileWidth;
3130
static const std::string avProfileHeight;

src/AvTranscoder/Profiles/Wave.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ void loadWave( Profile::ProfilesDesc& profiles )
1616
wave24b48kMono[ Profile::avProfileSampleFormat ] = "s32";
1717
wave24b48kMono[ Profile::avProfileSampleRate ] = "48000";
1818
wave24b48kMono[ Profile::avProfileChannel ] = "1";
19-
wave24b48kMono[ Profile::avProfileChannelLayout ] = "1";
2019

2120
Profile::ProfileDesc wave16b48kMono;
2221

@@ -28,7 +27,6 @@ void loadWave( Profile::ProfilesDesc& profiles )
2827
wave16b48kMono[ Profile::avProfileSampleFormat ] = "s16";
2928
wave16b48kMono[ Profile::avProfileSampleRate ] = "48000";
3029
wave16b48kMono[ Profile::avProfileChannel ] = "1";
31-
wave16b48kMono[ Profile::avProfileChannelLayout ] = "1";
3230

3331
profiles.push_back( wave24b48kMono );
3432
profiles.push_back( wave16b48kMono );

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy