diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-05-24 13:15:15 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-05-27 00:24:46 +0400 |
commit | 862f33c10ea38ea49fa4188725df5e5246dbd1d8 (patch) | |
tree | c5aa7b9c8be256e46bd30bb2905af7ee6b137c36 /libavfilter/vf_scale.c | |
parent | 45fc73edfe071f9690e8671ed2dc402b1cb02ece (diff) |
vf_scale: use the pixfmt descriptor API
Avoid using AV_PIX_FMT_NB, since that hardcodes the number of pixel
formats into lavfi and will break when a shared lavu is updated, adding
new pixel formats.
Diffstat (limited to 'libavfilter/vf_scale.c')
-rw-r--r-- | libavfilter/vf_scale.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index b06b179aa9..73ea9d23e0 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -120,25 +120,31 @@ static int query_formats(AVFilterContext *ctx) int ret; if (ctx->inputs[0]) { + const AVPixFmtDescriptor *desc = NULL; formats = NULL; - for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) + while ((desc = av_pix_fmt_desc_next(desc))) { + pix_fmt = av_pix_fmt_desc_get_id(desc); if ((sws_isSupportedInput(pix_fmt) || sws_isSupportedEndiannessConversion(pix_fmt)) && (ret = ff_add_format(&formats, pix_fmt)) < 0) { ff_formats_unref(&formats); return ret; } + } ff_formats_ref(formats, &ctx->inputs[0]->out_formats); } if (ctx->outputs[0]) { + const AVPixFmtDescriptor *desc = NULL; formats = NULL; - for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) + while ((desc = av_pix_fmt_desc_next(desc))) { + pix_fmt = av_pix_fmt_desc_get_id(desc); if ((sws_isSupportedOutput(pix_fmt) || sws_isSupportedEndiannessConversion(pix_fmt)) && (ret = ff_add_format(&formats, pix_fmt)) < 0) { ff_formats_unref(&formats); return ret; } + } ff_formats_ref(formats, &ctx->outputs[0]->in_formats); } |