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
1742@section select1742@section select
1743Select frames to pass in output.1743Select frames to pass in output.
1744 1744
1745It accepts in input an expression, which is evaluated for each input1745This filter accepts the following options:
1746frame. If the expression is evaluated to a non-zero value, the frame1746
1747is selected and passed to the output, otherwise it is discarded.1747@table @option
1748
1749@item expr
1750An expression, which is evaluated for each input frame. If the expression is
1751evaluated to a non-zero value, the frame is selected and passed to the output,
1752otherwise it is discarded.
1753
1754@end table
1748 1755
1749The expression can contain the following constants:1756The expression can contain the following constants:
1750 1757
@@ -1831,13 +1838,13 @@ Some examples follow: · 80 unmodified lines
1831select1838select
1832 1839
1833# the above is the same as:1840# the above is the same as:
1834select=11841select=expr=1
1835 1842
1836# skip all frames:1843# skip all frames:
1837select=01844select=expr=0
1838 1845
1839# select only I-frames1846# select only I-frames
1840select='eq(pict_type\,I)'1847select='expr=eq(pict_type\,I)'
1841 1848
1842# select one frame every 1001849# select one frame every 100
1843select='not(mod(n\,100))'1850select='not(mod(n\,100))'
libavfilter/vf_select.c+21−2
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include "libavutil/fifo.h"27#include "libavutil/fifo.h"
28#include "libavutil/internal.h"28#include "libavutil/internal.h"
29#include "libavutil/mathematics.h"29#include "libavutil/mathematics.h"
30#include "libavutil/opt.h"
30#include "avfilter.h"31#include "avfilter.h"
31#include "internal.h"32#include "internal.h"
32#include "video.h"33#include "video.h"
@@ -115,6 +116,8 @@ enum var_name { · 82 unmodified lines
115#define FIFO_SIZE 8116#define FIFO_SIZE 8
116 117
117typedef struct {118typedef struct {
119 const AVClass *class;
120 char *expr_str;
118 AVExpr *expr;121 AVExpr *expr;
119 double var_values[VAR_VARS_NB];122 double var_values[VAR_VARS_NB];
120 double select;123 double select;
@@ -127,9 +130,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 6 unmodified lines
127 SelectContext *select = ctx->priv;130 SelectContext *select = ctx->priv;
128 int ret;131 int ret;
129 132
130 if ((ret = av_expr_parse(&select->expr, args ? args : "1",133 if ((ret = av_expr_parse(&select->expr, select->expr_str,
131 var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {134 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);
133 return ret;137 return ret;
134 }138 }
135 139
@@ -309,6 +313,20 @@ static av_cold void uninit(AVFilterContext *ctx) · 173 unmodified lines
309 select->pending_frames = NULL;313 select->pending_frames = NULL;
310}314}
311 315
316#define OFFSET(x) offsetof(SelectContext, x)
317#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
318static 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
323static 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
312static const AVFilterPad avfilter_vf_select_inputs[] = {330static const AVFilterPad avfilter_vf_select_inputs[] = {
313 {331 {
314 .name = "default",332 .name = "default",
@@ -337,6 +355,7 @@ AVFilter avfilter_vf_select = { · 22 unmodified lines
337 .uninit = uninit,355 .uninit = uninit,
338 356
339 .priv_size = sizeof(SelectContext),357 .priv_size = sizeof(SelectContext),
358 .priv_class = &select_class,
340 359
341 .inputs = avfilter_vf_select_inputs,360 .inputs = avfilter_vf_select_inputs,
342 .outputs = avfilter_vf_select_outputs,361 .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