diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-10 23:18:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-10 23:24:48 +0200 |
commit | b3fb2d8cec91dadf935832f3bef97bf5a3a11352 (patch) | |
tree | 5cd66817a72919b0dd0ceaa55713959ad7a7a259 | |
parent | 7e99ccf5d8c25d7fe670d9402349b055c0c1449a (diff) | |
parent | 95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e (diff) | |
download | ffmpeg-b3fb2d8cec91dadf935832f3bef97bf5a3a11352.tar.gz |
Merge commit '95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e'
* commit '95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e':
vf_select: switch to an AVOptions-based system.
Conflicts:
doc/filters.texi
libavfilter/f_select.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | doc/filters.texi | 18 | ||||
-rw-r--r-- | libavfilter/avfilter.c | 1 | ||||
-rw-r--r-- | libavfilter/f_select.c | 32 |
3 files changed, 30 insertions, 21 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 03113cd387..e22a8ba672 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6421,14 +6421,16 @@ It accepts the following values: @section aselect, select Select frames to pass in output. -These filters accept a single option @option{expr} or @option{e} -specifying the select expression, which can be specified either by -specyfing @code{expr=VALUE} or specifying the expression -alone. - -The select expression is evaluated for each input frame. If the -evaluation result is a non-zero value, the frame is selected and -passed to the output, otherwise it is discarded. +This filter accepts the following options: + +@table @option + +@item expr +An expression, which is evaluated for each input frame. If the expression is +evaluated to a non-zero value, the frame is selected and passed to the output, +otherwise it is discarded. + +@end table The expression can contain the following constants: diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index addb7321e1..1c18c97230 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -682,6 +682,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "resample") || // !strcmp(filter->filter->name, "scale" ) || + !strcmp(filter->filter->name, "select") || 0 ; diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index 351b7f8d80..e2c4ef719a 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -125,8 +125,8 @@ enum var_name { typedef struct { const AVClass *class; - AVExpr *expr; char *expr_str; + AVExpr *expr; double var_values[VAR_VARS_NB]; int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise #if CONFIG_AVCODEC @@ -138,13 +138,6 @@ typedef struct { double select; } SelectContext; -#define OFFSET(x) offsetof(SelectContext, x) -#define FLAGS AV_OPT_FLAG_FILTERING_PARAM -static const AVOption options[] = { - { "expr", "set selection expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS }, - { "e", "set selection expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS }, - {NULL}, -}; static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *class) { @@ -153,7 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *c 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", select->expr_str); + av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", + select->expr_str); return ret; } select->do_scene_detect = !!strstr(select->expr_str, "scene"); @@ -398,7 +392,13 @@ static const char *const shorthand[] = { "expr", NULL }; #if CONFIG_ASELECT_FILTER -#define aselect_options options +#define OFFSET(x) offsetof(SelectContext, x) +#define AFLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM +static const AVOption aselect_options[] = { + { "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = AFLAGS }, + { "e", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = AFLAGS }, + { NULL }, +}; AVFILTER_DEFINE_CLASS(aselect); static av_cold int aselect_init(AVFilterContext *ctx, const char *args) @@ -451,7 +451,14 @@ AVFilter avfilter_af_aselect = { #if CONFIG_SELECT_FILTER -#define select_options options +#define OFFSET(x) offsetof(SelectContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM +static const AVOption select_options[] = { + { "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS }, + { "e", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS }, + { NULL }, +}; + AVFILTER_DEFINE_CLASS(select); static av_cold int select_init(AVFilterContext *ctx, const char *args) @@ -498,10 +505,9 @@ AVFilter avfilter_vf_select = { .query_formats = query_formats, .priv_size = sizeof(SelectContext), + .priv_class = &select_class, .inputs = avfilter_vf_select_inputs, .outputs = avfilter_vf_select_outputs, - .priv_class = &select_class, - .shorthand = shorthand, }; #endif /* CONFIG_SELECT_FILTER */ |