Post by tjWhat call in libid3tag returns the offset to the mp3 header?
Strictly speaking, none does. ID3 tags are autonomous entities, not
containers for MP3 data. However, MP3 data will typically begin
immediately following an ID3v2 tag, if any. So you just need to know
the length of the tag.
As I wrote before, id3_tag_query() will tell you the length of a tag,
if you pass it a small buffer containing the beginning of the tag data.
Usually it's easiest to assume MP3 data begins at the beginning of the
file. Try to decode a frame; if it fails due to lost sync, try
id3_tag_query() to see if an ID3 tag lives there. If so, parse the tag
and/or skip its length (e.g. with mad_stream_skip()) and then resume
decoding.
Post by tjPlus, how the hell is that four byte sync safe length decoded?
Each byte contains 7 bits of the number; libid3tag decodes it this way:
unsigned long value = 0;
value = (value << 7) | (*ptr++ & 0x7f);
value = (value << 7) | (*ptr++ & 0x7f);
value = (value << 7) | (*ptr++ & 0x7f);
value = (value << 7) | (*ptr++ & 0x7f);
return value;
--
Rob Leslie
***@mars.org