diff options
Diffstat (limited to 'media/ffvpx/libavutil/eval.c')
-rw-r--r-- | media/ffvpx/libavutil/eval.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/media/ffvpx/libavutil/eval.c b/media/ffvpx/libavutil/eval.c index fc12885c27..e5948793bd 100644 --- a/media/ffvpx/libavutil/eval.c +++ b/media/ffvpx/libavutil/eval.c @@ -38,6 +38,7 @@ #include "fftime.h" #include "avstring.h" #include "timer.h" +#include "reverse.h" typedef struct Parser { const AVClass *class; @@ -152,9 +153,9 @@ 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_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip, e_atan2, e_lerp, } type; double value; // is sign in other types union { @@ -188,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]) : @@ -206,6 +208,12 @@ static double eval_expr(Parser *p, AVExpr *e) return e->value * (d >= eval_expr(p, e->param[1]) && d <= eval_expr(p, e->param[2])); } + case e_lerp: { + double v0 = eval_expr(p, e->param[0]); + double v1 = eval_expr(p, e->param[1]); + double f = eval_expr(p, e->param[2]); + return v0 + (v1 - v0) * f; + } case e_print: { double x = eval_expr(p, e->param[0]); int level = e->param[1] ? av_clip(eval_expr(p, e->param[1]), INT_MIN, INT_MAX) : AV_LOG_INFO; @@ -305,6 +313,7 @@ static double eval_expr(Parser *p, AVExpr *e) case e_last:return e->value * d2; case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2); case e_hypot:return e->value * hypot(d, d2); + case e_atan2:return e->value * atan2(d, d2); case e_bitand: return isnan(d) || isnan(d2) ? NAN : e->value * ((long int)d & (long int)d2); case e_bitor: return isnan(d) || isnan(d2) ? NAN : e->value * ((long int)d | (long int)d2); } @@ -438,6 +447,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; @@ -451,6 +461,8 @@ static int parse_primary(AVExpr **e, Parser *p) else if (strmatch(next, "bitor" )) d->type = e_bitor; else if (strmatch(next, "between"))d->type = e_between; else if (strmatch(next, "clip" )) d->type = e_clip; + else if (strmatch(next, "atan2" )) d->type = e_atan2; + else if (strmatch(next, "lerp" )) d->type = e_lerp; else { for (i=0; p->func1_names && p->func1_names[i]; i++) { if (strmatch(next, p->func1_names[i])) { @@ -634,6 +646,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: @@ -648,6 +661,7 @@ static int verify_expr(AVExpr *e) && (!e->param[2] || verify_expr(e->param[2])); case e_between: case e_clip: + case e_lerp: return verify_expr(e->param[0]) && verify_expr(e->param[1]) && verify_expr(e->param[2]); |