]> git.sesse.net Git - ffmpeg/commit
avformat/matroskaenc: Move adding SeekEntry into end_ebml_master_crc32()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 27 Apr 2020 02:34:45 +0000 (04:34 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 6 May 2020 07:27:40 +0000 (09:27 +0200)
commit4ed3c925c370aa8dd0658d8248a1a60ac2c70337
treea7ade41cbf989c4579bf2e040b40c1dcc701f49d
parentc801ab43c36e8c4f88121aa09af26c77bcbd671b
avformat/matroskaenc: Move adding SeekEntry into end_ebml_master_crc32()

Up until now, SeekEntries were already added before
start_ebml_master_crc32() was even called and before we were actually
sure that we really write the element the SeekHead references: After
all, we might also error out later; and given that the allocations
implicit in dynamic buffers should be checked, end_ebml_master_crc32()
will eventually have to return errors itself, so that it is the right
place to add SeekHead entries.

The earlier behaviour is of course a remnant of the time in which
start_ebml_master_crc32() really did output something, so that the
position before start_ebml_master_crc32() needed to be recorded.
Erroring out later is also not as dangerous as it seems because in
this case no SeekHead will be written (if it happened when writing
the header, the whole muxing process would abort; if it happened
when writing the trailer (when writing chapters not available initially),
writing the trailer would be aborted and no SeekHead containing the
bogus chapter entry would be written).

This commit does not change the way the SeekEntries are added for those
elements that are output preliminarily; this is so because the SeekHead
is written before those elements are finally output and doing it
otherwise would increase the amount of seeks.

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