-
The routine which iterates over the RBSP to process the SEIs attempts to accommodate the individual parsers not reading all the bytes (i.e. by reading any remaining bytes before restarting the loop), as well as detecting if the parser for a given type read past the end of SEI. However the implementation does this by noting the position of the start of the NAL, getting the position after parsing, and computing the difference. This does not take into account that the bitstream parser has a pf_forward routine to strip out 3-byte emulation. Hence in cases where an emulation sequence is found, the number of bytes processed by the parser don't match how many bytes were actually consumed in the stream. The failure occurs at the bottom of the loop where either it fails to read out extra bytes if the parser didn't process the entire SEI, or aborting prematurely thinking that the parser processed too many bytes. To avoid this issue, clone the bitstream into a second instance which already has the three byte emulation stripped, and use that with the existing parser routines. The use case where this problem manifested was a low latency stream where it failed to find the SEI recovery point because there was an emulation sequence in the preceding picture timing SEI section, and this caused the loop to bail out because the bs_position was past the size of the picture_timing SEI length. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> Signed-off-by: Francois Cartegnie <fcvlcdev@free.fr>
9a478df9