First off, my question is about all MPEG versions/layers, not just MP3. So if this is posted in the wrong forum, hopefully one of the moderators can move it to the right one.
I need to calculate the frame length for an MPEG of any version (1, 2 or 2.5) and any layer (1, 2 or 3). I've tried to search online for this information but I've found some slightly contradictory information and I'm hoping someone here can confirm what I think is right.
(For the following code, bitrate = bitrate of the frame in kbps, samplerate = sample rate in Hz and padding = 1 if padding bit is set, 0 otherwise.)
For layer 1 (any version), I think it should be:
CODE
frame length = 4 * (floor(12000 * bitrate / samplerate) + padding)
For layers 2, I think it should be:
CODE
frame length = floor(144000 * bitrate / samplerate) + padding
For layer 3, it should be the same as layer 2 if it is version 1. For version 2 or 2.5 it should be:
CODE
frame length = floor(72000 * bitrate / samplerate) + padding
Do I have all this right?