问题
In the documentation for avcodec_decode_video2 it gives the following warning:
Warning:
The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end. The end of the input buffer buf should be set to 0 to ensure that no overreading happens for damaged MPEG streams.
If this were not implemented would this cause segmentation faults when overreading occurs? Or would it potentially cause weird corruption? I'm just curious as I have corruption and I'm not sure if this could potentially be causing my problem.
回答1:
It wouldn't necessarily cause segmentation faults, but it would be undefined behavior
, since these readers would be reading unallocated memory. This could make the program crash immediately, or work for a while, or even appear to work fine: you can never be sure when it comes to undefined behavior
.
来源:https://stackoverflow.com/questions/18857365/avcodec-decode-video2-what-do-the-extra-bytes-prevent