This project has moved and is read-only. For the latest updates, please go here.

Mp3FrameDecompressor has some issue when decode the layer2 mp3 file


Hi, I just got a problem when decoding the mp3 file. By using the following code, It is OK if the format version is layer 1. The output stream will be the 32kbps mp3. Maybe the lamemp3filewriter will do some format stuff. The output format version will be changed into layer 2.
                var freader = new Mp3FileReader(srcStream, format => new Mp3FrameDecompressor(format));
                using (var writer = new LameMP3FileWriter(resStream, freader.WaveFormat, 32))
Then if we use the generated layer 2 mp3 file go through the logic again we will find that some exception will be thrown in side the MP3FrameWrapper.cs. EndOfStreamException will be thrown out.
public int ReadBits(int bitCount)
            if (bitCount < 1 || bitCount > 32) throw new ArgumentOutOfRangeException("bitCount");
            while (_bitsRead < bitCount)
                if (_readOffset == _frame.FrameLength) throw new System.IO.EndOfStreamException();
I trace the stack of the issue. It happened in the trace: curDecoder.DecodeFrame(frame, _ch0, _ch1) MpegFrameDecoder.cs DecodeFrameImpl->_bitRes.AddBits(frame,_mainDataBegin) LayerIIIDecoder.cs DecodeFrame->frame.ReadBits(8) BitReservoir.cs

Please help take a look? Thanks