| @@ -27,6 +27,7 @@ · 26 unmodified lines |
| 27 | 27 | #include "libavutil/fifo.h" |
| 28 | 28 | #include "libavutil/internal.h" |
| 29 | 29 | #include "libavutil/mathematics.h" |
| 30 | +#include "libavutil/opt.h" |
| 30 | 31 | #include "avfilter.h" |
| 31 | 32 | #include "internal.h" |
| 32 | 33 | #include "video.h" |
| @@ -115,6 +116,8 @@ enum var_name { · 82 unmodified lines |
| 115 | 116 | #define FIFO_SIZE 8 |
| 116 | 117 | |
| 117 | 118 | typedef struct { |
| 119 | + const AVClass *class; |
| 120 | + char *expr_str; |
| 118 | 121 | AVExpr *expr; |
| 119 | 122 | double var_values[VAR_VARS_NB]; |
| 120 | 123 | double select; |
| @@ -127,9 +130,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 6 unmodified lines |
| 127 | 130 | SelectContext *select = ctx->priv; |
| 128 | 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 | 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 | 137 | return ret; |
| 134 | 138 | } |
| 135 | 139 | |
| @@ -309,6 +313,20 @@ static av_cold void uninit(AVFilterContext *ctx) · 173 unmodified lines |
| 309 | 313 | select->pending_frames = NULL; |
| 310 | 314 | } |
| 311 | 315 | |
| 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 | + |
| 312 | 330 | static const AVFilterPad avfilter_vf_select_inputs[] = { |
| 313 | 331 | { |
| 314 | 332 | .name = "default", |
| @@ -337,6 +355,7 @@ AVFilter avfilter_vf_select = { · 22 unmodified lines |
| 337 | 355 | .uninit = uninit, |
| 338 | 356 | |
| 339 | 357 | .priv_size = sizeof(SelectContext), |
| 358 | + .priv_class = &select_class, |
| 340 | 359 | |
| 341 | 360 | .inputs = avfilter_vf_select_inputs, |
| 342 | 361 | .outputs = avfilter_vf_select_outputs, |