QUOTE
What is a good behaviour for a code if the bitrate is a fixed value from the table and there's no MPEG frame synch at the calculated offset (broken frame sequence probably)?
I have a little experience with this, atm. I'm using the following to re-sync:
- Check for an end-tag header @ the calculated position: end-of-stream or stream-concatenation;
- If no tag-header or in case there's bytes after the end-tag: scan for a new MPEG header AFTER the calculated position.
I tried scanning from an arbitrary position inside the last found frame, but that gave me too much rubbish. That was because I wasn't using a validation of the next frame header after a newly found one.
So atm. I'm using validation of four bytes from the next frame in scanning for / validation of a new MPEG header.
I'm also using a preliminary scan-area which is two frames wide in case the stream is predicted to be a CBR one.
QUOTE
Should i try and find the next frame after the 'garbage' is encountered in a file?
I would suggest so.
QUOTE
Is it allowed for MPEG frame sequences to be broken (to include 'garbage' between frames)?
I guess a nice-&-neat MPEG audio stream does not contain any rubbish. I think it depends on the decoder to qualify part of a stream as rubbish or out-of-sync. This might for example depend on how the decoder calculates the amount of bytes in a frame. Now while this seems fairly straightforward, I've seen MPEG-1 L.I streams encoded by the MainConcept encoder containing frames which seem too long, or frame headers having the first (sync) byte chopped off / overwritten. Not nice if you want your decoder to detect that, but on the other hand, skipping one frame will not do much harm.
Anyway, a lot of redundancy in a decoder will slow it down, so I guess a trade-off has to be made.
QUOTE
What to do if there's only one or two consequent legal frames in the file (VERY short file) ? is it ok to handle these frames, or is there a minimum size and maximum size requirement a MPEG frame sequence should meet?
I have never read anything about a minimum or maximum number of frames. Again, if you want to be able to decode a one-frame or a two-frame MPEG audio stream you'll probably have to take these situations into account. Especially in case you're using a fixed size window / buffer for reading the stream. I think a decoder can distinguish itself by using a flexible stream-reading window, maybe even adapting to such exotic situations as you point out. In practice however, I've seen decoders which simply crash @ a one-frame stream.