From 45ee0e3282f9683fc1d5f1528f4edb889c4118a3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 27 Oct 2006 22:35:55 +0000 Subject: [PATCH] add support for while() loops again ugly syntax while(condition, statements) but very simple implementation Originally committed as revision 6814 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/eval.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/eval.c b/libavcodec/eval.c index 6b186640df..bbd6ae4ca5 100644 --- a/libavcodec/eval.c +++ b/libavcodec/eval.c @@ -133,7 +133,7 @@ struct ff_expr_s { e_squish, e_gauss, e_ld, 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_last, e_st, e_while, } type; double value; // is sign in other types union { @@ -155,6 +155,12 @@ static double eval_expr(Parser * p, AVEvalExpr * e) { case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0]))); 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[clip(eval_expr(p, e->param[0]), 0, VARS-1)]; + case e_while: { + double d; + while(eval_expr(p, e->param[0])) + d=eval_expr(p, e->param[1]); + return d; + } default: { double d = eval_expr(p, e->param[0]); double d2 = eval_expr(p, e->param[1]); @@ -266,6 +272,7 @@ static AVEvalExpr * parse_primary(Parser *p) { else if( strmatch(next, "lt" ) ) { AVEvalExpr * 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, "st" ) ) d->type = e_st; + else if( strmatch(next, "while" ) ) d->type = e_while; else { for(i=0; p->func1_name && p->func1_name[i]; i++){ if(strmatch(next, p->func1_name[i])){