Skip to content

Commit 5c13b9c

Browse files
author
Clement Champetier
committed
OptionLoader: fix loadOptions
* Fix bug when get several child options with the same unit. * Solution: use multimap instead of map.
1 parent 68d262b commit 5c13b9c

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/AvTranscoder/OptionLoader.cpp

Lines changed: 18 additions & 12 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;
@@ -262,19 +262,25 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
262262
}
263263

264264
// iterate on child options
265-
for( std::vector<Option>::iterator it = childOptions.begin(); it != childOptions.end(); ++it )
265+
for( std::vector<Option>::iterator itOption = childOptions.begin(); itOption != childOptions.end(); ++itOption )
266266
{
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 )
267+
for( std::multimap<std::string, int>::iterator itUnit = optionUnitToIndex.begin(); itUnit != optionUnitToIndex.end(); ++itUnit )
274268
{
275-
if( it->getDefaultValueInt() == parentOption.getDefaultValueInt() )
276-
parentOption.setDefaultChildIndex( parentOption.getNbChilds() - 1 );
277-
}
269+
if( itUnit->first == itOption->getUnit() )
270+
{
271+
int indexParentOption = itUnit->second;
272+
Option& parentOption = options.at( indexParentOption );
273+
274+
parentOption.appendChild( *itOption );
275+
276+
// child of a Choice
277+
if( parentOption.getType() == TypeChoice )
278+
{
279+
if( itOption->getDefaultValueInt() == parentOption.getDefaultValueInt() )
280+
parentOption.setDefaultChildIndex( parentOption.getNbChilds() - 1 );
281+
}
282+
}
283+
}
278284
}
279285
return options;
280286
}

0 commit comments

Comments
 (0)