The data size of each ID3v2 frame is stored in 4, 5, 6 and 7 bytes of the frame header block (according to documentation):
I am reading frame sizes from this mp3 file:
To convert to integer the frame data size, I use the following code:
int frame_data_sz = b4 << 21 | b5 << 14 | b6 << 7 | b7;
For example, for most frames, this code correctly calculates the frame size:
TALB -> 0x00 0x00 0x00 0x02 -> 2 bytes - correct!
TIT2 -> 0x00 0x00 0x00 0x02 -> 2 bytes - correct!
TPE1 -> 0x00 0x00 0x00 0x02 -> 2 bytes - correct!
TCON -> 0x00 0x00 0x00 0x02 -> 2 bytes - correct!
TCOM -> 0x00 0x00 0x00 0x02 -> 2 bytes - correct!
TRCK -> 0x00 0x00 0x00 0x03 -> 3 bytes - correct!
TLEN -> 0x00 0x00 0x00 0x06 -> 6 bytes - correct!
COMM -> 0x00 0x00 0x00 0x06 -> 6 bytes - correct!
APIC -> 0x00 0x01 0x0F 0x5D -> 18397 bytes - INCORRECT!
For "APIC" frame my code calculates wrong frame size value because actual data size value is 71517 bytes.
How correctly convert the frame size to an integer value?