[vorbis] Problem with decoding number of codebooks

Carsten Haese chaese at accesstoledo.com
Mon Jun 30 19:52:29 PDT 2003



Donal Riordan wrote:
> 
> Hello,
> 
> I'm trying to write a Vorbis decoder (just as a hobby) but I've got a
> problem with reading the setup header. According to the Vorbis
> documentation the first data that should be read after the initial
> 'vorbis' string is an eight bit integer which when incremented by one,
> contains the number of codebooks in the header. My problem is that
> whenever I read this number it seems to be wrong!
> For example, I created a very small Ogg Vorbis file and in this file the
> first byte of the setup header is 29 (hex). This means that 42 (dec)
> codebooks should follow. However this is not the case - in the entire file
> there are only 7 occurances of the 'BCV' string which identifies codebooks
> so the value stored should be 06.

The problem is that you're not counting all codebooks with your text search
method.

Vorbis is not a bytestream, it's a bitstream. The codebook sync pattern is not
the byte sequence 'BCV', it's the bit sequence 010000100100001101010110. By
looking for the 'BCV' byte sequence, you only see the codebooks that happen to
begin on a byte boundary. Since codebooks aren't padded to full bytes, most
codebooks will start in the middle of a byte, and your text search will miss the
(shifted) sync pattern.

Hope this helps,

Carsten "Purple" Haese
Ogg Traffic Editor
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis mailing list