summaryrefslogtreecommitdiff
path: root/libavutil/eval.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-08 04:12:00 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-08 04:38:01 +0200
commit9e5e086b7e67ba3a7d5842611855ce53a1fa7a54 (patch)
tree27d4ff1175c27bc79984e6586642d5ffe608635f /libavutil/eval.c
parent9b471735459d7274f6d7cc646f1d01011f844862 (diff)
eval:add hypot()
useage example: -vf 'scale=256:256,mp=geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128' Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/eval.c')
-rw-r--r--libavutil/eval.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavutil/eval.c b/libavutil/eval.c
index ecb389b57a..733514d8e4 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -126,7 +126,7 @@ struct AVExpr {
e_mod, e_max, e_min, e_eq, e_gt, e_gte,
e_pow, e_mul, e_div, e_add,
e_last, e_st, e_while, e_floor, e_ceil, e_trunc,
- e_sqrt, e_not, e_random,
+ e_sqrt, e_not, e_random, e_hypot,
} type;
double value; // is sign in other types
union {
@@ -185,6 +185,7 @@ static double eval_expr(Parser *p, AVExpr *e)
case e_add: return e->value * (d + d2);
case e_last:return e->value * d2;
case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);
+ case e_hypot:return e->value * (sqrt(d*d + d2*d2));
}
}
}
@@ -302,6 +303,7 @@ static int parse_primary(AVExpr **e, Parser *p)
else if (strmatch(next, "not" )) d->type = e_not;
else if (strmatch(next, "pow" )) d->type = e_pow;
else if (strmatch(next, "random")) d->type = e_random;
+ else if (strmatch(next, "hypot" )) d->type = e_hypot;
else {
for (i=0; p->func1_names && p->func1_names[i]; i++) {
if (strmatch(next, p->func1_names[i])) {