• Andreas Rheinhardt's avatar
    avformat/matroskaenc: Avoid allocations for SeekHead · dc2f6b54
    Andreas Rheinhardt authored
    Up until e7ddafd5, the Matroska muxer wrote two SeekHeads: One at the
    beginning referencing the main level 1 elements (i.e. not the Clusters)
    and one at the end, referencing the Clusters. This second SeekHead was
    useless and has therefore been removed. Yet the SeekHead-related
    functions and structures are still geared towards this usecase: They
    are built around an allocated array of variable size that gets
    reallocated every time an element is added to it although the maximum
    number of Seek entries is a small compile-time constant, so that one should
    rather include the array in the SeekHead structure itself; and said
    structure should be contained in the MatroskaMuxContext instead of being
    allocated separately.
    
    The earlier code reserved space for a SeekHead with 10 entries, although
    we currently write at most 6. Reducing said number implied that every
    Matroska/Webm file will be 84 bytes smaller and required to adapt
    several FATE tests; furthermore, the reserved amount overestimated the
    amount needed for for the SeekHead's length field and how many bytes
    need to be reserved to write a EBML Void element, bringing the total
    reduction to 89 bytes.
    
    This also fixes a potential segfault: If !mkv->is_live and if the
    AVIOContext is initially unseekable when writing the header, the
    SeekHead is already written when writing the header and this used to
    free the SeekHead-related structures that have been allocated. But if
    the AVIOContext happens to be seekable when writing the trailer, it will
    be attempted to write the SeekHead again which will lead to segfaults
    because the corresponding structures have already been freed.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    dc2f6b54
Name
Last commit
Last update
..
api Loading commit data...
checkasm Loading commit data...
dnn Loading commit data...
fate Loading commit data...
filtergraphs Loading commit data...
ref Loading commit data...
.gitignore Loading commit data...
Makefile Loading commit data...
audiogen.c Loading commit data...
audiomatch.c Loading commit data...
base64.c Loading commit data...
copycooker.sh Loading commit data...
extended.ffconcat Loading commit data...
fate-run.sh Loading commit data...
fate-valgrind.supp Loading commit data...
fate.sh Loading commit data...
md5.sh Loading commit data...
refcmp-metadata.awk Loading commit data...
reference.pnm Loading commit data...
rotozoom.c Loading commit data...
simple1.ffconcat Loading commit data...
simple2.ffconcat Loading commit data...
test.ffmeta Loading commit data...
tiny_psnr.c Loading commit data...
tiny_ssim.c Loading commit data...
utils.c Loading commit data...
videogen.c Loading commit data...