xbmc/xbmc — pull request #1770 by imhof (2012-11-11 23:03:28+00:00)
Title: MPEG2/TS timestamp overflow handling

When using the PVR/VDR plug-in I had trouble playing back some recordings (especially jumping immediately stopped playback).

I think I tracked this down to problems when the ffmpeg library does a binary search based on the timestamps in the TS stream. The binary search naturally does not work if there is an overflow in the recording and the timestamps are not ordered anymore.

As these MPEG2/TS timestamps seem to have only 33 bits they regularly overflow in DVB streams.
This patch tries to recognize these overflows (by comparing with the position in the file and the bit rate) and adds 2^33 to all timestamps after the overflow. This restores the order of the timestamps and the binary search works.

(I don't know much about video streaming, so I don't know if this patch has any negative effects or even if the bit rate is always available or if more changes would be needed. But at least I can say this fixed the playback problems for all VDR recordings I tested.)