Blame doc/programming.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

Programming with Xiph.Org <tt>libvorbis</tt>

Packit 06404a
Packit 06404a

Description

Packit 06404a
Packit 06404a

Libvorbis is the Xiph.Org Foundation's portable Ogg Vorbis CODEC

Packit 06404a
implemented as a programmatic library. Libvorbis provides primitives
Packit 06404a
to handle framing and manipulation of Ogg bitstreams (used by the
Packit 06404a
Vorbis for streaming), a full analysis (encoding) interface as well as
Packit 06404a
packet decoding and synthesis for playback.

Packit 06404a
Packit 06404a

The libvorbis library does not provide any system interface; a

Packit 06404a
full-featured demonstration player included with the library
Packit 06404a
distribtion provides example code for a variety of system interfaces
Packit 06404a
as well as a working example of using libvorbis in production code.

Packit 06404a
Packit 06404a

Encoding Overview

Packit 06404a
Packit 06404a

Decoding Overview

Packit 06404a
Packit 06404a

Decoding a bitstream with libvorbis follows roughly the following

Packit 06404a
steps:

Packit 06404a
Packit 06404a
    Packit 06404a
  1. Frame the incoming bitstream into pages
  2. Packit 06404a
  3. Sort the pages by logical bitstream and buffer then into logical streams
  4. Packit 06404a
  5. Decompose the logical streams into raw packets
  6. Packit 06404a
  7. Reconstruct segments of the original data from each packet
  8. Packit 06404a
  9. Glue the reconstructed segments back into a decoded stream
  10. Packit 06404a
    Packit 06404a
    Packit 06404a

    Framing

    Packit 06404a
    Packit 06404a

    An Ogg bitstream is logically arranged into pages, but to decode

    Packit 06404a
    the pages, we have to find them first. The raw bitstream is first fed
    Packit 06404a
    into an <tt>ogg_sync_state</tt> buffer using <tt>ogg_sync_buffer()</tt>
    Packit 06404a
    and <tt>ogg_sync_wrote()</tt>. After each block we submit to the sync
    Packit 06404a
    buffer, we should check to see if we can frame and extract a complete
    Packit 06404a
    page or pages using <tt>ogg_sync_pageout()</tt>. Extra pages are
    Packit 06404a
    buffered; allowing them to build up in the <tt>ogg_sync_state</tt>
    Packit 06404a
    buffer will eventually exhaust memory.

    Packit 06404a
    Packit 06404a

    The Ogg pages returned from <tt>ogg_sync_pageout</tt> need not be

    Packit 06404a
    decoded further to be used as landmarks in seeking; seeking can be
    Packit 06404a
    either a rough process of simply jumping to approximately intuited
    Packit 06404a
    portions of the bitstream, or it can be a precise bisection process
    Packit 06404a
    that captures pages and inspects data position. When seeking,
    Packit 06404a
    however, sequential multiplexing (chaining) must be accounted for;
    Packit 06404a
    beginning play in a new logical bitstream requires initializing a
    Packit 06404a
    synthesis engine with the headers from that bitstream. Vorbis
    Packit 06404a
    bitstreams do not make use of concurent multiplexing (grouping).

    Packit 06404a
    Packit 06404a

    Sorting

    Packit 06404a
    Packit 06404a

    The pages produced by <tt>ogg_sync_pageout</tt> are then sorted by

    Packit 06404a
    serial number to seperate logical bitstreams. Initialize logical
    Packit 06404a
    bitstream buffers (<tt>og_stream_state</tt>) using
    Packit 06404a
    <tt>ogg_stream_init()</tt>. Pages are submitted to the matching
    Packit 06404a
    logical bitstream buffer using <tt>ogg_stream_pagein</tt>; the serial
    Packit 06404a
    number of the page and the stream buffer must match, or the page will
    Packit 06404a
    be rejected. A page submitted out of sequence will simply be noted,
    Packit 06404a
    and in the course of outputting packets, the hole will be flagged
    Packit 06404a
    (<tt>ogg_sync_pageout</tt> and <tt>ogg_stream_packetout</tt> will
    Packit 06404a
    return a negative value at positions where they had to recapture the
    Packit 06404a
    stream).

    Packit 06404a
    Packit 06404a

    Extracting packets

    Packit 06404a
    Packit 06404a

    After submitting page[s] to a logical stream, read available packets

    Packit 06404a
    using <tt>ogg_stream_packetout</tt>.

    Packit 06404a
    Packit 06404a

    Decoding packets

    Packit 06404a
    Packit 06404a

    Reassembling data segments

    Packit 06404a
    Packit 06404a

    Ogg Bitstream Manipulation Structures

    Packit 06404a
    Packit 06404a

    Two of the Ogg bitstream data structures are intended to be

    Packit 06404a
    transparent to the developer; the fields should be used directly.

    Packit 06404a
    Packit 06404a

    ogg_packet

    Packit 06404a
    Packit 06404a
    Packit 06404a
    typedef struct {
    Packit 06404a
      unsigned char *packet;
    Packit 06404a
      long  bytes;
    Packit 06404a
      long  b_o_s;
    Packit 06404a
      long  e_o_s;
    Packit 06404a
    Packit 06404a
      size64 granulepos;
    Packit 06404a
    Packit 06404a
    } ogg_packet;
    Packit 06404a
    Packit 06404a
    Packit 06404a
    Packit 06404a
    packet:
    Packit 06404a
    a pointer to the byte data of the raw packet
    Packit 06404a
    bytes:
    Packit 06404a
    the size of the packet' raw data
    Packit 06404a
    b_o_s:
    Packit 06404a
    beginning of stream; nonzero if this is the first packet of
    Packit 06404a
      the logical bitstream
    Packit 06404a
    e_o_s:
    Packit 06404a
    end of stream; nonzero if this is the last packet of the
    Packit 06404a
      logical bitstream
    Packit 06404a
    granulepos:
    Packit 06404a
    the absolute position of this packet in the original
    Packit 06404a
      uncompressed data stream.
    Packit 06404a
    Packit 06404a
    Packit 06404a

    encoding notes

    Packit 06404a
    Packit 06404a

    The encoder is responsible for setting all of

    Packit 06404a
    the fields of the packet to appropriate values before submission to
    Packit 06404a
    <tt>ogg_stream_packetin()</tt>; however, it is noted that the value in
    Packit 06404a
    <tt>b_o_s</tt> is ignored; the first page produced from a given
    Packit 06404a
    <tt>ogg_stream_state</tt> structure will be stamped as the initial
    Packit 06404a
    page. <tt>e_o_s</tt>, however, must be set; this is the means by
    Packit 06404a
    which the stream encoding primitives handle end of stream and cleanup.

    Packit 06404a
    Packit 06404a

    decoding notes

    Packit 06404a
    Packit 06404a

    <tt>ogg_stream_packetout()</tt> sets the fields

    Packit 06404a
    to appropriate values. Note that granulepos will be >= 0 only in the
    Packit 06404a
    case that the given packet actually represents that position (ie, only
    Packit 06404a
    the last packet completed on any page will have a meaningful
    Packit 06404a
    <tt>granulepos</tt>). Intervening frames will see <tt>granulepos</tt> set
    Packit 06404a
    to -1.

    Packit 06404a
    Packit 06404a

    ogg_page

    Packit 06404a
    Packit 06404a
    Packit 06404a
    typedef struct {
    Packit 06404a
      unsigned char *header;
    Packit 06404a
      long header_len;
    Packit 06404a
      unsigned char *body;
    Packit 06404a
      long body_len;
    Packit 06404a
    } ogg_page;
    Packit 06404a
    Packit 06404a
    Packit 06404a
    Packit 06404a
    header:
    Packit 06404a
    pointer to the page header data
    Packit 06404a
    header_len:
    Packit 06404a
    length of the page header in bytes
    Packit 06404a
    body:
    Packit 06404a
    pointer to the page body
    Packit 06404a
    body_len:
    Packit 06404a
    length of the page body
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Note that although the <tt>header</tt> and <tt>body</tt> pointers do

    Packit 06404a
    not necessarily point into a single contiguous page vector, the page
    Packit 06404a
    body must immediately follow the header in the bitstream.

    Packit 06404a
    Packit 06404a

    Ogg Bitstream Manipulation Functions

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_page_bos(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the 'beginning of stream' flag for the given Ogg page. The

    Packit 06404a
    beginning of stream flag is set on the initial page of a logical
    Packit 06404a
    bitstream.

    Packit 06404a
    Packit 06404a

    Zero indicates the flag is cleared (this is not the initial page of a

    Packit 06404a
    logical bitstream). Nonzero indicates the flag is set (this is the
    Packit 06404a
    initial page of a logical bitstream).

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_page_continued(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the 'packet continued' flag for the given Ogg page. The packet

    Packit 06404a
    continued flag indicates whether or not the body data of this page
    Packit 06404a
    begins with packet continued from a preceeding page.

    Packit 06404a
    Packit 06404a

    Zero (unset) indicates that the body data begins with a new packet.

    Packit 06404a
    Nonzero (set) indicates that the first packet data on the page is a
    Packit 06404a
    continuation from the preceeding page.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_page_eos(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the 'end of stream' flag for a give Ogg page. The end of page

    Packit 06404a
    flag is set on the last (terminal) page of a logical bitstream.

    Packit 06404a
    Packit 06404a

    Zero (unset) indicates that this is not the last page of a logical

    Packit 06404a
    bitstream. Nonzero (set) indicates that this is the last page of a
    Packit 06404a
    logical bitstream and that no addiitonal pages belonging to this
    Packit 06404a
    bitstream may follow.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    size64 ogg_page_granulepos(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the position of this page as an absolute position within the

    Packit 06404a
    original uncompressed data. The position, as returned, is 'frames
    Packit 06404a
    encoded to date up to and including the last whole packet on this
    Packit 06404a
    page'. Partial packets begun on this page but continued to the
    Packit 06404a
    following page are not included. If no packet ends on this page, the
    Packit 06404a
    frame position value will be equal to the frame position value of the
    Packit 06404a
    preceeding page. If none of the original uncompressed data is yet
    Packit 06404a
    represented in the logical bitstream (for example, the first page of a
    Packit 06404a
    bitstream consists only of a header packet; this packet encodes only
    Packit 06404a
    metadata), the value shall be zero.

    Packit 06404a
    Packit 06404a

    The units of the framenumber are determined by media mapping. A

    Packit 06404a
    vorbis audio bitstream, for example, defines one frame to be the
    Packit 06404a
    channel values from a single sampling period (eg, a 16 bit stereo
    Packit 06404a
    bitstream consists of two samples of two bytes for a total of four
    Packit 06404a
    bytes, thus a frame would be four bytes). A video stream defines one
    Packit 06404a
    frame to be a single frame of video.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_page_pageno(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the sequential page number of the given Ogg page. The first

    Packit 06404a
    page in a logical bitstream is numbered zero; following pages are
    Packit 06404a
    numbered in increasing monotonic order.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_page_serialno(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the serial number of the given Ogg page. The serial number is

    Packit 06404a
    used as a handle to distinguish various logical bitstreams in a
    Packit 06404a
    physical Ogg bitstresm. Every logical bitstream within a
    Packit 06404a
    physical bitstream must use a unique (within the scope of the physical
    Packit 06404a
    bitstream) serial number, which is stamped on all bitstream pages.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_page_version(ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Returns the revision of the Ogg bitstream structure of the given page.

    Packit 06404a
    Currently, the only permitted number is zero. Later revisions of the
    Packit 06404a
    bitstream spec will increment this version should any changes be
    Packit 06404a
    incompatable.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_clear(ogg_stream_state *os);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Clears and deallocates the internal storage of the given Ogg stream.

    Packit 06404a
    After clearing, the stream structure is not initialized for use;
    Packit 06404a
    <tt>ogg_stream_init</tt> must be called to reinitialize for use.
    Packit 06404a
    Use <tt>ogg_stream_reset</tt> to reset the stream state
    Packit 06404a
    to a fresh, intiialized state.

    Packit 06404a
    Packit 06404a

    <tt>ogg_stream_clear</tt> does not call <tt>free()</tt> on the pointer

    Packit 06404a
    <tt>os</tt>, allowing use of this call on stream structures in static
    Packit 06404a
    or automatic storage. <tt>ogg_stream_destroy</tt>is a complimentary
    Packit 06404a
    function that frees the pointer as well.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure. This function always

    Packit 06404a
    succeeds.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_destroy(ogg_stream_state *os);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Clears and deallocates the internal storage of the given Ogg stream,

    Packit 06404a
    then frees the storage associated with the pointer <tt>os</tt>.

    Packit 06404a
    Packit 06404a

    <tt>ogg_stream_clear</tt> does not call <tt>free()</tt> on the pointer

    Packit 06404a
    <tt>os</tt>, allowing use of that call on stream structures in static
    Packit 06404a
    or automatic storage.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure. This function always

    Packit 06404a
    succeeds.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_init(ogg_stream_state *os,int serialno);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Initialize the storage associated with <tt>os</tt> for use as an Ogg

    Packit 06404a
    stream. This call is used to initialize a stream for both encode and
    Packit 06404a
    decode. The given serial number is the serial number that will be
    Packit 06404a
    stamped on pages of the produced bitstream (during encode), or used as
    Packit 06404a
    a check that pages match (during decode).

    Packit 06404a
    Packit 06404a

    Returns zero on success, nonzero on failure.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Used during encoding to add the given raw packet to the given Ogg

    Packit 06404a
    bitstream. The contents of <tt>op</tt> are copied;
    Packit 06404a
    <tt>ogg_stream_packetin</tt> does not retain any pointers into
    Packit 06404a
    <tt>op</tt>'s storage. The encoding proccess buffers incoming packets
    Packit 06404a
    until enough packets have been assembled to form an entire page;
    Packit 06404a
    <tt>ogg_stream_pageout</tt> is used to read complete pages.

    Packit 06404a
    Packit 06404a

    Returns zero on success, nonzero on failure.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Used during decoding to read raw packets from the given logical

    Packit 06404a
    bitstream. <tt>ogg_stream_packetout</tt> will only return complete
    Packit 06404a
    packets for which checksumming indicates no corruption. The size and
    Packit 06404a
    contents of the packet exactly match those given in the encoding
    Packit 06404a
    process. 

    Packit 06404a
    Packit 06404a

    Returns zero if the next packet is not ready to be read (not buffered

    Packit 06404a
    or incomplete), positive if it returned a complete packet in
    Packit 06404a
    <tt>op</tt> and negative if there is a gap, extra bytes or corruption
    Packit 06404a
    at this position in the bitstream (essentially that the bitstream had
    Packit 06404a
    to be recaptured). A negative value is not necessarily an error. It
    Packit 06404a
    would be a common occurence when seeking, for example, which requires
    Packit 06404a
    recapture of the bitstream at the position decoding continued.

    Packit 06404a
    Packit 06404a

    If the return value is positive, <tt>ogg_stream_packetout</tt> placed

    Packit 06404a
    a packet in <tt>op</tt>. The data in <tt>op</tt> points to static
    Packit 06404a
    storage that is valid until the next call to
    Packit 06404a
    <tt>ogg_stream_pagein</tt>, <tt>ogg_stream_clear</tt>,
    Packit 06404a
    <tt>ogg_stream_reset</tt>, or <tt>ogg_stream_destroy</tt>. The
    Packit 06404a
    pointers are not invalidated by more calls to
    Packit 06404a
    <tt>ogg_stream_packetout</tt>.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Used during decoding to buffer the given complete, pre-verified page

    Packit 06404a
    for decoding into raw Ogg packets. The given page must be framed,
    Packit 06404a
    normally produced by <tt>ogg_sync_pageout</tt>, and from the logical
    Packit 06404a
    bitstream associated with <tt>os</tt> (the serial numbers must match).
    Packit 06404a
    The contents of the given page are copied; <tt>ogg_stream_pagein</tt>
    Packit 06404a
    retains no pointers into <tt>og</tt> storage.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Used during encode to read complete pages from the stream buffer. The

    Packit 06404a
    returned page is ready for sending out to the real world.

    Packit 06404a
    Packit 06404a

    Returns zero if there is no complete page ready for reading. Returns

    Packit 06404a
    nonzero when it has placed data for a complete page into
    Packit 06404a
    <tt>og</tt>. Note that the storage returned in og points into internal
    Packit 06404a
    storage; the pointers in <tt>og</tt> are valid until the next call to
    Packit 06404a
    <tt>ogg_stream_pageout</tt>, <tt>ogg_stream_packetin</tt>,
    Packit 06404a
    <tt>ogg_stream_reset</tt>, <tt>ogg_stream_clear</tt> or
    Packit 06404a
    <tt>ogg_stream_destroy</tt>.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_stream_reset(ogg_stream_state *os);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Resets the given stream's state to that of a blank, unused stream;

    Packit 06404a
    this may be used during encode or decode.

    Packit 06404a
    Packit 06404a

    Note that if used during encode, it does not alter the stream's serial

    Packit 06404a
    number. In addition, the next page produced during encoding will be
    Packit 06404a
    marked as the 'initial' page of the logical bitstream.

    Packit 06404a
    Packit 06404a

    When used during decode, this simply clears the data buffer of any

    Packit 06404a
    pending pages. Beginning and end of stream cues are read from the
    Packit 06404a
    bitstream and are unaffected by reset.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure. This function always

    Packit 06404a
    succeeds.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    char  *ogg_sync_buffer(ogg_sync_state *oy, long size);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    This call is used to buffer a raw bitstream for framing and

    Packit 06404a
    verification. <tt>ogg_sync_buffer</tt> handles stream capture and
    Packit 06404a
    recapture, checksumming, and division into Ogg pages (as required by
    Packit 06404a
    <tt>ogg_stream_pagein</tt>).

    Packit 06404a
    Packit 06404a

    <tt>ogg_sync_buffer</tt> exposes a buffer area into which the decoder

    Packit 06404a
    copies the next (up to) <tt>size</tt> bytes. We expose the buffer
    Packit 06404a
    (rather than taking a buffer) in order to avoid an extra copy many
    Packit 06404a
    uses; this way, for example, <tt>read()</tt> can transfer data
    Packit 06404a
    directly into the stream buffer without first needing to place it in
    Packit 06404a
    temporary storage.

    Packit 06404a
    Packit 06404a

    Returns a pointer into <tt>oy</tt>'s internal bitstream sync buffer;

    Packit 06404a
    the remaining space in the sync buffer is at least <tt>size</tt>
    Packit 06404a
    bytes. The decoder need not write all of <tt>size</tt> bytes;
    Packit 06404a
    <tt>ogg_sync_wrote</tt> is used to inform the engine how many bytes
    Packit 06404a
    were actually written. Use of <tt>ogg_sync_wrote</tt> after writing
    Packit 06404a
    into the exposed buffer is mandantory.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_sync_clear(ogg_sync_state *oy);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    <tt>ogg_sync_clear</tt>

    Packit 06404a
    clears and deallocates the internal storage of the given Ogg sync
    Packit 06404a
    buffer. After clearing, the sync structure is not initialized for
    Packit 06404a
    use; <tt>ogg_sync_init</tt> must be called to reinitialize for use.
    Packit 06404a
    Use <tt>ogg_sync_reset</tt> to reset the sync state and buffer to a
    Packit 06404a
    fresh, intiialized state.

    Packit 06404a
    Packit 06404a

    <tt>ogg_sync_clear</tt> does not call <tt>free()</tt> on the pointer

    Packit 06404a
    <tt>oy</tt>, allowing use of this call on sync structures in static
    Packit 06404a
    or automatic storage. <tt>ogg_sync_destroy</tt>is a complimentary
    Packit 06404a
    function that frees the pointer as well.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure. This function always

    Packit 06404a
    succeeds.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_sync_destroy(ogg_sync_state *oy);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Clears and deallocates the internal storage of the given Ogg sync

    Packit 06404a
    buffer, then frees the storage associated with the pointer
    Packit 06404a
    <tt>oy</tt>.

    Packit 06404a
    Packit 06404a

    An alternative function,<tt>ogg_sync_clear</tt>, does not call

    Packit 06404a
    <tt>free()</tt> on the pointer <tt>oy</tt>, allowing use of that call on
    Packit 06404a
    stream structures in static or automatic storage.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure. This function always

    Packit 06404a
    succeeds.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_sync_init(ogg_sync_state *oy);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Initializes the sync buffer <tt>oy</tt> for use.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure. This function always

    Packit 06404a
    succeeds.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Reads complete, framed, verified Ogg pages from the sync buffer,

    Packit 06404a
    placing the page data in <tt>og</tt>.

    Packit 06404a
    Packit 06404a

    Returns zero when there's no complete pages buffered for

    Packit 06404a
    retrieval. Returns negative when a loss of sync or recapture occurred
    Packit 06404a
    (this is not necessarily an error; recapture would be required after
    Packit 06404a
    seeking, for example). Returns positive when a page is returned in
    Packit 06404a
    <tt>og</tt>. Note that the data in <tt>og</tt> points into the sync
    Packit 06404a
    buffer storage; the pointers are valid until the next call to
    Packit 06404a
    <tt>ogg_sync_buffer</tt>, <tt>ogg_sync_clear</tt>,
    Packit 06404a
    <tt>ogg_sync_destroy</tt> or <tt>ogg_sync_reset</tt>.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_sync_reset(ogg_sync_state *oy);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    <tt>ogg_sync_reset</tt> resets the sync state in <tt>oy</tt> to a

    Packit 06404a
    clean, empty state. This is useful, for example, when seeking to a
    Packit 06404a
    new location in a bitstream.

    Packit 06404a
    Packit 06404a

    Returns zero on success, nonzero on failure.

    Packit 06404a
    Packit 06404a

    Packit 06404a
    int    ogg_sync_wrote(ogg_sync_state *oy, long bytes);
    Packit 06404a
    Packit 06404a
    Packit 06404a

    Used to inform the sync state as to how many bytes were actually

    Packit 06404a
    written into the exposed sync buffer. It must be equal to or less
    Packit 06404a
    than the size of the buffer requested.

    Packit 06404a
    Packit 06404a

    Returns zero on success and non-zero on failure; failure occurs only

    Packit 06404a
    when the number of bytes written were larger than the buffer.

    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>