What is a damaged MPEG stream?

126 views Asked by At

I am reading through the avcodec documentation and I am trying to understand what it means for an MPEG stream to be damaged. It mentions:

The end of the input buffer buf should be set to 0 to ensure that no overreading happens for damaged MPEG streams.

So what would happen if the end of the input buffer was not set to 0? Would this a potential way to introduce corruption?

1

There are 1 answers

0
David Elliman On

To find the answer to this you could look at the code that reads the buffer for this kind of codec - here avcodec

It seems that the buffer is filled with a number of frames and at the end of each frame of data there is a byte count for the next. If this is set to zero then the decoder will not go on reading into uninitialised memory in the event of some kind of corruption of the MPEG stream. Such streams can be corrupted due to coding errors, transmission errors or (rarely) glitches on the storage medium. This is a good example of defensive programming.