1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-15"/>
6 <title>Ogg Vorbis Documentation
</title>
8 <style type=
"text/css">
10 margin: 0 18px 0 18px;
12 font-family: Verdana
, Arial
, Helvetica
, sans-serif
;
26 margin: 30px 0 16px 0;
33 h1
, h1 a
, h2
, h2 a
, h3
, h3 a
{
36 margin: 1.3em 0 8px 0;
70 <a href=
"http://www.xiph.org/"><img src=
"fish_xiph_org.png" alt=
"Fish Logo and Xiph.org"/></a>
73 <h1>Ogg logical and physical bitstream overview
</h1>
75 <h2>Ogg bitstreams
</h2>
77 <p>Ogg codecs use octet vectors of raw, compressed data
78 (
<em>packets
</em>). These compressed packets do not have any
79 high-level structure or boundary information; strung together, they
80 appear to be streams of random bytes with no landmarks.
</p>
82 <p>Raw packets may be used directly by transport mechanisms that provide
83 their own framing and packet-separation mechanisms (such as UDP
84 datagrams). For stream based storage (such as files) and transport
85 (such as TCP streams or pipes), Vorbis and other future Ogg codecs use
86 the Ogg bitstream format to provide framing/sync, sync recapture
87 after error, landmarks during seeking, and enough information to
88 properly separate data back into packets at the original packet
89 boundaries without relying on decoding to find packet boundaries.
</p>
91 <h2>Logical and physical bitstreams
</h2>
93 <p>Raw packets are grouped and encoded into contiguous pages of
94 structured bitstream data called
<em>logical bitstreams
</em>. A
95 logical bitstream consists of pages, in order, belonging to a single
96 codec instance. Each page is a self contained entity (although it is
97 possible that a packet may be split and encoded across one or more
98 pages); that is, the page decode mechanism is designed to recognize,
99 verify and handle single pages at a time from the overall bitstream.
</p>
101 <p>Multiple logical bitstreams can be combined (with restrictions) into a
102 single
<em>physical bitstream
</em>. A physical bitstream consists of
103 multiple logical bitstreams multiplexed at the page level and may
104 include a 'meta-header' at the beginning of the multiplexed logical
105 stream that serves as identification magic. Whole pages are taken in
106 order from multiple logical bitstreams and combined into a single
107 physical stream of pages. The decoder reconstructs the original
108 logical bitstreams from the physical bitstream by taking the pages in
109 order from the physical bitstream and redirecting them into the
110 appropriate logical decoding entity. The simplest physical bitstream
111 is a single, unmultiplexed logical bitstream with no meta-header; this
112 is referred to as a 'degenerate stream'.
</p>
114 <p><a href=
"framing.html">Ogg Logical Bitstream Framing
</a> discusses
115 the page format of an Ogg bitstream, the packet coding process
116 and logical bitstreams in detail. The remainder of this document
117 specifies requirements for constructing finished, physical Ogg
120 <h2>Mapping Restrictions
</h2>
122 <p>Logical bitstreams may not be mapped/multiplexed into physical
123 bitstreams without restriction. Here we discuss design restrictions
124 on Ogg physical bitstreams in general, mostly to introduce
125 design rationale. Each 'media' format defines its own (generally more
126 restrictive) mapping. An 'Ogg Vorbis Audio Bitstream', for example, has a
127 specific physical bitstream structure.
128 An 'Ogg A/V' bitstream (not currently specified) will also mandate a
129 specific, restricted physical bitstream format.
</p>
131 <h3>additional end-to-end structure
</h3>
133 <p>The
<a href=
"framing.html">framing specification
</a> defines
134 'beginning of stream' and 'end of stream' page markers via a header
135 flag (it is possible for a stream to consist of a single page). A
136 stream always consists of an integer number of pages, an easy
137 requirement given the variable size nature of pages.
</p>
139 <p>In addition to the header flag marking the first and last pages of a
140 logical bitstream, the first page of an Ogg bitstream obeys
141 additional restrictions. Each individual media mapping specifies its
142 own implementation details regarding these restrictions.
</p>
144 <p>The first page of a logical Ogg bitstream consists of a single,
145 small 'initial header' packet that includes sufficient information to
146 identify the exact CODEC type and media requirements of the logical
147 bitstream. The intent of this restriction is to simplify identifying
148 the bitstream type and content; for a given media type (or across all
149 Ogg media types) we can know that we only need a small, fixed
150 amount of data to uniquely identify the bitstream type.
</p>
152 <p>As an example, Ogg Vorbis places the name and revision of the Vorbis
153 CODEC, the audio rate and the audio quality into this initial header,
154 thus simplifying vastly the certain identification of an Ogg Vorbis
157 <h3>sequential multiplexing (chaining)
</h3>
159 <p>The simplest form of logical bitstream multiplexing is concatenation
160 (
<em>chaining
</em>). Complete logical bitstreams are strung
161 one-after-another in order. The bitstreams do not overlap; the final
162 page of a given logical bitstream is immediately followed by the
163 initial page of the next. Chaining is the only logical-
>physical
164 mapping allowed by Ogg Vorbis.
</p>
166 <p>Each chained logical bitstream must have a unique serial number within
167 the scope of the physical bitstream.
</p>
169 <h3>concurrent multiplexing (grouping)
</h3>
171 <p>Logical bitstreams may also be multiplexed 'in parallel'
172 (
<em>grouped
</em>). An example of grouping would be to allow
173 streaming of separate audio and video streams, using different codecs
174 and different logical bitstreams, in the same physical bitstream.
175 Whole pages from multiple logical bitstreams are mixed together.
</p>
177 <p>The initial pages of each logical bitstream must appear first; the
178 media mapping specifies the order of the initial pages. For example,
179 Ogg A/V will eventually specify an Ogg video bitstream with
180 audio. The mapping may specify that the physical bitstream must begin
181 with the initial page of a logical video bitstream, followed by the
182 initial page of an audio stream. Unlike initial pages, terminal pages
183 for the logical bitstreams need not all occur contiguously (although a
184 specific media mapping may require this; it is not mandated by the
185 generic Ogg stream spec). Terminal pages may be 'nil' pages,
186 that is, pages containing no content but simply a page header with
187 position information and the 'last page of bitstream' flag set in the
190 <p>Each grouped bitstream must have a unique serial number within the
191 scope of the physical bitstream.
</p>
193 <h3>sequential and concurrent multiplexing
</h3>
195 <p>Groups of concurrently multiplexed bitstreams may be chained
196 consecutively. Such a physical bitstream obeys all the rules of both
197 grouped and chained multiplexed streams; the groups, when unchained ,
198 must stand on their own as a valid concurrently multiplexed
201 <h3>multiplexing example
</h3>
203 <p>Below, we present an example of a grouped and chained bitstream:
</p>
205 <p><img src=
"stream.png" alt=
"stream"/></p>
207 <p>In this example, we see pages from five total logical bitstreams
208 multiplexed into a physical bitstream. Note the following
212 <li>Grouped bitstreams begin together; all of the initial pages
213 must appear before any data pages. When concurrently multiplexed
214 groups are chained, the new group does not begin until all the
215 bitstreams in the previous group have terminated.
</li>
217 <li>The pages of concurrently multiplexed bitstreams need not conform
218 to a regular order; the only requirement is that page
<tt>n
</tt> of a
219 logical bitstream follow page
<tt>n-
1</tt> in the physical bitstream.
220 There are no restrictions on intervening pages belonging to other
221 logical bitstreams. (Tying page appearance to bitrate demands is one
222 logical strategy, ie, the page appears at the chronological point
223 where decode requires more information).
</li>
227 The Xiph Fish Logo is a
228 trademark (
™) of Xiph.Org.
<br/>
230 These pages
© 1994 -
2005 Xiph.Org. All rights reserved.