diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-22 17:21:04 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-26 22:12:17 +0100 |
commit | 923092697a6600bf18cf881f821068379f5a42d5 (patch) | |
tree | b99402dd996a20f6249eaf316cb9a2a8a7b044e4 /libavutil/eval.c | |
parent | 02670762d25fd0b527534ff31fac193a3ea2109e (diff) | |
download | ffmpeg-923092697a6600bf18cf881f821068379f5a42d5.tar.gz |
eval: Allow specifying the variable id.
Reviewed-by: Nicolas George <nicolas.george@normalesup.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/eval.c')
-rw-r--r-- | libavutil/eval.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libavutil/eval.c b/libavutil/eval.c index cb4141a6f7..bd5902d42f 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -184,18 +184,19 @@ static double eval_expr(Parser *p, AVExpr *e) case e_taylor: { double t = 1, d = 0, v; double x = eval_expr(p, e->param[1]); + int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, VARS-1) : 0; int i; - double var0 = p->var[0]; + double var0 = p->var[id]; for(i=0; i<1000; i++) { double ld = d; - p->var[0] = i; + p->var[id] = i; v = eval_expr(p, e->param[0]); d += t*v; if(ld==d && v) break; t *= x / (i+1); } - p->var[0] = var0; + p->var[id] = var0; return d; } default: { @@ -523,6 +524,9 @@ static int verify_expr(AVExpr *e) case e_not: case e_random: return verify_expr(e->param[0]) && !e->param[2]; + case e_taylor: + return verify_expr(e->param[0]) && verify_expr(e->param[1]) + && (!e->param[2] || verify_expr(e->param[2])); default: return verify_expr(e->param[0]) && verify_expr(e->param[1]) && !e->param[2]; } } @@ -722,7 +726,7 @@ int main(int argc, char **argv) "ifnot(0, 23)", "ifnot(1, NaN) + if(0, 1)", "taylor(1, 1)", - "taylor(eq(mod(ld(0),4),1)-eq(mod(ld(0),4),3), PI/2)", + "taylor(eq(mod(ld(1),4),1)-eq(mod(ld(1),4),3), PI/2, 1)", NULL }; |