examples/sfexamples/oggvorbiscodec/src/libogg/doc/oggstream.html

00001 <HTML><HEAD><TITLE>xiph.org: Ogg Vorbis documentation</TITLE>
00002 <BODY bgcolor="#ffffff" text="#202020" link="#006666" vlink="#000000">
00003 <nobr><a href="http://www.xiph.org/ogg/index.html"><img src="white-ogg.png" border=0><img 
00004 src="vorbisword2.png" border=0></a></nobr><p>
00005 
00006 
00007 <h1><font color=#000070>
00008 Ogg logical and physical bitstream overview
00009 </font></h1>
00010 
00011 <em>Last update to this document: July 14, 2002</em><br> 
00012 
00013 <h2>Ogg bitstreams</h2>
00014 
00015 Ogg codecs use octet vectors of raw, compressed data
00016 (<em>packets</em>). These compressed packets do not have any
00017 high-level structure or boundary information; strung together, they
00018 appear to be streams of random bytes with no landmarks.<p>
00019 
00020 Raw packets may be used directly by transport mechanisms that provide
00021 their own framing and packet-separation mechanisms (such as UDP
00022 datagrams).  For stream based storage (such as files) and transport
00023 (such as TCP streams or pipes), Vorbis and other future Ogg codecs use
00024 the Ogg bitstream format to provide framing/sync, sync recapture
00025 after error, landmarks during seeking, and enough information to
00026 properly separate data back into packets at the original packet
00027 boundaries without relying on decoding to find packet boundaries.<p>
00028 
00029 <h2>Logical and physical bitstreams</h2>
00030 
00031 Raw packets are grouped and encoded into contiguous pages of
00032 structured bitstream data called <em>logical bitstreams</em>.  A
00033 logical bitstream consists of pages, in order, belonging to a single
00034 codec instance.  Each page is a self contained entity (although it is
00035 possible that a packet may be split and encoded across one or more
00036 pages); that is, the page decode mechanism is designed to recognize,
00037 verify and handle single pages at a time from the overall bitstream.<p>
00038 
00039 Multiple logical bitstreams can be combined (with restrictions) into a
00040 single <em>physical bitstream</em>.  A physical bitstream consists of
00041 multiple logical bitstreams multiplexed at the page level and may
00042 include a 'meta-header' at the beginning of the multiplexed logical
00043 stream that serves as identification magic. Whole pages are taken in
00044 order from multiple logical bitstreams and combined into a single
00045 physical stream of pages. The decoder reconstructs the original
00046 logical bitstreams from the physical bitstream by taking the pages in
00047 order from the physical bitstream and redirecting them into the
00048 appropriate logical decoding entity. The simplest physical bitstream
00049 is a single, unmultiplexed logical bitstream with no meta-header; this
00050 is referred to as a 'degenerate stream'.  <p>
00051 
00052 <a href=framing.html>Ogg Logical Bitstream Framing</a> discusses
00053 the page format of an Ogg bitstream, the packet coding process
00054 and logical bitstreams in detail.  The remainder of this document
00055 specifies requirements for constructing finished, physical Ogg
00056 bitstreams.<p>
00057 
00058 <h2>Mapping Restrictions</h2>
00059 
00060 Logical bitstreams may not be mapped/multiplexed into physical
00061 bitstreams without restriction.  Here we discuss design restrictions
00062 on Ogg physical bitstreams in general, mostly to introduce
00063 design rationale. Each 'media' format defines its own (generally more
00064 restrictive) mapping.  An '<a href="vorbis-ogg.html">Ogg Vorbis
00065 Audio Bitstream</a>', for example, has a <a
00066 href="vorbis-ogg.html">specific physical bitstream structure</a>.
00067 An 'Ogg A/V' bitstream (not currently specified) will also mandate a
00068 specific, restricted physical bitstream format.<p>
00069 
00070 <h3>additional end-to-end structure</h3>
00071 
00072 The <a href="framing.html">framing specification</a> defines
00073 'beginning of stream' and 'end of stream' page markers via a header
00074 flag (it is possible for a stream to consist of a single page).  A
00075 stream always consists of an integer number of pages, an easy
00076 requirement given the variable size nature of pages.<p>
00077 
00078 In addition to the header flag marking the first and last pages of a
00079 logical bitstream, the first page of an Ogg bitstream obeys
00080 additional restrictions.  Each individual media mapping specifies its
00081 own implementation details regarding these restrictions.<p>
00082 
00083 The first page of a logical Ogg bitstream consists of a single,
00084 small 'initial header' packet that includes sufficient information to
00085 identify the exact CODEC type and media requirements of the logical
00086 bitstream.  The intent of this restriction is to simplify identifying
00087 the bitstream type and content; for a given media type (or across all
00088 Ogg media types) we can know that we only need a small, fixed
00089 amount of data to uniquely identify the bitstream type.<p>
00090 
00091 As an example, Ogg Vorbis places the name and revision of the Vorbis
00092 CODEC, the audio rate and the audio quality into this initial header,
00093 thus simplifying vastly the certain identification of an Ogg Vorbis
00094 audio bitstream.<p>
00095 
00096 <h3>sequential multiplexing (chaining)</h3>
00097 
00098 The simplest form of logical bitstream multiplexing is concatenation
00099 (<em>chaining</em>).  Complete logical bitstreams are strung
00100 one-after-another in order.  The bitstreams do not overlap; the final
00101 page of a given logical bitstream is immediately followed by the
00102 initial page of the next.  Chaining is the only logical->physical
00103 mapping allowed by Ogg Vorbis.<p>
00104 
00105 Each chained logical bitstream must have a unique serial number within
00106 the scope of the physical bitstream.<p>
00107 
00108 <h3>concurrent multiplexing (grouping)</h3>
00109 
00110 Logical bitstreams may also be multiplexed 'in parallel'
00111 (<em>grouped</em>).  An example of grouping would be to allow
00112 streaming of separate audio and video streams, using different codecs
00113 and different logical bitstreams, in the same physical bitstream.
00114 Whole pages from multiple logical bitstreams are mixed together.<p>
00115 
00116 The initial pages of each logical bitstream must appear first; the
00117 media mapping specifies the order of the initial pages.  For example,
00118 Ogg A/V will eventually specify an Ogg video bitstream with
00119 audio.  The mapping may specify that the physical bitstream must begin
00120 with the initial page of a logical video bitstream, followed by the
00121 initial page of an audio stream.  Unlike initial pages, terminal pages
00122 for the logical bitstreams need not all occur contiguously (although a
00123 specific media mapping may require this; it is not mandated by the
00124 generic Ogg stream spec).  Terminal pages may be 'nil' pages,
00125 that is, pages containing no content but simply a page header with
00126 position information and the 'last page of bitstream' flag set in the
00127 page header.<p>
00128 
00129 Each grouped bitstream must have a unique serial number within the
00130 scope of the physical bitstream.<p>
00131 
00132 <h3>sequential and concurrent multiplexing</h3>
00133 
00134 Groups of concurrently multiplexed bitstreams may be chained
00135 consecutively.  Such a physical bitstream obeys all the rules of both
00136 grouped and chained multiplexed streams; the groups, when unchained ,
00137 must stand on their own as a valid concurrently multiplexed
00138 bitstream.<p>
00139 
00140 <h3>multiplexing example</h3>
00141 
00142 Below, we present an example of a grouped and chained bitstream:<p>
00143 
00144 <img src=stream.png><p>
00145 
00146 In this example, we see pages from five total logical bitstreams
00147 multiplexed into a physical bitstream.  Note the following
00148 characteristics:
00149 
00150 <ol><li>Grouped bitstreams begin together; all of the initial pages
00151 must appear before any data pages.  When concurrently multiplexed
00152 groups are chained, the new group does not begin until all the
00153 bitstreams in the previous group have terminated.<p>
00154 
00155 <li>The pages of concurrently multiplexed bitstreams need not conform
00156 to a regular order; the only requirement is that page <tt>n</tt> of a
00157 logical bitstream follow page <tt>n-1</tt> in the physical bitstream.
00158 There are no restrictions on intervening pages belonging to other
00159 logical bitstreams.  (Tying page appearance to bitrate demands is one
00160 logical strategy, ie, the page appears at the chronological point
00161 where decode requires more information).
00162 
00163 </ol>
00164 
00165 <hr>
00166 <a href="http://www.xiph.org/">
00167 <img src="white-xifish.png" align=left border=0>
00168 </a>
00169 <font size=-2 color=#505050>
00170 
00171 Ogg is a <a href="http://www.xiph.org">Xiph.org Foundation</a> effort
00172 to protect essential tenets of Internet multimedia from corporate
00173 hostage-taking; Open Source is the net's greatest tool to keep
00174 everyone honest. See <a href="http://www.xiph.org/about.html">About
00175 the Xiph.org Foundation</a> for details.
00176 <p>
00177 
00178 Ogg Vorbis is the first Ogg audio CODEC.  Anyone may freely use and
00179 distribute the Ogg and Vorbis specification, whether in a private,
00180 public or corporate capacity.  However, the Xiph.org Foundation and
00181 the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis
00182 specification and certify specification compliance.<p>
00183 
00184 Xiph.org's Vorbis software CODEC implementation is distributed under a
00185 BSD-like license.  This does not restrict third parties from
00186 distributing independent implementations of Vorbis software under
00187 other licenses.<p>
00188 
00189 Ogg, Vorbis, Xiph.org Foundation and their logos are trademarks (tm)
00190 of the <a href="http://www.xiph.org/">Xiph.org Foundation</a>.  These
00191 pages are copyright (C) 1994-2002 Xiph.org Foundation. All rights
00192 reserved.<p>
00193 
00194 </body>
00195 
00196 

Generated by  doxygen 1.6.2