History

Merge commit '95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e'

* commit '95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e': vf_select: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/f_select.c

Michael Niedermayer committed 13 years ago

Commit b3fb2d82 parents 7e99ccf 95f1f563 files · +30 −21Browse files

Unified · Split

3 files
  1. doc/filters.texi +10 −8
  2. libavfilter/avfilter.c +1 −0
  3. libavfilter/f_select.c +19 −13
doc/filters.texi+10−8
@@ -6421,14 +6421,16 @@ It accepts the following values: · 6420 unmodified lines
64216421 @section aselect, select
64226422 Select frames to pass in output.
64236423
6424−These filters accept a single option @option{expr} or @option{e}
6425−specifying the select expression, which can be specified either by
6426−specyfing @code{expr=VALUE} or specifying the expression
6427−alone.
6428−
6429−The select expression is evaluated for each input frame. If the
6430−evaluation result is a non-zero value, the frame is selected and
6431−passed to the output, otherwise it is discarded.
6424+This filter accepts the following options:
6425+
6426+@table @option
6427+
6428+@item expr
6429+An expression, which is evaluated for each input frame. If the expression is
6430+evaluated to a non-zero value, the frame is selected and passed to the output,
6431+otherwise it is discarded.
6432+
6433+@end table
64326434
64336435 The expression can contain the following constants:
64346436
libavfilter/avfilter.c+1−0
@@ -682,6 +682,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 681 unmodified lines
682682 !strcmp(filter->filter->name, "noformat") ||
683683 !strcmp(filter->filter->name, "resample") ||
684684 // !strcmp(filter->filter->name, "scale" ) ||
685+ !strcmp(filter->filter->name, "select") ||
685686 0
686687 ;
687688
libavfilter/f_select.c+19−13
@@ -125,8 +125,8 @@ enum var_name { · 124 unmodified lines
125125
126126 typedef struct {
127127 const AVClass *class;
128− AVExpr *expr;
129128 char *expr_str;
129+ AVExpr *expr;
130130 double var_values[VAR_VARS_NB];
131131 int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise
132132 #if CONFIG_AVCODEC
@@ -138,13 +138,6 @@ typedef struct { · 5 unmodified lines
138138 double select;
139139 } SelectContext;
140140
141−#define OFFSET(x) offsetof(SelectContext, x)
142−#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
143−static const AVOption options[] = {
144− { "expr", "set selection expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS },
145− { "e", "set selection expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS },
146− {NULL},
147−};
148141
149142 static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *class)
150143 {
@@ -153,7 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *c · 2 unmodified lines
153146
154147 if ((ret = av_expr_parse(&select->expr, select->expr_str,
155148 var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
156− av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", select->expr_str);
149+ av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n",
150+ select->expr_str);
157151 return ret;
158152 }
159153 select->do_scene_detect = !!strstr(select->expr_str, "scene");
@@ -398,7 +392,13 @@ static const char *const shorthand[] = { "expr", NULL }; · 238 unmodified lines
398392
399393 #if CONFIG_ASELECT_FILTER
400394
401−#define aselect_options options
395+#define OFFSET(x) offsetof(SelectContext, x)
396+#define AFLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
397+static const AVOption aselect_options[] = {
398+ { "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = AFLAGS },
399+ { "e", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = AFLAGS },
400+ { NULL },
401+};
402402 AVFILTER_DEFINE_CLASS(aselect);
403403
404404 static av_cold int aselect_init(AVFilterContext *ctx, const char *args)
@@ -451,7 +451,14 @@ AVFilter avfilter_af_aselect = { · 46 unmodified lines
451451
452452 #if CONFIG_SELECT_FILTER
453453
454−#define select_options options
454+#define OFFSET(x) offsetof(SelectContext, x)
455+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
456+static const AVOption select_options[] = {
457+ { "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
458+ { "e", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
459+ { NULL },
460+};
461+
455462 AVFILTER_DEFINE_CLASS(select);
456463
457464 static av_cold int select_init(AVFilterContext *ctx, const char *args)
@@ -498,10 +505,9 @@ AVFilter avfilter_vf_select = { · 40 unmodified lines
498505 .query_formats = query_formats,
499506
500507 .priv_size = sizeof(SelectContext),
508+ .priv_class = &select_class,
501509
502510 .inputs = avfilter_vf_select_inputs,
503511 .outputs = avfilter_vf_select_outputs,
504− .priv_class = &select_class,
505− .shorthand = shorthand,
506512 };
507513 #endif /* CONFIG_SELECT_FILTER */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t