summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavutil/eval.c16
-rw-r--r--libavutil/eval.h10
-rw-r--r--libavutil/version.h4
3 files changed, 28 insertions, 2 deletions
diff --git a/libavutil/eval.c b/libavutil/eval.c
index 48832979e2..62d2ae938b 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -735,6 +735,22 @@ end:
return ret;
}
+int av_expr_count_vars(AVExpr *e, unsigned *counter, int size)
+{
+ int i;
+
+ if (!e || !counter || !size)
+ return AVERROR(EINVAL);
+
+ for (i = 0; e->type != e_const && i < 3 && e->param[i]; i++)
+ av_expr_count_vars(e->param[i], counter, size);
+
+ if (e->type == e_const && e->a.const_index < size)
+ counter[e->a.const_index]++;
+
+ return 0;
+}
+
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
{
Parser p = { 0 };
diff --git a/libavutil/eval.h b/libavutil/eval.h
index dacd22b96e..9bdb10cca2 100644
--- a/libavutil/eval.h
+++ b/libavutil/eval.h
@@ -87,6 +87,16 @@ int av_expr_parse(AVExpr **expr, const char *s,
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
/**
+ * Track the presence of variables and their number of occurrences in a parsed expression
+ *
+ * @param counter a zero-initialized array where the count of each variable will be stored
+ * @param size size of array
+ * @return 0 on success, a negative value indicates that no expression or array was passed
+ * or size was zero
+ */
+int av_expr_count_vars(AVExpr *e, unsigned *counter, int size);
+
+/**
* Free a parsed expression previously created with av_expr_parse().
*/
void av_expr_free(AVExpr *e);
diff --git a/libavutil/version.h b/libavutil/version.h
index 27d663baf1..af3abf7265 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR 35
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR 36
+#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \