Hello all, I am currently writing an application for PalmOS handheld devices that organizes media files on a memory card and allows the user to easily create playlists. The tracks I am using for testing (totalling about 1.5 GB) are nearly all in Ogg Vorbis format. Throughout my testing I have had very little trouble in parsing the comment fields from mp3, asf and ogg files. That is, all except for one or two files. PalmOS runs on m68k hardware (or emulated m68k on newer devices) so the byte order is big endian. 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. On these one or two files I've encountered the application seems to hang. However on debugging the application I discover that the number of fields is exorbinately large. After byte swapping the value by hand I discover that it represents the correct number of fields for that file. My question is, I guess, is there a standard endianness for Ogg encapsulated Vorbis files' meta data? Thanks and best regards, Ryan Rix TamsPalm - The PalmOS Blog My heart is human, my blood is boiling, my brain: IBM
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
Ryan Rix wrote:> Hello all, > > I am currently writing an application for PalmOS handheld devices that > organizes media files on a memory card and allows the user to easily create > playlists. > > The tracks I am using for testing (totalling about 1.5 GB) are nearly all in > Ogg Vorbis format. > > Throughout my testing I have had very little trouble in parsing the comment > fields from mp3, asf and ogg files. > That is, all except for one or two files.WOuld you be able to post these suspect files on a web site somewhere for other people to test? Cheers, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "C++ is an atrocity, the bletcherous scab of the computing world, responsible for more buffer overflows, more security breaches, more blue screens of death, more mysterious failures than any other computer language in the history of the planet Earth." -- Eric Lee Green