From 143f1e92034429e0b87a24bca0f98da81f17d38a Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Sun, 1 Jul 2012 16:11:23 +0300 Subject: eval: Add the isinf() function and tests for it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavutil/eval.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libavutil/eval.c') diff --git a/libavutil/eval.c b/libavutil/eval.c index 36b5ce5dda..f2d619f5c9 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -120,7 +120,7 @@ static int strmatch(const char *s, const char *prefix) struct AVExpr { enum { e_value, e_const, e_func0, e_func1, e_func2, - e_squish, e_gauss, e_ld, e_isnan, + e_squish, e_gauss, e_ld, e_isnan, e_isinf, 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, @@ -148,6 +148,7 @@ static double eval_expr(Parser *p, AVExpr *e) case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); } case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)]; case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0])); + case e_isinf: return e->value * !!isinf(eval_expr(p, e->param[0])); case e_floor: return e->value * floor(eval_expr(p, e->param[0])); case e_ceil : return e->value * ceil (eval_expr(p, e->param[0])); case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); @@ -282,6 +283,7 @@ static int parse_primary(AVExpr **e, Parser *p) else if (strmatch(next, "lt" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gte; } else if (strmatch(next, "ld" )) d->type = e_ld; else if (strmatch(next, "isnan" )) d->type = e_isnan; + else if (strmatch(next, "isinf" )) d->type = e_isinf; else if (strmatch(next, "st" )) d->type = e_st; else if (strmatch(next, "while" )) d->type = e_while; else if (strmatch(next, "floor" )) d->type = e_floor; @@ -453,6 +455,7 @@ static int verify_expr(AVExpr *e) case e_ld: case e_gauss: case e_isnan: + case e_isinf: case e_floor: case e_ceil: case e_trunc: @@ -601,6 +604,10 @@ int main(int argc, char **argv) "st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))", "isnan(1)", "isnan(NAN)", + "isnan(INF)", + "isinf(1)", + "isinf(NAN)", + "isinf(INF)", "floor(NAN)", "floor(123.123)", "floor(-123.123)", -- cgit v1.2.3