Skip to content

Commit 849b910

Browse files
author
Clement Champetier
committed
Option: fixed missing childs of options with the same unit
* LibAV has some options with the same unit. Example, with these video encoding options with the unit 'cmp_func': * subcmp * mbcmp * ildctcmp * precmp * skipcmp * In our code, when looking for the parent options of a given unit, we use a multimap and the equal_range method.
1 parent 9f692e9 commit 849b910

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/AvTranscoder/Option.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ void loadOptions(OptionMap& outOptions, void* av_class, int req_flags)
229229
if(!av_class)
230230
return;
231231

232+
// Use multimap because it is possible to have several parent options with the same unit
232233
std::multimap<std::string, std::string> optionUnitToParentName;
233234
std::vector<Option> childOptions;
234235

@@ -270,22 +271,28 @@ void loadOptions(OptionMap& outOptions, void* av_class, int req_flags)
270271
itUnitToParents != optionUnitToParentName.end(); ++itUnitToParents)
271272
{
272273
const std::string parentUnit = itUnitToParents->first;
273-
const std::string parentName = itUnitToParents->second;
274274
if(parentUnit == itChild->getUnit())
275275
{
276-
Option& parentOption = outOptions.at(parentName);
277-
278-
parentOption.appendChild(*itChild);
279-
280-
// child of a Choice
281-
if(parentOption.getType() == eOptionBaseTypeChoice)
276+
// Get all the parent options with the same unit
277+
std::pair<std::multimap<std::string, std::string>::iterator, std::multimap<std::string, std::string>::iterator> parentOptions = optionUnitToParentName.equal_range(parentUnit);
278+
for(std::multimap<std::string, std::string>::iterator itParent = parentOptions.first; itParent != parentOptions.second; ++itParent)
282279
{
283-
if(itChild->getDefaultInt() == parentOption.getDefaultInt())
284-
parentOption.setDefaultChildIndex(parentOption.getChilds().size() - 1);
280+
const std::string parentName = itParent->second;
281+
Option& parentOption = outOptions.at(parentName);
282+
parentOption.appendChild(*itChild);
283+
284+
// child of a Choice
285+
if(parentOption.getType() == eOptionBaseTypeChoice)
286+
{
287+
if(itChild->getDefaultInt() == parentOption.getDefaultInt())
288+
parentOption.setDefaultChildIndex(parentOption.getChilds().size() - 1);
289+
}
290+
291+
parentFound = true;
285292
}
286293

287-
parentFound = true;
288-
break;
294+
if(parentFound)
295+
break;
289296
}
290297
}
291298

0 commit comments

Comments
 (0)