| @@ -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 8 | 116 | #define FIFO_SIZE 8 |
| 116 | | 117 | |
| 117 | typedef struct { | 118 | typedef 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 |
| | 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 | static const AVFilterPad avfilter_vf_select_inputs[] = { | 330 | static 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, |