]> git.sesse.net Git - ffmpeg/commit
avformat/matroskadec: Improve handling of circular SeekHeads
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 30 Apr 2020 21:16:44 +0000 (23:16 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 8 May 2020 11:39:24 +0000 (13:39 +0200)
commit7e9103535ab82b82cb2d440c205a65a7767fa060
treefe520a55e037a2a010039d021ff2bc81b4d10e73
parent7c243eece3427bc5a6d54657d488d5c0c2985a8e
avformat/matroskadec: Improve handling of circular SeekHeads

There can be more than one SeekHead in a Matroska file, but most of the
other level 1 elements can only occur once.* Therefore the Matroska
demuxer only allows one entry per ID in its internal list of level 1
elements known to it; the only exception to this are SeekHeads.

The only exception to this are SeekHeads: When one is encountered
(either directly or in the list of entries read from SeekHeads),
a new entry in the list of known level-1 elements is always added,
even when this entry is actually already known.

This leads to lots of seeks in case of circular SeekHeads: Each time a
SeekHead is parsed, a new entry for a SeekHead will be added to the list
of entries read from SeekHeads. The exception for SeekHeads mentioned
above now implies that this SeekHead will always appear new and unparsed
and parsing will be attempted. This continued until the list of known
level-1 elements is full.

Fixing this is pretty simple: Don't add a new entry for a SeekHead if
its position matches the position of an already known SeekHead.

*: Actually, there can be multiple Tags and several other level 1
elements are "identically recurring" which means they may be resent
multiple times, but each instance must be absolutely identical to the
previous.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/matroskadec.c