ID3 unsynchronization: how it works

2019-09-12 09:56发布

问题:

According the documentation, ID3 tags have an unsynchronization flag. As I understood, it should only be applied to ID3 frames (not headers or footer).

But how exactly should I process the frames before parsing (for reading, not writing)? Should I just replace all '11111111 111xxxxx' sequences for '11111111 00000000 111xxxxx'?

回答1:

No, that's what you do when WRITING the tag (and don't forget, in this case you also need to replace any "0xff,0x00" with "0xff,0x00,0x00", as stated in the spec).

When you are READING the tag, you can simply replace any "0xff,0x00" sequence with "0xff". It's easiest to do this at once while you're reading the file, by keeping track of the last byte read and discarding any single 0x00 byte which follows an 0xff.

It's not really so easy to figure this out because the spec only describes what to do in the way of unsynchronisation when you're writing the tag, not what you do when reading it.



标签: id3 id3v2