Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c899ef

Browse files
authored
Merge pull request#278 from cchampet/fix_optionsGetChilds
Option: fixed missing childs of options with the same unit
2 parents30b9bf4 +849b910 commit3c899ef

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

‎src/AvTranscoder/Option.cpp

Lines changed: 28 additions & 17 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

@@ -255,39 +256,49 @@ void loadOptions(OptionMap& outOptions, void* av_class, int req_flags)
255256
else
256257
{
257258
outOptions.insert(std::make_pair(option.getName(), option));
258-
optionUnitToParentName.insert(std::make_pair(option.getUnit(), option.getName()));
259+
if(! option.getUnit().empty())
260+
{
261+
optionUnitToParentName.insert(std::make_pair(option.getUnit(), option.getName()));
262+
}
259263
}
260264
}
261265

262266
// iterate on child options
263-
for(std::vector<Option>::iteratoritOption = childOptions.begin();itOption != childOptions.end(); ++itOption)
267+
for(std::vector<Option>::iteratoritChild = childOptions.begin();itChild != childOptions.end(); ++itChild)
264268
{
265269
bool parentFound =false;
266-
for(std::multimap<std::string, std::string>::iteratoritUnit = optionUnitToParentName.begin();
267-
itUnit != optionUnitToParentName.end(); ++itUnit)
270+
for(std::multimap<std::string, std::string>::iteratoritUnitToParents = optionUnitToParentName.begin();
271+
itUnitToParents != optionUnitToParentName.end(); ++itUnitToParents)
268272
{
269-
if(itUnit->first == itOption->getUnit())
273+
const std::string parentUnit = itUnitToParents->first;
274+
if(parentUnit == itChild->getUnit())
270275
{
271-
std::string nameParentOption = itUnit->second;
272-
Option& parentOption = outOptions.at(nameParentOption);
273-
274-
parentOption.appendChild(*itOption);
275-
276-
// child of a Choice
277-
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)
278279
{
279-
if(itOption->getDefaultInt() == parentOption.getDefaultInt())
280-
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;
281292
}
282293

283-
parentFound =true;
284-
break;
294+
if(parentFound)
295+
break;
285296
}
286297
}
287298

288299
if(!parentFound)
289300
{
290-
LOG_WARN("Can't find a choice option for" <<itOption->getName())
301+
LOG_WARN("Can't find a choice option for" <<itChild->getName())
291302
}
292303
}
293304
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp