Skip to content

Commit 4943351

Browse files
committed
Merge pull request #47 from cchampet/dev_videoProfile_with_no_frameRate
* Can use video profiles without frame rate * Check profiles before using them
2 parents b7f7931 + 4c024a5 commit 4943351

27 files changed

+170
-161
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ avProfileName=profileName
3434
avProfileLongName=profileLongName
3535
avProfileType=avProfileTypeVideo
3636
codec=codecName
37-
r=frameRate
3837
```
3938

4039
The minimum audio profile is:

ressource/v_dnxhd120.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ codec=dnxhd
55
b=120M
66
pix_fmt=yuv422p
77
g=1
8-
r=25

ressource/v_dnxhd185.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ codec=dnxhd
55
pix_fmt=yuv422p
66
b=185M
77
g=1
8-
r=25

ressource/v_dnxhd185x.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ codec=dnxhd
55
pix_fmt=yuv422p10le
66
b=185M
77
g=1
8-
r=25

ressource/v_dvcpro25.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ avProfileType=avProfileTypeVideo
44
codec=dvvideo
55
pix_fmt=yuv411p
66
b=25M
7-
r=25

ressource/v_dvcpro50.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ avProfileType=avProfileTypeVideo
44
codec=dvvideo
55
pix_fmt=yuv422p
66
b=50M
7-
r=25

ressource/v_h264.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ avProfileLongName=h264 High
33
avProfileType=avProfileTypeVideo
44
codec=h264
55
profile=High
6-
r=25

ressource/v_mpeg2.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ avProfileLongName=MPEG-2
33
avProfileType=avProfileTypeVideo
44
codec=mpeg2video
55
pix_fmt=yuv422p
6-
r=25

ressource/v_rawYuv.prf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ avProfileLongName=Raw YUV
33
avProfileType=avProfileTypeVideo
44
codec=rawvideo
55
pix_fmt=rgb24
6-
r=25

src/AvTranscoder/ProfileLoader.cpp

Lines changed: 82 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ ProfileLoader::ProfileLoader( bool autoload )
1616
loadProfiles();
1717
}
1818

19-
void ProfileLoader::loadProfile( const std::string& avProfileFile )
19+
void ProfileLoader::loadProfile( const std::string& avProfileFileName )
2020
{
2121
std::ifstream infile;
22-
infile.open( avProfileFile.c_str(), std::ifstream::in );
22+
infile.open( avProfileFileName.c_str(), std::ifstream::in );
2323

2424
ProfileLoader::Profile customProfile;
2525

@@ -31,18 +31,7 @@ void ProfileLoader::loadProfile( const std::string& avProfileFile )
3131
if( keyValue.size() == 2 )
3232
customProfile[ keyValue.at( 0 ) ] = keyValue.at( 1 );
3333
}
34-
// check if profile contains required values
35-
if(
36-
customProfile.count( constants::avProfileIdentificator ) &&
37-
customProfile.count( constants::avProfileIdentificatorHuman ) &&
38-
customProfile.count( constants::avProfileType ) &&
39-
( customProfile.find( constants::avProfileType )->second == constants::avProfileTypeFormat ||
40-
customProfile.find( constants::avProfileType )->second == constants::avProfileTypeVideo ||
41-
customProfile.find( constants::avProfileType )->second == constants::avProfileTypeAudio )
42-
)
43-
{
44-
_profiles.push_back( customProfile );
45-
}
34+
loadProfile( customProfile );
4635
}
4736

4837
void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
@@ -67,28 +56,46 @@ void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
6756
for( std::vector< std::string >::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt )
6857
{
6958
const std::string absPath = ( *dirIt ) + "/" + ( *fileIt );
70-
loadProfile( absPath );
59+
try
60+
{
61+
loadProfile( absPath );
62+
}
63+
catch( const std::exception& e )
64+
{
65+
std::cout << e.what() << std::endl;
66+
}
7167
}
7268
}
7369
}
7470

75-
void ProfileLoader::update( const Profile& profile )
71+
void ProfileLoader::loadProfile( const Profile& profile )
7672
{
77-
Profile::const_iterator profileIt = profile.find( constants::avProfileIdentificator );
78-
if( profileIt == profile.end() )
79-
throw std::runtime_error( "Invalid profile: can't get identificator" );
73+
// check profile long name
74+
if( ! profile.count( constants::avProfileIdentificator ) )
75+
{
76+
throw std::runtime_error( "Warning: A profile has no name. It will not be loaded." );
77+
}
8078

81-
std::string profileId( profileIt->second );
82-
size_t profileIndex = 0;
83-
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
79+
// check profile type
80+
if( profile.count( constants::avProfileType ) == 0 )
8481
{
85-
// profile already exists
86-
if( (*it).find( constants::avProfileIdentificator )->second == profileId )
87-
return;
88-
++profileIndex;
82+
throw std::runtime_error( "Warning: The profile " + profile.find( constants::avProfileIdentificator )->second + " has not type. It will not be loaded." );
8983
}
90-
// profile not found: add the new profile
91-
_profiles.push_back( profile );
84+
85+
// check complete profile
86+
bool isValid = false;
87+
std::string type( profile.find( constants::avProfileType )->second );
88+
if( type == constants::avProfileTypeFormat )
89+
isValid = checkFormatProfile( profile );
90+
else if( type == constants::avProfileTypeVideo )
91+
isValid = checkVideoProfile( profile );
92+
else if( type == constants::avProfileTypeAudio )
93+
isValid = checkAudioProfile( profile );
94+
95+
if( isValid )
96+
_profiles.push_back( profile );
97+
else
98+
throw std::runtime_error( "Warning: The profile " + profile.find( constants::avProfileIdentificator )->second + " is invalid. It will not be loaded." );
9299
}
93100

94101
const ProfileLoader::Profiles& ProfileLoader::getProfiles()
@@ -147,4 +154,51 @@ ProfileLoader::Profile& ProfileLoader::getProfile( const std::string& avProfileI
147154
throw std::runtime_error( "unable to find profile: " + avProfileIdentificator );
148155
}
149156

157+
158+
bool ProfileLoader::checkFormatProfile( const Profile& profileToCheck )
159+
{
160+
bool isValid = true;
161+
162+
if( ! profileToCheck.count( constants::avProfileIdentificator ) ||
163+
! profileToCheck.count( constants::avProfileIdentificatorHuman ) ||
164+
! profileToCheck.count( constants::avProfileType ) ||
165+
! profileToCheck.count( constants::avProfileFormat ) )
166+
{
167+
isValid = false;
168+
}
169+
170+
return isValid;
171+
}
172+
173+
bool ProfileLoader::checkVideoProfile( const Profile& profileToCheck )
174+
{
175+
bool isValid = true;
176+
177+
if( ! profileToCheck.count( constants::avProfileIdentificator ) ||
178+
! profileToCheck.count( constants::avProfileIdentificatorHuman ) ||
179+
! profileToCheck.count( constants::avProfileType ) ||
180+
! profileToCheck.count( constants::avProfileCodec ) )
181+
{
182+
isValid = false;
183+
}
184+
185+
return isValid;
186+
}
187+
188+
bool ProfileLoader::checkAudioProfile( const Profile& profileToCheck )
189+
{
190+
bool isValid = true;
191+
192+
if( ! profileToCheck.count( constants::avProfileIdentificator ) ||
193+
! profileToCheck.count( constants::avProfileIdentificatorHuman ) ||
194+
! profileToCheck.count( constants::avProfileType ) ||
195+
! profileToCheck.count( constants::avProfileCodec ) )
196+
{
197+
isValid = false;
198+
}
199+
200+
return isValid;
201+
}
202+
203+
150204
}

0 commit comments

Comments
 (0)