[Vorbis] ov_read, callbacks and 0 bytes read

Ralph Giles giles at xiph.org
Sat Oct 7 18:46:09 PDT 2006


On Sat, Oct 07, 2006 at 05:26:42PM -0700, Andrew Lentvorski wrote:

> vorbis/tremor depends on so many internal details of libogg that I'm 
> going nuts trying to untangle the two.  In addition, the vorbis and 
> tremor codebases have diverged from bug fixes as well as the difference 
> in functionality focus.

Tremor and libvorbis, while related, are effectively completely 
different decoders which mostly share an API for convenience.

libogg (and the libogg2 implementation compiled into Tremor) does two 
independent things. One is to read/write an Ogg stream. The other is a 
"bitpacker" that the decoder uses to read a bitstream from the 
compressed data. For convenience, libogg provides both, and also for 
convenience, the decoder takes an ogg_packet struct, so if you're using 
libogg you can just pass them from one library to the other. However, 
for that purpose, any length, data buffer pair would do. (or length, 
data buffer and timestamp triplet when encoding).

So the ogg_sync, ogg_stream, ogg_page stuff is all the Ogg file parsing. 
The point is the get a data packet out of the file and pass that to the 
vorbis decoder. ogg_stream_packetout() does that.

The ogg_packet gets passed by the decoding application from libogg to 
the vorbis decoder. Internally, libvorbis and Tremor use the oggpack_*() 
calls to read bits out of the buffer (well, virtual buffer in the case 
of Tremor/libogg2) when decoding. You shouldn't have to go that deep in 
the code to do what you want though.

See http://xiph.org/ogg/doc/libogg/ for a description of the libogg api. 
The libogg2 api is similar except the memory disciple is different; it
tries to be zero-copy.

Unfortunately, there's no API documentation for the low level libvorbis 
api you're trying to use. (If you want to write some, that would be 
great!) So you have to go with the call sequence from the examples and
reading the source when in doubt. It's not too bad; there are lots of 
helper functions, and not too many comments, so there's a lot to keep in 
your head, but each individual piece should be straightforward to trace 
through (at least for the decoder; the libvorbis encoder has some 
magic).

If you have specific questions, we're happy to help.

 -r


More information about the Vorbis mailing list