@@ -6,6 +6,8 @@ extern "C" {
6
6
#include < libavutil/pixdesc.h>
7
7
}
8
8
9
+ #include < utility>
10
+
9
11
namespace avtranscoder
10
12
{
11
13
@@ -116,27 +118,9 @@ AVSampleFormat getAVSampleFormat( const std::string& sampleFormat )
116
118
return av_get_sample_fmt ( sampleFormat.c_str () );
117
119
}
118
120
119
- std::vector<std::string> getFormatsLongNames ()
120
- {
121
- std::vector<std::string> formatsLongNames;
122
-
123
- AVOutputFormat* fmt = NULL ;
124
- while ( ( fmt = av_oformat_next ( fmt ) ) )
125
- {
126
- // skip undefined codec
127
- if ( fmt->video_codec == AV_CODEC_ID_NONE )
128
- continue ;
129
-
130
- if ( ! fmt->long_name )
131
- continue ;
132
-
133
- formatsLongNames.push_back ( std::string ( fmt->long_name ) );
134
- }
135
- return formatsLongNames;
136
- }
137
- std::vector<std::string> getFormatsShortNames ()
121
+ NamesArray getFormatsNames ()
138
122
{
139
- std::vector<std::string> formatsShortNames ;
123
+ NamesArray formatsNames ;
140
124
141
125
AVOutputFormat* fmt = NULL ;
142
126
while ( ( fmt = av_oformat_next ( fmt ) ) )
@@ -145,47 +129,17 @@ std::vector<std::string> getFormatsShortNames()
145
129
if ( fmt->video_codec == AV_CODEC_ID_NONE )
146
130
continue ;
147
131
148
- if ( ! fmt->name )
132
+ if ( ! fmt->name && ! fmt-> long_name )
149
133
continue ;
150
134
151
- formatsShortNames .push_back ( std::string ( fmt->name ) );
135
+ formatsNames .push_back ( std::make_pair ( std:: string ( fmt->name ? fmt-> name : " " ), std::string ( fmt-> long_name ? fmt-> long_name : " " ) ) );
152
136
}
153
- return formatsShortNames ;
137
+ return formatsNames ;
154
138
}
155
139
156
- std::vector<std::string> getVideoCodecsLongNames ()
157
- {
158
- std::vector<std::string> videoCodecsLongNames;
159
-
160
- AVCodec* c = NULL ;
161
- while ( ( c = av_codec_next ( c ) ) != NULL )
162
- {
163
- #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
164
- if ( ! c->encode )
165
- continue ;
166
- #else
167
- if ( ! c->encode2 )
168
- continue ;
169
- #endif
170
- switch ( c->type )
171
- {
172
- case AVMEDIA_TYPE_VIDEO:
173
- {
174
- if ( ! c->long_name )
175
- continue ;
176
-
177
- videoCodecsLongNames.push_back ( std::string ( c->long_name ) );
178
- break ;
179
- }
180
- default :
181
- break ;
182
- }
183
- }
184
- return videoCodecsLongNames;
185
- }
186
- std::vector<std::string> getVideoCodecsShortNames ()
140
+ NamesArray getVideoCodecsNames ()
187
141
{
188
- std::vector<std::string> videoCodecsShortNames ;
142
+ NamesArray videoCodecsNames ;
189
143
190
144
AVCodec* c = NULL ;
191
145
while ( ( c = av_codec_next ( c ) ) != NULL )
@@ -201,52 +155,22 @@ std::vector<std::string> getVideoCodecsShortNames()
201
155
{
202
156
case AVMEDIA_TYPE_VIDEO:
203
157
{
204
- if ( ! c->name )
158
+ if ( ! c->name && ! c-> long_name )
205
159
continue ;
206
160
207
- videoCodecsShortNames .push_back ( std::string ( c->name ) );
161
+ videoCodecsNames .push_back ( std::make_pair ( std:: string ( c->name ? c-> name : " " ), std::string ( c-> long_name ? c-> long_name : " " ) ) );
208
162
break ;
209
163
}
210
164
default :
211
165
break ;
212
166
}
213
167
}
214
- return videoCodecsShortNames ;
168
+ return videoCodecsNames ;
215
169
}
216
170
217
- std::vector<std::string> getAudioCodecsLongNames ()
218
- {
219
- std::vector<std::string> audioCodecsLongNames;
220
-
221
- AVCodec* c = NULL ;
222
- while ( ( c = av_codec_next ( c ) ) != NULL )
223
- {
224
- #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
225
- if ( ! c->encode )
226
- continue ;
227
- #else
228
- if ( ! c->encode2 )
229
- continue ;
230
- #endif
231
- switch ( c->type )
232
- {
233
- case AVMEDIA_TYPE_AUDIO:
234
- {
235
- if ( ! c->long_name )
236
- continue ;
237
-
238
- audioCodecsLongNames.push_back ( std::string ( c->long_name ) );
239
- break ;
240
- }
241
- default :
242
- break ;
243
- }
244
- }
245
- return audioCodecsLongNames;
246
- }
247
- std::vector<std::string> getAudioCodecsShortNames ()
171
+ NamesArray getAudioCodecsNames ()
248
172
{
249
- std::vector<std::string> audioCodecsShortNames ;
173
+ NamesArray audioCodecsNames ;
250
174
251
175
AVCodec* c = NULL ;
252
176
while ( ( c = av_codec_next ( c ) ) != NULL )
@@ -262,17 +186,17 @@ std::vector<std::string> getAudioCodecsShortNames()
262
186
{
263
187
case AVMEDIA_TYPE_AUDIO:
264
188
{
265
- if ( ! c->name )
189
+ if ( ! c->name && ! c-> long_name )
266
190
continue ;
267
191
268
- audioCodecsShortNames .push_back ( std::string ( c->name ) );
192
+ audioCodecsNames .push_back ( std::make_pair ( std:: string ( c->name ? c-> name : " " ), std::string ( c-> long_name ? c-> long_name : " " ) ) );
269
193
break ;
270
194
}
271
195
default :
272
196
break ;
273
197
}
274
198
}
275
- return audioCodecsShortNames ;
199
+ return audioCodecsNames ;
276
200
}
277
201
278
202
OptionArrayMap getOutputFormatOptions ()
0 commit comments