]> git.sesse.net Git - ffmpeg/blob - doc/utils.texi
avformat/avio: Add Metacube support
[ffmpeg] / doc / utils.texi
1 @chapter Syntax
2 @c man begin SYNTAX
3
4 This section documents the syntax and formats employed by the FFmpeg
5 libraries and tools.
6
7 @anchor{quoting_and_escaping}
8 @section Quoting and escaping
9
10 FFmpeg adopts the following quoting and escaping mechanism, unless
11 explicitly specified. The following rules are applied:
12
13 @itemize
14 @item
15 @samp{'} and @samp{\} are special characters (respectively used for
16 quoting and escaping). In addition to them, there might be other
17 special characters depending on the specific syntax where the escaping
18 and quoting are employed.
19
20 @item
21 A special character is escaped by prefixing it with a @samp{\}.
22
23 @item
24 All characters enclosed between @samp{''} are included literally in the
25 parsed string. The quote character @samp{'} itself cannot be quoted,
26 so you may need to close the quote and escape it.
27
28 @item
29 Leading and trailing whitespaces, unless escaped or quoted, are
30 removed from the parsed string.
31 @end itemize
32
33 Note that you may need to add a second level of escaping when using
34 the command line or a script, which depends on the syntax of the
35 adopted shell language.
36
37 The function @code{av_get_token} defined in
38 @file{libavutil/avstring.h} can be used to parse a token quoted or
39 escaped according to the rules defined above.
40
41 The tool @file{tools/ffescape} in the FFmpeg source tree can be used
42 to automatically quote or escape a string in a script.
43
44 @subsection Examples
45
46 @itemize
47 @item
48 Escape the string @code{Crime d'Amour} containing the @code{'} special
49 character:
50 @example
51 Crime d\'Amour
52 @end example
53
54 @item
55 The string above contains a quote, so the @code{'} needs to be escaped
56 when quoting it:
57 @example
58 'Crime d'\''Amour'
59 @end example
60
61 @item
62 Include leading or trailing whitespaces using quoting:
63 @example
64 '  this string starts and ends with whitespaces  '
65 @end example
66
67 @item
68 Escaping and quoting can be mixed together:
69 @example
70 ' The string '\'string\'' is a string '
71 @end example
72
73 @item
74 To include a literal @samp{\} you can use either escaping or quoting:
75 @example
76 'c:\foo' can be written as c:\\foo
77 @end example
78 @end itemize
79
80 @anchor{date syntax}
81 @section Date
82
83 The accepted syntax is:
84 @example
85 [(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m...]]])|(HHMMSS[.m...]]]))[Z]
86 now
87 @end example
88
89 If the value is "now" it takes the current time.
90
91 Time is local time unless Z is appended, in which case it is
92 interpreted as UTC.
93 If the year-month-day part is not specified it takes the current
94 year-month-day.
95
96 @anchor{time duration syntax}
97 @section Time duration
98
99 There are two accepted syntaxes for expressing time duration.
100
101 @example
102 [-][@var{HH}:]@var{MM}:@var{SS}[.@var{m}...]
103 @end example
104
105 @var{HH} expresses the number of hours, @var{MM} the number of minutes
106 for a maximum of 2 digits, and @var{SS} the number of seconds for a
107 maximum of 2 digits. The @var{m} at the end expresses decimal value for
108 @var{SS}.
109
110 @emph{or}
111
112 @example
113 [-]@var{S}+[.@var{m}...][s|ms|us]
114 @end example
115
116 @var{S} expresses the number of seconds, with the optional decimal part
117 @var{m}.  The optional literal suffixes @samp{s}, @samp{ms} or @samp{us}
118 indicate to interpret the value as seconds, milliseconds or microseconds,
119 respectively.
120
121 In both expressions, the optional @samp{-} indicates negative duration.
122
123 @subsection Examples
124
125 The following examples are all valid time duration:
126
127 @table @samp
128 @item 55
129 55 seconds
130
131 @item 0.2
132 0.2 seconds
133
134 @item 200ms
135 200 milliseconds, that's 0.2s
136
137 @item 200000us
138 200000 microseconds, that's 0.2s
139
140 @item 12:03:45
141 12 hours, 03 minutes and 45 seconds
142
143 @item 23.189
144 23.189 seconds
145 @end table
146
147 @anchor{video size syntax}
148 @section Video size
149 Specify the size of the sourced video, it may be a string of the form
150 @var{width}x@var{height}, or the name of a size abbreviation.
151
152 The following abbreviations are recognized:
153 @table @samp
154 @item ntsc
155 720x480
156 @item pal
157 720x576
158 @item qntsc
159 352x240
160 @item qpal
161 352x288
162 @item sntsc
163 640x480
164 @item spal
165 768x576
166 @item film
167 352x240
168 @item ntsc-film
169 352x240
170 @item sqcif
171 128x96
172 @item qcif
173 176x144
174 @item cif
175 352x288
176 @item 4cif
177 704x576
178 @item 16cif
179 1408x1152
180 @item qqvga
181 160x120
182 @item qvga
183 320x240
184 @item vga
185 640x480
186 @item svga
187 800x600
188 @item xga
189 1024x768
190 @item uxga
191 1600x1200
192 @item qxga
193 2048x1536
194 @item sxga
195 1280x1024
196 @item qsxga
197 2560x2048
198 @item hsxga
199 5120x4096
200 @item wvga
201 852x480
202 @item wxga
203 1366x768
204 @item wsxga
205 1600x1024
206 @item wuxga
207 1920x1200
208 @item woxga
209 2560x1600
210 @item wqsxga
211 3200x2048
212 @item wquxga
213 3840x2400
214 @item whsxga
215 6400x4096
216 @item whuxga
217 7680x4800
218 @item cga
219 320x200
220 @item ega
221 640x350
222 @item hd480
223 852x480
224 @item hd720
225 1280x720
226 @item hd1080
227 1920x1080
228 @item 2k
229 2048x1080
230 @item 2kflat
231 1998x1080
232 @item 2kscope
233 2048x858
234 @item 4k
235 4096x2160
236 @item 4kflat
237 3996x2160
238 @item 4kscope
239 4096x1716
240 @item nhd
241 640x360
242 @item hqvga
243 240x160
244 @item wqvga
245 400x240
246 @item fwqvga
247 432x240
248 @item hvga
249 480x320
250 @item qhd
251 960x540
252 @item 2kdci
253 2048x1080
254 @item 4kdci
255 4096x2160
256 @item uhd2160
257 3840x2160
258 @item uhd4320
259 7680x4320
260 @end table
261
262 @anchor{video rate syntax}
263 @section Video rate
264
265 Specify the frame rate of a video, expressed as the number of frames
266 generated per second. It has to be a string in the format
267 @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
268 number or a valid video frame rate abbreviation.
269
270 The following abbreviations are recognized:
271 @table @samp
272 @item ntsc
273 30000/1001
274 @item pal
275 25/1
276 @item qntsc
277 30000/1001
278 @item qpal
279 25/1
280 @item sntsc
281 30000/1001
282 @item spal
283 25/1
284 @item film
285 24/1
286 @item ntsc-film
287 24000/1001
288 @end table
289
290 @anchor{ratio syntax}
291 @section Ratio
292
293 A ratio can be expressed as an expression, or in the form
294 @var{numerator}:@var{denominator}.
295
296 Note that a ratio with infinite (1/0) or negative value is
297 considered valid, so you should check on the returned value if you
298 want to exclude those values.
299
300 The undefined value can be expressed using the "0:0" string.
301
302 @anchor{color syntax}
303 @section Color
304
305 It can be the name of a color as defined below (case insensitive match) or a
306 @code{[0x|#]RRGGBB[AA]} sequence, possibly followed by @@ and a string
307 representing the alpha component.
308
309 The alpha component may be a string composed by "0x" followed by an
310 hexadecimal number or a decimal number between 0.0 and 1.0, which
311 represents the opacity value (@samp{0x00} or @samp{0.0} means completely
312 transparent, @samp{0xff} or @samp{1.0} completely opaque). If the alpha
313 component is not specified then @samp{0xff} is assumed.
314
315 The string @samp{random} will result in a random color.
316
317 The following names of colors are recognized:
318 @table @samp
319 @item AliceBlue
320 0xF0F8FF
321 @item AntiqueWhite
322 0xFAEBD7
323 @item Aqua
324 0x00FFFF
325 @item Aquamarine
326 0x7FFFD4
327 @item Azure
328 0xF0FFFF
329 @item Beige
330 0xF5F5DC
331 @item Bisque
332 0xFFE4C4
333 @item Black
334 0x000000
335 @item BlanchedAlmond
336 0xFFEBCD
337 @item Blue
338 0x0000FF
339 @item BlueViolet
340 0x8A2BE2
341 @item Brown
342 0xA52A2A
343 @item BurlyWood
344 0xDEB887
345 @item CadetBlue
346 0x5F9EA0
347 @item Chartreuse
348 0x7FFF00
349 @item Chocolate
350 0xD2691E
351 @item Coral
352 0xFF7F50
353 @item CornflowerBlue
354 0x6495ED
355 @item Cornsilk
356 0xFFF8DC
357 @item Crimson
358 0xDC143C
359 @item Cyan
360 0x00FFFF
361 @item DarkBlue
362 0x00008B
363 @item DarkCyan
364 0x008B8B
365 @item DarkGoldenRod
366 0xB8860B
367 @item DarkGray
368 0xA9A9A9
369 @item DarkGreen
370 0x006400
371 @item DarkKhaki
372 0xBDB76B
373 @item DarkMagenta
374 0x8B008B
375 @item DarkOliveGreen
376 0x556B2F
377 @item Darkorange
378 0xFF8C00
379 @item DarkOrchid
380 0x9932CC
381 @item DarkRed
382 0x8B0000
383 @item DarkSalmon
384 0xE9967A
385 @item DarkSeaGreen
386 0x8FBC8F
387 @item DarkSlateBlue
388 0x483D8B
389 @item DarkSlateGray
390 0x2F4F4F
391 @item DarkTurquoise
392 0x00CED1
393 @item DarkViolet
394 0x9400D3
395 @item DeepPink
396 0xFF1493
397 @item DeepSkyBlue
398 0x00BFFF
399 @item DimGray
400 0x696969
401 @item DodgerBlue
402 0x1E90FF
403 @item FireBrick
404 0xB22222
405 @item FloralWhite
406 0xFFFAF0
407 @item ForestGreen
408 0x228B22
409 @item Fuchsia
410 0xFF00FF
411 @item Gainsboro
412 0xDCDCDC
413 @item GhostWhite
414 0xF8F8FF
415 @item Gold
416 0xFFD700
417 @item GoldenRod
418 0xDAA520
419 @item Gray
420 0x808080
421 @item Green
422 0x008000
423 @item GreenYellow
424 0xADFF2F
425 @item HoneyDew
426 0xF0FFF0
427 @item HotPink
428 0xFF69B4
429 @item IndianRed
430 0xCD5C5C
431 @item Indigo
432 0x4B0082
433 @item Ivory
434 0xFFFFF0
435 @item Khaki
436 0xF0E68C
437 @item Lavender
438 0xE6E6FA
439 @item LavenderBlush
440 0xFFF0F5
441 @item LawnGreen
442 0x7CFC00
443 @item LemonChiffon
444 0xFFFACD
445 @item LightBlue
446 0xADD8E6
447 @item LightCoral
448 0xF08080
449 @item LightCyan
450 0xE0FFFF
451 @item LightGoldenRodYellow
452 0xFAFAD2
453 @item LightGreen
454 0x90EE90
455 @item LightGrey
456 0xD3D3D3
457 @item LightPink
458 0xFFB6C1
459 @item LightSalmon
460 0xFFA07A
461 @item LightSeaGreen
462 0x20B2AA
463 @item LightSkyBlue
464 0x87CEFA
465 @item LightSlateGray
466 0x778899
467 @item LightSteelBlue
468 0xB0C4DE
469 @item LightYellow
470 0xFFFFE0
471 @item Lime
472 0x00FF00
473 @item LimeGreen
474 0x32CD32
475 @item Linen
476 0xFAF0E6
477 @item Magenta
478 0xFF00FF
479 @item Maroon
480 0x800000
481 @item MediumAquaMarine
482 0x66CDAA
483 @item MediumBlue
484 0x0000CD
485 @item MediumOrchid
486 0xBA55D3
487 @item MediumPurple
488 0x9370D8
489 @item MediumSeaGreen
490 0x3CB371
491 @item MediumSlateBlue
492 0x7B68EE
493 @item MediumSpringGreen
494 0x00FA9A
495 @item MediumTurquoise
496 0x48D1CC
497 @item MediumVioletRed
498 0xC71585
499 @item MidnightBlue
500 0x191970
501 @item MintCream
502 0xF5FFFA
503 @item MistyRose
504 0xFFE4E1
505 @item Moccasin
506 0xFFE4B5
507 @item NavajoWhite
508 0xFFDEAD
509 @item Navy
510 0x000080
511 @item OldLace
512 0xFDF5E6
513 @item Olive
514 0x808000
515 @item OliveDrab
516 0x6B8E23
517 @item Orange
518 0xFFA500
519 @item OrangeRed
520 0xFF4500
521 @item Orchid
522 0xDA70D6
523 @item PaleGoldenRod
524 0xEEE8AA
525 @item PaleGreen
526 0x98FB98
527 @item PaleTurquoise
528 0xAFEEEE
529 @item PaleVioletRed
530 0xD87093
531 @item PapayaWhip
532 0xFFEFD5
533 @item PeachPuff
534 0xFFDAB9
535 @item Peru
536 0xCD853F
537 @item Pink
538 0xFFC0CB
539 @item Plum
540 0xDDA0DD
541 @item PowderBlue
542 0xB0E0E6
543 @item Purple
544 0x800080
545 @item Red
546 0xFF0000
547 @item RosyBrown
548 0xBC8F8F
549 @item RoyalBlue
550 0x4169E1
551 @item SaddleBrown
552 0x8B4513
553 @item Salmon
554 0xFA8072
555 @item SandyBrown
556 0xF4A460
557 @item SeaGreen
558 0x2E8B57
559 @item SeaShell
560 0xFFF5EE
561 @item Sienna
562 0xA0522D
563 @item Silver
564 0xC0C0C0
565 @item SkyBlue
566 0x87CEEB
567 @item SlateBlue
568 0x6A5ACD
569 @item SlateGray
570 0x708090
571 @item Snow
572 0xFFFAFA
573 @item SpringGreen
574 0x00FF7F
575 @item SteelBlue
576 0x4682B4
577 @item Tan
578 0xD2B48C
579 @item Teal
580 0x008080
581 @item Thistle
582 0xD8BFD8
583 @item Tomato
584 0xFF6347
585 @item Turquoise
586 0x40E0D0
587 @item Violet
588 0xEE82EE
589 @item Wheat
590 0xF5DEB3
591 @item White
592 0xFFFFFF
593 @item WhiteSmoke
594 0xF5F5F5
595 @item Yellow
596 0xFFFF00
597 @item YellowGreen
598 0x9ACD32
599 @end table
600
601 @anchor{channel layout syntax}
602 @section Channel Layout
603
604 A channel layout specifies the spatial disposition of the channels in
605 a multi-channel audio stream. To specify a channel layout, FFmpeg
606 makes use of a special syntax.
607
608 Individual channels are identified by an id, as given by the table
609 below:
610 @table @samp
611 @item FL
612 front left
613 @item FR
614 front right
615 @item FC
616 front center
617 @item LFE
618 low frequency
619 @item BL
620 back left
621 @item BR
622 back right
623 @item FLC
624 front left-of-center
625 @item FRC
626 front right-of-center
627 @item BC
628 back center
629 @item SL
630 side left
631 @item SR
632 side right
633 @item TC
634 top center
635 @item TFL
636 top front left
637 @item TFC
638 top front center
639 @item TFR
640 top front right
641 @item TBL
642 top back left
643 @item TBC
644 top back center
645 @item TBR
646 top back right
647 @item DL
648 downmix left
649 @item DR
650 downmix right
651 @item WL
652 wide left
653 @item WR
654 wide right
655 @item SDL
656 surround direct left
657 @item SDR
658 surround direct right
659 @item LFE2
660 low frequency 2
661 @end table
662
663 Standard channel layout compositions can be specified by using the
664 following identifiers:
665 @table @samp
666 @item mono
667 FC
668 @item stereo
669 FL+FR
670 @item 2.1
671 FL+FR+LFE
672 @item 3.0
673 FL+FR+FC
674 @item 3.0(back)
675 FL+FR+BC
676 @item 4.0
677 FL+FR+FC+BC
678 @item quad
679 FL+FR+BL+BR
680 @item quad(side)
681 FL+FR+SL+SR
682 @item 3.1
683 FL+FR+FC+LFE
684 @item 5.0
685 FL+FR+FC+BL+BR
686 @item 5.0(side)
687 FL+FR+FC+SL+SR
688 @item 4.1
689 FL+FR+FC+LFE+BC
690 @item 5.1
691 FL+FR+FC+LFE+BL+BR
692 @item 5.1(side)
693 FL+FR+FC+LFE+SL+SR
694 @item 6.0
695 FL+FR+FC+BC+SL+SR
696 @item 6.0(front)
697 FL+FR+FLC+FRC+SL+SR
698 @item hexagonal
699 FL+FR+FC+BL+BR+BC
700 @item 6.1
701 FL+FR+FC+LFE+BC+SL+SR
702 @item 6.1
703 FL+FR+FC+LFE+BL+BR+BC
704 @item 6.1(front)
705 FL+FR+LFE+FLC+FRC+SL+SR
706 @item 7.0
707 FL+FR+FC+BL+BR+SL+SR
708 @item 7.0(front)
709 FL+FR+FC+FLC+FRC+SL+SR
710 @item 7.1
711 FL+FR+FC+LFE+BL+BR+SL+SR
712 @item 7.1(wide)
713 FL+FR+FC+LFE+BL+BR+FLC+FRC
714 @item 7.1(wide-side)
715 FL+FR+FC+LFE+FLC+FRC+SL+SR
716 @item octagonal
717 FL+FR+FC+BL+BR+BC+SL+SR
718 @item hexadecagonal
719 FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
720 @item downmix
721 DL+DR
722 @end table
723
724 A custom channel layout can be specified as a sequence of terms, separated by
725 '+' or '|'. Each term can be:
726 @itemize
727 @item
728 the name of a standard channel layout (e.g. @samp{mono},
729 @samp{stereo}, @samp{4.0}, @samp{quad}, @samp{5.0}, etc.)
730
731 @item
732 the name of a single channel (e.g. @samp{FL}, @samp{FR}, @samp{FC}, @samp{LFE}, etc.)
733
734 @item
735 a number of channels, in decimal, followed by 'c', yielding the default channel
736 layout for that number of channels (see the function
737 @code{av_get_default_channel_layout}). Note that not all channel counts have a
738 default layout.
739
740 @item
741 a number of channels, in decimal, followed by 'C', yielding an unknown channel
742 layout with the specified number of channels. Note that not all channel layout
743 specification strings support unknown channel layouts.
744
745 @item
746 a channel layout mask, in hexadecimal starting with "0x" (see the
747 @code{AV_CH_*} macros in @file{libavutil/channel_layout.h}.
748 @end itemize
749
750 Before libavutil version 53 the trailing character "c" to specify a number of
751 channels was optional, but now it is required, while a channel layout mask can
752 also be specified as a decimal number (if and only if not followed by "c" or "C").
753
754 See also the function @code{av_get_channel_layout} defined in
755 @file{libavutil/channel_layout.h}.
756 @c man end SYNTAX
757
758 @chapter Expression Evaluation
759 @c man begin EXPRESSION EVALUATION
760
761 When evaluating an arithmetic expression, FFmpeg uses an internal
762 formula evaluator, implemented through the @file{libavutil/eval.h}
763 interface.
764
765 An expression may contain unary, binary operators, constants, and
766 functions.
767
768 Two expressions @var{expr1} and @var{expr2} can be combined to form
769 another expression "@var{expr1};@var{expr2}".
770 @var{expr1} and @var{expr2} are evaluated in turn, and the new
771 expression evaluates to the value of @var{expr2}.
772
773 The following binary operators are available: @code{+}, @code{-},
774 @code{*}, @code{/}, @code{^}.
775
776 The following unary operators are available: @code{+}, @code{-}.
777
778 The following functions are available:
779 @table @option
780 @item abs(x)
781 Compute absolute value of @var{x}.
782
783 @item acos(x)
784 Compute arccosine of @var{x}.
785
786 @item asin(x)
787 Compute arcsine of @var{x}.
788
789 @item atan(x)
790 Compute arctangent of @var{x}.
791
792 @item atan2(x, y)
793 Compute principal value of the arc tangent of @var{y}/@var{x}.
794
795 @item between(x, min, max)
796 Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or
797 equal to @var{max}, 0 otherwise.
798
799 @item bitand(x, y)
800 @item bitor(x, y)
801 Compute bitwise and/or operation on @var{x} and @var{y}.
802
803 The results of the evaluation of @var{x} and @var{y} are converted to
804 integers before executing the bitwise operation.
805
806 Note that both the conversion to integer and the conversion back to
807 floating point can lose precision. Beware of unexpected results for
808 large numbers (usually 2^53 and larger).
809
810 @item ceil(expr)
811 Round the value of expression @var{expr} upwards to the nearest
812 integer. For example, "ceil(1.5)" is "2.0".
813
814 @item clip(x, min, max)
815 Return the value of @var{x} clipped between @var{min} and @var{max}.
816
817 @item cos(x)
818 Compute cosine of @var{x}.
819
820 @item cosh(x)
821 Compute hyperbolic cosine of @var{x}.
822
823 @item eq(x, y)
824 Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise.
825
826 @item exp(x)
827 Compute exponential of @var{x} (with base @code{e}, the Euler's number).
828
829 @item floor(expr)
830 Round the value of expression @var{expr} downwards to the nearest
831 integer. For example, "floor(-1.5)" is "-2.0".
832
833 @item gauss(x)
834 Compute Gauss function of @var{x}, corresponding to
835 @code{exp(-x*x/2) / sqrt(2*PI)}.
836
837 @item gcd(x, y)
838 Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
839 @var{y} are 0 or either or both are less than zero then behavior is undefined.
840
841 @item gt(x, y)
842 Return 1 if @var{x} is greater than @var{y}, 0 otherwise.
843
844 @item gte(x, y)
845 Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise.
846
847 @item hypot(x, y)
848 This function is similar to the C function with the same name; it returns
849 "sqrt(@var{x}*@var{x} + @var{y}*@var{y})", the length of the hypotenuse of a
850 right triangle with sides of length @var{x} and @var{y}, or the distance of the
851 point (@var{x}, @var{y}) from the origin.
852
853 @item if(x, y)
854 Evaluate @var{x}, and if the result is non-zero return the result of
855 the evaluation of @var{y}, return 0 otherwise.
856
857 @item if(x, y, z)
858 Evaluate @var{x}, and if the result is non-zero return the evaluation
859 result of @var{y}, otherwise the evaluation result of @var{z}.
860
861 @item ifnot(x, y)
862 Evaluate @var{x}, and if the result is zero return the result of the
863 evaluation of @var{y}, return 0 otherwise.
864
865 @item ifnot(x, y, z)
866 Evaluate @var{x}, and if the result is zero return the evaluation
867 result of @var{y}, otherwise the evaluation result of @var{z}.
868
869 @item isinf(x)
870 Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise.
871
872 @item isnan(x)
873 Return 1.0 if @var{x} is NAN, 0.0 otherwise.
874
875 @item ld(var)
876 Load the value of the internal variable with number
877 @var{var}, which was previously stored with st(@var{var}, @var{expr}).
878 The function returns the loaded value.
879
880 @item lerp(x, y, z)
881 Return linear interpolation between @var{x} and @var{y} by amount of @var{z}.
882
883 @item log(x)
884 Compute natural logarithm of @var{x}.
885
886 @item lt(x, y)
887 Return 1 if @var{x} is lesser than @var{y}, 0 otherwise.
888
889 @item lte(x, y)
890 Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise.
891
892 @item max(x, y)
893 Return the maximum between @var{x} and @var{y}.
894
895 @item min(x, y)
896 Return the minimum between @var{x} and @var{y}.
897
898 @item mod(x, y)
899 Compute the remainder of division of @var{x} by @var{y}.
900
901 @item not(expr)
902 Return 1.0 if @var{expr} is zero, 0.0 otherwise.
903
904 @item pow(x, y)
905 Compute the power of @var{x} elevated @var{y}, it is equivalent to
906 "(@var{x})^(@var{y})".
907
908 @item print(t)
909 @item print(t, l)
910 Print the value of expression @var{t} with loglevel @var{l}. If
911 @var{l} is not specified then a default log level is used.
912 Returns the value of the expression printed.
913
914 Prints t with loglevel l
915
916 @item random(x)
917 Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the
918 internal variable which will be used to save the seed/state.
919
920 @item root(expr, max)
921 Find an input value for which the function represented by @var{expr}
922 with argument @var{ld(0)} is 0 in the interval 0..@var{max}.
923
924 The expression in @var{expr} must denote a continuous function or the
925 result is undefined.
926
927 @var{ld(0)} is used to represent the function input value, which means
928 that the given expression will be evaluated multiple times with
929 various input values that the expression can access through
930 @code{ld(0)}. When the expression evaluates to 0 then the
931 corresponding input value will be returned.
932
933 @item round(expr)
934 Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0".
935
936 @item sgn(x)
937 Compute sign of @var{x}.
938
939 @item sin(x)
940 Compute sine of @var{x}.
941
942 @item sinh(x)
943 Compute hyperbolic sine of @var{x}.
944
945 @item sqrt(expr)
946 Compute the square root of @var{expr}. This is equivalent to
947 "(@var{expr})^.5".
948
949 @item squish(x)
950 Compute expression @code{1/(1 + exp(4*x))}.
951
952 @item st(var, expr)
953 Store the value of the expression @var{expr} in an internal
954 variable. @var{var} specifies the number of the variable where to
955 store the value, and it is a value ranging from 0 to 9. The function
956 returns the value stored in the internal variable.
957 Note, Variables are currently not shared between expressions.
958
959 @item tan(x)
960 Compute tangent of @var{x}.
961
962 @item tanh(x)
963 Compute hyperbolic tangent of @var{x}.
964
965 @item taylor(expr, x)
966 @item taylor(expr, x, id)
967 Evaluate a Taylor series at @var{x}, given an expression representing
968 the @code{ld(id)}-th derivative of a function at 0.
969
970 When the series does not converge the result is undefined.
971
972 @var{ld(id)} is used to represent the derivative order in @var{expr},
973 which means that the given expression will be evaluated multiple times
974 with various input values that the expression can access through
975 @code{ld(id)}. If @var{id} is not specified then 0 is assumed.
976
977 Note, when you have the derivatives at y instead of 0,
978 @code{taylor(expr, x-y)} can be used.
979
980 @item time(0)
981 Return the current (wallclock) time in seconds.
982
983 @item trunc(expr)
984 Round the value of expression @var{expr} towards zero to the nearest
985 integer. For example, "trunc(-1.5)" is "-1.0".
986
987 @item while(cond, expr)
988 Evaluate expression @var{expr} while the expression @var{cond} is
989 non-zero, and returns the value of the last @var{expr} evaluation, or
990 NAN if @var{cond} was always false.
991 @end table
992
993 The following constants are available:
994 @table @option
995 @item PI
996 area of the unit disc, approximately 3.14
997 @item E
998 exp(1) (Euler's number), approximately 2.718
999 @item PHI
1000 golden ratio (1+sqrt(5))/2, approximately 1.618
1001 @end table
1002
1003 Assuming that an expression is considered "true" if it has a non-zero
1004 value, note that:
1005
1006 @code{*} works like AND
1007
1008 @code{+} works like OR
1009
1010 For example the construct:
1011 @example
1012 if (A AND B) then C
1013 @end example
1014 is equivalent to:
1015 @example
1016 if(A*B, C)
1017 @end example
1018
1019 In your C code, you can extend the list of unary and binary functions,
1020 and define recognized constants, so that they are available for your
1021 expressions.
1022
1023 The evaluator also recognizes the International System unit prefixes.
1024 If 'i' is appended after the prefix, binary prefixes are used, which
1025 are based on powers of 1024 instead of powers of 1000.
1026 The 'B' postfix multiplies the value by 8, and can be appended after a
1027 unit prefix or used alone. This allows using for example 'KB', 'MiB',
1028 'G' and 'B' as number postfix.
1029
1030 The list of available International System prefixes follows, with
1031 indication of the corresponding powers of 10 and of 2.
1032 @table @option
1033 @item y
1034 10^-24 / 2^-80
1035 @item z
1036 10^-21 / 2^-70
1037 @item a
1038 10^-18 / 2^-60
1039 @item f
1040 10^-15 / 2^-50
1041 @item p
1042 10^-12 / 2^-40
1043 @item n
1044 10^-9 / 2^-30
1045 @item u
1046 10^-6 / 2^-20
1047 @item m
1048 10^-3 / 2^-10
1049 @item c
1050 10^-2
1051 @item d
1052 10^-1
1053 @item h
1054 10^2
1055 @item k
1056 10^3 / 2^10
1057 @item K
1058 10^3 / 2^10
1059 @item M
1060 10^6 / 2^20
1061 @item G
1062 10^9 / 2^30
1063 @item T
1064 10^12 / 2^40
1065 @item P
1066 10^15 / 2^40
1067 @item E
1068 10^18 / 2^50
1069 @item Z
1070 10^21 / 2^60
1071 @item Y
1072 10^24 / 2^70
1073 @end table
1074
1075 @c man end EXPRESSION EVALUATION