diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-10-28 02:35:55 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-10-28 02:35:55 +0400 |
commit | 45ee0e3282f9683fc1d5f1528f4edb889c4118a3 (patch) | |
tree | dfa3c3a13a6e00fbc59712664783abb84dc7339a /libavcodec/eval.c | |
parent | 835954e3a4c7c7885c174d2d5a458fd956eabc39 (diff) |
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
Diffstat (limited to 'libavcodec/eval.c')
-rw-r--r-- | libavcodec/eval.c | 9 |
1 files changed, 8 insertions, 1 deletions
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])){ |