I can not still figure this out, because then by adding 16 Bytes (16 Bytes = 4 Unsigned Bytes x 32 Bits size each). So in theory the header size is 4 Bytes now will be 16 Bytes.
As the spec you've now linked indicates that the 'size' field is a 28-bit value encoded in 7-lsbs of each of 4 bytes, my correction of your code was wrong. You should not read 16 byte and decode with a template of "I I I I" as I suggested.
But rather read 4 bytes as you were, but then decode with a template of 'C C C C' (or 'CCCC' or 'C4').
And if you unpack to a variable called my @size = unpack 'C4', ...; (rather than the 4 separate $lines_* variables), then the following code from your OP:
$mp3_size = ($size[0] & 0xFF) | (( $size[1] & 0xFF ) << 7) | (( $size[2] & 0xFF ) << 14) | (( $size[3] & 0xFF ) << 21);
starts to make sense. It extracts the 7-bit values from the 4 bytes and combines them together to produce the required 28-bit numeric value.
BTW: reading 4 bytes into a variable called $lines is also misleading.
In reply to Re^3: ID3v2 TAG unpack uninitialized value
by BrowserUk
in thread ID3v2 TAG unpack uninitialized value
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |