Skip to content

Commit b826dc2

Browse files
author
Clement Champetier
committed
util: getVideo/AudioCodecsNames: skip duplicates
1 parent 1127853 commit b826dc2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/AvTranscoder/util.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern "C" {
77
}
88

99
#include <utility>
10+
#include <algorithm>
1011

1112
namespace avtranscoder
1213
{
@@ -150,6 +151,11 @@ NamesArray getVideoCodecsNames()
150151
continue;
151152

152153
std::pair< std::string, std::string > codecNames( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) );
154+
155+
// skip duplicates
156+
if( std::find( videoCodecsNames.begin(), videoCodecsNames.end(), codecNames ) != videoCodecsNames.end() )
157+
continue;
158+
153159
videoCodecsNames.push_back( codecNames );
154160
}
155161
}
@@ -169,6 +175,11 @@ NamesArray getAudioCodecsNames()
169175
continue;
170176

171177
std::pair< std::string, std::string > codecNames( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) );
178+
179+
// skip duplicates
180+
if( std::find( audioCodecsNames.begin(), audioCodecsNames.end(), codecNames ) != audioCodecsNames.end() )
181+
continue;
182+
172183
audioCodecsNames.push_back( codecNames );
173184
}
174185
}

0 commit comments

Comments
 (0)