[Vorbis] Byte order in ogg vorbis headers
Ralph Giles
giles at xiph.org
Sun Jul 6 10:46:52 PDT 2008
On 6-Jul-08, at 12:07 AM, Ryan Rix wrote:
> The issue I seem to be having is that when parsing the comments I
> use a for loop limited by the number of fields, which is a value
> stored within the ogg file, one or two bytes before the comments
> begin (I don't have my code handy to check atm) According to the
> Vorbis docs this is stored as unsigned integer of 32 bits. I assume
> that it is x86 little endian and thus byte swap it using
> an OS provided macro.
Yes, the comment count and lengths are stored in little-endian order,
so either the files are broken or it's another issue with your code.
You can clip the count and comment lengths against the size of the
packet, which should get rid of the hang even if you fail to retrieve
the comments.
Otherwise, remember the 32 bit ints aren't necessarily aligned. Make
sure you take the vendor string's length into account in finding the
comment count. "A few bytes before the comments start" sounds
suspiciously like you're not using a full parser, so make sure you've
got the second packet in the vorbis stream, and note that if the
comments are more than 4kB, they may not be stored contiguously.
That's all I can suggest without seeing your code. Hope it helps,
-r
More information about the Vorbis
mailing list