Skip to content

Fix OptionLoader #36

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
merged 3 commits into from
Jul 31, 2014
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
2 changes: 1 addition & 1 deletion src/AvTranscoder/Option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum OptionType
TypeRatio,
TypeChoice,
TypeGroup,
TypeChild, // Option which brelongs to Choice or Group
TypeChild, // Option which belongs to Choice or Group
TypeUnknown
};

Expand Down
32 changes: 18 additions & 14 deletions src/AvTranscoder/OptionLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
{
OptionArray options;

std::map<std::string, int> optionUnitToIndex;
std::multimap<std::string, int> optionUnitToIndex;
std::vector<Option> childOptions;

const AVOption* avOption = NULL;
Expand All @@ -244,8 +244,6 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla

OptionType optionType = Option::getTypeFromAVOption( avOption->unit, avOption->type );

//std::cout << "The option is " << avOption->name << " of type : " << avOption->type << std::endl;

if( optionType == TypeChild )
{
childOptions.push_back( Option( *avOption, optionType ) );
Expand All @@ -262,19 +260,25 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
}

// iterate on child options
for( std::vector<Option>::iterator it = childOptions.begin(); it != childOptions.end(); ++it )
for( std::vector<Option>::iterator itOption = childOptions.begin(); itOption != childOptions.end(); ++itOption )
{
int indexParentOption = optionUnitToIndex.at( it->getUnit() );
Option& parentOption = options.at( indexParentOption );

parentOption.appendChild( *it );

// child of a Choice
if( parentOption.getType() == TypeChoice )
for( std::multimap<std::string, int>::iterator itUnit = optionUnitToIndex.begin(); itUnit != optionUnitToIndex.end(); ++itUnit )
{
if( it->getDefaultValueInt() == parentOption.getDefaultValueInt() )
parentOption.setDefaultChildIndex( parentOption.getNbChilds() - 1 );
}
if( itUnit->first == itOption->getUnit() )
{
int indexParentOption = itUnit->second;
Option& parentOption = options.at( indexParentOption );

parentOption.appendChild( *itOption );

// child of a Choice
if( parentOption.getType() == TypeChoice )
{
if( itOption->getDefaultValueInt() == parentOption.getDefaultValueInt() )
parentOption.setDefaultChildIndex( parentOption.getNbChilds() - 1 );
}
}
}
}
return options;
}
Expand Down