[vorbis-dev] Trouble decoding number of codebooks
Ralph Giles
giles at xiph.org
Fri Jun 13 17:18:24 PDT 2003
On Saturday, June 14, 2003, at 12:36 am, <ots1 at cs.waikato.ac.nz> wrote:
> I read in the sync pattern, and I think the codebook dimensions
> properly,
> but when I try and read in the number of codebook entries, I get a
> number
> larger than the number of bytes in the file, which I have to assume is
> wrong :)
The code you've written isn't at all portable, but assuming you're
trying to convert from vorbis little-endian to native integers on a
big-endian host, your problem is convertArray2().
Assuming 'readBytes()' reads in a byte at a time, you start with
entries = byte0,byte1,byte2,unknown,.... convertArray2 swaps this to
byte2,byte1,byte0,unknown, and then casts to a long. The actual value
is 0,byte2,byte1,byte0, so your result is multiplied by 256 + a random
value. The dimensions read is wrong too.
Hope that helps,
-r
--- >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-dev-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-dev
mailing list