Blame doc/oggstream.html

Packit 06404a
Packit 06404a
<html>
Packit 06404a
<head>
Packit 06404a
Packit 06404a
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
Packit 06404a
<title>Ogg Vorbis Documentation</title>
Packit 06404a
Packit 06404a
<style type="text/css">
Packit 06404a
body {
Packit 06404a
  margin: 0 18px 0 18px;
Packit 06404a
  padding-bottom: 30px;
Packit 06404a
  font-family: Verdana, Arial, Helvetica, sans-serif;
Packit 06404a
  color: #333333;
Packit 06404a
  font-size: .8em;
Packit 06404a
}
Packit 06404a
Packit 06404a
a {
Packit 06404a
  color: #3366cc;
Packit 06404a
}
Packit 06404a
Packit 06404a
img {
Packit 06404a
  border: 0;
Packit 06404a
}
Packit 06404a
Packit 06404a
#xiphlogo {
Packit 06404a
  margin: 30px 0 16px 0;
Packit 06404a
}
Packit 06404a
Packit 06404a
#content p {
Packit 06404a
  line-height: 1.4;
Packit 06404a
}
Packit 06404a
Packit 06404a
h1, h1 a, h2, h2 a, h3, h3 a {
Packit 06404a
  font-weight: bold;
Packit 06404a
  color: #ff9900;
Packit 06404a
  margin: 1.3em 0 8px 0;
Packit 06404a
}
Packit 06404a
Packit 06404a
h1 {
Packit 06404a
  font-size: 1.3em;
Packit 06404a
}
Packit 06404a
Packit 06404a
h2 {
Packit 06404a
  font-size: 1.2em;
Packit 06404a
}
Packit 06404a
Packit 06404a
h3 {
Packit 06404a
  font-size: 1.1em;
Packit 06404a
}
Packit 06404a
Packit 06404a
li {
Packit 06404a
  line-height: 1.4;
Packit 06404a
}
Packit 06404a
Packit 06404a
#copyright {
Packit 06404a
  margin-top: 30px;
Packit 06404a
  line-height: 1.5em;
Packit 06404a
  text-align: center;
Packit 06404a
  font-size: .8em;
Packit 06404a
  color: #888888;
Packit 06404a
  clear: both;
Packit 06404a
}
Packit 06404a
</style>
Packit 06404a
Packit 06404a
</head>
Packit 06404a
Packit 06404a
<body>
Packit 06404a
Packit 06404a
Packit 06404a
  Fish Logo and Xiph.Org
Packit 06404a
Packit 06404a
Packit 06404a

Ogg logical and physical bitstream overview

Packit 06404a
Packit 06404a

Ogg bitstreams

Packit 06404a
Packit 06404a

Ogg codecs use octet vectors of raw, compressed data

Packit 06404a
(packets). These compressed packets do not have any
Packit 06404a
high-level structure or boundary information; strung together, they
Packit 06404a
appear to be streams of random bytes with no landmarks.

Packit 06404a
Packit 06404a

Raw packets may be used directly by transport mechanisms that provide

Packit 06404a
their own framing and packet-separation mechanisms (such as UDP
Packit 06404a
datagrams). For stream based storage (such as files) and transport
Packit 06404a
(such as TCP streams or pipes), Vorbis and other future Ogg codecs use
Packit 06404a
the Ogg bitstream format to provide framing/sync, sync recapture
Packit 06404a
after error, landmarks during seeking, and enough information to
Packit 06404a
properly separate data back into packets at the original packet
Packit 06404a
boundaries without relying on decoding to find packet boundaries.

Packit 06404a
Packit 06404a

Logical and physical bitstreams

Packit 06404a
Packit 06404a

Raw packets are grouped and encoded into contiguous pages of

Packit 06404a
structured bitstream data called logical bitstreams. A
Packit 06404a
logical bitstream consists of pages, in order, belonging to a single
Packit 06404a
codec instance. Each page is a self contained entity (although it is
Packit 06404a
possible that a packet may be split and encoded across one or more
Packit 06404a
pages); that is, the page decode mechanism is designed to recognize,
Packit 06404a
verify and handle single pages at a time from the overall bitstream.

Packit 06404a
Packit 06404a

Multiple logical bitstreams can be combined (with restrictions) into a

Packit 06404a
single physical bitstream. A physical bitstream consists of
Packit 06404a
multiple logical bitstreams multiplexed at the page level and may
Packit 06404a
include a 'meta-header' at the beginning of the multiplexed logical
Packit 06404a
stream that serves as identification magic. Whole pages are taken in
Packit 06404a
order from multiple logical bitstreams and combined into a single
Packit 06404a
physical stream of pages. The decoder reconstructs the original
Packit 06404a
logical bitstreams from the physical bitstream by taking the pages in
Packit 06404a
order from the physical bitstream and redirecting them into the
Packit 06404a
appropriate logical decoding entity. The simplest physical bitstream
Packit 06404a
is a single, unmultiplexed logical bitstream with no meta-header; this
Packit 06404a
is referred to as a 'degenerate stream'.

Packit 06404a
Packit 06404a

Ogg Logical Bitstream Framing discusses

Packit 06404a
the page format of an Ogg bitstream, the packet coding process
Packit 06404a
and logical bitstreams in detail. The remainder of this document
Packit 06404a
specifies requirements for constructing finished, physical Ogg
Packit 06404a
bitstreams.

Packit 06404a
Packit 06404a

Mapping Restrictions

Packit 06404a
Packit 06404a

Logical bitstreams may not be mapped/multiplexed into physical

Packit 06404a
bitstreams without restriction. Here we discuss design restrictions
Packit 06404a
on Ogg physical bitstreams in general, mostly to introduce
Packit 06404a
design rationale. Each 'media' format defines its own (generally more
Packit 06404a
restrictive) mapping. An 'Ogg Vorbis Audio Bitstream', for example, has a
Packit 06404a
specific physical bitstream structure.
Packit 06404a
An 'Ogg A/V' bitstream (not currently specified) will also mandate a
Packit 06404a
specific, restricted physical bitstream format.

Packit 06404a
Packit 06404a

additional end-to-end structure

Packit 06404a
Packit 06404a

The framing specification defines

Packit 06404a
'beginning of stream' and 'end of stream' page markers via a header
Packit 06404a
flag (it is possible for a stream to consist of a single page). A
Packit 06404a
stream always consists of an integer number of pages, an easy
Packit 06404a
requirement given the variable size nature of pages.

Packit 06404a
Packit 06404a

In addition to the header flag marking the first and last pages of a

Packit 06404a
logical bitstream, the first page of an Ogg bitstream obeys
Packit 06404a
additional restrictions. Each individual media mapping specifies its
Packit 06404a
own implementation details regarding these restrictions.

Packit 06404a
Packit 06404a

The first page of a logical Ogg bitstream consists of a single,

Packit 06404a
small 'initial header' packet that includes sufficient information to
Packit 06404a
identify the exact CODEC type and media requirements of the logical
Packit 06404a
bitstream. The intent of this restriction is to simplify identifying
Packit 06404a
the bitstream type and content; for a given media type (or across all
Packit 06404a
Ogg media types) we can know that we only need a small, fixed
Packit 06404a
amount of data to uniquely identify the bitstream type.

Packit 06404a
Packit 06404a

As an example, Ogg Vorbis places the name and revision of the Vorbis

Packit 06404a
CODEC, the audio rate and the audio quality into this initial header,
Packit 06404a
thus simplifying vastly the certain identification of an Ogg Vorbis
Packit 06404a
audio bitstream.

Packit 06404a
Packit 06404a

sequential multiplexing (chaining)

Packit 06404a
Packit 06404a

The simplest form of logical bitstream multiplexing is concatenation

Packit 06404a
(chaining). Complete logical bitstreams are strung
Packit 06404a
one-after-another in order. The bitstreams do not overlap; the final
Packit 06404a
page of a given logical bitstream is immediately followed by the
Packit 06404a
initial page of the next. Chaining is the only logical->physical
Packit 06404a
mapping allowed by Ogg Vorbis.

Packit 06404a
Packit 06404a

Each chained logical bitstream must have a unique serial number within

Packit 06404a
the scope of the physical bitstream.

Packit 06404a
Packit 06404a

concurrent multiplexing (grouping)

Packit 06404a
Packit 06404a

Logical bitstreams may also be multiplexed 'in parallel'

Packit 06404a
(grouped). An example of grouping would be to allow
Packit 06404a
streaming of separate audio and video streams, using different codecs
Packit 06404a
and different logical bitstreams, in the same physical bitstream.
Packit 06404a
Whole pages from multiple logical bitstreams are mixed together.

Packit 06404a
Packit 06404a

The initial pages of each logical bitstream must appear first; the

Packit 06404a
media mapping specifies the order of the initial pages. For example,
Packit 06404a
Ogg A/V will eventually specify an Ogg video bitstream with
Packit 06404a
audio. The mapping may specify that the physical bitstream must begin
Packit 06404a
with the initial page of a logical video bitstream, followed by the
Packit 06404a
initial page of an audio stream. Unlike initial pages, terminal pages
Packit 06404a
for the logical bitstreams need not all occur contiguously (although a
Packit 06404a
specific media mapping may require this; it is not mandated by the
Packit 06404a
generic Ogg stream spec). Terminal pages may be 'nil' pages,
Packit 06404a
that is, pages containing no content but simply a page header with
Packit 06404a
position information and the 'last page of bitstream' flag set in the
Packit 06404a
page header.

Packit 06404a
Packit 06404a

Each grouped bitstream must have a unique serial number within the

Packit 06404a
scope of the physical bitstream.

Packit 06404a
Packit 06404a

sequential and concurrent multiplexing

Packit 06404a
Packit 06404a

Groups of concurrently multiplexed bitstreams may be chained

Packit 06404a
consecutively. Such a physical bitstream obeys all the rules of both
Packit 06404a
grouped and chained multiplexed streams; the groups, when unchained ,
Packit 06404a
must stand on their own as a valid concurrently multiplexed
Packit 06404a
bitstream.

Packit 06404a
Packit 06404a

multiplexing example

Packit 06404a
Packit 06404a

Below, we present an example of a grouped and chained bitstream:

Packit 06404a
Packit 06404a

stream

Packit 06404a
Packit 06404a

In this example, we see pages from five total logical bitstreams

Packit 06404a
multiplexed into a physical bitstream. Note the following
Packit 06404a
characteristics:

Packit 06404a
Packit 06404a
    Packit 06404a
  1. Grouped bitstreams begin together; all of the initial pages
  2. Packit 06404a
    must appear before any data pages. When concurrently multiplexed
    Packit 06404a
    groups are chained, the new group does not begin until all the
    Packit 06404a
    bitstreams in the previous group have terminated.
    Packit 06404a
    Packit 06404a
  3. The pages of concurrently multiplexed bitstreams need not conform
  4. Packit 06404a
    to a regular order; the only requirement is that page <tt>n</tt> of a
    Packit 06404a
    logical bitstream follow page <tt>n-1</tt> in the physical bitstream.
    Packit 06404a
    There are no restrictions on intervening pages belonging to other
    Packit 06404a
    logical bitstreams. (Tying page appearance to bitrate demands is one
    Packit 06404a
    logical strategy, ie, the page appears at the chronological point
    Packit 06404a
    where decode requires more information).
    Packit 06404a
    Packit 06404a
    Packit 06404a
    Packit 06404a
      The Xiph Fish Logo is a
    Packit 06404a
      trademark (™) of Xiph.Org.
    Packit 06404a
    Packit 06404a
      These pages © 1994 - 2005 Xiph.Org. All rights reserved.
    Packit 06404a
    Packit 06404a
    Packit 06404a
    </body>
    Packit 06404a
    </html>