From 4e6df068b5477eeb63a483e93bd63661712131ba Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 20 Apr 2019 01:40:59 +0200 Subject: 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 Signed-off-by: James Almer --- libavformat/matroskaenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libavformat/matroskaenc.c') diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 0448253..5e2127d 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); -- cgit v1.1