When evaluating an arithemetic expression, Libav uses an internal formula evaluator, implemented through the ‘libavutil/eval.h’ interface.
An expression may contain unary, binary operators, constants, and functions.
Two expressions expr1 and expr2 can be combined to form another expression "expr1;expr2". expr1 and expr2 are evaluated in turn, and the new expression evaluates to the value of expr2.
The following binary operators are available: +
, -
,
*
, /
, ^
.
The following unary operators are available: +
, -
.
The following functions are available:
Return 1.0 if x is NAN, 0.0 otherwise.
Allow to store the value of the expression expr in an internal variable. var specifies the number of the variable where to store the value, and it is a value ranging from 0 to 9. The function returns the value stored in the internal variable.
Allow to load the value of the internal variable with number var, which was previosly stored with st(var, expr). The function returns the loaded value.
Evaluate expression expr while the expression cond is non-zero, and returns the value of the last expr evaluation, or NAN if cond was always false.
Round the value of expression expr upwards to the nearest integer. For example, "ceil(1.5)" is "2.0".
Round the value of expression expr downwards to the nearest integer. For example, "floor(-1.5)" is "-2.0".
Round the value of expression expr towards zero to the nearest integer. For example, "trunc(-1.5)" is "-1.0".
Note that:
*
works like AND
+
works like OR
thus
if A then B else C |
is equivalent to
A*B + not(A)*C |
When A evaluates to either 1 or 0, that is the same as
A*B + eq(A,0)*C |
In your C code, you can extend the list of unary and binary functions, and define recognized constants, so that they are available for your expressions.
The evaluator also recognizes the International System number postfixes. If ’i’ is appended after the postfix, powers of 2 are used instead of powers of 10. The ’B’ postfix multiplies the value for 8, and can be appended after another postfix or used alone. This allows using for example ’KB’, ’MiB’, ’G’ and ’B’ as postfix.
Follows the list of available International System postfixes, with indication of the corresponding powers of 10 and of 2.
-24 / -80
-21 / -70
-18 / -60
-15 / -50
-12 / -40
-9 / -30
-6 / -20
-3 / -10
-2
-1
2
3 / 10
3 / 10
6 / 20
9 / 30
12 / 40
15 / 40
18 / 50
21 / 60
24 / 70
This document was generated by mdx on February 3, 2021 using texi2html 1.82.