File tree Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -276,28 +276,35 @@ std::vector<std::string> OptionLoader::getPixelFormats ( const std::string& vide
276
276
{
277
277
std::vector<std::string> pixelFormats;
278
278
279
- AVCodec* videoCodec = avcodec_find_encoder_by_name ( videoCodecName.c_str () );
280
-
281
- if ( videoCodec->pix_fmts == 0 )
279
+ // all video codec concerned
280
+ if ( videoCodecName == " " )
282
281
{
283
- for ( int pix_fmt = 0 ; pix_fmt < PIX_FMT_NB; pix_fmt++ )
282
+ for ( int pix_fmt = 0 ; pix_fmt < PIX_FMT_NB; ++pix_fmt )
284
283
{
285
- const AVPixFmtDescriptor* pix_desc = &av_pix_fmt_descriptors[pix_fmt];
284
+ const AVPixFmtDescriptor * pix_desc = &av_pix_fmt_descriptors[pix_fmt];
286
285
if ( ! pix_desc->name )
287
286
continue ;
288
287
pixelFormats.push_back ( std::string ( pix_desc->name ) );
289
288
}
290
- return pixelFormats;
291
289
}
292
-
293
- int i = 0 ;
294
- while ( videoCodec->pix_fmts [i] != -1 )
290
+ // specific video codec
291
+ else
295
292
{
296
- const AVPixFmtDescriptor* pix_desc = &av_pix_fmt_descriptors[ videoCodec->pix_fmts [i] ];
297
- pixelFormats.push_back ( std::string ( pix_desc->name ) );
298
- i++;
293
+ AVCodec* videoCodec = avcodec_find_encoder_by_name ( videoCodecName.c_str () );
294
+
295
+ if ( videoCodec->pix_fmts != NULL )
296
+ {
297
+ size_t pix_fmt = 0 ;
298
+ while ( videoCodec->pix_fmts [pix_fmt] != -1 )
299
+ {
300
+ const AVPixFmtDescriptor* pix_desc = &av_pix_fmt_descriptors[ videoCodec->pix_fmts [pix_fmt] ];
301
+ if ( ! pix_desc->name )
302
+ continue ;
303
+ pixelFormats.push_back ( std::string ( pix_desc->name ) );
304
+ ++pix_fmt;
305
+ }
306
+ }
299
307
}
300
-
301
308
return pixelFormats;
302
309
}
303
310
Original file line number Diff line number Diff line change @@ -63,8 +63,9 @@ class OptionLoader
63
63
64
64
/* *
65
65
* Get array of pixel format supported by video codec.
66
+ * @param videoCodecName: the video codec name (empty if not indicated, and so get all pixel formats supported by all video codecs).
66
67
*/
67
- std::vector<std::string> getPixelFormats ( const std::string& videoCodecName ) const ;
68
+ std::vector<std::string> getPixelFormats ( const std::string& videoCodecName = " " ) const ;
68
69
69
70
private:
70
71
/* *
You can’t perform that action at this time.
0 commit comments