Skip to content

Profile: rename to ProfileLoader #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/avTranscoder/avTranscoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )

// av_log_set_level( AV_LOG_DEBUG );

Profile profile( true );
ProfileLoader profileLoader( true );
ConsoleProgress p;

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

// init video encoder
AvOutputVideo outputVideo;
outputVideo.setProfile( profile.getProfile( "xdcamhd422" ), VideoFrameDesc );
outputVideo.setProfile( profileLoader.getProfile( "xdcamhd422" ), VideoFrameDesc );
VideoFrame imageToEncode( outputVideo.getVideoCodec().getVideoFrameDesc() );

CodedData codedImage;
Expand Down
6 changes: 2 additions & 4 deletions app/genericProcessor/genericProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static const std::string dummyAudioCodec = "pcm_s16le";

bool verbose = false;

void parseConfigFile( const std::string& configFilename, avtranscoder::Transcoder& transcoder, avtranscoder::Profile& profile )
void parseConfigFile( const std::string& configFilename, avtranscoder::Transcoder& transcoder )
{
std::ifstream configFile( configFilename.c_str(), std::ifstream::in );

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

avtranscoder::Profile profiles( true );

if( verbose )
std::cout << "output file: " << argv[2] << std::endl;

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

if( verbose )
std::cout << "parse config file" << std::endl;
parseConfigFile( inputConfigFile, transcoder, profiles );
parseConfigFile( inputConfigFile, transcoder );

// set verbose of all stream
transcoder.setVerbose( verbose );
Expand Down
4 changes: 2 additions & 2 deletions app/presetChecker/presetChecker.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

#include <iostream>
#include <iomanip>
#include <AvTranscoder/Profile.hpp>
#include <AvTranscoder/ProfileLoader.hpp>

#include <AvTranscoder/essenceStream/AvOutputVideo.hpp>
#include <AvTranscoder/essenceStream/AvOutputAudio.hpp>


int main( int argc, char** argv )
{
avtranscoder::Profile p;
avtranscoder::ProfileLoader p;
p.loadProfiles();

std::cout << p.getProfiles().size() << std::endl;
Expand Down
38 changes: 19 additions & 19 deletions src/AvTranscoder/Profile.cpp → src/AvTranscoder/ProfileLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Profile.hpp"
#include "ProfileLoader.hpp"

#include "common.hpp"

Expand All @@ -16,18 +16,18 @@
namespace avtranscoder
{

Profile::Profile( bool autoload )
ProfileLoader::ProfileLoader( bool autoload )
{
if( autoload )
loadProfiles();
}

void Profile::loadProfile( const std::string& avProfileFile )
void ProfileLoader::loadProfile( const std::string& avProfileFile )
{
std::ifstream infile;
infile.open( avProfileFile.c_str(), std::ifstream::in );

Profile::ProfileDesc customProfile;
ProfileLoader::Profile customProfile;

std::string line;
while( std::getline( infile, line ) )
Expand All @@ -50,7 +50,7 @@ void Profile::loadProfile( const std::string& avProfileFile )
}
}

void Profile::loadProfiles( const std::string& avProfilesPath )
void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
{
loadXdCamHD422( _profiles );
loadDNxHD( _profiles );
Expand Down Expand Up @@ -83,11 +83,11 @@ void Profile::loadProfiles( const std::string& avProfilesPath )
}
}

void Profile::update( const ProfileDesc& profile )
void ProfileLoader::update( const Profile& profile )
{
std::string profileId( profile.find( constants::avProfileIdentificator )->second );
size_t profileIndex = 0;
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
{
if( (*it).find( constants::avProfileIdentificator )->second == profileId )
{
Expand All @@ -100,16 +100,16 @@ void Profile::update( const ProfileDesc& profile )
_profiles.push_back( profile );
}

const Profile::ProfilesDesc& Profile::getProfiles()
const ProfileLoader::Profiles& ProfileLoader::getProfiles()
{
return _profiles;
}

Profile::ProfilesDesc Profile::getFormatProfiles()
ProfileLoader::Profiles ProfileLoader::getFormatProfiles()
{
ProfilesDesc profiles;
Profiles profiles;

for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
{
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeFormat )
profiles.push_back( *it );
Expand All @@ -118,11 +118,11 @@ Profile::ProfilesDesc Profile::getFormatProfiles()
return profiles;
}

Profile::ProfilesDesc Profile::getVideoProfiles()
ProfileLoader::Profiles ProfileLoader::getVideoProfiles()
{
ProfilesDesc profiles;
Profiles profiles;

for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
{
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeVideo )
profiles.push_back( *it );
Expand All @@ -131,11 +131,11 @@ Profile::ProfilesDesc Profile::getVideoProfiles()
return profiles;
}

Profile::ProfilesDesc Profile::getAudioProfiles()
ProfileLoader::Profiles ProfileLoader::getAudioProfiles()
{
ProfilesDesc profiles;
Profiles profiles;

for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
{
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeAudio )
profiles.push_back( *it );
Expand All @@ -144,9 +144,9 @@ Profile::ProfilesDesc Profile::getAudioProfiles()
return profiles;
}

Profile::ProfileDesc& Profile::getProfile( const std::string& searchProfile )
ProfileLoader::Profile& ProfileLoader::getProfile( const std::string& searchProfile )
{
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
{
if( (*it).find( constants::avProfileIdentificator )->second == searchProfile )
{
Expand Down
31 changes: 12 additions & 19 deletions src/AvTranscoder/Profile.hpp → src/AvTranscoder/ProfileLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,31 @@ namespace constants
const std::string avProfileChannel = "ac";
}

class AvExport Profile
class AvExport ProfileLoader
{
public:


public:
// typedef std::pair< std::string, std::string > KeyDesc;
typedef std::map< std::string, std::string > ProfileDesc;
typedef std::vector< ProfileDesc > ProfilesDesc;
typedef std::map< std::string, std::string > Profile;
typedef std::vector< Profile > Profiles;

public:
Profile( bool autoload = false );
ProfileLoader( bool autoload = false );

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

void update( const ProfileDesc& profile );
void update( const Profile& profile );

const ProfilesDesc& getProfiles();
const Profiles& getProfiles();

ProfilesDesc getFormatProfiles();
ProfilesDesc getVideoProfiles();
ProfilesDesc getAudioProfiles();
Profiles getFormatProfiles();
Profiles getVideoProfiles();
Profiles getAudioProfiles();

ProfileDesc& getProfile( const std::string& searchProfile );
Profile& getProfile( const std::string& searchProfile );

private:
ProfilesDesc _profiles;

Profiles _profiles;
};



}
#endif
#endif
8 changes: 2 additions & 6 deletions src/AvTranscoder/avTranscoder.i
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%include "AvTranscoder/swig/avRational.i"

%{
#include <AvTranscoder/Profile.hpp>
#include <AvTranscoder/ProfileLoader.hpp>

#include <AvTranscoder/frame/Pixel.hpp>
#include <AvTranscoder/frame/Frame.hpp>
Expand All @@ -27,8 +27,6 @@

#include <AvTranscoder/mediaProperty/mediaProperty.hpp>

#include <AvTranscoder/Profile.hpp>

#include <AvTranscoder/codedStream/IOutputStream.hpp>
#include <AvTranscoder/codedStream/AvOutputStream.hpp>

Expand Down Expand Up @@ -65,7 +63,7 @@ namespace std {

%include "AvTranscoder/progress/progress.i"

%include <AvTranscoder/Profile.hpp>
%include <AvTranscoder/ProfileLoader.hpp>

%include <AvTranscoder/frame/Pixel.hpp>
%include <AvTranscoder/frame/Frame.hpp>
Expand All @@ -79,8 +77,6 @@ namespace std {

%include <AvTranscoder/mediaProperty/mediaProperty.hpp>

%include <AvTranscoder/Profile.hpp>

%include <AvTranscoder/codedStream/IOutputStream.hpp>
%include <AvTranscoder/codedStream/AvOutputStream.hpp>

Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/essenceStream/AvInputVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ void AvInputVideo::flushDecoder()
avcodec_flush_buffers( _codec.getAVCodecContext() );
}

void AvInputVideo::setProfile( const Profile::ProfileDesc& desc )
void AvInputVideo::setProfile( const ProfileLoader::Profile& profile )
{
Context codecContext( _codec.getAVCodecContext() );

for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
{
if( (*it).first == constants::avProfileIdentificator ||
(*it).first == constants::avProfileIdentificatorHuman ||
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/essenceStream/AvInputVideo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "IInputEssence.hpp"
#include <AvTranscoder/codec/VideoCodec.hpp>
#include <AvTranscoder/Profile.hpp>
#include <AvTranscoder/ProfileLoader.hpp>

struct AVFrame;

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

void flushDecoder();

void setProfile( const Profile::ProfileDesc& desc );
void setProfile( const ProfileLoader::Profile& profile );

private:
AvInputStream* _inputStream;
Expand Down
14 changes: 7 additions & 7 deletions src/AvTranscoder/essenceStream/AvOutputAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,20 @@ bool AvOutputAudio::encodeFrame( Frame& codedFrame )
#endif
}

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

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

Context codecContext( _codec.getAVCodecContext() );

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

setup();

for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
{
if( (*it).first == constants::avProfileIdentificator ||
(*it).first == constants::avProfileIdentificatorHuman ||
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/essenceStream/AvOutputAudio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "IOutputEssence.hpp"
#include <AvTranscoder/codec/AudioCodec.hpp>
#include <AvTranscoder/Profile.hpp>
#include <AvTranscoder/ProfileLoader.hpp>

namespace avtranscoder
{
Expand All @@ -25,7 +25,7 @@ class AvExport AvOutputAudio : public IOutputEssence
*/
bool encodeFrame( Frame& codedFrame );

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

ICodec& getCodec() { return _codec; }
AudioCodec& getAudioCodec() { return _codec; }
Expand Down
18 changes: 9 additions & 9 deletions src/AvTranscoder/essenceStream/AvOutputVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,25 @@ bool AvOutputVideo::encodeFrame( Frame& codedFrame )
#endif
}

void AvOutputVideo::setProfile( const Profile::ProfileDesc& desc, const avtranscoder::VideoFrameDesc& frameDesc )
void AvOutputVideo::setProfile( const ProfileLoader::Profile& profile, const avtranscoder::VideoFrameDesc& frameDesc )
{
if( ! desc.count( constants::avProfileCodec ) ||
! desc.count( constants::avProfilePixelFormat ) ||
! desc.count( constants::avProfileFrameRate ) )
if( ! profile.count( constants::avProfileCodec ) ||
! profile.count( constants::avProfilePixelFormat ) ||
! profile.count( constants::avProfileFrameRate ) )
{
throw std::runtime_error( "The profile " + desc.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
throw std::runtime_error( "The profile " + profile.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
}

_codec.setCodec( eCodecTypeEncoder, desc.find( constants::avProfileCodec )->second );
_codec.setCodec( eCodecTypeEncoder, profile.find( constants::avProfileCodec )->second );

const size_t frameRate = std::strtoul( desc.find( constants::avProfileFrameRate )->second.c_str(), NULL, 0 );
const size_t frameRate = std::strtoul( profile.find( constants::avProfileFrameRate )->second.c_str(), NULL, 0 );
_codec.setTimeBase( 1, frameRate );

_codec.setImageParameters( frameDesc );

Context codecContext( _codec.getAVCodecContext() );

for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
{
if( (*it).first == constants::avProfileIdentificator ||
(*it).first == constants::avProfileIdentificatorHuman ||
Expand All @@ -213,7 +213,7 @@ void AvOutputVideo::setProfile( const Profile::ProfileDesc& desc, const avtransc

setup();

for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
{
if( (*it).first == constants::avProfileIdentificator ||
(*it).first == constants::avProfileIdentificatorHuman ||
Expand Down
Loading