Skip to content

Commit 323f28b

Browse files
Merge pull request #36 from cchampet/fix_optionLoader_2
Fix OptionLoader
2 parents aeaea6a + 6d7c48f commit 323f28b

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/AvTranscoder/Option.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum OptionType
2424
TypeRatio,
2525
TypeChoice,
2626
TypeGroup,
27-
TypeChild, // Option which brelongs to Choice or Group
27+
TypeChild, // Option which belongs to Choice or Group
2828
TypeUnknown
2929
};
3030

src/AvTranscoder/OptionLoader.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
223223
{
224224
OptionArray options;
225225

226-
std::map<std::string, int> optionUnitToIndex;
226+
std::multimap<std::string, int> optionUnitToIndex;
227227
std::vector<Option> childOptions;
228228

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

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

247-
//std::cout << "The option is " << avOption->name << " of type : " << avOption->type << std::endl;
248-
249247
if( optionType == TypeChild )
250248
{
251249
childOptions.push_back( Option( *avOption, optionType ) );
@@ -262,19 +260,25 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
262260
}
263261

264262
// iterate on child options
265-
for( std::vector<Option>::iterator it = childOptions.begin(); it != childOptions.end(); ++it )
263+
for( std::vector<Option>::iterator itOption = childOptions.begin(); itOption != childOptions.end(); ++itOption )
266264
{
267-
int indexParentOption = optionUnitToIndex.at( it->getUnit() );
268-
Option& parentOption = options.at( indexParentOption );
269-
270-
parentOption.appendChild( *it );
271-
272-
// child of a Choice
273-
if( parentOption.getType() == TypeChoice )
265+
for( std::multimap<std::string, int>::iterator itUnit = optionUnitToIndex.begin(); itUnit != optionUnitToIndex.end(); ++itUnit )
274266
{
275-
if( it->getDefaultValueInt() == parentOption.getDefaultValueInt() )
276-
parentOption.setDefaultChildIndex( parentOption.getNbChilds() - 1 );
277-
}
267+
if( itUnit->first == itOption->getUnit() )
268+
{
269+
int indexParentOption = itUnit->second;
270+
Option& parentOption = options.at( indexParentOption );
271+
272+
parentOption.appendChild( *itOption );
273+
274+
// child of a Choice
275+
if( parentOption.getType() == TypeChoice )
276+
{
277+
if( itOption->getDefaultValueInt() == parentOption.getDefaultValueInt() )
278+
parentOption.setDefaultChildIndex( parentOption.getNbChilds() - 1 );
279+
}
280+
}
281+
}
278282
}
279283
return options;
280284
}

0 commit comments

Comments
 (0)