diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-02-25 21:21:29 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-04-09 19:06:51 +0200 |
commit | 95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e (patch) | |
tree | 9c69fffdfb2f510ec362738012a19c920809d340 /libavfilter | |
parent | 40c885c589808455a1c4b473509f1e6cd4908f55 (diff) | |
download | ffmpeg-95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e.tar.gz |
vf_select: switch to an AVOptions-based system.
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_select.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c index 7839e44168..ce56e33757 100644 --- a/libavfilter/vf_select.c +++ b/libavfilter/vf_select.c @@ -27,6 +27,7 @@ #include "libavutil/fifo.h" #include "libavutil/internal.h" #include "libavutil/mathematics.h" +#include "libavutil/opt.h" #include "avfilter.h" #include "internal.h" #include "video.h" @@ -115,6 +116,8 @@ enum var_name { #define FIFO_SIZE 8 typedef struct { + const AVClass *class; + char *expr_str; AVExpr *expr; double var_values[VAR_VARS_NB]; double select; @@ -127,9 +130,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args) SelectContext *select = ctx->priv; int ret; - if ((ret = av_expr_parse(&select->expr, args ? args : "1", + if ((ret = av_expr_parse(&select->expr, select->expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { - av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", args); + av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", + select->expr_str); return ret; } @@ -309,6 +313,20 @@ static av_cold void uninit(AVFilterContext *ctx) select->pending_frames = NULL; } +#define OFFSET(x) offsetof(SelectContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM +static const AVOption options[] = { + { "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS }, + { NULL }, +}; + +static const AVClass select_class = { + .class_name = "select", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + static const AVFilterPad avfilter_vf_select_inputs[] = { { .name = "default", @@ -337,6 +355,7 @@ AVFilter avfilter_vf_select = { .uninit = uninit, .priv_size = sizeof(SelectContext), + .priv_class = &select_class, .inputs = avfilter_vf_select_inputs, .outputs = avfilter_vf_select_outputs, |