MSC Thesis about audio compression
Reply #46 – 2008-06-20 18:18:00
Hi Omion, I know this thread has been dead for a long time, but I have a question. Well, more of an observation really. It seems to me that the bit reservoir cannot ever stretch back more than one frame. The reason is that the decoder doesn't know where to look for the bits (or, rather, bytes) to be carried forward from the preceding frames if there is more than one of them (frames, that is, not bytes). With the bit reservoir entirely contained in one frame, the calculation is simple:start_of_data_to_be_carried_forward = start_of_frame + frame_size - next_frame->bit_reservoir; But with two preceding frames, what do you do? Specifically, you don't know (or, at least, cannot easily find out) how much of the immediately preceding frame (let's say there are two, for the sake of argument) is available for reservoir bytes and how many bytes are being used to encode the frame itself (I hope this makes some kind of sense!). A quick glance at the LAME source code (check out maxmp3buf) supports this view, and my own experiments (with files encoded using LAME) bear this out, but I would be interested in your opinion. <EDIT> OK, I worked it out! If the bit reservoir stretches back, say, two frames, then *all* of the audio data in the immediately preceding frame is to be considered as part of the bit reservoir. All coded and working now But what a mess the MP3 spec is! Diabolical. They should have thrown MP's 1 and 2 away and started again with a proper framing scheme. And the ISO spec is just plain wrong in this regard - it talks about about main_data_end when it really means main_data_begin. Clearly the person who wrote it up did not understand - it simply would not work as specified. </EDIT> Incidentally, I found your posts very helpful. Up to now, we have been recording to VBR format with the bit reservoir disabled to make it easy to cut and splice our MP3 files, but this is clearly not optimal and in any case we have to deal with files imported from other sources. We are now in the process of cleaning up our act, thanks, in part, to you. Regards, Paul Sandershttp://www.alpinesoft.co.uk