]> git.sesse.net Git - ffmpeg/commit
avformat/matroskaenc: Don't waste bytes writing durations
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 4 Apr 2020 13:35:48 +0000 (15:35 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 13 Apr 2020 06:08:42 +0000 (08:08 +0200)
commitbd7dea3f4f185a32966d7542837030d843c8518d
treeac6cf675b9983f1f3a83b3db08a3df7a953dc155
parent3c3ad1deb0826e14697858e91985ff113d6ace23
avformat/matroskaenc: Don't waste bytes writing durations

Tags in the Matroska file format can be summarized as follows: There is
a level 1-element called Tags containing one or many Tag elements each
of which in turn contain a Targets element and one or many SimpleTags.
Each SimpleTag roughly corresponds to a single key-value pair similar to
an AVDictionaryEntry. The Targets meanwhile contains information to what
the metadata contained in the SimpleTags contained in the containing Tag
applies (i.e. to the file as a whole or to an individual track).

The Matroska muxer writes such metadata. It puts the metadata of every
stream into a Tag whose Targets makes it point to the corresponding
track. And if the output is seekable, then it also adds another Tag for
each track whose Targets corresponds to the track and where it reserves
space in a SimpleTag to write the duration at the end of the muxing
process into.

Yet there is no reason to write two Tag elements for a track and a few
bytes (typically 24 bytes per track) can be saved by adding the duration
SimpleTag to the other Tag of the same track (if it exists).

FATE has been updated because the output files changed. (Tests that
write to unseekable output (pipes) needn't be updated (no duration tag
has ever been written for them) and the same applies to tests without
further metadata.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/matroskaenc.c
tests/ref/fate/matroska-flac-extradata-update
tests/ref/fate/rgb24-mkv
tests/ref/lavf/mka
tests/ref/lavf/mkv
tests/ref/lavf/mkv_attachment
tests/ref/seek/lavf-mkv