more mpglib changes.
Ryan C. Gordon
icculus at clutteredmind.org
Sun Mar 10 14:28:06 EST 2002
Some sanity fixes in mpglib, now in CVS.
Most of the decoding problems with mpglib are due to the fact that
mpg123's recovery code has been stripped from mpglib, so if it hits a
corrupted frame, it just gives up, instead of trying to skip the frame.
This is somewhat simple to reimplement, but it can't just be added back
in. It was likely removed because mpg123 has direct access to the data
stream (and thus, can attempt to seek) whereas mpglib reads from a buffer
that the calling application has to feed.
What can be done is this: If a bogus frame is hit, try to skip ahead in
the buffer. If skipping ahead means going past the end of the buffer,
report MP3_NEED_MORE to the caller, note internally how many bytes in
the next buffer fill need to be skipped, and skip them on the next
I haven't really thought too much about it, but theoretically this solves
all the problems with corrupted MP3s, since sooner than later it will find
a bad frame header and attempt to recover. If we play our cards right, we
can even use this to discard ID3 and LYRICS tags with more certainty.
That's probably naive of me to think that, though. :)
More information about the sdlsound