diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-02-26 00:21:29 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-04-09 20:56:39 +0400 |
commit | e67a87eac814c7805d18c983c43033a8a1bd62af (patch) | |
tree | d5fad4b282033b3736dcc4da93f0e2279fdfdbf4 /libavfilter | |
parent | 0af7fe1f95a9e4a25e7e46f386360c701c49763d (diff) |
vf_(no)format: switch to an AVOptions-based system.
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/avfilter.c | 27 | ||||
-rw-r--r-- | libavfilter/vf_format.c | 30 |
2 files changed, 55 insertions, 2 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a8429aac3e..e5a7f13464 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -486,6 +486,33 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ret = av_dict_parse_string(&options, args, "=", ":", 0); if (ret < 0) goto fail; +#if FF_API_OLD_FILTER_OPTS + } else if (!strcmp(filter->filter->name, "format") || + !strcmp(filter->filter->name, "noformat")) { + /* a hack for compatibility with the old syntax + * replace colons with |s */ + char *copy = av_strdup(args); + char *p = copy; + + if (!copy) { + ret = AVERROR(ENOMEM); + goto fail; + } + + if (strchr(copy, ':')) { + av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use " + "'|' to separate the list items.\n"); + } + + while ((p = strchr(p, ':'))) + *p++ = '|'; + + ret = process_unnamed_options(filter, &options, copy); + av_freep(©); + + if (ret < 0) + goto fail; +#endif } else { ret = process_unnamed_options(filter, &options, args); if (ret < 0) diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c index 7e4a26e302..c08a707721 100644 --- a/libavfilter/vf_format.c +++ b/libavfilter/vf_format.c @@ -28,12 +28,16 @@ #include "libavutil/internal.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" +#include "libavutil/opt.h" + #include "avfilter.h" #include "formats.h" #include "internal.h" #include "video.h" typedef struct { + const AVClass *class; + char *pix_fmts; /** * List of flags telling if a given image format has been listed * as argument to the filter. @@ -52,8 +56,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args) enum AVPixelFormat pix_fmt; /* parse the list of formats */ - for (cur = args; cur; cur = sep ? sep+1 : NULL) { - if (!(sep = strchr(cur, ':'))) + for (cur = format->pix_fmts; cur; cur = sep ? sep + 1 : NULL) { + if (!(sep = strchr(cur, '|'))) pix_fmt_name_len = strlen(cur); else pix_fmt_name_len = sep - cur; @@ -92,6 +96,12 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag) return formats; } +#define OFFSET(x) offsetof(FormatContext, x) +static const AVOption options[] = { + { "pix_fmts", "A '|'-separated list of pixel formats", OFFSET(pix_fmts), AV_OPT_TYPE_STRING, .flags = AV_OPT_FLAG_VIDEO_PARAM }, + { NULL }, +}; + #if CONFIG_FORMAT_FILTER static int query_formats_format(AVFilterContext *ctx) { @@ -99,6 +109,13 @@ static int query_formats_format(AVFilterContext *ctx) return 0; } +static const AVClass format_class = { + .class_name = "format", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + static const AVFilterPad avfilter_vf_format_inputs[] = { { .name = "default", @@ -125,6 +142,7 @@ AVFilter avfilter_vf_format = { .query_formats = query_formats_format, .priv_size = sizeof(FormatContext), + .priv_class = &format_class, .inputs = avfilter_vf_format_inputs, .outputs = avfilter_vf_format_outputs, @@ -138,6 +156,13 @@ static int query_formats_noformat(AVFilterContext *ctx) return 0; } +static const AVClass noformat_class = { + .class_name = "noformat", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + static const AVFilterPad avfilter_vf_noformat_inputs[] = { { .name = "default", @@ -164,6 +189,7 @@ AVFilter avfilter_vf_noformat = { .query_formats = query_formats_noformat, .priv_size = sizeof(FormatContext), + .priv_class = &noformat_class, .inputs = avfilter_vf_noformat_inputs, .outputs = avfilter_vf_noformat_outputs, |