diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-05-03 23:31:14 +0200 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-05-05 18:38:35 +0200 |
commit | e5272e729e9991c1705f53e0bf421e8026fab0c9 (patch) | |
tree | db30f1504c96c8bc68fc7434122cb6ae914fef3e /libavutil | |
parent | 5d2ce3a7782ade1ea661c139b58e2ab5389aaf17 (diff) | |
download | ffmpeg-e5272e729e9991c1705f53e0bf421e8026fab0c9.tar.gz |
eval: add sqrt function for computing the square root
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/avutil.h | 2 | ||||
-rw-r--r-- | libavutil/eval.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 83a559d7ce..09188f837e 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -41,7 +41,7 @@ #define LIBAVUTIL_VERSION_MAJOR 51 #define LIBAVUTIL_VERSION_MINOR 2 -#define LIBAVUTIL_VERSION_MICRO 0 +#define LIBAVUTIL_VERSION_MICRO 1 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/libavutil/eval.c b/libavutil/eval.c index 494b936c4b..98b4e0ac52 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -122,6 +122,7 @@ struct AVExpr { 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_while, e_floor, e_ceil, e_trunc, + e_sqrt, } type; double value; // is sign in other types union { @@ -148,6 +149,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_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); case e_while: { double d = NAN; while (eval_expr(p, e->param[0])) @@ -282,6 +284,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, "sqrt" )) d->type = e_sqrt; else { for (i=0; p->func1_names && p->func1_names[i]; i++) { if (strmatch(next, p->func1_names[i])) { @@ -449,6 +452,7 @@ static int verify_expr(AVExpr *e) case e_floor: case e_ceil: case e_trunc: + case e_sqrt: return verify_expr(e->param[0]); default: return verify_expr(e->param[0]) && verify_expr(e->param[1]); } @@ -628,6 +632,8 @@ int main(void) "trunc(-123.123)", "ceil(123.123)", "ceil(-123.123)", + "sqrt(1764)", + "sqrt(-1)", NULL }; |