• Andreas Rheinhardt's avatar
    avformat/matroskaenc: Simplify writing Cues · 5e3b7bd5
    Andreas Rheinhardt authored
    When the Matroska muxer writes the Cues (the index), it groups index
    entries with the same timestamp into the same CuePoint to save space.
    But given Matroska's variable-length length fields, it either needs
    to have an upper bound of the final size of the CuePoint before writing it
    or the CuePoint has to be assembled in a different buffer, so that after
    having assembled the CuePoint (when the real size is known), the CuePoint's
    header can be written and its data copied after it.
    
    The first of these approaches is the currently used one. This entails
    finding out the number of entries in a CuePoint before starting the
    CuePoint and therefore means that the list is read at least twice.
    Furthermore, a worst-case upper-bound for the length of a single entry
    was used, so that sometimes bytes are wasted on length fields.
    
    This commit switches to the second approach. This is no longer more
    expensive than the current approach if one only resets the dynamic
    buffer used to write the CuePoint's content instead of opening a new
    buffer for every CuePoint: Writing the trailer of a file with 540.000
    CuePoints improved actually from 219054414 decicycles to 2164379394
    decicycles (based upon 50 iterations).
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    5e3b7bd5
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
configure Loading commit data...