draft-ietf-codec-oggopus.xml 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE rfc SYSTEM 'rfc2629.dtd' [
  3. <!ENTITY rfc2119 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
  4. <!ENTITY rfc3533 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3533.xml'>
  5. <!ENTITY rfc3629 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3629.xml'>
  6. <!ENTITY rfc4732 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4732.xml'>
  7. <!ENTITY rfc5334 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5334.xml'>
  8. <!ENTITY rfc6381 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6381.xml'>
  9. <!ENTITY rfc6716 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6716.xml'>
  10. <!ENTITY rfc6982 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6982.xml'>
  11. ]>
  12. <?rfc toc="yes" symrefs="yes" ?>
  13. <rfc ipr="trust200902" category="std" docName="draft-ietf-codec-oggopus-03">
  14. <front>
  15. <title abbrev="Ogg Opus">Ogg Encapsulation for the Opus Audio Codec</title>
  16. <author initials="T.B." surname="Terriberry" fullname="Timothy B. Terriberry">
  17. <organization>Mozilla Corporation</organization>
  18. <address>
  19. <postal>
  20. <street>650 Castro Street</street>
  21. <city>Mountain View</city>
  22. <region>CA</region>
  23. <code>94041</code>
  24. <country>USA</country>
  25. </postal>
  26. <phone>+1 650 903-0800</phone>
  27. <email>tterribe@xiph.org</email>
  28. </address>
  29. </author>
  30. <author initials="R." surname="Lee" fullname="Ron Lee">
  31. <organization>Voicetronix</organization>
  32. <address>
  33. <postal>
  34. <street>246 Pulteney Street, Level 1</street>
  35. <city>Adelaide</city>
  36. <region>SA</region>
  37. <code>5000</code>
  38. <country>Australia</country>
  39. </postal>
  40. <phone>+61 8 8232 9112</phone>
  41. <email>ron@debian.org</email>
  42. </address>
  43. </author>
  44. <author initials="R." surname="Giles" fullname="Ralph Giles">
  45. <organization>Mozilla Corporation</organization>
  46. <address>
  47. <postal>
  48. <street>163 West Hastings Street</street>
  49. <city>Vancouver</city>
  50. <region>BC</region>
  51. <code>V6B 1H5</code>
  52. <country>Canada</country>
  53. </postal>
  54. <phone>+1 778 785 1540</phone>
  55. <email>giles@xiph.org</email>
  56. </address>
  57. </author>
  58. <date day="7" month="February" year="2014"/>
  59. <area>RAI</area>
  60. <workgroup>codec</workgroup>
  61. <abstract>
  62. <t>
  63. This document defines the Ogg encapsulation for the Opus interactive speech and
  64. audio codec.
  65. This allows data encoded in the Opus format to be stored in an Ogg logical
  66. bitstream.
  67. Ogg encapsulation provides Opus with a long-term storage format supporting
  68. all of the essential features, including metadata, fast and accurate seeking,
  69. corruption detection, recapture after errors, low overhead, and the ability to
  70. multiplex Opus with other codecs (including video) with minimal buffering.
  71. It also provides a live streamable format, capable of delivery over a reliable
  72. stream-oriented transport, without requiring all the data, or even the total
  73. length of the data, up-front, in a form that is identical to the on-disk
  74. storage format.
  75. </t>
  76. </abstract>
  77. </front>
  78. <middle>
  79. <section anchor="intro" title="Introduction">
  80. <t>
  81. The IETF Opus codec is a low-latency audio codec optimized for both voice and
  82. general-purpose audio.
  83. See <xref target="RFC6716"/> for technical details.
  84. This document defines the encapsulation of Opus in a continuous, logical Ogg
  85. bitstream&nbsp;<xref target="RFC3533"/>.
  86. </t>
  87. <t>
  88. Ogg bitstreams are made up of a series of 'pages', each of which contains data
  89. from one or more 'packets'.
  90. Pages are the fundamental unit of multiplexing in an Ogg stream.
  91. Each page is associated with a particular logical stream and contains a capture
  92. pattern and checksum, flags to mark the beginning and end of the logical
  93. stream, and a 'granule position' that represents an absolute position in the
  94. stream, to aid seeking.
  95. A single page can contain up to 65,025 octets of packet data from up to 255
  96. different packets.
  97. Packets may be split arbitrarily across pages, and continued from one page to
  98. the next (allowing packets much larger than would fit on a single page).
  99. Each page contains 'lacing values' that indicate how the data is partitioned
  100. into packets, allowing a demuxer to recover the packet boundaries without
  101. examining the encoded data.
  102. A packet is said to 'complete' on a page when the page contains the final
  103. lacing value corresponding to that packet.
  104. </t>
  105. <t>
  106. This encapsulation defines the required contents of the packet data, including
  107. the necessary headers, the organization of those packets into a logical
  108. stream, and the interpretation of the codec-specific granule position field.
  109. It does not attempt to describe or specify the existing Ogg container format.
  110. Readers unfamiliar with the basic concepts mentioned above are encouraged to
  111. review the details in <xref target="RFC3533"/>.
  112. </t>
  113. </section>
  114. <section anchor="terminology" title="Terminology">
  115. <t>
  116. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
  117. "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this
  118. document are to be interpreted as described in <xref target="RFC2119"/>.
  119. </t>
  120. <t>
  121. Implementations that fail to satisfy one or more "MUST" requirements are
  122. considered non-compliant.
  123. Implementations that satisfy all "MUST" requirements, but fail to satisfy one
  124. or more "SHOULD" requirements are said to be "conditionally compliant".
  125. All other implementations are "unconditionally compliant".
  126. </t>
  127. </section>
  128. <section anchor="packet_organization" title="Packet Organization">
  129. <t>
  130. An Opus stream is organized as follows.
  131. </t>
  132. <t>
  133. There are two mandatory header packets.
  134. The granule position of the pages on which these packets complete MUST be zero.
  135. </t>
  136. <t>
  137. The first packet in the logical Ogg bitstream MUST contain the identification
  138. (ID) header, which uniquely identifies a stream as Opus audio.
  139. The format of this header is defined in <xref target="id_header"/>.
  140. It MUST be placed alone (without any other packet data) on the first page of
  141. the logical Ogg bitstream, and must complete on that page.
  142. This page MUST have its 'beginning of stream' flag set.
  143. </t>
  144. <t>
  145. The second packet in the logical Ogg bitstream MUST contain the comment header,
  146. which contains user-supplied metadata.
  147. The format of this header is defined in <xref target="comment_header"/>.
  148. It MAY span one or more pages, beginning on the second page of the logical
  149. stream.
  150. However many pages it spans, the comment header packet MUST finish the page on
  151. which it completes.
  152. </t>
  153. <t>
  154. All subsequent pages are audio data pages, and the Ogg packets they contain are
  155. audio data packets.
  156. Each audio data packet contains one Opus packet for each of N different
  157. streams, where N is typically one for mono or stereo, but may be greater than
  158. one for multichannel audio.
  159. The value N is specified in the ID header (see
  160. <xref target="channel_mapping"/>), and is fixed over the entire length of the
  161. logical Ogg bitstream.
  162. </t>
  163. <t>
  164. The first N-1 Opus packets, if any, are packed one after another into the Ogg
  165. packet, using the self-delimiting framing from Appendix&nbsp;B of
  166. <xref target="RFC6716"/>.
  167. The remaining Opus packet is packed at the end of the Ogg packet using the
  168. regular, undelimited framing from Section&nbsp;3 of <xref target="RFC6716"/>.
  169. All of the Opus packets in a single Ogg packet MUST be constrained to have the
  170. same duration.
  171. A decoder SHOULD treat any Opus packet whose duration is different from that of
  172. the first Opus packet in an Ogg packet as if it were an Opus packet with an
  173. illegal TOC sequence.
  174. </t>
  175. <t>
  176. The coding mode (SILK, Hybrid, or CELT), audio bandwidth, channel count,
  177. duration (frame size), and number of frames per packet, are indicated in the
  178. TOC (table of contents) in the first byte of each Opus packet, as described
  179. in Section&nbsp;3.1 of&nbsp;<xref target="RFC6716"/>.
  180. The combination of mode, audio bandwidth, and frame size is referred to as
  181. the configuration of an Opus packet.
  182. </t>
  183. <t>
  184. The first audio data page SHOULD NOT have the 'continued packet' flag set
  185. (which would indicate the first audio data packet is continued from a previous
  186. page).
  187. Packets MUST be placed into Ogg pages in order until the end of stream.
  188. Audio packets MAY span page boundaries.
  189. A decoder MUST treat a zero-octet audio data packet as if it were an Opus
  190. packet with an illegal TOC sequence.
  191. The last page SHOULD have the 'end of stream' flag set, but implementations
  192. should be prepared to deal with truncated streams that do not have a page
  193. marked 'end of stream'.
  194. The final packet on the last page SHOULD NOT be a continued packet, i.e., the
  195. final lacing value should be less than 255.
  196. There MUST NOT be any more pages in an Opus logical bitstream after a page
  197. marked 'end of stream'.
  198. </t>
  199. </section>
  200. <section anchor="granpos" title="Granule Position">
  201. <t>
  202. The granule position of an audio data page encodes the total number of PCM
  203. samples in the stream up to and including the last fully-decodable sample from
  204. the last packet completed on that page.
  205. A page that is entirely spanned by a single packet (that completes on a
  206. subsequent page) has no granule position, and the granule position field MUST
  207. be set to the special value '-1' in two's complement.
  208. </t>
  209. <t>
  210. The granule position of an audio data page is in units of PCM audio samples at
  211. a fixed rate of 48&nbsp;kHz (per channel; a stereo stream's granule position
  212. does not increment at twice the speed of a mono stream).
  213. It is possible to run an Opus decoder at other sampling rates, but the value
  214. in the granule position field always counts samples assuming a 48&nbsp;kHz
  215. decoding rate, and the rest of this specification makes the same assumption.
  216. </t>
  217. <t>
  218. The duration of an Opus packet may be any multiple of 2.5&nbsp;ms, up to a
  219. maximum of 120&nbsp;ms.
  220. This duration is encoded in the TOC sequence at the beginning of each packet.
  221. The number of samples returned by a decoder corresponds to this duration
  222. exactly, even for the first few packets.
  223. For example, a 20&nbsp;ms packet fed to a decoder running at 48&nbsp;kHz will
  224. always return 960&nbsp;samples.
  225. A demuxer can parse the TOC sequence at the beginning of each Ogg packet to
  226. work backwards or forwards from a packet with a known granule position (i.e.,
  227. the last packet completed on some page) in order to assign granule positions
  228. to every packet, or even every individual sample.
  229. The one exception is the last page in the stream, as described below.
  230. </t>
  231. <t>
  232. All other pages with completed packets after the first MUST have a granule
  233. position equal to the number of samples contained in packets that complete on
  234. that page plus the granule position of the most recent page with completed
  235. packets.
  236. This guarantees that a demuxer can assign individual packets the same granule
  237. position when working forwards as when working backwards.
  238. For this to work, there cannot be any gaps.
  239. </t>
  240. <section anchor="gap-repair" title="Repairing Gaps in Real-time Streams">
  241. <t>
  242. In order to support capturing a real-time stream that has lost or not
  243. transmitted packets, a muxer SHOULD emit packets that explicitly request the
  244. use of Packet Loss Concealment (PLC) in place of the missing packets.
  245. Only gaps that are a multiple of 2.5&nbsp;ms are repairable, as these are the
  246. only durations that can be created by packet loss or discontinuous
  247. transmission.
  248. Muxers need not handle other gap sizes.
  249. Creating the necessary packets involves synthesizing a TOC byte (defined in
  250. Section&nbsp;3.1 of&nbsp;<xref target="RFC6716"/>)&mdash;and whatever
  251. additional internal framing is needed&mdash;to indicate the packet duration
  252. for each stream.
  253. The actual length of each missing Opus frame inside the packet is zero bytes,
  254. as defined in Section&nbsp;3.2.1 of&nbsp;<xref target="RFC6716"/>.
  255. </t>
  256. <t>
  257. Zero-byte frames MAY be packed into packets using any of codes&nbsp;0, 1,
  258. 2, or&nbsp;3.
  259. When successive frames have the same configuration, the higher code packings
  260. reduce overhead.
  261. Likewise, if the TOC configuration matches, the muxer MAY further combine the
  262. empty frames with previous or subsequent non-zero-length frames (using
  263. code&nbsp;2 or VBR code&nbsp;3).
  264. </t>
  265. <t>
  266. <xref target="RFC6716"/> does not impose any requirements on the PLC, but this
  267. section outlines choices that are expected to have a positive influence on
  268. most PLC implementations, including the reference implementation.
  269. Synthesized TOC bytes SHOULD maintain the same mode, audio bandwidth,
  270. channel count, and frame size as the previous packet (if any).
  271. This is the simplest and usually the most well-tested case for the PLC to
  272. handle and it covers all losses that do not include a configuration switch,
  273. as defined in Section&nbsp;4.5 of&nbsp;<xref target="RFC6716"/>.
  274. </t>
  275. <t>
  276. When a previous packet is available, keeping the audio bandwidth and channel
  277. count the same allows the PLC to provide maximum continuity in the concealment
  278. data it generates.
  279. However, if the size of the gap is not a multiple of the most recent frame
  280. size, then the frame size will have to change for at least some frames.
  281. Such changes SHOULD be delayed as long as possible to simplify
  282. things for PLC implementations.
  283. </t>
  284. <t>
  285. As an example, a 95&nbsp;ms gap could be encoded as nineteen 5&nbsp;ms frames
  286. in two bytes with a single CBR code&nbsp;3 packet.
  287. If the previous frame size was 20&nbsp;ms, using four 20&nbsp;ms frames
  288. followed by three 5&nbsp;ms frames requires 4&nbsp;bytes (plus an extra byte
  289. of Ogg lacing overhead), but allows the PLC to use its well-tested steady
  290. state behavior for as long as possible.
  291. The total bitrate of the latter approach, including Ogg overhead, is about
  292. 0.4&nbsp;kbps, so the impact on file size is minimal.
  293. </t>
  294. <t>
  295. Changing modes is discouraged, since this causes some decoder implementations
  296. to reset their PLC state.
  297. However, SILK and Hybrid mode frames cannot fill gaps that are not a multiple
  298. of 10&nbsp;ms.
  299. If switching to CELT mode is needed to match the gap size, a muxer SHOULD do
  300. so at the end of the gap to allow the PLC to function for as long as possible.
  301. </t>
  302. <t>
  303. In the example above, if the previous frame was a 20&nbsp;ms SILK mode frame,
  304. the better solution is to synthesize a packet describing four 20&nbsp;ms SILK
  305. frames, followed by a packet with a single 10&nbsp;ms SILK
  306. frame, and finally a packet with a 5&nbsp;ms CELT frame, to fill the 95&nbsp;ms
  307. gap.
  308. This also requires four bytes to describe the synthesized packet data (two
  309. bytes for a CBR code 3 and one byte each for two code 0 packets) but three
  310. bytes of Ogg lacing overhead are required to mark the packet boundaries.
  311. At 0.6 kbps, this is still a minimal bitrate impact over a naive, low quality
  312. solution.
  313. </t>
  314. <t>
  315. Since medium-band audio is an option only in the SILK mode, wideband frames
  316. SHOULD be generated if switching from that configuration to CELT mode, to
  317. ensure that any PLC implementation which does try to migrate state between
  318. the modes will be able to preserve all of the available audio bandwidth.
  319. </t>
  320. </section>
  321. <section anchor="preskip" title="Pre-skip">
  322. <t>
  323. There is some amount of latency introduced during the decoding process, to
  324. allow for overlap in the CELT mode, stereo mixing in the SILK mode, and
  325. resampling.
  326. The encoder will also introduce latency (though the exact amount is not
  327. specified).
  328. Therefore, the first few samples produced by the decoder do not correspond to
  329. real input audio, but are instead composed of padding inserted by the encoder
  330. to compensate for this latency.
  331. These samples need to be stored and decoded, as Opus is an asymptotically
  332. convergent predictive codec, meaning the decoded contents of each frame depend
  333. on the recent history of decoder inputs.
  334. However, a decoder will want to skip these samples after decoding them.
  335. </t>
  336. <t>
  337. A 'pre-skip' field in the ID header (see <xref target="id_header"/>) signals
  338. the number of samples which SHOULD be skipped (decoded but discarded) at the
  339. beginning of the stream.
  340. This provides sufficient history to the decoder so that it has already
  341. converged before the stream's output begins.
  342. It may also be used to perform sample-accurate cropping of existing encoded
  343. streams.
  344. This amount need not be a multiple of 2.5&nbsp;ms, may be smaller than a single
  345. packet, or may span the contents of several packets.
  346. </t>
  347. </section>
  348. <section anchor="pcm_sample_position" title="PCM Sample Position">
  349. <t>
  350. <figure align="center">
  351. <preamble>
  352. The PCM sample position is determined from the granule position using the
  353. formula
  354. </preamble>
  355. <artwork align="center"><![CDATA[
  356. 'PCM sample position' = 'granule position' - 'pre-skip' .
  357. ]]></artwork>
  358. </figure>
  359. </t>
  360. <t>
  361. For example, if the granule position of the first audio data page is 59,971,
  362. and the pre-skip is 11,971, then the PCM sample position of the last decoded
  363. sample from that page is 48,000.
  364. <figure align="center">
  365. <preamble>
  366. This can be converted into a playback time using the formula
  367. </preamble>
  368. <artwork align="center"><![CDATA[
  369. 'PCM sample position'
  370. 'playback time' = --------------------- .
  371. 48000.0
  372. ]]></artwork>
  373. </figure>
  374. </t>
  375. <t>
  376. The initial PCM sample position before any samples are played is normally '0'.
  377. In this case, the PCM sample position of the first audio sample to be played
  378. starts at '1', because it marks the time on the clock
  379. <spanx style="emph">after</spanx> that sample has been played, and a stream
  380. that is exactly one second long has a final PCM sample position of '48000',
  381. as in the example here.
  382. </t>
  383. <t>
  384. Vorbis streams use a granule position smaller than the number of audio samples
  385. contained in the first audio data page to indicate that some of those samples
  386. must be trimmed from the output (see <xref target="vorbis-trim"/>).
  387. However, to do so, Vorbis requires that the first audio data page contains
  388. exactly two packets, in order to allow the decoder to perform PCM position
  389. adjustments before needing to return any PCM data.
  390. Opus uses the pre-skip mechanism for this purpose instead, since the encoder
  391. may introduce more than a single packet's worth of latency, and since very
  392. large packets in streams with a very large number of channels might not fit
  393. on a single page.
  394. </t>
  395. </section>
  396. <section anchor="end_trimming" title="End Trimming">
  397. <t>
  398. The page with the 'end of stream' flag set MAY have a granule position that
  399. indicates the page contains less audio data than would normally be returned by
  400. decoding up through the final packet.
  401. This is used to end the stream somewhere other than an even frame boundary.
  402. The granule position of the most recent audio data page with completed packets
  403. is used to make this determination, or '0' is used if there were no previous
  404. audio data pages with a completed packet.
  405. The difference between these granule positions indicates how many samples to
  406. keep after decoding the packets that completed on the final page.
  407. The remaining samples are discarded.
  408. The number of discarded samples SHOULD be no larger than the number decoded
  409. from the last packet.
  410. </t>
  411. </section>
  412. <section anchor="start_granpos_restrictions"
  413. title="Restrictions on the Initial Granule Position">
  414. <t>
  415. The granule position of the first audio data page with a completed packet MAY
  416. be larger than the number of samples contained in packets that complete on
  417. that page, however it MUST NOT be smaller, unless that page has the 'end of
  418. stream' flag set.
  419. Allowing a granule position larger than the number of samples allows the
  420. beginning of a stream to be cropped or a live stream to be joined without
  421. rewriting the granule position of all the remaining pages.
  422. This means that the PCM sample position just before the first sample to be
  423. played may be larger than '0'.
  424. Synchronization when multiplexing with other logical streams still uses the PCM
  425. sample position relative to '0' to compute sample times.
  426. This does not affect the behavior of pre-skip: exactly 'pre-skip' samples
  427. should be skipped from the beginning of the decoded output, even if the
  428. initial PCM sample position is greater than zero.
  429. </t>
  430. <t>
  431. On the other hand, a granule position that is smaller than the number of
  432. decoded samples prevents a demuxer from working backwards to assign each
  433. packet or each individual sample a valid granule position, since granule
  434. positions must be non-negative.
  435. A decoder MUST reject as invalid any stream where the granule position is
  436. smaller than the number of samples contained in packets that complete on the
  437. first audio data page with a completed packet, unless that page has the 'end
  438. of stream' flag set.
  439. It MAY defer this action until it decodes the last packet completed on that
  440. page.
  441. </t>
  442. <t>
  443. If that page has the 'end of stream' flag set, a demuxer MUST reject as invalid
  444. any stream where its granule position is smaller than the 'pre-skip' amount.
  445. This would indicate that more samples should be skipped from the initial
  446. decoded output than exist in the stream.
  447. If the granule position is smaller than the number of decoded samples produced
  448. by the packets that complete on that page, then a demuxer MUST use an initial
  449. granule position of '0', and can work forwards from '0' to timestamp
  450. individual packets.
  451. If the granule position is larger than the number of decoded samples available,
  452. then the demuxer MUST still work backwards as described above, even if the
  453. 'end of stream' flag is set, to determine the initial granule position, and
  454. thus the initial PCM sample position.
  455. Both of these will be greater than '0' in this case.
  456. </t>
  457. </section>
  458. <section anchor="seeking_and_preroll" title="Seeking and Pre-roll">
  459. <t>
  460. Seeking in Ogg files is best performed using a bisection search for a page
  461. whose granule position corresponds to a PCM position at or before the seek
  462. target.
  463. With appropriately weighted bisection, accurate seeking can be performed with
  464. just three or four bisections even in multi-gigabyte files.
  465. See <xref target="seeking"/> for general implementation guidance.
  466. </t>
  467. <t>
  468. When seeking within an Ogg Opus stream, the decoder SHOULD start decoding (and
  469. discarding the output) at least 3840&nbsp;samples (80&nbsp;ms) prior to the
  470. seek target in order to ensure that the output audio is correct by the time it
  471. reaches the seek target.
  472. This 'pre-roll' is separate from, and unrelated to, the 'pre-skip' used at the
  473. beginning of the stream.
  474. If the point 80&nbsp;ms prior to the seek target comes before the initial PCM
  475. sample position, the decoder SHOULD start decoding from the beginning of the
  476. stream, applying pre-skip as normal, regardless of whether the pre-skip is
  477. larger or smaller than 80&nbsp;ms, and then continue to discard the samples
  478. required to reach the seek target (if any).
  479. </t>
  480. </section>
  481. </section>
  482. <section anchor="headers" title="Header Packets">
  483. <t>
  484. An Opus stream contains exactly two mandatory header packets:
  485. an identification header and a comment header.
  486. </t>
  487. <section anchor="id_header" title="Identification Header">
  488. <figure anchor="id_header_packet" title="ID Header Packet" align="center">
  489. <artwork align="center"><![CDATA[
  490. 0 1 2 3
  491. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  492. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  493. | 'O' | 'p' | 'u' | 's' |
  494. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  495. | 'H' | 'e' | 'a' | 'd' |
  496. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  497. | Version = 1 | Channel Count | Pre-skip |
  498. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  499. | Input Sample Rate (Hz) |
  500. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  501. | Output Gain (Q7.8 in dB) | Mapping Family| |
  502. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ :
  503. | |
  504. : Optional Channel Mapping Table... :
  505. | |
  506. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  507. ]]></artwork>
  508. </figure>
  509. <t>
  510. The fields in the identification (ID) header have the following meaning:
  511. <list style="numbers">
  512. <t><spanx style="strong">Magic Signature</spanx>:
  513. <vspace blankLines="1"/>
  514. This is an 8-octet (64-bit) field that allows codec identification and is
  515. human-readable.
  516. It contains, in order, the magic numbers:
  517. <list style="empty">
  518. <t>0x4F 'O'</t>
  519. <t>0x70 'p'</t>
  520. <t>0x75 'u'</t>
  521. <t>0x73 's'</t>
  522. <t>0x48 'H'</t>
  523. <t>0x65 'e'</t>
  524. <t>0x61 'a'</t>
  525. <t>0x64 'd'</t>
  526. </list>
  527. Starting with "Op" helps distinguish it from audio data packets, as this is an
  528. invalid TOC sequence.
  529. <vspace blankLines="1"/>
  530. </t>
  531. <t><spanx style="strong">Version</spanx> (8 bits, unsigned):
  532. <vspace blankLines="1"/>
  533. The version number MUST always be '1' for this version of the encapsulation
  534. specification.
  535. Implementations SHOULD treat streams where the upper four bits of the version
  536. number match that of a recognized specification as backwards-compatible with
  537. that specification.
  538. That is, the version number can be split into "major" and "minor" version
  539. sub-fields, with changes to the "minor" sub-field (in the lower four bits)
  540. signaling compatible changes.
  541. For example, a decoder implementing this specification SHOULD accept any stream
  542. with a version number of '15' or less, and SHOULD assume any stream with a
  543. version number '16' or greater is incompatible.
  544. The initial version '1' was chosen to keep implementations from relying on this
  545. octet as a null terminator for the "OpusHead" string.
  546. <vspace blankLines="1"/>
  547. </t>
  548. <t><spanx style="strong">Output Channel Count</spanx> 'C' (8 bits, unsigned):
  549. <vspace blankLines="1"/>
  550. This is the number of output channels.
  551. This might be different than the number of encoded channels, which can change
  552. on a packet-by-packet basis.
  553. This value MUST NOT be zero.
  554. The maximum allowable value depends on the channel mapping family, and might be
  555. as large as 255.
  556. See <xref target="channel_mapping"/> for details.
  557. <vspace blankLines="1"/>
  558. </t>
  559. <t><spanx style="strong">Pre-skip</spanx> (16 bits, unsigned, little
  560. endian):
  561. <vspace blankLines="1"/>
  562. This is the number of samples (at 48&nbsp;kHz) to discard from the decoder
  563. output when starting playback, and also the number to subtract from a page's
  564. granule position to calculate its PCM sample position.
  565. When cropping the beginning of existing Ogg Opus streams, a pre-skip of at
  566. least 3,840&nbsp;samples (80&nbsp;ms) is RECOMMENDED to ensure complete
  567. convergence in the decoder.
  568. <vspace blankLines="1"/>
  569. </t>
  570. <t><spanx style="strong">Input Sample Rate</spanx> (32 bits, unsigned, little
  571. endian):
  572. <vspace blankLines="1"/>
  573. This field is <spanx style="emph">not</spanx> the sample rate to use for
  574. playback of the encoded data.
  575. <vspace blankLines="1"/>
  576. Opus can switch between internal audio bandwidths of 4, 6, 8, 12, and
  577. 20&nbsp;kHz.
  578. Each packet in the stream may have a different audio bandwidth.
  579. Regardless of the audio bandwidth, the reference decoder supports decoding any
  580. stream at a sample rate of 8, 12, 16, 24, or 48&nbsp;kHz.
  581. The original sample rate of the encoder input is not preserved by the lossy
  582. compression.
  583. <vspace blankLines="1"/>
  584. An Ogg Opus player SHOULD select the playback sample rate according to the
  585. following procedure:
  586. <list style="numbers">
  587. <t>If the hardware supports 48&nbsp;kHz playback, decode at 48&nbsp;kHz.</t>
  588. <t>Otherwise, if the hardware's highest available sample rate is a supported
  589. rate, decode at this sample rate.</t>
  590. <t>Otherwise, if the hardware's highest available sample rate is less than
  591. 48&nbsp;kHz, decode at the next highest supported rate above this and
  592. resample.</t>
  593. <t>Otherwise, decode at 48&nbsp;kHz and resample.</t>
  594. </list>
  595. However, the 'Input Sample Rate' field allows the encoder to pass the sample
  596. rate of the original input stream as metadata.
  597. This may be useful when the user requires the output sample rate to match the
  598. input sample rate.
  599. For example, a non-player decoder writing PCM format samples to disk might
  600. choose to resample the output audio back to the original input sample rate to
  601. reduce surprise to the user, who might reasonably expect to get back a file
  602. with the same sample rate as the one they fed to the encoder.
  603. <vspace blankLines="1"/>
  604. A value of zero indicates 'unspecified'.
  605. Encoders SHOULD write the actual input sample rate or zero, but decoder
  606. implementations which do something with this field SHOULD take care to behave
  607. sanely if given crazy values (e.g., do not actually upsample the output to
  608. 10 MHz if requested).
  609. <vspace blankLines="1"/>
  610. </t>
  611. <t><spanx style="strong">Output Gain</spanx> (16 bits, signed, little
  612. endian):
  613. <vspace blankLines="1"/>
  614. This is a gain to be applied by the decoder.
  615. It is 20*log10 of the factor to scale the decoder output by to achieve the
  616. desired playback volume, stored in a 16-bit, signed, two's complement
  617. fixed-point value with 8 fractional bits (i.e., Q7.8).
  618. <figure align="center">
  619. <preamble>
  620. To apply the gain, a decoder could use
  621. </preamble>
  622. <artwork align="center"><![CDATA[
  623. sample *= pow(10, output_gain/(20.0*256)) ,
  624. ]]></artwork>
  625. <postamble>
  626. where output_gain is the raw 16-bit value from the header.
  627. </postamble>
  628. </figure>
  629. <vspace blankLines="1"/>
  630. Virtually all players and media frameworks should apply it by default.
  631. If a player chooses to apply any volume adjustment or gain modification, such
  632. as the R128_TRACK_GAIN (see <xref target="comment_header"/>) or a user-facing
  633. volume knob, the adjustment MUST be applied in addition to this output gain in
  634. order to achieve playback at the desired volume.
  635. <vspace blankLines="1"/>
  636. An encoder SHOULD set this field to zero, and instead apply any gain prior to
  637. encoding, when this is possible and does not conflict with the user's wishes.
  638. The output gain should only be nonzero when the gain is adjusted after
  639. encoding, or when the user wishes to adjust the gain for playback while
  640. preserving the ability to recover the original signal amplitude.
  641. <vspace blankLines="1"/>
  642. Although the output gain has enormous range (+/- 128 dB, enough to amplify
  643. inaudible sounds to the threshold of physical pain), most applications can
  644. only reasonably use a small portion of this range around zero.
  645. The large range serves in part to ensure that gain can always be losslessly
  646. transferred between OpusHead and R128_TRACK_GAIN (see below) without
  647. saturating.
  648. <vspace blankLines="1"/>
  649. </t>
  650. <t><spanx style="strong">Channel Mapping Family</spanx> (8 bits,
  651. unsigned):
  652. <vspace blankLines="1"/>
  653. This octet indicates the order and semantic meaning of the various channels
  654. encoded in each Ogg packet.
  655. <vspace blankLines="1"/>
  656. Each possible value of this octet indicates a mapping family, which defines a
  657. set of allowed channel counts, and the ordered set of channel names for each
  658. allowed channel count.
  659. The details are described in <xref target="channel_mapping"/>.
  660. </t>
  661. <t><spanx style="strong">Channel Mapping Table</spanx>:
  662. This table defines the mapping from encoded streams to output channels.
  663. It is omitted when the channel mapping family is 0, but REQUIRED otherwise.
  664. Its contents are specified in <xref target="channel_mapping"/>.
  665. </t>
  666. </list>
  667. </t>
  668. <t>
  669. All fields in the ID headers are REQUIRED, except for the channel mapping
  670. table, which is omitted when the channel mapping family is 0.
  671. Implementations SHOULD reject ID headers which do not contain enough data for
  672. these fields, even if they contain a valid Magic Signature.
  673. Future versions of this specification, even backwards-compatible versions,
  674. might include additional fields in the ID header.
  675. If an ID header has a compatible major version, but a larger minor version,
  676. an implementation MUST NOT reject it for containing additional data not
  677. specified here.
  678. However, implementations MAY reject streams in which the ID header does not
  679. complete on the first page.
  680. </t>
  681. <section anchor="channel_mapping" title="Channel Mapping">
  682. <t>
  683. An Ogg Opus stream allows mapping one number of Opus streams (N) to a possibly
  684. larger number of decoded channels (M+N) to yet another number of output
  685. channels (C), which might be larger or smaller than the number of decoded
  686. channels.
  687. The order and meaning of these channels are defined by a channel mapping,
  688. which consists of the 'channel mapping family' octet and, for channel mapping
  689. families other than family&nbsp;0, a channel mapping table, as illustrated in
  690. <xref target="channel_mapping_table"/>.
  691. </t>
  692. <figure anchor="channel_mapping_table" title="Channel Mapping Table"
  693. align="center">
  694. <artwork align="center"><![CDATA[
  695. 0 1 2 3
  696. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  697. +-+-+-+-+-+-+-+-+
  698. | Stream Count |
  699. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  700. | Coupled Count | Channel Mapping... :
  701. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  702. ]]></artwork>
  703. </figure>
  704. <t>
  705. The fields in the channel mapping table have the following meaning:
  706. <list style="numbers" counter="8">
  707. <t><spanx style="strong">Stream Count</spanx> 'N' (8 bits, unsigned):
  708. <vspace blankLines="1"/>
  709. This is the total number of streams encoded in each Ogg packet.
  710. This value is required to correctly parse the packed Opus packets inside an
  711. Ogg packet, as described in <xref target="packet_organization"/>.
  712. This value MUST NOT be zero, as without at least one Opus packet with a valid
  713. TOC sequence, a demuxer cannot recover the duration of an Ogg packet.
  714. <vspace blankLines="1"/>
  715. For channel mapping family&nbsp;0, this value defaults to 1, and is not coded.
  716. <vspace blankLines="1"/>
  717. </t>
  718. <t><spanx style="strong">Coupled Stream Count</spanx> 'M' (8 bits, unsigned):
  719. This is the number of streams whose decoders should be configured to produce
  720. two channels.
  721. This MUST be no larger than the total number of streams, N.
  722. <vspace blankLines="1"/>
  723. Each packet in an Opus stream has an internal channel count of 1 or 2, which
  724. can change from packet to packet.
  725. This is selected by the encoder depending on the bitrate and the audio being
  726. encoded.
  727. The original channel count of the encoder input is not preserved by the lossy
  728. compression.
  729. <vspace blankLines="1"/>
  730. Regardless of the internal channel count, any Opus stream can be decoded as
  731. mono (a single channel) or stereo (two channels) by appropriate initialization
  732. of the decoder.
  733. The 'coupled stream count' field indicates that the first M Opus decoders are
  734. to be initialized for stereo output, and the remaining N-M decoders are to be
  735. initialized for mono only.
  736. The total number of decoded channels, (M+N), MUST be no larger than 255, as
  737. there is no way to index more channels than that in the channel mapping.
  738. <vspace blankLines="1"/>
  739. For channel mapping family&nbsp;0, this value defaults to C-1 (i.e., 0 for mono
  740. and 1 for stereo), and is not coded.
  741. <vspace blankLines="1"/>
  742. </t>
  743. <t><spanx style="strong">Channel Mapping</spanx> (8*C bits):
  744. This contains one octet per output channel, indicating which decoded channel
  745. should be used for each one.
  746. Let 'index' be the value of this octet for a particular output channel.
  747. This value MUST either be smaller than (M+N), or be the special value 255.
  748. If 'index' is less than 2*M, the output MUST be taken from decoding stream
  749. ('index'/2) as stereo and selecting the left channel if 'index' is even, and
  750. the right channel if 'index' is odd.
  751. If 'index' is 2*M or larger, the output MUST be taken from decoding stream
  752. ('index'-M) as mono.
  753. If 'index' is 255, the corresponding output channel MUST contain pure silence.
  754. <vspace blankLines="1"/>
  755. The number of output channels, C, is not constrained to match the number of
  756. decoded channels (M+N).
  757. A single index value MAY appear multiple times, i.e., the same decoded channel
  758. might be mapped to multiple output channels.
  759. Some decoded channels might not be assigned to any output channel, as well.
  760. <vspace blankLines="1"/>
  761. For channel mapping family&nbsp;0, the first index defaults to 0, and if C==2,
  762. the second index defaults to 1.
  763. Neither index is coded.
  764. </t>
  765. </list>
  766. </t>
  767. <t>
  768. After producing the output channels, the channel mapping family determines the
  769. semantic meaning of each one.
  770. Currently there are three defined mapping families, although more may be added.
  771. </t>
  772. <section anchor="channel_mapping_0" title="Channel Mapping Family 0">
  773. <t>
  774. Allowed numbers of channels: 1 or 2.
  775. RTP mapping.
  776. </t>
  777. <t>
  778. <list style="symbols">
  779. <t>1 channel: monophonic (mono).</t>
  780. <t>2 channels: stereo (left, right).</t>
  781. </list>
  782. <spanx style="strong">Special mapping</spanx>: This channel mapping value also
  783. indicates that the contents consists of a single Opus stream that is stereo if
  784. and only if C==2, with stream index 0 mapped to output channel 0 (mono, or
  785. left channel) and stream index 1 mapped to output channel 1 (right channel)
  786. if stereo.
  787. When the 'channel mapping family' octet has this value, the channel mapping
  788. table MUST be omitted from the ID header packet.
  789. </t>
  790. </section>
  791. <section anchor="channel_mapping_1" title="Channel Mapping Family 1">
  792. <t>
  793. Allowed numbers of channels: 1...8.
  794. Vorbis channel order.
  795. </t>
  796. <t>
  797. Each channel is assigned to a speaker location in a conventional surround
  798. arrangement.
  799. Specific locations depend on the number of channels, and are given below
  800. in order of the corresponding channel indicies.
  801. <list style="symbols">
  802. <t>1 channel: monophonic (mono).</t>
  803. <t>2 channels: stereo (left, right).</t>
  804. <t>3 channels: linear surround (left, center, right)</t>
  805. <t>4 channels: quadraphonic (front&nbsp;left, front&nbsp;right, rear&nbsp;left, rear&nbsp;right).</t>
  806. <t>5 channels: 5.0 surround (front&nbsp;left, front&nbsp;center, front&nbsp;right, rear&nbsp;left, rear&nbsp;right).</t>
  807. <t>6 channels: 5.1 surround (front&nbsp;left, front&nbsp;center, front&nbsp;right, rear&nbsp;left, rear&nbsp;right, LFE).</t>
  808. <t>7 channels: 6.1 surround (front&nbsp;left, front&nbsp;center, front&nbsp;right, side&nbsp;left, side&nbsp;right, rear&nbsp;center, LFE).</t>
  809. <t>8 channels: 7.1 surround (front&nbsp;left, front&nbsp;center, front&nbsp;right, side&nbsp;left, side&nbsp;right, rear&nbsp;left, rear&nbsp;right, LFE)</t>
  810. </list>
  811. </t>
  812. <t>
  813. This set of surround options and speaker location orderings is the same
  814. as those used by the Vorbis codec <xref target="vorbis-mapping"/>.
  815. The ordering is different from the one used by the
  816. WAVE <xref target="wave-multichannel"/> and
  817. FLAC <xref target="flac"/> formats,
  818. so correct ordering requires permutation of the output channels when decoding
  819. to or encoding from those formats.
  820. 'LFE' here refers to a Low Frequency Effects, often mapped to a subwoofer
  821. with no particular spatial position.
  822. Implementations SHOULD identify 'side' or 'rear' speaker locations with
  823. 'surround' and 'back' as appropriate when interfacing with audio formats
  824. or systems which prefer that terminology.
  825. </t>
  826. </section>
  827. <section anchor="channel_mapping_255"
  828. title="Channel Mapping Family 255">
  829. <t>
  830. Allowed numbers of channels: 1...255.
  831. No defined channel meaning.
  832. </t>
  833. <t>
  834. Channels are unidentified.
  835. General-purpose players SHOULD NOT attempt to play these streams, and offline
  836. decoders MAY deinterleave the output into separate PCM files, one per channel.
  837. Decoders SHOULD NOT produce output for channels mapped to stream index 255
  838. (pure silence) unless they have no other way to indicate the index of
  839. non-silent channels.
  840. </t>
  841. </section>
  842. <section anchor="channel_mapping_undefined"
  843. title="Undefined Channel Mappings">
  844. <t>
  845. The remaining channel mapping families (2...254) are reserved.
  846. A decoder encountering a reserved channel mapping family value SHOULD act as
  847. though the value is 255.
  848. </t>
  849. </section>
  850. <section anchor="downmix" title="Downmixing">
  851. <t>
  852. An Ogg Opus player MUST play any Ogg Opus stream with a channel mapping family
  853. of 0 or 1, even if the number of channels does not match the physically
  854. connected audio hardware.
  855. Players SHOULD perform channel mixing to increase or reduce the number of
  856. channels as needed.
  857. </t>
  858. <t>
  859. Implementations MAY use the following matricies to implement downmixing from
  860. multichannel files using <xref target="channel_mapping_1">Channel Mapping
  861. Family 1</xref>, which are known to give acceptable results for stereo.
  862. Matricies for 3 and 4 channels are normalized so each coefficent row sums
  863. to 1 to avoid clipping.
  864. For 5 or more channels they are normalized to 2 as a compromise between
  865. clipping and dynamic range reduction.
  866. </t>
  867. <t>
  868. In these matricies the front left and front right channels are generally
  869. passed through directly.
  870. When a surround channel is split between both the left and right stereo
  871. channels, coefficients are chosen so their squares sum to 1, which
  872. helps preserve the perceived intensity.
  873. Rear channels are mixed more diffusely or attenuated to maintain focus
  874. on the front channels.
  875. </t>
  876. <figure anchor="downmix-matrix-3"
  877. title="Stereo downmix matrix for the linear surround channel mapping"
  878. align="center">
  879. <artwork align="center"><![CDATA[
  880. L output = ( 0.585786 * left + 0.414214 * center )
  881. R output = ( 0.414214 * center + 0.585786 * right )
  882. ]]></artwork>
  883. <postamble>
  884. Exact coefficient values are 1 and 1/sqrt(2), multiplied by
  885. 1/(1 + 1/sqrt(2)) for normalization.
  886. </postamble>
  887. </figure>
  888. <figure anchor="downmix-matrix-4"
  889. title="Stereo downmix matrix for the quadraphonic channel mapping"
  890. align="center">
  891. <artwork align="center"><![CDATA[
  892. / \ / \ / FL \
  893. | L output | | 0.422650 0.000000 0.366025 0.211325 | | FR |
  894. | R output | = | 0.000000 0.422650 0.211325 0.366025 | | RL |
  895. \ / \ / \ RR /
  896. ]]></artwork>
  897. <postamble>
  898. Exact coefficient values are 1, sqrt(3)/2 and 1/2, multiplied by
  899. 1/(1&nbsp;+&nbsp;sqrt(3)/2&nbsp;+&nbsp;1/2) for normalization.
  900. </postamble>
  901. </figure>
  902. <figure anchor="downmix-matrix-5"
  903. title="Stereo downmix matrix for the 5.0 surround mapping"
  904. align="center">
  905. <artwork align="center"><![CDATA[
  906. / FL \
  907. / \ / \ | FC |
  908. | L | | 0.650802 0.460186 0.000000 0.563611 0.325401 | | FR |
  909. | R | = | 0.000000 0.460186 0.650802 0.325401 0.563611 | | RL |
  910. \ / \ / | RR |
  911. \ /
  912. ]]></artwork>
  913. <postamble>
  914. Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2 and 1/2, multiplied by
  915. 2/(1&nbsp;+&nbsp;1/sqrt(2)&nbsp;+&nbsp;sqrt(3)/2&nbsp;+&nbsp;1/2)
  916. for normalization.
  917. </postamble>
  918. </figure>
  919. <figure anchor="downmix-matrix-6"
  920. title="Stereo downmix matrix for the 5.1 surround mapping"
  921. align="center">
  922. <artwork align="center"><![CDATA[
  923. /FL \
  924. / \ / \ |FC |
  925. |L| | 0.529067 0.374107 0.000000 0.458186 0.264534 0.374107 | |FR |
  926. |R| = | 0.000000 0.374107 0.529067 0.264534 0.458186 0.374107 | |RL |
  927. \ / \ / |RR |
  928. \LFE/
  929. ]]></artwork>
  930. <postamble>
  931. Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2 and 1/2, multiplied by
  932. 2/(1&nbsp;+&nbsp;1/sqrt(2)&nbsp;+&nbsp;sqrt(3)/2&nbsp;+&nbsp;1/2 + 1/sqrt(2))
  933. for normalization.
  934. </postamble>
  935. </figure>
  936. <figure anchor="downmix-matrix-7"
  937. title="Stereo downmix matrix for the 6.1 surround mapping"
  938. align="center">
  939. <artwork align="center"><![CDATA[
  940. / \
  941. | 0.455310 0.321953 0.000000 0.394310 0.227655 0.278819 0.321953 |
  942. | 0.000000 0.321953 0.455310 0.227655 0.394310 0.278819 0.321953 |
  943. \ /
  944. ]]></artwork>
  945. <postamble>
  946. Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2, 1/2 and
  947. sqrt(3)/2/sqrt(2), multiplied by
  948. 2/(1&nbsp;+&nbsp;1/sqrt(2)&nbsp;+&nbsp;sqrt(3)/2&nbsp;+&nbsp;1/2 +
  949. sqrt(3)/2/sqrt(2) + 1/sqrt(2)) for normalization.
  950. The coeffients are in the same order as in <xref target="channel_mapping_1" />,
  951. and the matricies above.
  952. </postamble>
  953. </figure>
  954. <figure anchor="downmix-matrix-8"
  955. title="Stereo downmix matrix for the 7.1 surround mapping"
  956. align="center">
  957. <artwork align="center"><![CDATA[
  958. / \
  959. | .388631 .274804 .000000 .336565 .194316 .336565 .194316 .274804 |
  960. | .000000 .274804 .388631 .194316 .336565 .194316 .336565 .274804 |
  961. \ /
  962. ]]></artwork>
  963. <postamble>
  964. Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2 and 1/2, multiplied by
  965. 2/(2&nbsp;+&nbsp;2/sqrt(2)&nbsp;+&nbsp;sqrt(3)) for normalization.
  966. The coeffients are in the same order as in <xref target="channel_mapping_1" />,
  967. and the matricies above.
  968. </postamble>
  969. </figure>
  970. </section>
  971. </section> <!-- end channel_mapping_table -->
  972. </section> <!-- end id_header -->
  973. <section anchor="comment_header" title="Comment Header">
  974. <figure anchor="comment_header_packet" title="Comment Header Packet"
  975. align="center">
  976. <artwork align="center"><![CDATA[
  977. 0 1 2 3
  978. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  979. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  980. | 'O' | 'p' | 'u' | 's' |
  981. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  982. | 'T' | 'a' | 'g' | 's' |
  983. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  984. | Vendor String Length |
  985. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  986. | |
  987. : Vendor String... :
  988. | |
  989. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  990. | User Comment List Length |
  991. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  992. | User Comment #0 String Length |
  993. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  994. | |
  995. : User Comment #0 String... :
  996. | |
  997. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  998. | User Comment #1 String Length |
  999. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1000. : :
  1001. ]]></artwork>
  1002. </figure>
  1003. <t>
  1004. The comment header consists of a 64-bit magic signature, followed by data in
  1005. the same format as the <xref target="vorbis-comment"/> header used in Ogg
  1006. Vorbis, except (like Ogg Theora and Speex) the final "framing bit" specified
  1007. in the Vorbis spec is not present.
  1008. <list style="numbers">
  1009. <t><spanx style="strong">Magic Signature</spanx>:
  1010. <vspace blankLines="1"/>
  1011. This is an 8-octet (64-bit) field that allows codec identification and is
  1012. human-readable.
  1013. It contains, in order, the magic numbers:
  1014. <list style="empty">
  1015. <t>0x4F 'O'</t>
  1016. <t>0x70 'p'</t>
  1017. <t>0x75 'u'</t>
  1018. <t>0x73 's'</t>
  1019. <t>0x54 'T'</t>
  1020. <t>0x61 'a'</t>
  1021. <t>0x67 'g'</t>
  1022. <t>0x73 's'</t>
  1023. </list>
  1024. Starting with "Op" helps distinguish it from audio data packets, as this is an
  1025. invalid TOC sequence.
  1026. <vspace blankLines="1"/>
  1027. </t>
  1028. <t><spanx style="strong">Vendor String Length</spanx> (32 bits, unsigned,
  1029. little endian):
  1030. <vspace blankLines="1"/>
  1031. This field gives the length of the following vendor string, in octets.
  1032. It MUST NOT indicate that the vendor string is longer than the rest of the
  1033. packet.
  1034. <vspace blankLines="1"/>
  1035. </t>
  1036. <t><spanx style="strong">Vendor String</spanx> (variable length, UTF-8 vector):
  1037. <vspace blankLines="1"/>
  1038. This is a simple human-readable tag for vendor information, encoded as a UTF-8
  1039. string&nbsp;<xref target="RFC3629"/>.
  1040. No terminating null octet is required.
  1041. <vspace blankLines="1"/>
  1042. This tag is intended to identify the codec encoder and encapsulation
  1043. implementations, for tracing differences in technical behavior.
  1044. User-facing encoding applications can use the 'ENCODER' user comment tag
  1045. to identify themselves.
  1046. <vspace blankLines="1"/>
  1047. </t>
  1048. <t><spanx style="strong">User Comment List Length</spanx> (32 bits, unsigned,
  1049. little endian):
  1050. <vspace blankLines="1"/>
  1051. This field indicates the number of user-supplied comments.
  1052. It MAY indicate there are zero user-supplied comments, in which case there are
  1053. no additional fields in the packet.
  1054. It MUST NOT indicate that there are so many comments that the comment string
  1055. lengths would require more data than is available in the rest of the packet.
  1056. <vspace blankLines="1"/>
  1057. </t>
  1058. <t><spanx style="strong">User Comment #i String Length</spanx> (32 bits,
  1059. unsigned, little endian):
  1060. <vspace blankLines="1"/>
  1061. This field gives the length of the following user comment string, in octets.
  1062. There is one for each user comment indicated by the 'user comment list length'
  1063. field.
  1064. It MUST NOT indicate that the string is longer than the rest of the packet.
  1065. <vspace blankLines="1"/>
  1066. </t>
  1067. <t><spanx style="strong">User Comment #i String</spanx> (variable length, UTF-8
  1068. vector):
  1069. <vspace blankLines="1"/>
  1070. This field contains a single user comment string.
  1071. There is one for each user comment indicated by the 'user comment list length'
  1072. field.
  1073. </t>
  1074. </list>
  1075. </t>
  1076. <t>
  1077. The vendor string length and user comment list length are REQUIRED, and
  1078. implementations SHOULD reject comment headers that do not contain enough data
  1079. for these fields, or that do not contain enough data for the corresponding
  1080. vendor string or user comments they describe.
  1081. Making this check before allocating the associated memory to contain the data
  1082. helps prevent a possible Denial-of-Service (DoS) attack from small comment
  1083. headers that claim to contain strings longer than the entire packet or more
  1084. user comments than than could possibly fit in the packet.
  1085. </t>
  1086. <t>
  1087. The user comment strings follow the NAME=value format described by
  1088. <xref target="vorbis-comment"/> with the same recommended tag names.
  1089. </t>
  1090. <figure align="center">
  1091. <preamble>One new comment tag is introduced for Ogg Opus:</preamble>
  1092. <artwork align="left"><![CDATA[
  1093. R128_TRACK_GAIN=-573
  1094. ]]></artwork>
  1095. <postamble>
  1096. representing the volume shift needed to normalize the track's volume.
  1097. The gain is a Q7.8 fixed point number in dB, as in the ID header's 'output
  1098. gain' field.
  1099. </postamble>
  1100. </figure>
  1101. <t>
  1102. This tag is similar to the REPLAYGAIN_TRACK_GAIN tag in
  1103. Vorbis&nbsp;<xref target="replay-gain"/>, except that the normal volume
  1104. reference is the <xref target="EBU-R128"/> standard.
  1105. </t>
  1106. <t>
  1107. An Ogg Opus file MUST NOT have more than one such tag, and if present its
  1108. value MUST be an integer from -32768 to 32767, inclusive, represented in
  1109. ASCII with no whitespace.
  1110. If present, it MUST correctly represent the R128 normalization gain relative
  1111. to the 'output gain' field specified in the ID header.
  1112. If a player chooses to make use of the R128_TRACK_GAIN tag, it MUST be
  1113. applied <spanx style="emph">in addition</spanx> to the 'output gain' value.
  1114. If an encoder wishes to use R128 normalization, and the output gain is not
  1115. otherwise constrained or specified, the encoder SHOULD write the R128 gain
  1116. into the 'output gain' field and store a tag containing "R128_TRACK_GAIN=0".
  1117. That is, it should assume that by default tools will respect the 'output gain'
  1118. field, and not the comment tag.
  1119. If a tool modifies the ID header's 'output gain' field, it MUST also update or
  1120. remove the R128_TRACK_GAIN comment tag.
  1121. </t>
  1122. <t>
  1123. To avoid confusion with multiple normalization schemes, an Opus comment header
  1124. SHOULD NOT contain any of the REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK,
  1125. REPLAYGAIN_ALBUM_GAIN, or REPLAYGAIN_ALBUM_PEAK tags.
  1126. </t>
  1127. <t>
  1128. There is no Opus comment tag corresponding to REPLAYGAIN_ALBUM_GAIN.
  1129. That information should instead be stored in the ID header's 'output gain'
  1130. field.
  1131. </t>
  1132. </section>
  1133. </section>
  1134. <section anchor="packet_size_limits" title="Packet Size Limits">
  1135. <t>
  1136. Technically valid Opus packets can be arbitrarily large due to the padding
  1137. format, although the amount of non-padding data they can contain is bounded.
  1138. These packets might be spread over a similarly enormous number of Ogg pages.
  1139. Encoders SHOULD use no more padding than required to make a variable bitrate
  1140. (VBR) stream constant bitrate (CBR).
  1141. Decoders SHOULD avoid attempting to allocate excessive amounts of memory when
  1142. presented with a very large packet.
  1143. The presence of an extremely large packet in the stream could indicate a
  1144. memory exhaustion attack or stream corruption.
  1145. Decoders SHOULD reject a packet that is too large to process, and display a
  1146. warning message.
  1147. </t>
  1148. <t>
  1149. In an Ogg Opus stream, the largest possible valid packet that does not use
  1150. padding has a size of (61,298*N&nbsp;-&nbsp;2) octets, or about 60&nbsp;kB per
  1151. Opus stream.
  1152. With 255&nbsp;streams, this is 15,630,988&nbsp;octets (14.9&nbsp;MB) and can
  1153. span up to 61,298&nbsp;Ogg pages, all but one of which will have a granule
  1154. position of -1.
  1155. This is of course a very extreme packet, consisting of 255&nbsp;streams, each
  1156. containing 120&nbsp;ms of audio encoded as 2.5&nbsp;ms frames, each frame
  1157. using the maximum possible number of octets (1275) and stored in the least
  1158. efficient manner allowed (a VBR code&nbsp;3 Opus packet).
  1159. Even in such a packet, most of the data will be zeros as 2.5&nbsp;ms frames
  1160. cannot actually use all 1275&nbsp;octets.
  1161. The largest packet consisting of entirely useful data is
  1162. (15,326*N&nbsp;-&nbsp;2) octets, or about 15&nbsp;kB per stream.
  1163. This corresponds to 120&nbsp;ms of audio encoded as 10&nbsp;ms frames in either
  1164. SILK or Hybrid mode, but at a data rate of over 1&nbsp;Mbps, which makes little
  1165. sense for the quality achieved.
  1166. A more reasonable limit is (7,664*N&nbsp;-&nbsp;2) octets, or about 7.5&nbsp;kB
  1167. per stream.
  1168. This corresponds to 120&nbsp;ms of audio encoded as 20&nbsp;ms stereo CELT mode
  1169. frames, with a total bitrate just under 511&nbsp;kbps (not counting the Ogg
  1170. encapsulation overhead).
  1171. With N=8, the maximum number of channels currently defined by mapping
  1172. family&nbsp;1, this gives a maximum packet size of 61,310&nbsp;octets, or just
  1173. under 60&nbsp;kB.
  1174. This is still quite conservative, as it assumes each output channel is taken
  1175. from one decoded channel of a stereo packet.
  1176. An implementation could reasonably choose any of these numbers for its internal
  1177. limits.
  1178. </t>
  1179. </section>
  1180. <section anchor="encoder" title="Encoder Guidelines">
  1181. <t>
  1182. When encoding Opus files, Ogg encoders should take into account the
  1183. algorithmic delay of the Opus encoder.
  1184. </t>
  1185. <figure align="center">
  1186. <preamble>
  1187. In encoders derived from the reference implementation, the number of
  1188. samples can be queried with:
  1189. </preamble>
  1190. <artwork align="center"><![CDATA[
  1191. opus_encoder_ctl(encoder_state, OPUS_GET_LOOKAHEAD, &delay_samples);
  1192. ]]></artwork>
  1193. </figure>
  1194. <t>
  1195. To achieve good quality in the very first samples of a stream, the Ogg encoder
  1196. MAY use linear predictive coding (LPC) extrapolation
  1197. <xref target="linear-prediction"/> to generate at least 120 extra samples at
  1198. the beginning to avoid the Opus encoder having to encode a discontinuous
  1199. signal.
  1200. For an input file containing 'length' samples, the Ogg encoder SHOULD set the
  1201. pre-skip header value to delay_samples+extra_samples, encode at least
  1202. length+delay_samples+extra_samples samples, and set the granulepos of the last
  1203. page to length+delay_samples+extra_samples.
  1204. This ensures that the encoded file has the same duration as the original, with
  1205. no time offset. The best way to pad the end of the stream is to also use LPC
  1206. extrapolation, but zero-padding is also acceptable.
  1207. </t>
  1208. <section anchor="lpc" title="LPC Extrapolation">
  1209. <t>
  1210. The first step in LPC extrapolation is to compute linear prediction
  1211. coefficients. <xref target="lpc-sample"/>
  1212. When extending the end of the signal, order-N (typically with N ranging from 8
  1213. to 40) LPC analysis is performed on a window near the end of the signal.
  1214. The last N samples are used as memory to an infinite impulse response (IIR)
  1215. filter.
  1216. </t>
  1217. <figure align="center">
  1218. <preamble>
  1219. The filter is then applied on a zero input to extrapolate the end of the signal.
  1220. Let a(k) be the kth LPC coefficient and x(n) be the nth sample of the signal,
  1221. each new sample past the end of the signal is computed as:
  1222. </preamble>
  1223. <artwork align="center"><![CDATA[
  1224. N
  1225. ---
  1226. x(n) = \ a(k)*x(n-k)
  1227. /
  1228. ---
  1229. k=1
  1230. ]]></artwork>
  1231. </figure>
  1232. <t>
  1233. The process is repeated independently for each channel.
  1234. It is possible to extend the beginning of the signal by applying the same
  1235. process backward in time.
  1236. When extending the beginning of the signal, it is best to apply a "fade in" to
  1237. the extrapolated signal, e.g. by multiplying it by a half-Hanning window
  1238. <xref target="hanning"/>.
  1239. </t>
  1240. </section>
  1241. <section anchor="continuous_chaining" title="Continuous Chaining">
  1242. <t>
  1243. In some applications, such as Internet radio, it is desirable to cut a long
  1244. stream into smaller chains, e.g. so the comment header can be updated.
  1245. This can be done simply by separating the input streams into segments and
  1246. encoding each segment independently.
  1247. The drawback of this approach is that it creates a small discontinuity
  1248. at the boundary due to the lossy nature of Opus.
  1249. An encoder MAY avoid this discontinuity by using the following procedure:
  1250. <list style="numbers">
  1251. <t>Encode the last frame of the first segment as an independent frame by
  1252. turning off all forms of inter-frame prediction.
  1253. De-emphasis is allowed.</t>
  1254. <t>Set the granulepos of the last page to a point near the end of the last
  1255. frame.</t>
  1256. <t>Begin the second segment with a copy of the last frame of the first
  1257. segment.</t>
  1258. <t>Set the pre-skip value of the second stream in such a way as to properly
  1259. join the two streams.</t>
  1260. <t>Continue the encoding process normally from there, without any reset to
  1261. the encoder.</t>
  1262. </list>
  1263. </t>
  1264. <figure align="center">
  1265. <preamble>
  1266. In encoders derived from the reference implementation, inter-frame prediction
  1267. can be turned off by calling:
  1268. </preamble>
  1269. <artwork align="center"><![CDATA[
  1270. opus_encoder_ctl(encoder_state, OPUS_SET_PREDICTION_DISABLED, 1);
  1271. ]]></artwork>
  1272. <postamble>
  1273. Prediction should be enabled again before resuming normal encoding, even
  1274. after a reset.
  1275. </postamble>
  1276. </figure>
  1277. </section>
  1278. </section>
  1279. <section anchor="implementation" title="Implementation Status">
  1280. <t>
  1281. A brief summary of major implementations of this draft is available
  1282. at <eref target="https://wiki.xiph.org/OggOpusImplementation"/>,
  1283. along with their status.
  1284. </t>
  1285. <t>
  1286. [Note to RFC Editor: please remove this entire section before
  1287. final publication per <xref target="RFC6982"/>.]
  1288. </t>
  1289. </section>
  1290. <section anchor="security" title="Security Considerations">
  1291. <t>
  1292. Implementations of the Opus codec need to take appropriate security
  1293. considerations into account, as outlined in <xref target="RFC4732"/>.
  1294. This is just as much a problem for the container as it is for the codec itself.
  1295. It is extremely important for the decoder to be robust against malicious
  1296. payloads.
  1297. Malicious payloads must not cause the decoder to overrun its allocated memory
  1298. or to take an excessive amount of resources to decode.
  1299. Although problems in encoders are typically rarer, the same applies to the
  1300. encoder.
  1301. Malicious audio streams must not cause the encoder to misbehave because this
  1302. would allow an attacker to attack transcoding gateways.
  1303. </t>
  1304. <t>
  1305. Like most other container formats, Ogg Opus files should not be used with
  1306. insecure ciphers or cipher modes that are vulnerable to known-plaintext
  1307. attacks.
  1308. Elements such as the Ogg page capture pattern and the magic signatures in the
  1309. ID header and the comment header all have easily predictable values, in
  1310. addition to various elements of the codec data itself.
  1311. </t>
  1312. </section>
  1313. <section anchor="content_type" title="Content Type">
  1314. <t>
  1315. An "Ogg Opus file" consists of one or more sequentially multiplexed segments,
  1316. each containing exactly one Ogg Opus stream.
  1317. The RECOMMENDED mime-type for Ogg Opus files is "audio/ogg".
  1318. </t>
  1319. <figure>
  1320. <preamble>
  1321. If more specificity is desired, one MAY indicate the presence of Opus streams
  1322. using the codecs parameter defined in <xref target="RFC6381"/>, e.g.,
  1323. </preamble>
  1324. <artwork align="center"><![CDATA[
  1325. audio/ogg; codecs=opus
  1326. ]]></artwork>
  1327. <postamble>
  1328. for an Ogg Opus file.
  1329. </postamble>
  1330. </figure>
  1331. <t>
  1332. The RECOMMENDED filename extension for Ogg Opus files is '.opus'.
  1333. </t>
  1334. <t>
  1335. When Opus is concurrently multiplexed with other streams in an Ogg container,
  1336. one SHOULD use one of the "audio/ogg", "video/ogg", or "application/ogg"
  1337. mime-types, as defined in <xref target="RFC5334"/>.
  1338. Such streams are not strictly "Ogg Opus files" as described above,
  1339. since they contain more than a single Opus stream per sequentially
  1340. multiplexed segment, e.g. video or multiple audio tracks.
  1341. In such cases the the '.opus' filename extension is NOT RECOMMENDED.
  1342. </t>
  1343. </section>
  1344. <section title="IANA Considerations">
  1345. <t>
  1346. This document has no actions for IANA.
  1347. </t>
  1348. </section>
  1349. <section anchor="Acknowledgments" title="Acknowledgments">
  1350. <t>
  1351. Thanks to Greg Maxwell, Christopher "Monty" Montgomery, and Jean-Marc Valin for
  1352. their valuable contributions to this document.
  1353. Additional thanks to Andrew D'Addesio, Greg Maxwell, and Vincent Penqeurc'h for
  1354. their feedback based on early implementations.
  1355. </t>
  1356. </section>
  1357. <section title="Copying Conditions">
  1358. <t>
  1359. The authors agree to grant third parties the irrevocable right to copy, use,
  1360. and distribute the work, with or without modification, in any medium, without
  1361. royalty, provided that, unless separate permission is granted, redistributed
  1362. modified works do not contain misleading author, version, name of work, or
  1363. endorsement information.
  1364. </t>
  1365. </section>
  1366. </middle>
  1367. <back>
  1368. <references title="Normative References">
  1369. &rfc2119;
  1370. &rfc3533;
  1371. &rfc3629;
  1372. &rfc5334;
  1373. &rfc6381;
  1374. &rfc6716;
  1375. <reference anchor="EBU-R128" target="https://tech.ebu.ch/loudness">
  1376. <front>
  1377. <title>Loudness Recommendation EBU R128</title>
  1378. <author>
  1379. <organization>EBU Technical Committee</organization>
  1380. </author>
  1381. <date month="August" year="2011"/>
  1382. </front>
  1383. </reference>
  1384. <reference anchor="vorbis-comment"
  1385. target="https://www.xiph.org/vorbis/doc/v-comment.html">
  1386. <front>
  1387. <title>Ogg Vorbis I Format Specification: Comment Field and Header
  1388. Specification</title>
  1389. <author initials="C." surname="Montgomery"
  1390. fullname="Christopher &quot;Monty&quot; Montgomery"/>
  1391. <date month="July" year="2002"/>
  1392. </front>
  1393. </reference>
  1394. </references>
  1395. <references title="Informative References">
  1396. <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.3550.xml"?-->
  1397. &rfc4732;
  1398. &rfc6982;
  1399. <reference anchor="flac"
  1400. target="https://xiph.org/flac/format.html">
  1401. <front>
  1402. <title>FLAC - Free Lossless Audio Codec Format Description</title>
  1403. <author initials="J." surname="Coalson" fullname="Josh Coalson"/>
  1404. <date month="January" year="2008"/>
  1405. </front>
  1406. </reference>
  1407. <reference anchor="hanning"
  1408. target="https://en.wikipedia.org/wiki/Hamming_function#Hann_.28Hanning.29_window">
  1409. <front>
  1410. <title>Hann window</title>
  1411. <author>
  1412. <organization>Wikipedia</organization>
  1413. </author>
  1414. <date month="May" year="2013"/>
  1415. </front>
  1416. </reference>
  1417. <reference anchor="linear-prediction"
  1418. target="https://en.wikipedia.org/wiki/Linear_predictive_coding">
  1419. <front>
  1420. <title>Linear Predictive Coding</title>
  1421. <author>
  1422. <organization>Wikipedia</organization>
  1423. </author>
  1424. <date month="January" year="2014"/>
  1425. </front>
  1426. </reference>
  1427. <reference anchor="lpc-sample"
  1428. target="https://svn.xiph.org/trunk/vorbis/lib/lpc.c">
  1429. <front>
  1430. <title>Autocorrelation LPC coeff generation algorithm
  1431. (Vorbis source code)</title>
  1432. <author initials="J." surname="Degener" fullname="Jutta Degener"/>
  1433. <author initials="C." surname="Bormann" fullname="Carsten Bormann"/>
  1434. <date month="November" year="1994"/>
  1435. </front>
  1436. </reference>
  1437. <reference anchor="replay-gain"
  1438. target="https://wiki.xiph.org/VorbisComment#Replay_Gain">
  1439. <front>
  1440. <title>VorbisComment: Replay Gain</title>
  1441. <author initials="C." surname="Parker" fullname="Conrad Parker"/>
  1442. <author initials="M." surname="Leese" fullname="Martin Leese"/>
  1443. <date month="June" year="2009"/>
  1444. </front>
  1445. </reference>
  1446. <reference anchor="seeking"
  1447. target="https://wiki.xiph.org/Seeking">
  1448. <front>
  1449. <title>Granulepos Encoding and How Seeking Really Works</title>
  1450. <author initials="S." surname="Pfeiffer" fullname="Silvia Pfeiffer"/>
  1451. <author initials="C." surname="Parker" fullname="Conrad Parker"/>
  1452. <author initials="G." surname="Maxwell" fullname="Greg Maxwell"/>
  1453. <date month="May" year="2012"/>
  1454. </front>
  1455. </reference>
  1456. <reference anchor="vorbis-mapping"
  1457. target="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9">
  1458. <front>
  1459. <title>The Vorbis I Specification, Section 4.3.9 Output Channel Order</title>
  1460. <author initials="C." surname="Montgomery"
  1461. fullname="Christopher &quot;Monty&quot; Montgomery"/>
  1462. <date month="January" year="2010"/>
  1463. </front>
  1464. </reference>
  1465. <reference anchor="vorbis-trim"
  1466. target="https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-130000A.2">
  1467. <front>
  1468. <title>The Vorbis I Specification, Appendix&nbsp;A: Embedding Vorbis
  1469. into an Ogg stream</title>
  1470. <author initials="C." surname="Montgomery"
  1471. fullname="Christopher &quot;Monty&quot; Montgomery"/>
  1472. <date month="November" year="2008"/>
  1473. </front>
  1474. </reference>
  1475. <reference anchor="wave-multichannel"
  1476. target="http://msdn.microsoft.com/en-us/windows/hardware/gg463006.aspx">
  1477. <front>
  1478. <title>Multiple Channel Audio Data and WAVE Files</title>
  1479. <author>
  1480. <organization>Microsoft Corporation</organization>
  1481. </author>
  1482. <date month="March" year="2007"/>
  1483. </front>
  1484. </reference>
  1485. </references>
  1486. </back>
  1487. </rfc>