mirror of https://git.ffmpeg.org/ffmpeg.git
eval: add mathematical constants (PI, E, PHI).
Signed-off-by: Nicolas George <nicolas.george@normalesup.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
4d518f1230
commit
40963ea9e9
|
@ -99,6 +99,16 @@ Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
|
||||||
@var{y} are 0 or either or both are less than zero then behavior is undefined.
|
@var{y} are 0 or either or both are less than zero then behavior is undefined.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
The following constants are available:
|
||||||
|
@table @option
|
||||||
|
@item PI
|
||||||
|
area of the unit disc, approximatively 3.14
|
||||||
|
@item E
|
||||||
|
exp(1) (Euler's number), approximatively 2.718
|
||||||
|
@item PHI
|
||||||
|
golden ratio (1+sqrt(5))/2, approximatively 1.618
|
||||||
|
@end table
|
||||||
|
|
||||||
Note that:
|
Note that:
|
||||||
|
|
||||||
@code{*} works like AND
|
@code{*} works like AND
|
||||||
|
|
|
@ -72,6 +72,15 @@ static const int8_t si_prefixes['z' - 'E' + 1] = {
|
||||||
['Y'-'E']= 24,
|
['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 av_strtod(const char *numstr, char **tail)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
|
@ -233,6 +242,15 @@ static int parse_primary(AVExpr **e, Parser *p)
|
||||||
return 0;
|
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, '(');
|
p->s= strchr(p->s, '(');
|
||||||
if (p->s==NULL) {
|
if (p->s==NULL) {
|
||||||
|
|
Loading…
Reference in New Issue