Minor updates to docs, conversion to .png.
[platform/upstream/libvorbis.git] / 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="vorbis.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 18, 1999</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-seperation 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 seperate 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 restricctions) into
40 a single <em>physical bitstream</em>.  A physical bitstream consists
41 of multiple logical bitstreams multiplexed at the page level. Whole
42 pages are taken in order from multiple logical bitstreams and combined
43 into a single physical stream of pages. The decoder reconstructs the
44 original logical bitstreams from the physical bitstream by taking the
45 pages in order fromt he physical bitstream and redirecting them into
46 the appropriate logical decoding entitiy. The simplest physical
47 bitstream is a single, unmultiplexed logical bitstream.  <p>
48
49 <a href=framing.html>Ogg Logical Bitstream Framing</a> discusses
50 the page format of an Ogg bitstream, the packet coding process
51 and logical bitstreams in detail.  The remainder of this document
52 specifies requirements for constructing finished, physical Ogg
53 bitstreams.<p>
54
55 <h2>Mapping Restrictions</h2>
56
57 Logical bitstreams may not be mapped/multiplexed into physical
58 bitstreams without restriction.  Here we discuss design restrictions
59 on Ogg physical bitstreams in general, mostly to introduce
60 design rationale. Each 'media' format defines its own (generally more
61 restrictive) mapping.  An '<a href="vorbis-stream.html">Ogg Vorbis
62 Audio Bitstream</a>', for example, has a <a
63 href="vorbis-stream.html">specific physical bitstream structure</a>.
64 An 'Ogg A/V' bitstream (not currently specified) will also mandate a
65 specific, restricted physical bitstream format.<p>
66
67 <h3>additional end-to-end structure</h3>
68
69 The <a href="framing.html">framing specification</a> defines
70 'beginning of stream' and 'end of stream' page markers via a header
71 flag (it is possible for a stream to consist of a single page).  A
72 stream always consists of an integer number of pages, an easy
73 requirement given the variable size nature of pages.<p>
74
75 In addition to the header flag marking the first and last pages of a
76 logical bitstream, the first page of an Ogg bitstream obeys
77 additional restrictions.  Each individual media mapping specifies its
78 own implementation details regarding these restrictions.<p>
79
80 The first page of a logical Ogg bitstream consists of a single,
81 small 'initial header' packet that includes sufficient information to
82 identify the exact CODEC type and media requirements of the logical
83 bitstream.  The intent of this restriction is to simplify identifying
84 the bitstream type and content; for a given media type (or across all
85 Ogg media types) we can know that we only need a small, fixed
86 amount of data to uniquely identify the bitstream type.<p>
87
88 As an example, Ogg Vorbis places the name and revision of the Vorbis
89 CODEC, the audio rate and the audio quality into this initial header,
90 thus simplifying vastly the certain identification of an Ogg Vorbis
91 audio bitstream.<p>
92
93 <h3>sequential multiplexing (chaining)</h3>
94
95 The simplest form of logical bitstream multiplexing is concatenation
96 (<em>chaining</em>).  Complete logical bitstreams are strung
97 one-after-another in order.  The bitstreams do not overlap; the final
98 page of a given logical bitstream is immediately followed by the
99 initial page of the next.  Chaining is the only logical->physical
100 mapping allowed by Ogg Vorbis.<p>
101
102 Each chained logical bitstream must have a unique serial number within
103 the scope of the physical bitstream.<p>
104
105 <h3>concurrent multiplexing (grouping)</h3>
106
107 Logical bitstreams may also be multiplexed 'in parallel'
108 (<em>grouped</em>).  An example of grouping would be to allow
109 streaming of seperate audio and video streams, using differnt codecs
110 and different logical bitstreams, in the same physical bitstream.
111 Whole pages from multiple logical bitstreams are mixed together.<p>
112
113 The initial pages of each logical bitstream must appear first; the
114 media mapping specifies the order of the initial pages.  For example,
115 Ogg A/V will eventually specify an Ogg video bitstream with
116 audio.  The mapping may specify that the physical bitstream must begin
117 with the initial page of a logical video bitstream, followed by the
118 initial page of an audio stream.  Unlike initial pages, terminal pages
119 for the logical bitstreams need not all occur contiguously (although a
120 specific media mapping may require this; it is not mandated by the
121 generic Ogg stream spec).  Terminal pages may be 'nil' pages,
122 that is, pages containing no content but simply a page header with
123 position information and the 'last page of bitstream' flag set in the
124 page header.<p>
125
126 Each grouped bitstream must have a unique serial number within the
127 scope of the physical bitstream.<p>
128
129 <h3>sequential and concurrent multiplexing</h3>
130
131 Groups of concurrently multiplexed bitstreams may be chained
132 consecutively.  Such a physical bitstream obeys all the rules of both
133 grouped and chained multiplexed streams; the groups, when unchained ,
134 must stand on their own as a valid concurrently multiplexed
135 bitstream.<p>
136
137 <h3>multiplexing example</h3>
138
139 Below, we present an example of a grouped and chained bitstream:<p>
140
141 <img src=stream.png><p>
142
143 In this example, we see pages from five total logical bitstreams
144 multiplexed into a physical bitstream.  Note the following
145 characteristics:
146
147 <ol><li>Grouped bitstreams begin together; all of the initial pages
148 must appear before any data pages.  When concurrently multiplexed
149 groups are chained, the new group does not begin until all the
150 bitstreams in the previous group have terminated.<p>
151
152 <li>The pages of concurrently multiplexed bitstreams need not conform
153 to a regular order; the only requirement is that page <tt>n</tt> of a
154 logical bitstream follow page <tt>n-1</tt> in the physical bitstream.
155 There are no restrictions on intervening pages belonging to other
156 logical bitstreams.  (Tying page appearence to bitrate demands is one
157 logical strategy, ie, the page appears at the chronological point
158 where decode requires more information).
159
160 </ol>
161
162 <hr>
163 <a href="http://www.xiph.org/">
164 <img src="white-xifish.png" align=left border=0>
165 </a>
166 <font size=-2 color=#505050>
167
168 Ogg is a <a href="http://www.xiph.org">Xiphophorus</a> effort to
169 protect essential tenets of Internet multimedia from corporate
170 hostage-taking; Open Source is the net's greatest tool to keep
171 everyone honest. See <a href="http://www.xiph.org/about.html">About
172 Xiphophorus</a> for details.
173 <p>
174
175 Ogg Vorbis is the first Ogg audio CODEC.  Anyone may
176 freely use and distribute the Ogg and Vorbis specification,
177 whether in a private, public or corporate capacity.  However,
178 Xiphophorus and the Ogg project (xiph.org) reserve the right to set
179 the Ogg/Vorbis specification and certify specification compliance.<p>
180
181 Xiphophorus's Vorbis software CODEC implementation is distributed
182 under the Lesser/Library GNU Public License.  This does not restrict
183 third parties from distributing independent implementations of Vorbis
184 software under other licenses.<p>
185
186 OggSquish, Vorbis, Xiphophorus and their logos are trademarks (tm) of
187 <a href="http://www.xiph.org/">Xiphophorus</a>.  These pages are
188 copyright (C) 1994-2000 Xiphophorus. All rights reserved.<p>
189
190 </body>
191
192