summaryrefslogtreecommitdiffstats
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-04-20 01:40:59 +0200
committerJames Almer <jamrial@gmail.com>2019-05-08 13:02:29 -0300
commit4e6df068b5477eeb63a483e93bd63661712131ba (patch)
tree3d6432bd595e1cffed725d18751c92627462a06c /libavformat/matroskaenc.c
parent5d7d0fcd70b9d50f093df6f42f9124be55895575 (diff)
downloadffmpeg-streaming-4e6df068b5477eeb63a483e93bd63661712131ba.zip
ffmpeg-streaming-4e6df068b5477eeb63a483e93bd63661712131ba.tar.gz
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.c5
1 files changed, 4 insertions, 1 deletions
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);
OpenPOWER on IntegriCloud