From e26782a9b4c170c272920da014b2265b5bf01d87 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 22 Aug 2011 14:56:23 +0200 Subject: lavfi: add ff_parse_pixel_format() internal function, and use it Reduce code duplication. --- libavfilter/formats.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libavfilter/formats.c') diff --git a/libavfilter/formats.c b/libavfilter/formats.c index c863be638d..1959a0efcf 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -236,6 +236,21 @@ void avfilter_formats_changeref(AVFilterFormats **oldref, /* internal functions for parsing audio format arguments */ +int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx) +{ + char *tail; + int pix_fmt = av_get_pix_fmt(arg); + if (pix_fmt == PIX_FMT_NONE) { + pix_fmt = strtol(arg, &tail, 0); + if (*tail || (unsigned)pix_fmt >= PIX_FMT_NB) { + av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg); + return AVERROR(EINVAL); + } + } + *ret = pix_fmt; + return 0; +} + int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx) { char *tail; -- cgit v1.2.3