[vlc-devel] [PATCH 02/14] mkv: make sure indexes are in order

Filip Roséen filip at videolabs.io
Wed Mar 9 13:12:15 CET 2016


To add a little bit of information regarding the mental process leading up this
patch:

I could not find anything proving that the Cues are guaranteed to appear in
order, and since we (when looking for the index) are doing a sequential search
for the _first_ Cue (index) that is bigger than the desired seekpoint I was
worried that a file containing Cues that are not in ascending order would make
us beginning seeking at the wrong place.

Let's say we receive the Cues in the following order:

  - Cue #1: i_mk_time = 0
  - Cue #2: i_mk_time = 100
  - Cue #3: i_mk_time = 90

The code responsible for seeking used a for-loop iterating through each Cue
(index) (in order), breaking when `i_mk_date < mkv_index.i_mk_time +
mkv_index.i_mk_time_offset` (where `i_mk_date` is the desired seeking position,
and `mkv_index` is an object of type `mkv_index_t`).

It then takes one step back (since it expects the index before our find to be
smaller than `i_mk_date`).

If we then imagine `i_mk_date = 95`, we would first end up at *Cue #2*, and then
begin to seek from *Cue #1* (even though *Cue #3* would be a far better place).

We would find *Cue #3* if the cue's appeared in sorted order inside our
container of indexes.

Please correct me if I understood things incorrectly, I am still very new to the
matroska fileformat and libebml; thanks!

------------------------------------------------------------------------------

On 16/03/09 13:00, Jean-Baptiste Kempf wrote:

> On 09/03/2016 12:49, Filip Roséen wrote:
> >This patch will protect us from seeking too far if a mkv-files contains
> >Cues that are not in ascending order.
> 
> TypX, robux?
> 
> 
> -- 
> Jean-Baptiste Kempf
> http://www.jbkempf.com/ - +33 672 704 734
> Sent from my Electronic Device
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160309/05dfafb6/attachment.html>


More information about the vlc-devel mailing list