• 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
..
aac.mak Loading commit data...
ac3.mak Loading commit data...
acodec.mak Loading commit data...
adpcm.mak Loading commit data...
alac.mak Loading commit data...
als.mak Loading commit data...
amrnb.mak Loading commit data...
amrwb.mak Loading commit data...
api.mak Loading commit data...
apng.mak Loading commit data...
atrac.mak Loading commit data...
audio.mak Loading commit data...
bmp.mak Loading commit data...
build.mak Loading commit data...
canopus.mak Loading commit data...
cbs.mak Loading commit data...
cdxl.mak Loading commit data...
checkasm.mak Loading commit data...
concatdec.mak Loading commit data...
cover-art.mak Loading commit data...
dca.mak Loading commit data...
demux.mak Loading commit data...
dfa.mak Loading commit data...
dnn.mak Loading commit data...
dnxhd.mak Loading commit data...
dpcm.mak Loading commit data...
ea.mak Loading commit data...
exif.mak Loading commit data...
ffmpeg.mak Loading commit data...
ffprobe.mak Loading commit data...
fft.mak Loading commit data...
fifo-muxer.mak Loading commit data...
filter-audio.mak Loading commit data...
filter-video.mak Loading commit data...
fits.mak Loading commit data...
flac.mak Loading commit data...
flvenc.mak Loading commit data...
gapless.mak Loading commit data...
gif.mak Loading commit data...
h264.mak Loading commit data...
hap.mak Loading commit data...
hevc.mak Loading commit data...
hlsenc.mak Loading commit data...
hw.mak Loading commit data...
id3v2.mak Loading commit data...
image.mak Loading commit data...
indeo.mak Loading commit data...
lavf-audio.mak Loading commit data...
lavf-container.mak Loading commit data...
lavf-image.mak Loading commit data...
lavf-image2pipe.mak Loading commit data...
lavf-video.mak Loading commit data...
libavcodec.mak Loading commit data...
libavdevice.mak Loading commit data...
libavformat.mak Loading commit data...
libavresample.mak Loading commit data...
libavutil.mak Loading commit data...
libswresample.mak Loading commit data...
libswscale.mak Loading commit data...
lossless-audio.mak Loading commit data...
lossless-video.mak Loading commit data...
matroska.mak Loading commit data...
microsoft.mak Loading commit data...
monkeysaudio.mak Loading commit data...
mov.mak Loading commit data...
mp3.mak Loading commit data...
mpc.mak Loading commit data...
mpeg4.mak Loading commit data...
mpegps.mak Loading commit data...
mpegts.mak Loading commit data...
mxf.mak Loading commit data...
opus.mak Loading commit data...
pcm.mak Loading commit data...
pixfmt.mak Loading commit data...
pixlet.mak Loading commit data...
probe.mak Loading commit data...
prores.mak Loading commit data...
qt.mak Loading commit data...
qtrle.mak Loading commit data...
real.mak Loading commit data...
screen.mak Loading commit data...
seek.mak Loading commit data...
segment.mak Loading commit data...
source-check.sh Loading commit data...
source.mak Loading commit data...
speedhq.mak Loading commit data...
subtitles.mak Loading commit data...
utvideo.mak Loading commit data...
vcodec.mak Loading commit data...
video.mak Loading commit data...
voice.mak Loading commit data...
vorbis.mak Loading commit data...
vpx.mak Loading commit data...
vqf.mak Loading commit data...
wavpack.mak Loading commit data...
wma.mak Loading commit data...
xvid.mak Loading commit data...