aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-29 10:22:49 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-04-21 08:11:09 +0200
commit5b6e164b4baccc5b36eb8fa5aa91c02d16c88dcf (patch)
tree645a6428e6cfd948fdb9b2dacad145cb9f7d1b28 /libavformat
parenta9844341f78e6eba78a9bb503e71a5d9e3ceea81 (diff)
downloadffmpeg-5b6e164b4baccc5b36eb8fa5aa91c02d16c88dcf.tar.gz
avformat/matroskaenc: Don't waste bytes on length fields
Several EBML Master elements for which a good upper bound of the final length was available were nevertheless written without giving an upper bound of the final length to start_ebml_master(), so that their length fields were eight bytes long. This has been changed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/matroskaenc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 6796ac4747..b03239f9c7 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -849,7 +849,7 @@ static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStre
&side_data_size);
if (side_data_size == sizeof(AVMasteringDisplayMetadata)) {
ebml_master meta_element = start_ebml_master(
- dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 0);
+ dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 10 * (2 + 1 + 8));
const AVMasteringDisplayMetadata *metadata =
(const AVMasteringDisplayMetadata*)side_data;
if (metadata->has_primaries) {
@@ -1313,7 +1313,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
// no mkv-specific ID, use ACM mode
put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM");
- subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
+ subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 6 + 4 * 9);
put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , par->channels);
track->sample_rate_offset = avio_tell(pb);
@@ -1504,7 +1504,7 @@ static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid,
pb = mkv->tags_bc;
*tag = start_ebml_master(pb, MATROSKA_ID_TAG, 0);
- targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 0);
+ targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 4 + 1 + 8);
if (elementid)
put_ebml_uid(pb, elementid, uid);
end_ebml_master(pb, targets);
@@ -1594,7 +1594,8 @@ static int mkv_write_tags(AVFormatContext *s)
AVIOContext *pb = mkv->tags_bc;
ebml_master simpletag;
- simpletag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);
+ simpletag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG,
+ 2 + 1 + 8 + 23);
put_ebml_string(pb, MATROSKA_ID_TAGNAME, "DURATION");
mkv->tracks[i].duration_offset = avio_tell(pb);