xbmc/xbmc — pull request #2057 by popcornmix (2013-01-09 21:07:42+00:00)
Title: [rbp] Fix for timestamp problems commonly seen with avi files.

Fix for #13450

The previous fix (271d7b7dd5a91af857d15a1d3f01db8a1a7bfdb7) to handle h264 in avi (where pts are monotonic even though there are B frames) and for mpeg2 in ts files (where some pts values are unknown, but the dts is not a suitable replacement) resulted in dts values largely being ignored, with the GPU generating unknown timestamps based on the container framerate.

This has produced a number of synchronisation problems with avi files where the container framerate is wrong, or there are glitches/discontinuities with timestamps.

It turns out that hints.ptsinvalid identifies the first problematic category, and Broadcom has an OpenMax extension to apply the timestamps from a fifo, rather than reordering them as the video frames gets reordered through the decoder.

The second category can be identified as most timestamps are valid (presumably the I and P frames), and as long as we've seen a valid pts, then we can label the unknown (B frames) as unknown.

The standard AVI packed bitstream files have all pts values as unknown, and using the dts does the right thing.

Sensible containers (e.g. mkv) will be unaffected.

This patch seems to fix all the problematic files (I've got 23) that people have posted with stutter and out of sync problems.