diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-08-22 16:56:23 +0400 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-08-23 17:45:44 +0400 |
commit | e26782a9b4c170c272920da014b2265b5bf01d87 (patch) | |
tree | 6b456db8e60e23dfb705e702c95be8f1e8f274e2 /libavfilter/formats.c | |
parent | 2c6348ea67a6a2313dc9f9fab8d24c40b3303bca (diff) |
lavfi: add ff_parse_pixel_format() internal function, and use it
Reduce code duplication.
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r-- | libavfilter/formats.c | 15 |
1 files changed, 15 insertions, 0 deletions
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; |