[Vorbis-dev] Fwd: Newbie q: decoupling vorbis from ogg
n8gray at gmail.com
Thu Sep 15 00:08:20 PDT 2005
On 9/14/05, Michael Smith <msmith at xiph.org> wrote:
> > Hi,
> > Sorry if this is a newbie question. I'm trying to write an OS X
> > AudioCodec for Vorbis using libvorbis. I'm confused about the
> > libvorbis dependency on libogg. I thought the vorbis spec didn't
> > require ogg as the container, but the libvorbis API requires ogg data
> > structures in various synthesis layer functions like
> > vorbis_synthesis_headerin. Is this library only intended to be used
> > with ogg containers or is there a way to use it without ogg?
> Well first up - great news - there are a lot of people who'd love to
> have properly working vorbis in OS X. Are you intending to make this
> work open source (if so, we'd be happy to host your source in our svn
Yes, the work will be open source. It will recycle parts of the
qtcomponents.sf.net project, providing new AudioCodec components to
support Quicktime 7 and beyond. I suppose we should keep the project
there if possible, but we haven't contacted the maintainers of that
project yet to discuss it. We'll have to wait and see, but we may
take you up on the offer for repository space.
> On to your actual question... Yes, libvorbis depends on part of
> libogg. There are two points of reliance - one is the ogg_packet
> structure. This is a public structure - you can look at the ogg.h
> header file to see the definition. Though libogg fills all of this out
> for you automatically if you're using it, it's perfectly normal and
> legal for an application to directly fill in this structure in any way
> it so chooses. Other than the fact that this structure is defined in a
> libogg header file, there's nothing that actually ties it to libogg.
Ok, that helps a lot. Names can be powerful things, and when I saw
the ogg_ prefix I started to worry...
> The second place libvorbis uses libogg is for the bitpacker. This
> usage is extensive, and would be difficult to remove. However, the
> bitpacker code is part of libogg basically just for convenience - it's
> in no way tied to the ogg format. This is just code that knows how to
> take a data buffer (i.e. an actual vorbis packet, whereever it came
> from) and read bits from it incrementally. It's actually just a single
> file (ogg/src/bitwise.c).
It sounds like maybe you're saying this is an internal dependency. Is
that correct? That's fine, I'm not too concerned about what happens
behind the scenes and I've got no problem linking libogg into the
codec. It was really just the apparent conceptual dependency in the
Vorbis API that confused me.
> So in summary - you're correct that you have to use libogg with
> libvorbis, but this does not require actual usage of an ogg bitstream.
> If you have any more questions, we're happy to help out.
Well, if you insist... ;^) So looking at the decoder example, it
looks like if I have an ogg stream handy I can basically do this
(ignoring error checking for the moment):
and now (assuming it worked) I have a nice ogg_packet to feed to
vorbis_synthesis(...). If, on the other hand, I'm completely
disconnected from the container format and just have a buffer
containing one or more raw vorbis packets (as I believe will be the
case in the AudioCodec) is there a comparably simple way to get the
ogg_packet struct filled out? Or perhaps this is where the bitpacker
ceases to be an internal dependency and I have to start reading the
vorbis spec closely... :-/
Thanks Mike (and you too Ralph!),
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->
More information about the Vorbis-dev