utils.texi 21 KB

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