|
|
@ -180,8 +180,10 @@ static double eval_expr(Parser *p, AVExpr *e) |
|
|
|
case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); |
|
|
|
case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); |
|
|
|
case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); |
|
|
|
case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); |
|
|
|
case e_not: return e->value * (eval_expr(p, e->param[0]) == 0); |
|
|
|
case e_not: return e->value * (eval_expr(p, e->param[0]) == 0); |
|
|
|
case e_if: return e->value * ( eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); |
|
|
|
case e_if: return e->value * (eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : |
|
|
|
case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); |
|
|
|
e->param[2] ? eval_expr(p, e->param[2]) : 0); |
|
|
|
|
|
|
|
case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : |
|
|
|
|
|
|
|
e->param[2] ? eval_expr(p, e->param[2]) : 0); |
|
|
|
case e_random:{ |
|
|
|
case e_random:{ |
|
|
|
int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1); |
|
|
|
int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1); |
|
|
|
uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx]; |
|
|
|
uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx]; |
|
|
@ -599,6 +601,8 @@ static int verify_expr(AVExpr *e) |
|
|
|
case e_not: |
|
|
|
case e_not: |
|
|
|
case e_random: |
|
|
|
case e_random: |
|
|
|
return verify_expr(e->param[0]) && !e->param[1]; |
|
|
|
return verify_expr(e->param[0]) && !e->param[1]; |
|
|
|
|
|
|
|
case e_if: |
|
|
|
|
|
|
|
case e_ifnot: |
|
|
|
case e_taylor: |
|
|
|
case e_taylor: |
|
|
|
return verify_expr(e->param[0]) && verify_expr(e->param[1]) |
|
|
|
return verify_expr(e->param[0]) && verify_expr(e->param[1]) |
|
|
|
&& (!e->param[2] || verify_expr(e->param[2])); |
|
|
|
&& (!e->param[2] || verify_expr(e->param[2])); |
|
|
@ -777,8 +781,12 @@ int main(int argc, char **argv) |
|
|
|
"PI^1.23", |
|
|
|
"PI^1.23", |
|
|
|
"pow(-1,1.23)", |
|
|
|
"pow(-1,1.23)", |
|
|
|
"if(1, 2)", |
|
|
|
"if(1, 2)", |
|
|
|
|
|
|
|
"if(1, 1, 2)", |
|
|
|
|
|
|
|
"if(0, 1, 2)", |
|
|
|
"ifnot(0, 23)", |
|
|
|
"ifnot(0, 23)", |
|
|
|
"ifnot(1, NaN) + if(0, 1)", |
|
|
|
"ifnot(1, NaN) + if(0, 1)", |
|
|
|
|
|
|
|
"ifnot(1, 1, 2)", |
|
|
|
|
|
|
|
"ifnot(0, 1, 2)", |
|
|
|
"taylor(1, 1)", |
|
|
|
"taylor(1, 1)", |
|
|
|
"taylor(eq(mod(ld(1),4),1)-eq(mod(ld(1),4),3), PI/2, 1)", |
|
|
|
"taylor(eq(mod(ld(1),4),1)-eq(mod(ld(1),4),3), PI/2, 1)", |
|
|
|
"root(sin(ld(0))-1, 2)", |
|
|
|
"root(sin(ld(0))-1, 2)", |
|
|
|