diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-04-20 01:40:59 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2019-05-08 13:02:29 -0300 |
commit | 4e6df068b5477eeb63a483e93bd63661712131ba (patch) | |
tree | 3d6432bd595e1cffed725d18751c92627462a06c /libavformat/matroskaenc.c | |
parent | 5d7d0fcd70b9d50f093df6f42f9124be55895575 (diff) |
avformat/matroskaenc: Don't waste bytes in EBML Header
Up until now the EBML Header length field has been written with eight
bytes, although the EBML Header is always so small that only one byte
is needed for it. This patch saves seven bytes for every Matroska/Webm
file.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 0448253a77..5e2127de7e 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -164,6 +164,9 @@ typedef struct MatroskaMuxContext { int allow_raw_vfw; } MatroskaMuxContext; +/** 2 bytes * 7 for EBML IDs, 7 1-byte EBML lengths, 6 1-byte uint, + * 8 byte for "matroska" doctype string */ +#define MAX_EBML_HEADER_SIZE 35 /** 2 bytes * 3 for EBML IDs, 3 1-byte EBML lengths, 8 bytes for 64 bit * offset, 4 bytes for target EBML ID */ @@ -1886,7 +1889,7 @@ static int mkv_write_header(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } - ebml_header = start_ebml_master(pb, EBML_ID_HEADER, 0); + ebml_header = start_ebml_master(pb, EBML_ID_HEADER, MAX_EBML_HEADER_SIZE); put_ebml_uint (pb, EBML_ID_EBMLVERSION , 1); put_ebml_uint (pb, EBML_ID_EBMLREADVERSION , 1); put_ebml_uint (pb, EBML_ID_EBMLMAXIDLENGTH , 4); |