[FFmpeg-devel] [PATCH 7/30] avformat/matroskaenc: Avoid allocations for SeekHead

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sun Feb 16 13:50:00 EET 2020


Andreas Rheinhardt:
> 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.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---

Ping.

- Andreas


More information about the ffmpeg-devel mailing list