diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-05-24 11:15:15 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-05-26 22:25:47 +0200 |
commit | 7cc4c9f32f446feaec5447e3d097e8147e35f156 (patch) | |
tree | 6a397c02ea184bc4cc56f16014ca8fdbb8a252af | |
parent | b03b2d86aa9d79670825b42d8a8a7c41f59cb444 (diff) | |
download | ffmpeg-7cc4c9f32f446feaec5447e3d097e8147e35f156.tar.gz |
lavfi/formats: avoid using AV_{PIX,SAMPLE}_FMT_NB
Thatt hardcodes the number of formats into lavfi and will break when a
shared lavu is updated, adding new formats.
-rw-r--r-- | libavfilter/formats.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 1441161daa..24a4fab0d1 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -209,15 +209,19 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) AVFilterFormats *ff_all_formats(enum AVMediaType type) { AVFilterFormats *ret = NULL; - int fmt; - int num_formats = type == AVMEDIA_TYPE_VIDEO ? AV_PIX_FMT_NB : - type == AVMEDIA_TYPE_AUDIO ? AV_SAMPLE_FMT_NB : 0; - for (fmt = 0; fmt < num_formats; fmt++) { - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); - if ((type != AVMEDIA_TYPE_VIDEO) || - (type == AVMEDIA_TYPE_VIDEO && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))) + if (type == AVMEDIA_TYPE_VIDEO) { + const AVPixFmtDescriptor *desc = NULL; + while ((desc = av_pix_fmt_desc_next(desc))) { + if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) + ff_add_format(&ret, av_pix_fmt_desc_get_id(desc)); + } + } else if (type == AVMEDIA_TYPE_AUDIO) { + enum AVSampleFormat fmt = 0; + while (av_get_sample_fmt_name(fmt)) { ff_add_format(&ret, fmt); + fmt++; + } } return ret; |