Signed-off-by: Nicolas George <nicolas.george@normalesup.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -99,6 +99,16 @@ Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
|
| 99 | 99 |
@var{y} are 0 or either or both are less than zero then behavior is undefined.
|
| 100 | 100 |
@end table |
| 101 | 101 |
|
| 102 |
+The following constants are available: |
|
| 103 |
+@table @option |
|
| 104 |
+@item PI |
|
| 105 |
+area of the unit disc, approximatively 3.14 |
|
| 106 |
+@item E |
|
| 107 |
+exp(1) (Euler's number), approximatively 2.718 |
|
| 108 |
+@item PHI |
|
| 109 |
+golden ratio (1+sqrt(5))/2, approximatively 1.618 |
|
| 110 |
+@end table |
|
| 111 |
+ |
|
| 102 | 112 |
Note that: |
| 103 | 113 |
|
| 104 | 114 |
@code{*} works like AND
|
| ... | ... |
@@ -72,6 +72,15 @@ static const int8_t si_prefixes['z' - 'E' + 1] = {
|
| 72 | 72 |
['Y'-'E']= 24, |
| 73 | 73 |
}; |
| 74 | 74 |
|
| 75 |
+static const struct {
|
|
| 76 |
+ const char *name; |
|
| 77 |
+ double value; |
|
| 78 |
+} constants[] = {
|
|
| 79 |
+ { "E", M_E },
|
|
| 80 |
+ { "PI", M_PI },
|
|
| 81 |
+ { "PHI", M_PHI },
|
|
| 82 |
+}; |
|
| 83 |
+ |
|
| 75 | 84 |
double av_strtod(const char *numstr, char **tail) |
| 76 | 85 |
{
|
| 77 | 86 |
double d; |
| ... | ... |
@@ -233,6 +242,15 @@ static int parse_primary(AVExpr **e, Parser *p) |
| 233 | 233 |
return 0; |
| 234 | 234 |
} |
| 235 | 235 |
} |
| 236 |
+ for (i = 0; i < FF_ARRAY_ELEMS(constants); i++) {
|
|
| 237 |
+ if (strmatch(p->s, constants[i].name)) {
|
|
| 238 |
+ p->s += strlen(constants[i].name); |
|
| 239 |
+ d->type = e_value; |
|
| 240 |
+ d->value = constants[i].value; |
|
| 241 |
+ *e = d; |
|
| 242 |
+ return 0; |
|
| 243 |
+ } |
|
| 244 |
+ } |
|
| 236 | 245 |
|
| 237 | 246 |
p->s= strchr(p->s, '(');
|
| 238 | 247 |
if (p->s==NULL) {
|