Nathaniel Gray
2005-Sep-14 11:49 UTC
[Vorbis-dev] Fwd: Newbie q: decoupling vorbis from ogg
From: Nathaniel Gray <n8gray@gmail.com> Date: Sep 14, 2005 11:30 AM Subject: Newbie q: decoupling vorbis from ogg To: vorbis-dev@lists.xiph.org 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? Thanks, -n8 -->>>-- Nathaniel Gray -- Caltech Computer Science ------> >>>-- Mojave Project -- http://mojave.cs.caltech.edu -->
On Wed, Sep 14, 2005 at 11:49:39AM -0700, Nathaniel Gray wrote:> 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?Yes, this is a little confusing. The Ogg container definitely not required, but libogg implements "more" than just container support. While libvorbis does not require that the packets it creates/consumes come from an Ogg container, it does use the libogg bitpacker internally, This code is shared among many of our codecs, and libogg seems a reasonable place to put it. Further, libvorbis uses the ogg_packet structure defined by the libogg api for handling the compressed data packets. This is just for convenience, since most applications do use Vorbis with the Ogg container. It also fills out the granulepos field properly, which is tedious and better not left to the caller. So there is a code dependency, but not a format dependency. Hope that clarifies the situation. -r
Michael Smith
2005-Sep-14 13:23 UTC
[Vorbis-dev] Fwd: Newbie q: decoupling vorbis from ogg
> 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 repository)? 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. 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). 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. Mike