History

vf_select: switch to an AVOptions-based system.

Anton Khirnov committed 13 years ago

Commit 95f1f561 parent 40c885c2 files · +34 −8Browse files

Unified · Split

2 files
  1. doc/filters.texi +13 −6
  2. libavfilter/vf_select.c +21 −2
doc/filters.texi+13−6
@@ -1742,9 +1742,16 @@ scale=w='min(500\, iw*3/2):h=-1' · 1741 unmodified lines
17421742 @section select
17431743 Select frames to pass in output.
17441744
1745−It accepts in input an expression, which is evaluated for each input
1746−frame. If the expression is evaluated to a non-zero value, the frame
1747−is selected and passed to the output, otherwise it is discarded.
1745+This filter accepts the following options:
1746+
1747+@table @option
1748+
1749+@item expr
1750+An expression, which is evaluated for each input frame. If the expression is
1751+evaluated to a non-zero value, the frame is selected and passed to the output,
1752+otherwise it is discarded.
1753+
1754+@end table
17481755
17491756 The expression can contain the following constants:
17501757
@@ -1831,13 +1838,13 @@ Some examples follow: · 80 unmodified lines
18311838 select
18321839
18331840 # the above is the same as:
1834−select=1
1841+select=expr=1
18351842
18361843 # skip all frames:
1837−select=0
1844+select=expr=0
18381845
18391846 # select only I-frames
1840−select='eq(pict_type\,I)'
1847+select='expr=eq(pict_type\,I)'
18411848
18421849 # select one frame every 100
18431850 select='not(mod(n\,100))'
libavfilter/vf_select.c+21−2
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/fifo.h"
2828 #include "libavutil/internal.h"
2929 #include "libavutil/mathematics.h"
30+#include "libavutil/opt.h"
3031 #include "avfilter.h"
3132 #include "internal.h"
3233 #include "video.h"
@@ -115,6 +116,8 @@ enum var_name { · 82 unmodified lines
115116 #define FIFO_SIZE 8
116117
117118 typedef struct {
119+ const AVClass *class;
120+ char *expr_str;
118121 AVExpr *expr;
119122 double var_values[VAR_VARS_NB];
120123 double select;
@@ -127,9 +130,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 6 unmodified lines
127130 SelectContext *select = ctx->priv;
128131 int ret;
129132
130− if ((ret = av_expr_parse(&select->expr, args ? args : "1",
133+ if ((ret = av_expr_parse(&select->expr, select->expr_str,
131134 var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
132− av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", args);
135+ av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n",
136+ select->expr_str);
133137 return ret;
134138 }
135139
@@ -309,6 +313,20 @@ static av_cold void uninit(AVFilterContext *ctx) · 173 unmodified lines
309313 select->pending_frames = NULL;
310314 }
311315
316+#define OFFSET(x) offsetof(SelectContext, x)
317+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
318+static const AVOption options[] = {
319+ { "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
320+ { NULL },
321+};
322+
323+static const AVClass select_class = {
324+ .class_name = "select",
325+ .item_name = av_default_item_name,
326+ .option = options,
327+ .version = LIBAVUTIL_VERSION_INT,
328+};
329+
312330 static const AVFilterPad avfilter_vf_select_inputs[] = {
313331 {
314332 .name = "default",
@@ -337,6 +355,7 @@ AVFilter avfilter_vf_select = { · 22 unmodified lines
337355 .uninit = uninit,
338356
339357 .priv_size = sizeof(SelectContext),
358+ .priv_class = &select_class,
340359
341360 .inputs = avfilter_vf_select_inputs,
342361 .outputs = avfilter_vf_select_outputs,

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