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
6421@section aselect, select6421@section aselect, select
6422Select frames to pass in output.6422Select frames to pass in output.
6423 6423
6424These filters accept a single option @option{expr} or @option{e}6424This filter accepts the following options:
6425specifying the select expression, which can be specified either by6425
6426specyfing @code{expr=VALUE} or specifying the expression6426@table @option
6427alone.6427
6428 6428@item expr
6429The select expression is evaluated for each input frame. If the6429An expression, which is evaluated for each input frame. If the expression is
6430evaluation result is a non-zero value, the frame is selected and6430evaluated to a non-zero value, the frame is selected and passed to the output,
6431passed to the output, otherwise it is discarded.6431otherwise it is discarded.
6432
6433@end table
6432 6434
6433The expression can contain the following constants:6435The expression can contain the following constants:
6434 6436
libavfilter/avfilter.c+1−0
@@ -682,6 +682,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 681 unmodified lines
682 !strcmp(filter->filter->name, "noformat") ||682 !strcmp(filter->filter->name, "noformat") ||
683 !strcmp(filter->filter->name, "resample") ||683 !strcmp(filter->filter->name, "resample") ||
684// !strcmp(filter->filter->name, "scale" ) ||684// !strcmp(filter->filter->name, "scale" ) ||
685 !strcmp(filter->filter->name, "select") ||
685 0686 0
686 ;687 ;
687 688
libavfilter/f_select.c+19−13
@@ -125,8 +125,8 @@ enum var_name { · 124 unmodified lines
125 125
126typedef struct {126typedef struct {
127 const AVClass *class;127 const AVClass *class;
128 AVExpr *expr;
129 char *expr_str;128 char *expr_str;
129 AVExpr *expr;
130 double var_values[VAR_VARS_NB];130 double var_values[VAR_VARS_NB];
131 int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise131 int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise
132#if CONFIG_AVCODEC132#if CONFIG_AVCODEC
@@ -138,13 +138,6 @@ typedef struct { · 5 unmodified lines
138 double select;138 double select;
139} SelectContext;139} SelectContext;
140 140
141#define OFFSET(x) offsetof(SelectContext, x)
142#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
143static 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};
148 141
149static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *class)142static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *class)
150{143{
@@ -153,7 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *c · 2 unmodified lines
153 146
154 if ((ret = av_expr_parse(&select->expr, select->expr_str,147 if ((ret = av_expr_parse(&select->expr, select->expr_str,
155 var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {148 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);
157 return ret;151 return ret;
158 }152 }
159 select->do_scene_detect = !!strstr(select->expr_str, "scene");153 select->do_scene_detect = !!strstr(select->expr_str, "scene");
@@ -398,7 +392,13 @@ static const char *const shorthand[] = { "expr", NULL }; · 238 unmodified lines
398 392
399#if CONFIG_ASELECT_FILTER393#if CONFIG_ASELECT_FILTER
400 394
401#define aselect_options options395#define OFFSET(x) offsetof(SelectContext, x)
396#define AFLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
397static 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};
402AVFILTER_DEFINE_CLASS(aselect);402AVFILTER_DEFINE_CLASS(aselect);
403 403
404static av_cold int aselect_init(AVFilterContext *ctx, const char *args)404static av_cold int aselect_init(AVFilterContext *ctx, const char *args)
@@ -451,7 +451,14 @@ AVFilter avfilter_af_aselect = { · 46 unmodified lines
451 451
452#if CONFIG_SELECT_FILTER452#if CONFIG_SELECT_FILTER
453 453
454#define select_options options454#define OFFSET(x) offsetof(SelectContext, x)
455#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
456static 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
455AVFILTER_DEFINE_CLASS(select);462AVFILTER_DEFINE_CLASS(select);
456 463
457static av_cold int select_init(AVFilterContext *ctx, const char *args)464static av_cold int select_init(AVFilterContext *ctx, const char *args)
@@ -498,10 +505,9 @@ AVFilter avfilter_vf_select = { · 40 unmodified lines
498 .query_formats = query_formats,505 .query_formats = query_formats,
499 506
500 .priv_size = sizeof(SelectContext),507 .priv_size = sizeof(SelectContext),
508 .priv_class = &select_class,
501 509
502 .inputs = avfilter_vf_select_inputs,510 .inputs = avfilter_vf_select_inputs,
503 .outputs = avfilter_vf_select_outputs,511 .outputs = avfilter_vf_select_outputs,
504 .priv_class = &select_class,
505 .shorthand = shorthand,
506};512};
507#endif /* CONFIG_SELECT_FILTER */513#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