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