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

Filip Roséen filip at videolabs.io
Thu Mar 10 12:01:35 CET 2016


> For the record, file written with libmatroska are guaranteed to have
> sorted Cues thanks to this line:
> https://github.com/Matroska-Org/libmatroska/blob/master/matroska/KaxCues.h#L67

That is very good to know, but given the "trust nothing" mentality I kinda vote
for doing another pass on the data just to make sure that it is actually sorted.

> Since we're using libmatroska for reading, rather than recreating a
> sort, you might use the same Sort() call before actually using the
> data in the KaxCues that you just read.

The reason an "additional" sort was introduced is because I couldn't find
anything that would allow you to really sort a bunch of `KaxCluster`s. The
default implementation of the virtual `EbmlElement::IsSmallerThan` (which is
inherited down, together with `EbmlMaster::Sort`) simply compares the equality
of the `EbmlIds`.

Disregarding the fact that equality is used instead of proper less-than, given
the fact that there is not a way to properly sort KaxClusters we still need to
have our own sorting method somewhere (if we care about files where these do not
appear in order), and as such I added the code in question.

Using a container where sorting happens implicitly (such as a map) would of
course allow us to remove the code in question if we use the (integer) time as
key.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160310/dfb63951/attachment.html>


More information about the vlc-devel mailing list