Commit 5b6e164b authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

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: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent a9844341
...@@ -849,7 +849,7 @@ static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStre ...@@ -849,7 +849,7 @@ static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStre
&side_data_size); &side_data_size);
if (side_data_size == sizeof(AVMasteringDisplayMetadata)) { if (side_data_size == sizeof(AVMasteringDisplayMetadata)) {
ebml_master meta_element = start_ebml_master( 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 *metadata =
(const AVMasteringDisplayMetadata*)side_data; (const AVMasteringDisplayMetadata*)side_data;
if (metadata->has_primaries) { if (metadata->has_primaries) {
...@@ -1313,7 +1313,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, ...@@ -1313,7 +1313,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
// no mkv-specific ID, use ACM mode // no mkv-specific ID, use ACM mode
put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM"); 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); put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , par->channels);
track->sample_rate_offset = avio_tell(pb); track->sample_rate_offset = avio_tell(pb);
...@@ -1504,7 +1504,7 @@ static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid, ...@@ -1504,7 +1504,7 @@ static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid,
pb = mkv->tags_bc; pb = mkv->tags_bc;
*tag = start_ebml_master(pb, MATROSKA_ID_TAG, 0); *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) if (elementid)
put_ebml_uid(pb, elementid, uid); put_ebml_uid(pb, elementid, uid);
end_ebml_master(pb, targets); end_ebml_master(pb, targets);
...@@ -1594,7 +1594,8 @@ static int mkv_write_tags(AVFormatContext *s) ...@@ -1594,7 +1594,8 @@ static int mkv_write_tags(AVFormatContext *s)
AVIOContext *pb = mkv->tags_bc; AVIOContext *pb = mkv->tags_bc;
ebml_master simpletag; 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"); put_ebml_string(pb, MATROSKA_ID_TAGNAME, "DURATION");
mkv->tracks[i].duration_offset = avio_tell(pb); mkv->tracks[i].duration_offset = avio_tell(pb);
......
...@@ -91,12 +91,12 @@ fate-wavpack-matroskamode: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/special/matros ...@@ -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-$(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: 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: CMP = oneline
fate-wavpack-matroska_mux-mono: REF = 7ebd447336f0ba76b41a3f32d1551f05 fate-wavpack-matroska_mux-mono: REF = a378996c1bb5a54998fc804fb1ad97b1
FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-61 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: 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: CMP = oneline
fate-wavpack-matroska_mux-61: REF = c95bca3c3023230a324c633942c453d5 fate-wavpack-matroska_mux-61: REF = 3d708dfce5ac85df114ea91b30143708
FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes) FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes)
fate-wavpack: $(FATE_WAVPACK-yes) fate-wavpack: $(FATE_WAVPACK-yes)
76a14cc1b3292c7f724006d56b7e2eac *tests/data/fate/aac-autobsf-adtstoasc.matroska 6ffdfc7f11f06f94c22cda3a29bf576b *tests/data/fate/aac-autobsf-adtstoasc.matroska
6648 tests/data/fate/aac-autobsf-adtstoasc.matroska 6627 tests/data/fate/aac-autobsf-adtstoasc.matroska
#extradata 0: 2, 0x0030001c #extradata 0: 2, 0x0030001c
#tb 0: 1/1000 #tb 0: 1/1000
#media_type 0: audio #media_type 0: audio
......
5f6a67a45906f1bc7dd11d840470b0e4 *tests/data/fate/matroska-flac-extradata-update.matroska 2b82ee67ace359edb464e289486b3ebd *tests/data/fate/matroska-flac-extradata-update.matroska
2071 tests/data/fate/matroska-flac-extradata-update.matroska 2008 tests/data/fate/matroska-flac-extradata-update.matroska
#extradata 0: 34, 0x7acb09e7 #extradata 0: 34, 0x7acb09e7
#extradata 1: 34, 0x7acb09e7 #extradata 1: 34, 0x7acb09e7
#extradata 2: 34, 0x443402dd #extradata 2: 34, 0x443402dd
......
661b2d8ad9b7c5bf7389d3408c3695c4 *tests/data/fate/rgb24-mkv.matroska 84474651e0744e7049e27dd19b8c18a8 *tests/data/fate/rgb24-mkv.matroska
58206 tests/data/fate/rgb24-mkv.matroska 58192 tests/data/fate/rgb24-mkv.matroska
#tb 0: 1/10 #tb 0: 1/10
#media_type 0: video #media_type 0: video
#codec_id 0: rawvideo #codec_id 0: rawvideo
......
ff403ab0d4194601df201189df012e65 *tests/data/fate/webm-dash-chapters.webm eada3550583906e53114d30cb39126f5 *tests/data/fate/webm-dash-chapters.webm
111220 tests/data/fate/webm-dash-chapters.webm 111199 tests/data/fate/webm-dash-chapters.webm
#extradata 0: 3469, 0xc6769ddc #extradata 0: 3469, 0xc6769ddc
#tb 0: 1/1000 #tb 0: 1/1000
#media_type 0: audio #media_type 0: audio
......
339f457b665fb5e8652fd50f2d3c4823 *tests/data/lavf-fate/lavf.av1.mkv 696074a7600fb5a02a434839d09201f0 *tests/data/lavf-fate/lavf.av1.mkv
55650 tests/data/lavf-fate/lavf.av1.mkv 55636 tests/data/lavf-fate/lavf.av1.mkv
tests/data/lavf-fate/lavf.av1.mkv CRC=0x7c27cc15 tests/data/lavf-fate/lavf.av1.mkv CRC=0x7c27cc15
df7155d4333e9993c9ea2a9d53868881 *tests/data/lavf/lavf.mka a67d0e6113de91ee53ee00b47fa6ff42 *tests/data/lavf/lavf.mka
43580 tests/data/lavf/lavf.mka 43559 tests/data/lavf/lavf.mka
tests/data/lavf/lavf.mka CRC=0x3a1da17e tests/data/lavf/lavf.mka CRC=0x3a1da17e
06c38b55305367672a7fc4efb71947bc *tests/data/lavf/lavf.mkv e08b2effe716fb6b72f4a2cd2598b6d4 *tests/data/lavf/lavf.mkv
320446 tests/data/lavf/lavf.mkv 320411 tests/data/lavf/lavf.mkv
tests/data/lavf/lavf.mkv CRC=0xec6c3c68 tests/data/lavf/lavf.mkv CRC=0xec6c3c68
cf27537eabb1f4f222e7391aa4f5250d *tests/data/lavf/lavf.mkv_attachment aa2419820c590d0512ce199b7b59b9c9 *tests/data/lavf/lavf.mkv_attachment
472601 tests/data/lavf/lavf.mkv_attachment 472566 tests/data/lavf/lavf.mkv_attachment
tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68 tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 694 size: 208 ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 659 size: 208
ret: 0 st:-1 flags:0 ts:-1.000000 ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
ret: 0 st:-1 flags:1 ts: 1.894167 ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292326 size: 27834 ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292291 size: 27834
ret: 0 st: 0 flags:0 ts: 0.788000 ret: 0 st: 0 flags:0 ts: 0.788000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292326 size: 27834 ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292291 size: 27834
ret: 0 st: 0 flags:1 ts:-0.317000 ret: 0 st: 0 flags:1 ts:-0.317000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
ret:-1 st: 1 flags:0 ts: 2.577000 ret:-1 st: 1 flags:0 ts: 2.577000
ret: 0 st: 1 flags:1 ts: 1.471000 ret: 0 st: 1 flags:1 ts: 1.471000
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320167 size: 209 ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320132 size: 209
ret: 0 st:-1 flags:0 ts: 0.365002 ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146878 size: 27925 ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146843 size: 27925
ret: 0 st:-1 flags:1 ts:-0.740831 ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
ret:-1 st: 0 flags:0 ts: 2.153000 ret:-1 st: 0 flags:0 ts: 2.153000
ret: 0 st: 0 flags:1 ts: 1.048000 ret: 0 st: 0 flags:1 ts: 1.048000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292326 size: 27834 ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292291 size: 27834
ret: 0 st: 1 flags:0 ts:-0.058000 ret: 0 st: 1 flags:0 ts:-0.058000
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 694 size: 208 ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 659 size: 208
ret: 0 st: 1 flags:1 ts: 2.836000 ret: 0 st: 1 flags:1 ts: 2.836000
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320167 size: 209 ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320132 size: 209
ret:-1 st:-1 flags:0 ts: 1.730004 ret:-1 st:-1 flags:0 ts: 1.730004
ret: 0 st:-1 flags:1 ts: 0.624171 ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146878 size: 27925 ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146843 size: 27925
ret: 0 st: 0 flags:0 ts:-0.482000 ret: 0 st: 0 flags:0 ts:-0.482000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
ret: 0 st: 0 flags:1 ts: 2.413000 ret: 0 st: 0 flags:1 ts: 2.413000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292326 size: 27834 ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292291 size: 27834
ret:-1 st: 1 flags:0 ts: 1.307000 ret:-1 st: 1 flags:0 ts: 1.307000
ret: 0 st: 1 flags:1 ts: 0.201000 ret: 0 st: 1 flags:1 ts: 0.201000
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 694 size: 208 ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 659 size: 208
ret: 0 st:-1 flags:0 ts:-0.904994 ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
ret: 0 st:-1 flags:1 ts: 1.989173 ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292326 size: 27834 ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292291 size: 27834
ret: 0 st: 0 flags:0 ts: 0.883000 ret: 0 st: 0 flags:0 ts: 0.883000
ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292326 size: 27834 ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292291 size: 27834
ret: 0 st: 0 flags:1 ts:-0.222000 ret: 0 st: 0 flags:1 ts:-0.222000
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
ret:-1 st: 1 flags:0 ts: 2.672000 ret:-1 st: 1 flags:0 ts: 2.672000
ret: 0 st: 1 flags:1 ts: 1.566000 ret: 0 st: 1 flags:1 ts: 1.566000
ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320167 size: 209 ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320132 size: 209
ret: 0 st:-1 flags:0 ts: 0.460008 ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146878 size: 27925 ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146843 size: 27925
ret: 0 st:-1 flags:1 ts:-0.645825 ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 910 size: 27837 ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 875 size: 27837
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment