[vorbis-dev] Data smearing

Monty xiphmont at xiph.org
Wed Aug 18 16:54:29 PDT 1999



> MP3 has this nasty habit of smearing data across many frames and
> seeking into an MP3 stream is a messy task. The developer of oolabola
> and myself are trying to get support for mp3 into his program, and one
> of the problems is that seeking into an MP3 stream often gives you
> artifacts because of the data smearing.
> 
> When you jump into the middle of an MP3 stream you may need to have a
> number of previous frames available in order to properly decode the
> current frame. That's not terrible if you can limit or predict how many
> frames you need to back up to in order to get a clean decode of your
> desired frame. But with MP3 there is no way to know how many frames you
> need -- its a trial and error situation.
> 
> How does Vorbis handle this?

Vorbis frames are self-contained.  I considered more complex ways of doing this
and then decided to opt for simplicity; good psychoacoustics mostly need access
to multiple frames for analysis rather than need to spread the data out during
coding.

So, one can reaquire the stream (this function is part of the core lib, handled
by vorbis_sync_buffer; just start stuffing data in) and start decoding
immediately at the first complete packet returned by ogg_stream_packetout.

The docs for the stream handling part of the lib are up, although they're
currently a bit too terse.  The basic idea is that one submits the data stream
starting at an arbitrary location to the ogg stream handling functions, which
capture the stream, break it down into pages, and then down into raw packets.
The packets are then handed to the vorbis decoder.  All this can be done in
five inline calls (it's broken up to allow greater flexibility should a
developer need it),

ogg_sync_buffer()        /* exposes a buffer to write raw bitstream data into */
ogg_sync_wrote()         /* Tells ogg how much data you wrote into the buffer */
ogg_sync_pageout()       /* Get the next synced/verfied/checksummed page from
                            the buffered stream. */
ogg_stream_pagein()      /* submit the page to the appropriate virtual bitstream
                            buffer */
ogg_stream_packetout()   /* extract a raw packet from the virtual bitstream */

That raw packet is then sent for audio synthesis using
vorbis_synthesis_packetin.

Monty

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/



More information about the Vorbis-dev mailing list