utils.texi 21 KB

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