audiomp3audio-streamingmpeglamemp3

What is the furthest an MP3 reservoir can be from a frame referencing it?


The compressed data of an MP3 frame can be smaller than the space available in a frame. When that happens, we call the space available a reservoir.

When a future frame is too large and can't fit in the space available in one frame, it can use a reservoir for its surplus. This allows a constant bitrate and yet variable compression length including length that are too big for a normal frame.

What I'm wondering is how far back can a reservoir be from the current frame?

For example, in the following I show 8 frames. The Current Frame (CF) and the 7 frames before it.

+----+----+----+----+----+----+----+----+
| -7 | -6 | -5 | -4 | -3 | -2 | -1 | CF |
+----+----+----+----+----+----+----+----+

Say CF is frame 100,000, could it use the reservoir still available in frame 0?

Or is there a limit such as 255 frames back?


Solution

  • As far as I know, there is no specific limit of number of frames, but there is a reference limit of 4,088 bits (511 bytes) back. So, the exact bit reservoir frame limit then depends on the bitrate.

    I found this information over on the LAME Technical FAQ:

    The MP3 data for frame N is not stored in frame N, but can be spread over several frames. In a typical case, the data for frame N will have 20% of it stored in frame N-1 and 80% stored in frame N. If the encoder builds up a large bit reservoir, the data for frame N can actually be stored 4088 bits back in the bitstream. Then if a very hard-to-encode passage comes up, then the encoder is free to use the normal bits for this frame plus up to 4088 more. The resulting data will then take up several frames. The starting negative offset in the bitstream for the data associated with a given frame in bytes is given by main_data_begin.