annotate src/libvorbis-1.3.3/doc/programming.html @ 1:05aa0afa9217

Bring in flac, ogg, vorbis
author Chris Cannam
date Tue, 19 Mar 2013 17:37:49 +0000
parents
children
rev   line source
Chris@1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Chris@1 2 <html>
Chris@1 3 <head>
Chris@1 4
Chris@1 5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
Chris@1 6 <title>Ogg Vorbis Documentation</title>
Chris@1 7
Chris@1 8 <style type="text/css">
Chris@1 9 body {
Chris@1 10 margin: 0 18px 0 18px;
Chris@1 11 padding-bottom: 30px;
Chris@1 12 font-family: Verdana, Arial, Helvetica, sans-serif;
Chris@1 13 color: #333333;
Chris@1 14 font-size: .8em;
Chris@1 15 }
Chris@1 16
Chris@1 17 a {
Chris@1 18 color: #3366cc;
Chris@1 19 }
Chris@1 20
Chris@1 21 img {
Chris@1 22 border: 0;
Chris@1 23 }
Chris@1 24
Chris@1 25 #xiphlogo {
Chris@1 26 margin: 30px 0 16px 0;
Chris@1 27 }
Chris@1 28
Chris@1 29 #content p {
Chris@1 30 line-height: 1.4;
Chris@1 31 }
Chris@1 32
Chris@1 33 h1, h1 a, h2, h2 a, h3, h3 a {
Chris@1 34 font-weight: bold;
Chris@1 35 color: #ff9900;
Chris@1 36 margin: 1.3em 0 8px 0;
Chris@1 37 }
Chris@1 38
Chris@1 39 h1 {
Chris@1 40 font-size: 1.3em;
Chris@1 41 }
Chris@1 42
Chris@1 43 h2 {
Chris@1 44 font-size: 1.2em;
Chris@1 45 }
Chris@1 46
Chris@1 47 h3 {
Chris@1 48 font-size: 1.1em;
Chris@1 49 }
Chris@1 50
Chris@1 51 li {
Chris@1 52 line-height: 1.4;
Chris@1 53 }
Chris@1 54
Chris@1 55 #copyright {
Chris@1 56 margin-top: 30px;
Chris@1 57 line-height: 1.5em;
Chris@1 58 text-align: center;
Chris@1 59 font-size: .8em;
Chris@1 60 color: #888888;
Chris@1 61 clear: both;
Chris@1 62 }
Chris@1 63 </style>
Chris@1 64
Chris@1 65 </head>
Chris@1 66
Chris@1 67 <body>
Chris@1 68
Chris@1 69 <div id="xiphlogo">
Chris@1 70 <a href="http://www.xiph.org/"><img src="fish_xiph_org.png" alt="Fish Logo and Xiph.Org"/></a>
Chris@1 71 </div>
Chris@1 72
Chris@1 73 <h1>Programming with Xiph.Org <tt>libvorbis</tt></h1>
Chris@1 74
Chris@1 75 <h2>Description</h2>
Chris@1 76
Chris@1 77 <p>Libvorbis is the Xiph.Org Foundation's portable Ogg Vorbis CODEC
Chris@1 78 implemented as a programmatic library. Libvorbis provides primitives
Chris@1 79 to handle framing and manipulation of Ogg bitstreams (used by the
Chris@1 80 Vorbis for streaming), a full analysis (encoding) interface as well as
Chris@1 81 packet decoding and synthesis for playback.</p>
Chris@1 82
Chris@1 83 <p>The libvorbis library does not provide any system interface; a
Chris@1 84 full-featured demonstration player included with the library
Chris@1 85 distribtion provides example code for a variety of system interfaces
Chris@1 86 as well as a working example of using libvorbis in production code.</p>
Chris@1 87
Chris@1 88 <h2>Encoding Overview</h2>
Chris@1 89
Chris@1 90 <h2>Decoding Overview</h2>
Chris@1 91
Chris@1 92 <p>Decoding a bitstream with libvorbis follows roughly the following
Chris@1 93 steps:</p>
Chris@1 94
Chris@1 95 <ol>
Chris@1 96 <li>Frame the incoming bitstream into pages</li>
Chris@1 97 <li>Sort the pages by logical bitstream and buffer then into logical streams</li>
Chris@1 98 <li>Decompose the logical streams into raw packets</li>
Chris@1 99 <li>Reconstruct segments of the original data from each packet</li>
Chris@1 100 <li>Glue the reconstructed segments back into a decoded stream</li>
Chris@1 101 </ol>
Chris@1 102
Chris@1 103 <h3>Framing</h3>
Chris@1 104
Chris@1 105 <p>An Ogg bitstream is logically arranged into pages, but to decode
Chris@1 106 the pages, we have to find them first. The raw bitstream is first fed
Chris@1 107 into an <tt>ogg_sync_state</tt> buffer using <tt>ogg_sync_buffer()</tt>
Chris@1 108 and <tt>ogg_sync_wrote()</tt>. After each block we submit to the sync
Chris@1 109 buffer, we should check to see if we can frame and extract a complete
Chris@1 110 page or pages using <tt>ogg_sync_pageout()</tt>. Extra pages are
Chris@1 111 buffered; allowing them to build up in the <tt>ogg_sync_state</tt>
Chris@1 112 buffer will eventually exhaust memory.</p>
Chris@1 113
Chris@1 114 <p>The Ogg pages returned from <tt>ogg_sync_pageout</tt> need not be
Chris@1 115 decoded further to be used as landmarks in seeking; seeking can be
Chris@1 116 either a rough process of simply jumping to approximately intuited
Chris@1 117 portions of the bitstream, or it can be a precise bisection process
Chris@1 118 that captures pages and inspects data position. When seeking,
Chris@1 119 however, sequential multiplexing (chaining) must be accounted for;
Chris@1 120 beginning play in a new logical bitstream requires initializing a
Chris@1 121 synthesis engine with the headers from that bitstream. Vorbis
Chris@1 122 bitstreams do not make use of concurent multiplexing (grouping).</p>
Chris@1 123
Chris@1 124 <h3>Sorting</h3>
Chris@1 125
Chris@1 126 <p>The pages produced by <tt>ogg_sync_pageout</tt> are then sorted by
Chris@1 127 serial number to seperate logical bitstreams. Initialize logical
Chris@1 128 bitstream buffers (<tt>og_stream_state</tt>) using
Chris@1 129 <tt>ogg_stream_init()</tt>. Pages are submitted to the matching
Chris@1 130 logical bitstream buffer using <tt>ogg_stream_pagein</tt>; the serial
Chris@1 131 number of the page and the stream buffer must match, or the page will
Chris@1 132 be rejected. A page submitted out of sequence will simply be noted,
Chris@1 133 and in the course of outputting packets, the hole will be flagged
Chris@1 134 (<tt>ogg_sync_pageout</tt> and <tt>ogg_stream_packetout</tt> will
Chris@1 135 return a negative value at positions where they had to recapture the
Chris@1 136 stream).</p>
Chris@1 137
Chris@1 138 <h3>Extracting packets</h3>
Chris@1 139
Chris@1 140 <p>After submitting page[s] to a logical stream, read available packets
Chris@1 141 using <tt>ogg_stream_packetout</tt>.</p>
Chris@1 142
Chris@1 143 <h3>Decoding packets</h3>
Chris@1 144
Chris@1 145 <h3>Reassembling data segments</h3>
Chris@1 146
Chris@1 147 <h2>Ogg Bitstream Manipulation Structures</h2>
Chris@1 148
Chris@1 149 <p>Two of the Ogg bitstream data structures are intended to be
Chris@1 150 transparent to the developer; the fields should be used directly.</p>
Chris@1 151
Chris@1 152 <h3>ogg_packet</h3>
Chris@1 153
Chris@1 154 <pre>
Chris@1 155 typedef struct {
Chris@1 156 unsigned char *packet;
Chris@1 157 long bytes;
Chris@1 158 long b_o_s;
Chris@1 159 long e_o_s;
Chris@1 160
Chris@1 161 size64 granulepos;
Chris@1 162
Chris@1 163 } ogg_packet;
Chris@1 164 </pre>
Chris@1 165
Chris@1 166 <dl>
Chris@1 167 <dt>packet:</dt>
Chris@1 168 <dd>a pointer to the byte data of the raw packet</dd>
Chris@1 169 <dt>bytes:</dt>
Chris@1 170 <dd>the size of the packet' raw data</dd>
Chris@1 171 <dt>b_o_s:</dt>
Chris@1 172 <dd>beginning of stream; nonzero if this is the first packet of
Chris@1 173 the logical bitstream</dd>
Chris@1 174 <dt>e_o_s:</dt>
Chris@1 175 <dd>end of stream; nonzero if this is the last packet of the
Chris@1 176 logical bitstream</dd>
Chris@1 177 <dt>granulepos:</dt>
Chris@1 178 <dd>the absolute position of this packet in the original
Chris@1 179 uncompressed data stream.</dd>
Chris@1 180 </dl>
Chris@1 181
Chris@1 182 <h4>encoding notes</h4>
Chris@1 183
Chris@1 184 <p>The encoder is responsible for setting all of
Chris@1 185 the fields of the packet to appropriate values before submission to
Chris@1 186 <tt>ogg_stream_packetin()</tt>; however, it is noted that the value in
Chris@1 187 <tt>b_o_s</tt> is ignored; the first page produced from a given
Chris@1 188 <tt>ogg_stream_state</tt> structure will be stamped as the initial
Chris@1 189 page. <tt>e_o_s</tt>, however, must be set; this is the means by
Chris@1 190 which the stream encoding primitives handle end of stream and cleanup.</p>
Chris@1 191
Chris@1 192 <h4>decoding notes</h4>
Chris@1 193
Chris@1 194 <p><tt>ogg_stream_packetout()</tt> sets the fields
Chris@1 195 to appropriate values. Note that granulepos will be >= 0 only in the
Chris@1 196 case that the given packet actually represents that position (ie, only
Chris@1 197 the last packet completed on any page will have a meaningful
Chris@1 198 <tt>granulepos</tt>). Intervening frames will see <tt>granulepos</tt> set
Chris@1 199 to -1.</p>
Chris@1 200
Chris@1 201 <h3>ogg_page</h3>
Chris@1 202
Chris@1 203 <pre>
Chris@1 204 typedef struct {
Chris@1 205 unsigned char *header;
Chris@1 206 long header_len;
Chris@1 207 unsigned char *body;
Chris@1 208 long body_len;
Chris@1 209 } ogg_page;
Chris@1 210 </pre>
Chris@1 211
Chris@1 212 <dl>
Chris@1 213 <dt>header:</dt>
Chris@1 214 <dd>pointer to the page header data</dd>
Chris@1 215 <dt>header_len:</dt>
Chris@1 216 <dd>length of the page header in bytes</dd>
Chris@1 217 <dt>body:</dt>
Chris@1 218 <dd>pointer to the page body</dd>
Chris@1 219 <dt>body_len:</dt>
Chris@1 220 <dd>length of the page body</dd>
Chris@1 221 </dl>
Chris@1 222
Chris@1 223 <p>Note that although the <tt>header</tt> and <tt>body</tt> pointers do
Chris@1 224 not necessarily point into a single contiguous page vector, the page
Chris@1 225 body must immediately follow the header in the bitstream.</p>
Chris@1 226
Chris@1 227 <h2>Ogg Bitstream Manipulation Functions</h2>
Chris@1 228
Chris@1 229 <h3>
Chris@1 230 int ogg_page_bos(ogg_page *og);
Chris@1 231 </h3>
Chris@1 232
Chris@1 233 <p>Returns the 'beginning of stream' flag for the given Ogg page. The
Chris@1 234 beginning of stream flag is set on the initial page of a logical
Chris@1 235 bitstream.</p>
Chris@1 236
Chris@1 237 <p>Zero indicates the flag is cleared (this is not the initial page of a
Chris@1 238 logical bitstream). Nonzero indicates the flag is set (this is the
Chris@1 239 initial page of a logical bitstream).</p>
Chris@1 240
Chris@1 241 <h3>
Chris@1 242 int ogg_page_continued(ogg_page *og);
Chris@1 243 </h3>
Chris@1 244
Chris@1 245 <p>Returns the 'packet continued' flag for the given Ogg page. The packet
Chris@1 246 continued flag indicates whether or not the body data of this page
Chris@1 247 begins with packet continued from a preceeding page.</p>
Chris@1 248
Chris@1 249 <p>Zero (unset) indicates that the body data begins with a new packet.
Chris@1 250 Nonzero (set) indicates that the first packet data on the page is a
Chris@1 251 continuation from the preceeding page.</p>
Chris@1 252
Chris@1 253 <h3>
Chris@1 254 int ogg_page_eos(ogg_page *og);
Chris@1 255 </h3>
Chris@1 256
Chris@1 257 <p>Returns the 'end of stream' flag for a give Ogg page. The end of page
Chris@1 258 flag is set on the last (terminal) page of a logical bitstream.</p>
Chris@1 259
Chris@1 260 <p>Zero (unset) indicates that this is not the last page of a logical
Chris@1 261 bitstream. Nonzero (set) indicates that this is the last page of a
Chris@1 262 logical bitstream and that no addiitonal pages belonging to this
Chris@1 263 bitstream may follow.</p>
Chris@1 264
Chris@1 265 <h3>
Chris@1 266 size64 ogg_page_granulepos(ogg_page *og);
Chris@1 267 </h3>
Chris@1 268
Chris@1 269 <p>Returns the position of this page as an absolute position within the
Chris@1 270 original uncompressed data. The position, as returned, is 'frames
Chris@1 271 encoded to date up to and including the last whole packet on this
Chris@1 272 page'. Partial packets begun on this page but continued to the
Chris@1 273 following page are not included. If no packet ends on this page, the
Chris@1 274 frame position value will be equal to the frame position value of the
Chris@1 275 preceeding page. If none of the original uncompressed data is yet
Chris@1 276 represented in the logical bitstream (for example, the first page of a
Chris@1 277 bitstream consists only of a header packet; this packet encodes only
Chris@1 278 metadata), the value shall be zero.</p>
Chris@1 279
Chris@1 280 <p>The units of the framenumber are determined by media mapping. A
Chris@1 281 vorbis audio bitstream, for example, defines one frame to be the
Chris@1 282 channel values from a single sampling period (eg, a 16 bit stereo
Chris@1 283 bitstream consists of two samples of two bytes for a total of four
Chris@1 284 bytes, thus a frame would be four bytes). A video stream defines one
Chris@1 285 frame to be a single frame of video.</p>
Chris@1 286
Chris@1 287 <h3>
Chris@1 288 int ogg_page_pageno(ogg_page *og);
Chris@1 289 </h3>
Chris@1 290
Chris@1 291 <p>Returns the sequential page number of the given Ogg page. The first
Chris@1 292 page in a logical bitstream is numbered zero; following pages are
Chris@1 293 numbered in increasing monotonic order.</p>
Chris@1 294
Chris@1 295 <h3>
Chris@1 296 int ogg_page_serialno(ogg_page *og);
Chris@1 297 </h3>
Chris@1 298
Chris@1 299 <p>Returns the serial number of the given Ogg page. The serial number is
Chris@1 300 used as a handle to distinguish various logical bitstreams in a
Chris@1 301 physical Ogg bitstresm. Every logical bitstream within a
Chris@1 302 physical bitstream must use a unique (within the scope of the physical
Chris@1 303 bitstream) serial number, which is stamped on all bitstream pages.</p>
Chris@1 304
Chris@1 305 <h3>
Chris@1 306 int ogg_page_version(ogg_page *og);
Chris@1 307 </h3>
Chris@1 308
Chris@1 309 <p>Returns the revision of the Ogg bitstream structure of the given page.
Chris@1 310 Currently, the only permitted number is zero. Later revisions of the
Chris@1 311 bitstream spec will increment this version should any changes be
Chris@1 312 incompatable.</p>
Chris@1 313
Chris@1 314 <h3>
Chris@1 315 int ogg_stream_clear(ogg_stream_state *os);
Chris@1 316 </h3>
Chris@1 317
Chris@1 318 <p>Clears and deallocates the internal storage of the given Ogg stream.
Chris@1 319 After clearing, the stream structure is not initialized for use;
Chris@1 320 <tt>ogg_stream_init</tt> must be called to reinitialize for use.
Chris@1 321 Use <tt>ogg_stream_reset</tt> to reset the stream state
Chris@1 322 to a fresh, intiialized state.</p>
Chris@1 323
Chris@1 324 <p><tt>ogg_stream_clear</tt> does not call <tt>free()</tt> on the pointer
Chris@1 325 <tt>os</tt>, allowing use of this call on stream structures in static
Chris@1 326 or automatic storage. <tt>ogg_stream_destroy</tt>is a complimentary
Chris@1 327 function that frees the pointer as well.</p>
Chris@1 328
Chris@1 329 <p>Returns zero on success and non-zero on failure. This function always
Chris@1 330 succeeds.</p>
Chris@1 331
Chris@1 332 <h3>
Chris@1 333 int ogg_stream_destroy(ogg_stream_state *os);
Chris@1 334 </h3>
Chris@1 335
Chris@1 336 <p>Clears and deallocates the internal storage of the given Ogg stream,
Chris@1 337 then frees the storage associated with the pointer <tt>os</tt>.</p>
Chris@1 338
Chris@1 339 <p><tt>ogg_stream_clear</tt> does not call <tt>free()</tt> on the pointer
Chris@1 340 <tt>os</tt>, allowing use of that call on stream structures in static
Chris@1 341 or automatic storage.</p>
Chris@1 342
Chris@1 343 <p>Returns zero on success and non-zero on failure. This function always
Chris@1 344 succeeds.</p>
Chris@1 345
Chris@1 346 <h3>
Chris@1 347 int ogg_stream_init(ogg_stream_state *os,int serialno);
Chris@1 348 </h3>
Chris@1 349
Chris@1 350 <p>Initialize the storage associated with <tt>os</tt> for use as an Ogg
Chris@1 351 stream. This call is used to initialize a stream for both encode and
Chris@1 352 decode. The given serial number is the serial number that will be
Chris@1 353 stamped on pages of the produced bitstream (during encode), or used as
Chris@1 354 a check that pages match (during decode).</p>
Chris@1 355
Chris@1 356 <p>Returns zero on success, nonzero on failure.</p>
Chris@1 357
Chris@1 358 <h3>
Chris@1 359 int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
Chris@1 360 </h3>
Chris@1 361
Chris@1 362 <p>Used during encoding to add the given raw packet to the given Ogg
Chris@1 363 bitstream. The contents of <tt>op</tt> are copied;
Chris@1 364 <tt>ogg_stream_packetin</tt> does not retain any pointers into
Chris@1 365 <tt>op</tt>'s storage. The encoding proccess buffers incoming packets
Chris@1 366 until enough packets have been assembled to form an entire page;
Chris@1 367 <tt>ogg_stream_pageout</tt> is used to read complete pages.</p>
Chris@1 368
Chris@1 369 <p>Returns zero on success, nonzero on failure.</p>
Chris@1 370
Chris@1 371 <h3>
Chris@1 372 int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
Chris@1 373 </h3>
Chris@1 374
Chris@1 375 <p>Used during decoding to read raw packets from the given logical
Chris@1 376 bitstream. <tt>ogg_stream_packetout</tt> will only return complete
Chris@1 377 packets for which checksumming indicates no corruption. The size and
Chris@1 378 contents of the packet exactly match those given in the encoding
Chris@1 379 process. </p>
Chris@1 380
Chris@1 381 <p>Returns zero if the next packet is not ready to be read (not buffered
Chris@1 382 or incomplete), positive if it returned a complete packet in
Chris@1 383 <tt>op</tt> and negative if there is a gap, extra bytes or corruption
Chris@1 384 at this position in the bitstream (essentially that the bitstream had
Chris@1 385 to be recaptured). A negative value is not necessarily an error. It
Chris@1 386 would be a common occurence when seeking, for example, which requires
Chris@1 387 recapture of the bitstream at the position decoding continued.</p>
Chris@1 388
Chris@1 389 <p>If the return value is positive, <tt>ogg_stream_packetout</tt> placed
Chris@1 390 a packet in <tt>op</tt>. The data in <tt>op</tt> points to static
Chris@1 391 storage that is valid until the next call to
Chris@1 392 <tt>ogg_stream_pagein</tt>, <tt>ogg_stream_clear</tt>,
Chris@1 393 <tt>ogg_stream_reset</tt>, or <tt>ogg_stream_destroy</tt>. The
Chris@1 394 pointers are not invalidated by more calls to
Chris@1 395 <tt>ogg_stream_packetout</tt>.</p>
Chris@1 396
Chris@1 397 <h3>
Chris@1 398 int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
Chris@1 399 </h3>
Chris@1 400
Chris@1 401 <p>Used during decoding to buffer the given complete, pre-verified page
Chris@1 402 for decoding into raw Ogg packets. The given page must be framed,
Chris@1 403 normally produced by <tt>ogg_sync_pageout</tt>, and from the logical
Chris@1 404 bitstream associated with <tt>os</tt> (the serial numbers must match).
Chris@1 405 The contents of the given page are copied; <tt>ogg_stream_pagein</tt>
Chris@1 406 retains no pointers into <tt>og</tt> storage.</p>
Chris@1 407
Chris@1 408 <p>Returns zero on success and non-zero on failure.</p>
Chris@1 409
Chris@1 410 <h3>
Chris@1 411 int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
Chris@1 412 </h3>
Chris@1 413
Chris@1 414 <p>Used during encode to read complete pages from the stream buffer. The
Chris@1 415 returned page is ready for sending out to the real world.</p>
Chris@1 416
Chris@1 417 <p>Returns zero if there is no complete page ready for reading. Returns
Chris@1 418 nonzero when it has placed data for a complete page into
Chris@1 419 <tt>og</tt>. Note that the storage returned in og points into internal
Chris@1 420 storage; the pointers in <tt>og</tt> are valid until the next call to
Chris@1 421 <tt>ogg_stream_pageout</tt>, <tt>ogg_stream_packetin</tt>,
Chris@1 422 <tt>ogg_stream_reset</tt>, <tt>ogg_stream_clear</tt> or
Chris@1 423 <tt>ogg_stream_destroy</tt>.</p>
Chris@1 424
Chris@1 425 <h3>
Chris@1 426 int ogg_stream_reset(ogg_stream_state *os);
Chris@1 427 </h3>
Chris@1 428
Chris@1 429 <p>Resets the given stream's state to that of a blank, unused stream;
Chris@1 430 this may be used during encode or decode.</p>
Chris@1 431
Chris@1 432 <p>Note that if used during encode, it does not alter the stream's serial
Chris@1 433 number. In addition, the next page produced during encoding will be
Chris@1 434 marked as the 'initial' page of the logical bitstream.</p>
Chris@1 435
Chris@1 436 <p>When used during decode, this simply clears the data buffer of any
Chris@1 437 pending pages. Beginning and end of stream cues are read from the
Chris@1 438 bitstream and are unaffected by reset.</p>
Chris@1 439
Chris@1 440 <p>Returns zero on success and non-zero on failure. This function always
Chris@1 441 succeeds.</p>
Chris@1 442
Chris@1 443 <h3>
Chris@1 444 char *ogg_sync_buffer(ogg_sync_state *oy, long size);
Chris@1 445 </h3>
Chris@1 446
Chris@1 447 <p>This call is used to buffer a raw bitstream for framing and
Chris@1 448 verification. <tt>ogg_sync_buffer</tt> handles stream capture and
Chris@1 449 recapture, checksumming, and division into Ogg pages (as required by
Chris@1 450 <tt>ogg_stream_pagein</tt>).</p>
Chris@1 451
Chris@1 452 <p><tt>ogg_sync_buffer</tt> exposes a buffer area into which the decoder
Chris@1 453 copies the next (up to) <tt>size</tt> bytes. We expose the buffer
Chris@1 454 (rather than taking a buffer) in order to avoid an extra copy many
Chris@1 455 uses; this way, for example, <tt>read()</tt> can transfer data
Chris@1 456 directly into the stream buffer without first needing to place it in
Chris@1 457 temporary storage.</p>
Chris@1 458
Chris@1 459 <p>Returns a pointer into <tt>oy</tt>'s internal bitstream sync buffer;
Chris@1 460 the remaining space in the sync buffer is at least <tt>size</tt>
Chris@1 461 bytes. The decoder need not write all of <tt>size</tt> bytes;
Chris@1 462 <tt>ogg_sync_wrote</tt> is used to inform the engine how many bytes
Chris@1 463 were actually written. Use of <tt>ogg_sync_wrote</tt> after writing
Chris@1 464 into the exposed buffer is mandantory.</p>
Chris@1 465
Chris@1 466 <h3>
Chris@1 467 int ogg_sync_clear(ogg_sync_state *oy);
Chris@1 468 </h3>
Chris@1 469
Chris@1 470 <p><tt>ogg_sync_clear</tt>
Chris@1 471 clears and deallocates the internal storage of the given Ogg sync
Chris@1 472 buffer. After clearing, the sync structure is not initialized for
Chris@1 473 use; <tt>ogg_sync_init</tt> must be called to reinitialize for use.
Chris@1 474 Use <tt>ogg_sync_reset</tt> to reset the sync state and buffer to a
Chris@1 475 fresh, intiialized state.</p>
Chris@1 476
Chris@1 477 <p><tt>ogg_sync_clear</tt> does not call <tt>free()</tt> on the pointer
Chris@1 478 <tt>oy</tt>, allowing use of this call on sync structures in static
Chris@1 479 or automatic storage. <tt>ogg_sync_destroy</tt>is a complimentary
Chris@1 480 function that frees the pointer as well.</p>
Chris@1 481
Chris@1 482 <p>Returns zero on success and non-zero on failure. This function always
Chris@1 483 succeeds.</p>
Chris@1 484
Chris@1 485 <h3>
Chris@1 486 int ogg_sync_destroy(ogg_sync_state *oy);
Chris@1 487 </h3>
Chris@1 488
Chris@1 489 <p>Clears and deallocates the internal storage of the given Ogg sync
Chris@1 490 buffer, then frees the storage associated with the pointer
Chris@1 491 <tt>oy</tt>.</p>
Chris@1 492
Chris@1 493 <p>An alternative function,<tt>ogg_sync_clear</tt>, does not call
Chris@1 494 <tt>free()</tt> on the pointer <tt>oy</tt>, allowing use of that call on
Chris@1 495 stream structures in static or automatic storage.</p>
Chris@1 496
Chris@1 497 <p>Returns zero on success and non-zero on failure. This function always
Chris@1 498 succeeds.</p>
Chris@1 499
Chris@1 500 <h3>
Chris@1 501 int ogg_sync_init(ogg_sync_state *oy);
Chris@1 502 </h3>
Chris@1 503
Chris@1 504 <p>Initializes the sync buffer <tt>oy</tt> for use.</p>
Chris@1 505
Chris@1 506 <p>Returns zero on success and non-zero on failure. This function always
Chris@1 507 succeeds.</p>
Chris@1 508
Chris@1 509 <h3>
Chris@1 510 int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
Chris@1 511 </h3>
Chris@1 512
Chris@1 513 <p>Reads complete, framed, verified Ogg pages from the sync buffer,
Chris@1 514 placing the page data in <tt>og</tt>.</p>
Chris@1 515
Chris@1 516 <p>Returns zero when there's no complete pages buffered for
Chris@1 517 retrieval. Returns negative when a loss of sync or recapture occurred
Chris@1 518 (this is not necessarily an error; recapture would be required after
Chris@1 519 seeking, for example). Returns positive when a page is returned in
Chris@1 520 <tt>og</tt>. Note that the data in <tt>og</tt> points into the sync
Chris@1 521 buffer storage; the pointers are valid until the next call to
Chris@1 522 <tt>ogg_sync_buffer</tt>, <tt>ogg_sync_clear</tt>,
Chris@1 523 <tt>ogg_sync_destroy</tt> or <tt>ogg_sync_reset</tt>.</p>
Chris@1 524
Chris@1 525 <h3>
Chris@1 526 int ogg_sync_reset(ogg_sync_state *oy);
Chris@1 527 </h3>
Chris@1 528
Chris@1 529 <p><tt>ogg_sync_reset</tt> resets the sync state in <tt>oy</tt> to a
Chris@1 530 clean, empty state. This is useful, for example, when seeking to a
Chris@1 531 new location in a bitstream.</p>
Chris@1 532
Chris@1 533 <p>Returns zero on success, nonzero on failure.</p>
Chris@1 534
Chris@1 535 <h3>
Chris@1 536 int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
Chris@1 537 </h3>
Chris@1 538
Chris@1 539 <p>Used to inform the sync state as to how many bytes were actually
Chris@1 540 written into the exposed sync buffer. It must be equal to or less
Chris@1 541 than the size of the buffer requested.</p>
Chris@1 542
Chris@1 543 <p>Returns zero on success and non-zero on failure; failure occurs only
Chris@1 544 when the number of bytes written were larger than the buffer.</p>
Chris@1 545
Chris@1 546 <div id="copyright">
Chris@1 547 The Xiph Fish Logo is a
Chris@1 548 trademark (&trade;) of Xiph.Org.<br/>
Chris@1 549
Chris@1 550 These pages &copy; 1994 - 2005 Xiph.Org. All rights reserved.
Chris@1 551 </div>
Chris@1 552
Chris@1 553 </body>
Chris@1 554 </html>