mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 03:59:43 +00:00
libavutil/eval: Add round function to expression parser
We have floor, ceil, and trunc. Let's add round. Signed-off-by: Kevin Mark <kmark937@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
850cbd496f
commit
482566ccc3
@ -914,6 +914,9 @@ various input values that the expression can access through
|
||||
@code{ld(0)}. When the expression evaluates to 0 then the
|
||||
corresponding input value will be returned.
|
||||
|
||||
@item round(expr)
|
||||
Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0".
|
||||
|
||||
@item sin(x)
|
||||
Compute sine of @var{x}.
|
||||
|
||||
|
@ -153,7 +153,7 @@ struct AVExpr {
|
||||
e_squish, e_gauss, e_ld, e_isnan, e_isinf,
|
||||
e_mod, e_max, e_min, e_eq, e_gt, e_gte, e_lte, e_lt,
|
||||
e_pow, e_mul, e_div, e_add,
|
||||
e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
|
||||
e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc, e_round,
|
||||
e_sqrt, e_not, e_random, e_hypot, e_gcd,
|
||||
e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip, e_atan2
|
||||
} type;
|
||||
@ -189,6 +189,7 @@ static double eval_expr(Parser *p, AVExpr *e)
|
||||
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]));
|
||||
case e_round: return e->value * round(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_if: return e->value * (eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) :
|
||||
@ -440,6 +441,7 @@ static int parse_primary(AVExpr **e, Parser *p)
|
||||
else if (strmatch(next, "floor" )) d->type = e_floor;
|
||||
else if (strmatch(next, "ceil" )) d->type = e_ceil;
|
||||
else if (strmatch(next, "trunc" )) d->type = e_trunc;
|
||||
else if (strmatch(next, "round" )) d->type = e_round;
|
||||
else if (strmatch(next, "sqrt" )) d->type = e_sqrt;
|
||||
else if (strmatch(next, "not" )) d->type = e_not;
|
||||
else if (strmatch(next, "pow" )) d->type = e_pow;
|
||||
@ -637,6 +639,7 @@ static int verify_expr(AVExpr *e)
|
||||
case e_floor:
|
||||
case e_ceil:
|
||||
case e_trunc:
|
||||
case e_round:
|
||||
case e_sqrt:
|
||||
case e_not:
|
||||
case e_random:
|
||||
|
Loading…
Reference in New Issue
Block a user