summaryrefslogtreecommitdiff
path: root/libavutil/eval.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2013-03-13 14:09:10 +0100
committerStefano Sabatini <stefasab@gmail.com>2013-03-17 00:22:47 +0100
commitb2098d2417a085d33d99738dd7f963c7b260a0bf (patch)
tree17d9adea1b9546f3607d1166dbe9e561e23ef5b6 /libavutil/eval.c
parentd8dccf69ff2df7014a2bb8e0e17828a820f45b27 (diff)
downloadffmpeg-b2098d2417a085d33d99738dd7f963c7b260a0bf.tar.gz
lavu/eval: add bitor and bitand functions
Warning note suggested by Reimar.
Diffstat (limited to 'libavutil/eval.c')
-rw-r--r--libavutil/eval.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavutil/eval.c b/libavutil/eval.c
index 4875725886..9a688ae573 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -145,7 +145,7 @@ struct AVExpr {
e_pow, e_mul, e_div, e_add,
e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
e_sqrt, e_not, e_random, e_hypot, e_gcd,
- e_if, e_ifnot, e_print,
+ e_if, e_ifnot, e_print, e_bitand, e_bitor,
} type;
double value; // is sign in other types
union {
@@ -284,6 +284,8 @@ static double eval_expr(Parser *p, AVExpr *e)
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));
+ case e_bitand: return isnan(d) || isnan(d2) ? NAN : e->value * ((long int)d & (long int)d2);
+ case e_bitor: return isnan(d) || isnan(d2) ? NAN : e->value * ((long int)d | (long int)d2);
}
}
}
@@ -424,6 +426,8 @@ static int parse_primary(AVExpr **e, Parser *p)
else if (strmatch(next, "gcd" )) d->type = e_gcd;
else if (strmatch(next, "if" )) d->type = e_if;
else if (strmatch(next, "ifnot" )) d->type = e_ifnot;
+ else if (strmatch(next, "bitand")) d->type = e_bitand;
+ else if (strmatch(next, "bitor" )) d->type = e_bitor;
else {
for (i=0; p->func1_names && p->func1_names[i]; i++) {
if (strmatch(next, p->func1_names[i])) {
@@ -809,6 +813,9 @@ int main(int argc, char **argv)
"gauss(0.1)",
"hypot(4,3)",
"gcd(30,55)*print(min(9,1))",
+ "bitor(42, 12)",
+ "bitand(42, 12)",
+ "bitand(NAN, 1)",
NULL
};