]> git.sesse.net Git - ffmpeg/commit
avformat/matroskaenc: Fix edge case of writing Cues at the beginning
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 28 Dec 2019 17:39:38 +0000 (18:39 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 2 Apr 2020 17:50:05 +0000 (19:50 +0200)
commitb788343446094203773968e5188ca53af5ed5d97
tree130666784f123a58213310d9ce27a3c7d2e3c639
parent06f108907d75bae89a568eda02e188a91deb4ec9
avformat/matroskaenc: Fix edge case of writing Cues at the beginning

The Matroska muxer has the ability to write the Cues (the index) at the
beginning of the file (in front of the Cluster): The user inputs the
amount of space that should be reserved at the beginning of the file and
if this is sufficient, the Cues will be written there and the part of the
reserved space not used up by the Cues will be filled with a "Void"
element.

There is just one problem with this: One can not fill a single byte this
way, because said Void element is minimally two bytes long (one byte ID,
one byte length field). Up until now, if one reserved one byte more than
needed, one would run into an assert when writing the Void element.

There are two solutions for this: Error out if it happens. Or adjust the
length field of the Cues in order to ensure that the above situation
can't happen (i.e. write the length on one byte more than necessary).
The first solution is very unsatisfactory, as enough space has been
reserved. Therefore this commit implements the second solution.

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