Skip to content

Commit 175b1a8

Browse files
author
Clement Champetier
committed
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder into dev_setFrame_v2
Conflicts: src/AvTranscoder/transcoder/Transcoder.cpp src/AvTranscoder/transcoder/Transcoder.hpp Fix pyTest testSetFrame.
2 parents e5e706e + 804ac76 commit 175b1a8

33 files changed

+314
-252
lines changed

app/avTranscoder/avTranscoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
2222

2323
// av_log_set_level( AV_LOG_DEBUG );
2424

25-
Profile profile( true );
25+
ProfileLoader profileLoader( true );
2626
ConsoleProgress p;
2727

2828
InputFile input( inputfilename );
@@ -37,7 +37,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
3737

3838
// init video encoder
3939
AvOutputVideo outputVideo;
40-
outputVideo.setProfile( profile.getProfile( "xdcamhd422" ), VideoFrameDesc );
40+
outputVideo.setProfile( profileLoader.getProfile( "xdcamhd422" ), VideoFrameDesc );
4141
VideoFrame imageToEncode( outputVideo.getVideoCodec().getVideoFrameDesc() );
4242

4343
CodedData codedImage;

app/genericProcessor/genericProcessor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static const std::string dummyAudioCodec = "pcm_s16le";
1717

1818
bool verbose = false;
1919

20-
void parseConfigFile( const std::string& configFilename, avtranscoder::Transcoder& transcoder, avtranscoder::Profile& profile )
20+
void parseConfigFile( const std::string& configFilename, avtranscoder::Transcoder& transcoder )
2121
{
2222
std::ifstream configFile( configFilename.c_str(), std::ifstream::in );
2323

@@ -99,8 +99,6 @@ int main( int argc, char** argv )
9999
if( verbose )
100100
std::cout << "start ..." << std::endl;
101101

102-
avtranscoder::Profile profiles( true );
103-
104102
if( verbose )
105103
std::cout << "output file: " << argv[2] << std::endl;
106104

@@ -111,7 +109,7 @@ int main( int argc, char** argv )
111109

112110
if( verbose )
113111
std::cout << "parse config file" << std::endl;
114-
parseConfigFile( inputConfigFile, transcoder, profiles );
112+
parseConfigFile( inputConfigFile, transcoder );
115113

116114
// set verbose of all stream
117115
transcoder.setVerbose( verbose );

app/presetChecker/presetChecker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

22
#include <iostream>
33
#include <iomanip>
4-
#include <AvTranscoder/Profile.hpp>
4+
#include <AvTranscoder/ProfileLoader.hpp>
55

66
#include <AvTranscoder/essenceStream/AvOutputVideo.hpp>
77
#include <AvTranscoder/essenceStream/AvOutputAudio.hpp>
88

99

1010
int main( int argc, char** argv )
1111
{
12-
avtranscoder::Profile p;
12+
avtranscoder::ProfileLoader p;
1313
p.loadProfiles();
1414

1515
std::cout << p.getProfiles().size() << std::endl;

src/AvTranscoder/Profile.cpp renamed to src/AvTranscoder/ProfileLoader.cpp

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Profile.hpp"
1+
#include "ProfileLoader.hpp"
22

33
#include "common.hpp"
44

@@ -16,18 +16,18 @@
1616
namespace avtranscoder
1717
{
1818

19-
Profile::Profile( bool autoload )
19+
ProfileLoader::ProfileLoader( bool autoload )
2020
{
2121
if( autoload )
2222
loadProfiles();
2323
}
2424

25-
void Profile::loadProfile( const std::string& avProfileFile )
25+
void ProfileLoader::loadProfile( const std::string& avProfileFile )
2626
{
2727
std::ifstream infile;
2828
infile.open( avProfileFile.c_str(), std::ifstream::in );
2929

30-
Profile::ProfileDesc customProfile;
30+
ProfileLoader::Profile customProfile;
3131

3232
std::string line;
3333
while( std::getline( infile, line ) )
@@ -50,7 +50,7 @@ void Profile::loadProfile( const std::string& avProfileFile )
5050
}
5151
}
5252

53-
void Profile::loadProfiles( const std::string& avProfilesPath )
53+
void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
5454
{
5555
loadXdCamHD422( _profiles );
5656
loadDNxHD( _profiles );
@@ -83,33 +83,35 @@ void Profile::loadProfiles( const std::string& avProfilesPath )
8383
}
8484
}
8585

86-
void Profile::update( const ProfileDesc& profile )
86+
void ProfileLoader::update( const Profile& profile )
8787
{
88-
std::string profileId( profile.find( constants::avProfileIdentificator )->second );
88+
Profile::const_iterator profileIt = profile.find( constants::avProfileIdentificator );
89+
if( profileIt == profile.end() )
90+
throw std::runtime_error( "Invalid profile: can't get identificator" );
91+
92+
std::string profileId( profileIt->second );
8993
size_t profileIndex = 0;
90-
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
94+
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
9195
{
96+
// profile already exists
9297
if( (*it).find( constants::avProfileIdentificator )->second == profileId )
93-
{
94-
_profiles.at( profileIndex ) = profile;
9598
return;
96-
}
9799
++profileIndex;
98100
}
99101
// profile not found: add the new profile
100102
_profiles.push_back( profile );
101103
}
102104

103-
const Profile::ProfilesDesc& Profile::getProfiles()
105+
const ProfileLoader::Profiles& ProfileLoader::getProfiles()
104106
{
105107
return _profiles;
106108
}
107109

108-
Profile::ProfilesDesc Profile::getFormatProfiles()
110+
ProfileLoader::Profiles ProfileLoader::getFormatProfiles()
109111
{
110-
ProfilesDesc profiles;
112+
Profiles profiles;
111113

112-
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
114+
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
113115
{
114116
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeFormat )
115117
profiles.push_back( *it );
@@ -118,11 +120,11 @@ Profile::ProfilesDesc Profile::getFormatProfiles()
118120
return profiles;
119121
}
120122

121-
Profile::ProfilesDesc Profile::getVideoProfiles()
123+
ProfileLoader::Profiles ProfileLoader::getVideoProfiles()
122124
{
123-
ProfilesDesc profiles;
125+
Profiles profiles;
124126

125-
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
127+
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
126128
{
127129
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeVideo )
128130
profiles.push_back( *it );
@@ -131,11 +133,11 @@ Profile::ProfilesDesc Profile::getVideoProfiles()
131133
return profiles;
132134
}
133135

134-
Profile::ProfilesDesc Profile::getAudioProfiles()
136+
ProfileLoader::Profiles ProfileLoader::getAudioProfiles()
135137
{
136-
ProfilesDesc profiles;
138+
Profiles profiles;
137139

138-
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
140+
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
139141
{
140142
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeAudio )
141143
profiles.push_back( *it );
@@ -144,9 +146,9 @@ Profile::ProfilesDesc Profile::getAudioProfiles()
144146
return profiles;
145147
}
146148

147-
Profile::ProfileDesc& Profile::getProfile( const std::string& searchProfile )
149+
ProfileLoader::Profile& ProfileLoader::getProfile( const std::string& searchProfile )
148150
{
149-
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
151+
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
150152
{
151153
if( (*it).find( constants::avProfileIdentificator )->second == searchProfile )
152154
{

src/AvTranscoder/Profile.hpp renamed to src/AvTranscoder/ProfileLoader.hpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,31 @@ namespace constants
2828
const std::string avProfileChannel = "ac";
2929
}
3030

31-
class AvExport Profile
31+
class AvExport ProfileLoader
3232
{
3333
public:
34-
35-
36-
public:
37-
// typedef std::pair< std::string, std::string > KeyDesc;
38-
typedef std::map< std::string, std::string > ProfileDesc;
39-
typedef std::vector< ProfileDesc > ProfilesDesc;
34+
typedef std::map< std::string, std::string > Profile;
35+
typedef std::vector< Profile > Profiles;
4036

4137
public:
42-
Profile( bool autoload = false );
38+
ProfileLoader( bool autoload = false );
4339

4440
void loadProfiles( const std::string& avProfilesPath = "" );
4541
void loadProfile( const std::string& avProfileFile );
4642

47-
void update( const ProfileDesc& profile );
43+
void update( const Profile& profile );
4844

49-
const ProfilesDesc& getProfiles();
45+
const Profiles& getProfiles();
5046

51-
ProfilesDesc getFormatProfiles();
52-
ProfilesDesc getVideoProfiles();
53-
ProfilesDesc getAudioProfiles();
47+
Profiles getFormatProfiles();
48+
Profiles getVideoProfiles();
49+
Profiles getAudioProfiles();
5450

55-
ProfileDesc& getProfile( const std::string& searchProfile );
51+
Profile& getProfile( const std::string& searchProfile );
5652

5753
private:
58-
ProfilesDesc _profiles;
59-
54+
Profiles _profiles;
6055
};
6156

62-
63-
6457
}
65-
#endif
58+
#endif

src/AvTranscoder/avTranscoder.i

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
%include "AvTranscoder/swig/avRational.i"
1414

1515
%{
16-
#include <AvTranscoder/Profile.hpp>
16+
#include <AvTranscoder/ProfileLoader.hpp>
1717

1818
#include <AvTranscoder/frame/Pixel.hpp>
1919
#include <AvTranscoder/frame/Frame.hpp>
@@ -27,8 +27,6 @@
2727

2828
#include <AvTranscoder/mediaProperty/mediaProperty.hpp>
2929

30-
#include <AvTranscoder/Profile.hpp>
31-
3230
#include <AvTranscoder/codedStream/IOutputStream.hpp>
3331
#include <AvTranscoder/codedStream/AvOutputStream.hpp>
3432

@@ -68,7 +66,7 @@ namespace std {
6866

6967
%include "AvTranscoder/progress/progress.i"
7068

71-
%include <AvTranscoder/Profile.hpp>
69+
%include <AvTranscoder/ProfileLoader.hpp>
7270

7371
%include <AvTranscoder/frame/Pixel.hpp>
7472
%include <AvTranscoder/frame/Frame.hpp>
@@ -82,8 +80,6 @@ namespace std {
8280

8381
%include <AvTranscoder/mediaProperty/mediaProperty.hpp>
8482

85-
%include <AvTranscoder/Profile.hpp>
86-
8783
%include <AvTranscoder/codedStream/IOutputStream.hpp>
8884
%include <AvTranscoder/codedStream/AvOutputStream.hpp>
8985

src/AvTranscoder/essenceStream/AvInputVideo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ void AvInputVideo::flushDecoder()
136136
avcodec_flush_buffers( _codec->getAVCodecContext() );
137137
}
138138

139-
void AvInputVideo::setProfile( const Profile::ProfileDesc& desc )
139+
void AvInputVideo::setProfile( const ProfileLoader::Profile& profile )
140140
{
141141
Context codecContext( _codec->getAVCodecContext() );
142142

143-
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
143+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
144144
{
145145
if( (*it).first == constants::avProfileIdentificator ||
146146
(*it).first == constants::avProfileIdentificatorHuman ||
@@ -154,7 +154,7 @@ void AvInputVideo::setProfile( const Profile::ProfileDesc& desc )
154154
}
155155
catch( std::exception& e )
156156
{
157-
std::cout << "[InputVideo] warning: " << e.what() << std::endl;
157+
std::cout << "[InputVideo] warning - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() << std::endl;
158158
}
159159
}
160160
}

src/AvTranscoder/essenceStream/AvInputVideo.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "IInputEssence.hpp"
55
#include <AvTranscoder/codec/VideoCodec.hpp>
6-
#include <AvTranscoder/Profile.hpp>
6+
#include <AvTranscoder/ProfileLoader.hpp>
77

88
struct AVFrame;
99

@@ -25,7 +25,7 @@ class AvExport AvInputVideo : public IInputEssence
2525

2626
void flushDecoder();
2727

28-
void setProfile( const Profile::ProfileDesc& desc );
28+
void setProfile( const ProfileLoader::Profile& profile );
2929

3030
private:
3131
bool decodeNextFrame();

src/AvTranscoder/essenceStream/AvOutputAudio.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,20 @@ bool AvOutputAudio::encodeFrame( Frame& codedFrame )
171171
#endif
172172
}
173173

174-
void AvOutputAudio::setProfile( const Profile::ProfileDesc& desc, const AudioFrameDesc& frameDesc )
174+
void AvOutputAudio::setProfile( const ProfileLoader::Profile& profile, const AudioFrameDesc& frameDesc )
175175
{
176-
if( ! desc.count( constants::avProfileCodec ) ||
177-
! desc.count( constants::avProfileSampleFormat ) )
176+
if( ! profile.count( constants::avProfileCodec ) ||
177+
! profile.count( constants::avProfileSampleFormat ) )
178178
{
179-
throw std::runtime_error( "The profile " + desc.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
179+
throw std::runtime_error( "The profile " + profile.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
180180
}
181181

182-
_codec.setCodec( eCodecTypeEncoder, desc.find( constants::avProfileCodec )->second );
182+
_codec.setCodec( eCodecTypeEncoder, profile.find( constants::avProfileCodec )->second );
183183
_codec.setAudioParameters( frameDesc );
184184

185185
Context codecContext( _codec.getAVCodecContext() );
186186

187-
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
187+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
188188
{
189189
if( (*it).first == constants::avProfileIdentificator ||
190190
(*it).first == constants::avProfileIdentificatorHuman ||
@@ -206,7 +206,7 @@ void AvOutputAudio::setProfile( const Profile::ProfileDesc& desc, const AudioFra
206206

207207
setup();
208208

209-
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
209+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
210210
{
211211
if( (*it).first == constants::avProfileIdentificator ||
212212
(*it).first == constants::avProfileIdentificatorHuman ||
@@ -222,7 +222,7 @@ void AvOutputAudio::setProfile( const Profile::ProfileDesc& desc, const AudioFra
222222
}
223223
catch( std::exception& e )
224224
{
225-
std::cout << "[OutputAudio] warning: " << e.what() << std::endl;
225+
std::cout << "[OutputAudio] warning - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() << std::endl;
226226
}
227227
}
228228
}

src/AvTranscoder/essenceStream/AvOutputAudio.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "IOutputEssence.hpp"
55
#include <AvTranscoder/codec/AudioCodec.hpp>
6-
#include <AvTranscoder/Profile.hpp>
6+
#include <AvTranscoder/ProfileLoader.hpp>
77

88
namespace avtranscoder
99
{
@@ -25,7 +25,7 @@ class AvExport AvOutputAudio : public IOutputEssence
2525
*/
2626
bool encodeFrame( Frame& codedFrame );
2727

28-
void setProfile( const Profile::ProfileDesc& desc, const AudioFrameDesc& frameDesc );
28+
void setProfile( const ProfileLoader::Profile& profile, const AudioFrameDesc& frameDesc );
2929

3030
ICodec& getCodec() { return _codec; }
3131
AudioCodec& getAudioCodec() { return _codec; }

0 commit comments

Comments
 (0)