]> git.sesse.net Git - ffmpeg/commit
avformat/matroskaenc: Don't assert when writing huge files
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 2 May 2020 02:39:01 +0000 (04:39 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 18 May 2020 23:51:06 +0000 (01:51 +0200)
commit575557ce665238832e792e2886ee05f592e9dd11
tree3d22d20bcf169e85870400ac7ac5cecad44aa91b
parentefeb3a53adddfba7b06131ee9d36a0c567ddf7d8
avformat/matroskaenc: Don't assert when writing huge files

EBML numbers are variable length numbers: Only seven bits of every byte
are available to encode the number, the other bits encode the length of
the number itself. So an eight byte EBML number can only encode numbers
in the range 0..(2^56 - 1). And when using EBML numbers to encode the
length of an EBML element, the EBML number corresponding to 2^56 - 1 is
actually reserved to mean that the length of the corresponding element
is unknown.

And therefore put_ebml_length() asserted that the length it should
represent is < 2^56 - 1. Yet there was nothing that actually guaranteed
this to be true for the Segment (the main/root EBML element of a
Matroska file that encompasses nearly the whole file). This commit
changes this by checking in advance how big the length is and only
updating the number if it is representable at all; if not, the unknown
length element is not touched.

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