demux_mkv: improve seeking with generated index
commit52126e574c7872ca95e7974cfe5445421b74f24c
authorUoti Urpala <uau@glyph.nonexistent.invalid>
Fri, 1 Jan 2010 16:42:52 +0000 (1 18:42 +0200)
committerUoti Urpala <uau@glyph.nonexistent.invalid>
Fri, 1 Jan 2010 17:17:51 +0000 (1 19:17 +0200)
tree77a6979297fa8e3729668657ad001b61a4da650b
parent3ad06dd7d2fb381670a741c769401501c10aacc8
demux_mkv: improve seeking with generated index

When using generated index (-idx / -forceidx) the Matroska seeking
code first guessed a file position using bitrate-based heuristics,
then located the cluster nearest to that file position. Change it to
store cluster timestamps in addition to file positions and seek to the
cluster with the closest timestamp. This makes seeking with -idx a lot
more accurate.

This change also fixes a crash when trying to seek with generated
index before playing any data from the beginning of the file (could be
triggered by -idx together with ordered chapters or -ss for example).

I removed the code handling MATROSKA_ID_CUES in the middle of parsing
clusters. Such cue entries were not consistently handled if
encountered during playback instead of index creation and the seek
code was also buggy when they were encountered and parsed; i didn't
consider it worth the effort to fix it.
libmpdemux/demux_mkv.c