diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2011-10-13 13:24:24 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-10-13 16:50:20 +0200 |
commit | 40963ea9e9f8fbc178673c963f1d9662f3f20cfb (patch) | |
tree | af66991fc6e44a67971469cc58643b8780203c3c /libavutil/eval.c | |
parent | 4d518f123029f6cda1d3875902bbf9566c1fa76f (diff) | |
download | ffmpeg-40963ea9e9f8fbc178673c963f1d9662f3f20cfb.tar.gz |
eval: add mathematical constants (PI, E, PHI).
Signed-off-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 | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavutil/eval.c b/libavutil/eval.c index 0c61ad072b..3a8b60d505 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -72,6 +72,15 @@ static const int8_t si_prefixes['z' - 'E' + 1] = { ['Y'-'E']= 24, }; +static const struct { + const char *name; + double value; +} constants[] = { + { "E", M_E }, + { "PI", M_PI }, + { "PHI", M_PHI }, +}; + double av_strtod(const char *numstr, char **tail) { double d; @@ -233,6 +242,15 @@ static int parse_primary(AVExpr **e, Parser *p) return 0; } } + for (i = 0; i < FF_ARRAY_ELEMS(constants); i++) { + if (strmatch(p->s, constants[i].name)) { + p->s += strlen(constants[i].name); + d->type = e_value; + d->value = constants[i].value; + *e = d; + return 0; + } + } p->s= strchr(p->s, '('); if (p->s==NULL) { |