• 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
..
aiff Loading commit data...
al Loading commit data...
apng Loading commit data...
apng.png Loading commit data...
asf Loading commit data...
ast Loading commit data...
au Loading commit data...
avi Loading commit data...
bmp Loading commit data...
caf Loading commit data...
dpx Loading commit data...
dv Loading commit data...
dv_ntsc Loading commit data...
dv_pal Loading commit data...
flm Loading commit data...
flv Loading commit data...
gbrap.fits Loading commit data...
gbrap16be.fits Loading commit data...
gbrp.fits Loading commit data...
gbrp10le.dpx Loading commit data...
gbrp12le.dpx Loading commit data...
gbrp16be.fits Loading commit data...
gif Loading commit data...
gray.fits Loading commit data...
gray.pam Loading commit data...
gray.xwd Loading commit data...
gray16be.fits Loading commit data...
gray16be.pam Loading commit data...
gray16be.png Loading commit data...
gxf Loading commit data...
gxf_ntsc Loading commit data...
gxf_pal Loading commit data...
ircam Loading commit data...
ismv Loading commit data...
jpg Loading commit data...
mka Loading commit data...
mkv Loading commit data...
mkv_attachment Loading commit data...
mmf Loading commit data...
monob.pam Loading commit data...
monow.xwd Loading commit data...
mov Loading commit data...
mov_rtphint Loading commit data...
mp4 Loading commit data...
mpg Loading commit data...
mxf Loading commit data...
mxf_d10 Loading commit data...
mxf_dv25 Loading commit data...
mxf_dvcpro50 Loading commit data...
mxf_opatom Loading commit data...
mxf_opatom_audio Loading commit data...
nut Loading commit data...
ogg Loading commit data...
pam Loading commit data...
pbmpipe Loading commit data...
pcx Loading commit data...
peak.wav Loading commit data...
peak_only.wav Loading commit data...
pgm Loading commit data...
pgmpipe Loading commit data...
png Loading commit data...
ppm Loading commit data...
ppmpipe Loading commit data...
rgb48be.pam Loading commit data...
rgb48be.png Loading commit data...
rgb48le.dpx Loading commit data...
rgb48le_10.dpx Loading commit data...
rgb4_byte.xwd Loading commit data...
rgb555be.xwd Loading commit data...
rgb565be.xwd Loading commit data...
rgb8.xwd Loading commit data...
rgba.pam Loading commit data...
rgba.xwd Loading commit data...
rgba64le.dpx Loading commit data...
rm Loading commit data...
rso Loading commit data...
s16.voc Loading commit data...
sgi Loading commit data...
smjpeg Loading commit data...
sox Loading commit data...
sun Loading commit data...
swf Loading commit data...
tga Loading commit data...
tiff Loading commit data...
ts Loading commit data...
tta Loading commit data...
ul Loading commit data...
voc Loading commit data...
w64 Loading commit data...
wav Loading commit data...
wtv Loading commit data...
wv Loading commit data...
xbm Loading commit data...
xwd Loading commit data...
y4m Loading commit data...