[Vorbis-dev] Codebook decoding help

Ralph Giles giles at xiph.org
Wed May 10 09:29:23 PDT 2006


On Sun, Apr 16, 2006 at 02:42:42PM +0200, thomas.guettinger at aon.at wrote:

> So we proceeded in programming both cases but in both cases there still occurs a problem: With Java you can't read bits directly from a file so you have to read bytes instead (8 bit).

You're going to have to write a bitstream reader for your java 
application; vorbis (and a number of other codecs) don't generally
use octet-aligned data. Much of the header data is aligned for
convenience, but once you get into the codebooks and decoding data
packets it's pretty much a requirement.

This isn't too hard if you don't already have a library for it; you
just keep a bit offset index and mask and shift to construct the
read value from the given number of bits. You call use the oggpack_* 
calls in the libogg C implementation as an example, or if the LGPL is 
acceptable, borrow code from http://www.jcraft.com/jorbis/.

Hope that helps,
 -r


More information about the Vorbis-dev mailing list