oggstream.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <HTML><HEAD><TITLE>xiph.org: Ogg Vorbis documentation</TITLE>
  2. <BODY bgcolor="#ffffff" text="#202020" link="#006666" vlink="#000000">
  3. <nobr><a href="http://www.xiph.org/ogg/index.html"><img src="white-ogg.png" border=0><img
  4. src="vorbisword2.png" border=0></a></nobr><p>
  5. <h1><font color=#000070>
  6. Ogg logical and physical bitstream overview
  7. </font></h1>
  8. <em>Last update to this document: July 14, 2002</em><br>
  9. <h2>Ogg bitstreams</h2>
  10. Ogg codecs use octet vectors of raw, compressed data
  11. (<em>packets</em>). These compressed packets do not have any
  12. high-level structure or boundary information; strung together, they
  13. appear to be streams of random bytes with no landmarks.<p>
  14. Raw packets may be used directly by transport mechanisms that provide
  15. their own framing and packet-separation mechanisms (such as UDP
  16. datagrams). For stream based storage (such as files) and transport
  17. (such as TCP streams or pipes), Vorbis and other future Ogg codecs use
  18. the Ogg bitstream format to provide framing/sync, sync recapture
  19. after error, landmarks during seeking, and enough information to
  20. properly separate data back into packets at the original packet
  21. boundaries without relying on decoding to find packet boundaries.<p>
  22. <h2>Logical and physical bitstreams</h2>
  23. Raw packets are grouped and encoded into contiguous pages of
  24. structured bitstream data called <em>logical bitstreams</em>. A
  25. logical bitstream consists of pages, in order, belonging to a single
  26. codec instance. Each page is a self contained entity (although it is
  27. possible that a packet may be split and encoded across one or more
  28. pages); that is, the page decode mechanism is designed to recognize,
  29. verify and handle single pages at a time from the overall bitstream.<p>
  30. Multiple logical bitstreams can be combined (with restrictions) into a
  31. single <em>physical bitstream</em>. A physical bitstream consists of
  32. multiple logical bitstreams multiplexed at the page level and may
  33. include a 'meta-header' at the beginning of the multiplexed logical
  34. stream that serves as identification magic. Whole pages are taken in
  35. order from multiple logical bitstreams and combined into a single
  36. physical stream of pages. The decoder reconstructs the original
  37. logical bitstreams from the physical bitstream by taking the pages in
  38. order from the physical bitstream and redirecting them into the
  39. appropriate logical decoding entity. The simplest physical bitstream
  40. is a single, unmultiplexed logical bitstream with no meta-header; this
  41. is referred to as a 'degenerate stream'. <p>
  42. <a href=framing.html>Ogg Logical Bitstream Framing</a> discusses
  43. the page format of an Ogg bitstream, the packet coding process
  44. and logical bitstreams in detail. The remainder of this document
  45. specifies requirements for constructing finished, physical Ogg
  46. bitstreams.<p>
  47. <h2>Mapping Restrictions</h2>
  48. Logical bitstreams may not be mapped/multiplexed into physical
  49. bitstreams without restriction. Here we discuss design restrictions
  50. on Ogg physical bitstreams in general, mostly to introduce
  51. design rationale. Each 'media' format defines its own (generally more
  52. restrictive) mapping. An '<a href="vorbis-ogg.html">Ogg Vorbis
  53. Audio Bitstream</a>', for example, has a <a
  54. href="vorbis-ogg.html">specific physical bitstream structure</a>.
  55. An 'Ogg A/V' bitstream (not currently specified) will also mandate a
  56. specific, restricted physical bitstream format.<p>
  57. <h3>additional end-to-end structure</h3>
  58. The <a href="framing.html">framing specification</a> defines
  59. 'beginning of stream' and 'end of stream' page markers via a header
  60. flag (it is possible for a stream to consist of a single page). A
  61. stream always consists of an integer number of pages, an easy
  62. requirement given the variable size nature of pages.<p>
  63. In addition to the header flag marking the first and last pages of a
  64. logical bitstream, the first page of an Ogg bitstream obeys
  65. additional restrictions. Each individual media mapping specifies its
  66. own implementation details regarding these restrictions.<p>
  67. The first page of a logical Ogg bitstream consists of a single,
  68. small 'initial header' packet that includes sufficient information to
  69. identify the exact CODEC type and media requirements of the logical
  70. bitstream. The intent of this restriction is to simplify identifying
  71. the bitstream type and content; for a given media type (or across all
  72. Ogg media types) we can know that we only need a small, fixed
  73. amount of data to uniquely identify the bitstream type.<p>
  74. As an example, Ogg Vorbis places the name and revision of the Vorbis
  75. CODEC, the audio rate and the audio quality into this initial header,
  76. thus simplifying vastly the certain identification of an Ogg Vorbis
  77. audio bitstream.<p>
  78. <h3>sequential multiplexing (chaining)</h3>
  79. The simplest form of logical bitstream multiplexing is concatenation
  80. (<em>chaining</em>). Complete logical bitstreams are strung
  81. one-after-another in order. The bitstreams do not overlap; the final
  82. page of a given logical bitstream is immediately followed by the
  83. initial page of the next. Chaining is the only logical->physical
  84. mapping allowed by Ogg Vorbis.<p>
  85. Each chained logical bitstream must have a unique serial number within
  86. the scope of the physical bitstream.<p>
  87. <h3>concurrent multiplexing (grouping)</h3>
  88. Logical bitstreams may also be multiplexed 'in parallel'
  89. (<em>grouped</em>). An example of grouping would be to allow
  90. streaming of separate audio and video streams, using different codecs
  91. and different logical bitstreams, in the same physical bitstream.
  92. Whole pages from multiple logical bitstreams are mixed together.<p>
  93. The initial pages of each logical bitstream must appear first; the
  94. media mapping specifies the order of the initial pages. For example,
  95. Ogg A/V will eventually specify an Ogg video bitstream with
  96. audio. The mapping may specify that the physical bitstream must begin
  97. with the initial page of a logical video bitstream, followed by the
  98. initial page of an audio stream. Unlike initial pages, terminal pages
  99. for the logical bitstreams need not all occur contiguously (although a
  100. specific media mapping may require this; it is not mandated by the
  101. generic Ogg stream spec). Terminal pages may be 'nil' pages,
  102. that is, pages containing no content but simply a page header with
  103. position information and the 'last page of bitstream' flag set in the
  104. page header.<p>
  105. Each grouped bitstream must have a unique serial number within the
  106. scope of the physical bitstream.<p>
  107. <h3>sequential and concurrent multiplexing</h3>
  108. Groups of concurrently multiplexed bitstreams may be chained
  109. consecutively. Such a physical bitstream obeys all the rules of both
  110. grouped and chained multiplexed streams; the groups, when unchained ,
  111. must stand on their own as a valid concurrently multiplexed
  112. bitstream.<p>
  113. <h3>multiplexing example</h3>
  114. Below, we present an example of a grouped and chained bitstream:<p>
  115. <img src=stream.png><p>
  116. In this example, we see pages from five total logical bitstreams
  117. multiplexed into a physical bitstream. Note the following
  118. characteristics:
  119. <ol><li>Grouped bitstreams begin together; all of the initial pages
  120. must appear before any data pages. When concurrently multiplexed
  121. groups are chained, the new group does not begin until all the
  122. bitstreams in the previous group have terminated.<p>
  123. <li>The pages of concurrently multiplexed bitstreams need not conform
  124. to a regular order; the only requirement is that page <tt>n</tt> of a
  125. logical bitstream follow page <tt>n-1</tt> in the physical bitstream.
  126. There are no restrictions on intervening pages belonging to other
  127. logical bitstreams. (Tying page appearance to bitrate demands is one
  128. logical strategy, ie, the page appears at the chronological point
  129. where decode requires more information).
  130. </ol>
  131. <hr>
  132. <a href="http://www.xiph.org/">
  133. <img src="white-xifish.png" align=left border=0>
  134. </a>
  135. <font size=-2 color=#505050>
  136. Ogg is a <a href="http://www.xiph.org">Xiph.org Foundation</a> effort
  137. to protect essential tenets of Internet multimedia from corporate
  138. hostage-taking; Open Source is the net's greatest tool to keep
  139. everyone honest. See <a href="http://www.xiph.org/about.html">About
  140. the Xiph.org Foundation</a> for details.
  141. <p>
  142. Ogg Vorbis is the first Ogg audio CODEC. Anyone may freely use and
  143. distribute the Ogg and Vorbis specification, whether in a private,
  144. public or corporate capacity. However, the Xiph.org Foundation and
  145. the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis
  146. specification and certify specification compliance.<p>
  147. Xiph.org's Vorbis software CODEC implementation is distributed under a
  148. BSD-like license. This does not restrict third parties from
  149. distributing independent implementations of Vorbis software under
  150. other licenses.<p>
  151. Ogg, Vorbis, Xiph.org Foundation and their logos are trademarks (tm)
  152. of the <a href="http://www.xiph.org/">Xiph.org Foundation</a>. These
  153. pages are copyright (C) 1994-2002 Xiph.org Foundation. All rights
  154. reserved.<p>
  155. </body>