[ID3 Dev] Reading the MCDI frame
Ben Bennett
fiji at ayup.limey.net
Mon Jul 14 06:20:28 PDT 2008
On Mon, Jul 14, 2008 at 06:27:04PM +1000, Troy Watson wrote:
> typedef struct {
> char name[4];
> unsigned int size;
> char flags[2];
> } ID3_FRAME;
> ID3_FRAME id3_frame;
This is the start of a problem. The size is not a uint in 2.4, see
http://id3.org/id3v2.4.0-structure section 4:
Frame ID $xx xx xx xx (four characters)
Size 4 * %0xxxxxxx
Flags $xx xx
The frame ID is followed by a size descriptor containing the size
of
the data in the final frame, after encryption, compression and
unsynchronisation. The size is excluding the frame header ('total
frame size' - 10 bytes) and stored as a 32 bit synchsafe integer.
So you need to do some bitshifting. From your example below, the size
is 0x00 0x00 0x01 0x38. Ignoring the first two zero bytes you have:
0x01: 0000 0001
0x38: 0011 1000
Dropping the first column gives:
*000 0001
*011 1000
And re-packing into bytes:
1011 1000
Which is 0xB8 (184 decmal).
BUT BEWARE. iTunes makes the same error you made when writing 2.4
tags. They do not write syncsafe sizes so you have to be aware of
that and sanity check to see if you got something that looks like a
valid frame header and be prepared to try the un-syncsafe version to
see if it is better. (Some small notes are at http://id3.org/iTunes)
-ben
---------------------------------------------------------------------
To unsubscribe, e-mail: id3v2-unsubscribe at id3.org
For additional commands, e-mail: id3v2-help at id3.org
More information about the ID3v2
mailing list