1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Andreas Rheinhardt 2019-04-20 01:40:59 +02:00 committed by James Almer
parent 5d7d0fcd70
commit 4e6df068b5
10 changed files with 40 additions and 37 deletions

View File

@ -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);

View File

@ -4,7 +4,7 @@
FATE_MATROSKA-$(call DEMMUX, MATROSKA, MATROSKA) += fate-matroska-remux
fate-matroska-remux: CMD = md5pipe -i $(TARGET_SAMPLES)/vp9-test-vectors/vp90-2-2pass-akiyo.webm -color_trc 4 -c:v copy -fflags +bitexact -strict -2 -f matroska
fate-matroska-remux: CMP = oneline
fate-matroska-remux: REF = 1ed49a4f2b6790357fac268938357353
fate-matroska-remux: REF = 768af2b49132a0de5e0502926ab9ca4f
FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += fate-matroska-spherical-mono
fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream_side_data_list -select_streams v -v 0 $(TARGET_SAMPLES)/mkv/spherical.mkv

View File

@ -91,12 +91,12 @@ fate-wavpack-matroskamode: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/special/matros
FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-mono
fate-wavpack-matroska_mux-mono: CMD = md5pipe -i $(TARGET_SAMPLES)/wavpack/num_channels/mono_16bit_int.wv -c copy -fflags +bitexact -f matroska
fate-wavpack-matroska_mux-mono: CMP = oneline
fate-wavpack-matroska_mux-mono: REF = 11773e2a518edc788475f3880d849230
fate-wavpack-matroska_mux-mono: REF = 646c726a80857b74a55ba16a6d83aeed
FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-61
fate-wavpack-matroska_mux-61: CMD = md5pipe -i $(TARGET_SAMPLES)/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv -c copy -fflags +bitexact -f matroska
fate-wavpack-matroska_mux-61: CMP = oneline
fate-wavpack-matroska_mux-61: REF = 9641abdf596c10c2e21bd9b026d4bade
fate-wavpack-matroska_mux-61: REF = 35b033bc75a0e18bbaabbaef38914837
FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes)
fate-wavpack: $(FATE_WAVPACK-yes)

View File

@ -1,5 +1,5 @@
b0375ba00bcbd55023a176255b8d4ba2 *tests/data/fate/aac-autobsf-adtstoasc.matroska
6728 tests/data/fate/aac-autobsf-adtstoasc.matroska
63292d538da403964777e17eb65deae7 *tests/data/fate/aac-autobsf-adtstoasc.matroska
6721 tests/data/fate/aac-autobsf-adtstoasc.matroska
#extradata 0: 2, 0x0030001c
#tb 0: 1/1000
#media_type 0: audio

View File

@ -1 +1 @@
f80f42e646fce972e73aa6d99dcfa470
5d6f6f595b38d33424c186484f1c39ee

View File

@ -1,5 +1,5 @@
d84d5a83971be9c2caa2f4c37bbbfefd *tests/data/fate/rgb24-mkv.matroska
58343 tests/data/fate/rgb24-mkv.matroska
a00bb0c1bc614872d2267ce9059ae3c7 *tests/data/fate/rgb24-mkv.matroska
58336 tests/data/fate/rgb24-mkv.matroska
#tb 0: 1/10
#media_type 0: video
#codec_id 0: rawvideo

View File

@ -1,3 +1,3 @@
2d9722c0691e140237af0036e3a178b0 *tests/data/lavf/lavf.mka
43684 tests/data/lavf/lavf.mka
8b1992d17a836e07c1464dc1eb4595ac *tests/data/lavf/lavf.mka
43677 tests/data/lavf/lavf.mka
tests/data/lavf/lavf.mka CRC=0x3a1da17e

View File

@ -1,3 +1,3 @@
9767a3b526d7e56d7400164cb888990c *tests/data/lavf/lavf.mkv
320603 tests/data/lavf/lavf.mkv
c6d8a608b7d90820812962972926ef25 *tests/data/lavf/lavf.mkv
320596 tests/data/lavf/lavf.mkv
tests/data/lavf/lavf.mkv CRC=0xec6c3c68

View File

@ -1,3 +1,3 @@
7c8697c324e8ad79c5ea14364a6c39b8 *tests/data/lavf/lavf.mkv_attachment
472759 tests/data/lavf/lavf.mkv_attachment
27cb59473419ffb0b24fa1737ddcd6c7 *tests/data/lavf/lavf.mkv_attachment
472752 tests/data/lavf/lavf.mkv_attachment
tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68

View File

@ -1,48 +1,48 @@
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 834 size: 208
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 827 size: 208
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292469 size: 27834
ret: 0 st: 0 flags:0 ts: 0.788000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292469 size: 27834
ret: 0 st: 0 flags:1 ts:-0.317000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837
ret:-1 st: 1 flags:0 ts: 2.577000
ret: 0 st: 1 flags:1 ts: 1.471000
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320317 size: 209
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320310 size: 209
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147023 size: 27925
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147016 size: 27925
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837
ret:-1 st: 0 flags:0 ts: 2.153000
ret: 0 st: 0 flags:1 ts: 1.048000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292469 size: 27834
ret: 0 st: 1 flags:0 ts:-0.058000
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 834 size: 208
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 827 size: 208
ret: 0 st: 1 flags:1 ts: 2.836000
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320317 size: 209
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320310 size: 209
ret:-1 st:-1 flags:0 ts: 1.730004
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147023 size: 27925
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147016 size: 27925
ret: 0 st: 0 flags:0 ts:-0.482000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837
ret: 0 st: 0 flags:1 ts: 2.413000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292469 size: 27834
ret:-1 st: 1 flags:0 ts: 1.307000
ret: 0 st: 1 flags:1 ts: 0.201000
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 834 size: 208
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 827 size: 208
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292469 size: 27834
ret: 0 st: 0 flags:0 ts: 0.883000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 27834
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292469 size: 27834
ret: 0 st: 0 flags:1 ts:-0.222000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837
ret:-1 st: 1 flags:0 ts: 2.672000
ret: 0 st: 1 flags:1 ts: 1.566000
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320317 size: 209
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320310 size: 209
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147023 size: 27925
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147016 size: 27925
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1050 size: 27837
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 1043 size: 27837