diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-14 00:33:13 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-19 11:34:17 +0100 |
commit | b845fff57d358657d1c2efb63a883fb5505b6a32 (patch) | |
tree | 808497c9fd62b9774cfaad7e3dc5a702cb2e7176 /tests/ref/seek/vsynth_lena-snow-ll | |
parent | 5e186f9693db11dc720afa867659afee978b02d8 (diff) | |
download | ffmpeg-b845fff57d358657d1c2efb63a883fb5505b6a32.tar.gz |
avformat/matroskaenc: Add API to write Masters with minimal length field
This muxer currently uses two ways to ensure that no bytes
are wasted by writing unnecessary long EBML length fields
for Master elements and the (Simple)Block element
(all the other elements are fine as one either already has
the right length or getting the actual length is easy
and necessary anyway):
Either use an upper bound that is good enough in case one
is available or write the data into a dynamic buffer first
to get the length; the former approach is impossible in
lots of cases, whereas the latter incurs allocations and
memcpying. It is therefore unfeasible to use the latter
for e.g. the attachments or the BlockGroups.
This patch adds a third alternative to complement the other two:
It consists of an EbmlWriter that one can add EBML elements to
that can be written later by calling ebml_writer_write();
the latter function first traverses the written elements recursively
and calculates the length of each element; then a second pass
is performed in which all the elements are written directly
(without any seeks).
This new API also performs checks for overlong elements;
this is in contrast to put_ebml_string() which simply performs
a size_t->int conversion even for strings originating from the user.
The new API is designed to have very low overhead: It uses
stack arrays and performs no allocations; this also comes
at a price: Right now, it can only be used in contexts in which
there is a compile-time upper bound for the number of elements.
It is also incompatible with storing the offset of an element
in order to update this field later. Furthermore, it puts
the onus of memory management (i.e. ensuring that pointers stay valid)
on the user.
These restrictions might be overcome in the future.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'tests/ref/seek/vsynth_lena-snow-ll')
0 files changed, 0 insertions, 0 deletions