[FFmpeg-cvslog] avformat/matroskaenc: Don't waste bytes on SimpleTags length fields
Andreas Rheinhardt
git at videolan.org
Wed Jan 19 13:54:24 EET 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Jan 14 00:51:42 2022 +0100| [0148e85c3ca143a3b7ae56e21f221cd78c334740] | committer: Andreas Rheinhardt
avformat/matroskaenc: Don't waste bytes on SimpleTags length fields
Also check the (user-provided) tags for being overlong; the earlier
code had an implicit unchecked size_t->int conversion.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0148e85c3ca143a3b7ae56e21f221cd78c334740
---
libavformat/matroskaenc.c | 15 ++++----
tests/ref/fate/matroska-dovi-write-config7 | 4 +-
tests/ref/fate/matroska-flac-extradata-update | 4 +-
tests/ref/fate/matroska-h264-remux | 4 +-
tests/ref/fate/matroska-mastering-display-metadata | 4 +-
tests/ref/fate/matroska-move-cues-to-front | 4 +-
tests/ref/fate/matroska-qt-mode | 4 +-
tests/ref/fate/matroska-vp8-alpha-remux | 4 +-
tests/ref/fate/matroska-zero-length-block | 4 +-
tests/ref/fate/rgb24-mkv | 4 +-
tests/ref/fate/webm-dash-chapters | 4 +-
tests/ref/lavf/mka | 4 +-
tests/ref/lavf/mkv | 4 +-
tests/ref/lavf/mkv_attachment | 4 +-
tests/ref/seek/lavf-mkv | 44 +++++++++++-----------
15 files changed, 56 insertions(+), 55 deletions(-)
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 086d403c85..7bda9fdb6b 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1754,10 +1754,11 @@ static int mkv_write_tracks(AVFormatContext *s)
static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t)
{
+ EBML_WRITER(4);
uint8_t *key = av_strdup(t->key);
uint8_t *p = key;
const uint8_t *lang = NULL;
- ebml_master tag;
+ int ret;
if (!key)
return AVERROR(ENOMEM);
@@ -1775,15 +1776,15 @@ static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t)
p++;
}
- tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);
- put_ebml_string(pb, MATROSKA_ID_TAGNAME, key);
+ ebml_writer_open_master(&writer, MATROSKA_ID_SIMPLETAG);
+ ebml_writer_add_string(&writer, MATROSKA_ID_TAGNAME, key);
if (lang)
- put_ebml_string(pb, MATROSKA_ID_TAGLANG, lang);
- put_ebml_string(pb, MATROSKA_ID_TAGSTRING, t->value);
- end_ebml_master(pb, tag);
+ ebml_writer_add_string(&writer, MATROSKA_ID_TAGLANG, lang);
+ ebml_writer_add_string(&writer, MATROSKA_ID_TAGSTRING, t->value);
+ ret = ebml_writer_write(&writer, pb);
av_freep(&key);
- return 0;
+ return ret;
}
static int mkv_write_tag_targets(MatroskaMuxContext *mkv, AVIOContext **pb,
diff --git a/tests/ref/fate/matroska-dovi-write-config7 b/tests/ref/fate/matroska-dovi-write-config7
index 1c1422c0e4..b652fe411d 100644
--- a/tests/ref/fate/matroska-dovi-write-config7
+++ b/tests/ref/fate/matroska-dovi-write-config7
@@ -1,5 +1,5 @@
-3fa1f47c5c3d22b5c33156ff14928d6c *tests/data/fate/matroska-dovi-write-config7.matroska
-72758 tests/data/fate/matroska-dovi-write-config7.matroska
+058e95f1effefe3842b6174bba2693fc *tests/data/fate/matroska-dovi-write-config7.matroska
+72707 tests/data/fate/matroska-dovi-write-config7.matroska
#extradata 0: 116, 0x2b8d1669
#extradata 1: 116, 0x2b8d1669
#tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-flac-extradata-update b/tests/ref/fate/matroska-flac-extradata-update
index 1a8add7736..260d596904 100644
--- a/tests/ref/fate/matroska-flac-extradata-update
+++ b/tests/ref/fate/matroska-flac-extradata-update
@@ -1,5 +1,5 @@
-c2b76d47a9f0e9626a4999bd395cae08 *tests/data/fate/matroska-flac-extradata-update.matroska
-2029 tests/data/fate/matroska-flac-extradata-update.matroska
+56ff5763fd81ad3bc02c22402cd685e2 *tests/data/fate/matroska-flac-extradata-update.matroska
+2008 tests/data/fate/matroska-flac-extradata-update.matroska
#extradata 0: 34, 0x7acb09e7
#extradata 1: 34, 0x7acb09e7
#extradata 2: 34, 0x443402dd
diff --git a/tests/ref/fate/matroska-h264-remux b/tests/ref/fate/matroska-h264-remux
index b5ecebaf24..e55708ce37 100644
--- a/tests/ref/fate/matroska-h264-remux
+++ b/tests/ref/fate/matroska-h264-remux
@@ -1,5 +1,5 @@
-36fda8942bfed91fed04c5ba63dc8b1a *tests/data/fate/matroska-h264-remux.matroska
-2036089 tests/data/fate/matroska-h264-remux.matroska
+ae0ccd32cc0d3bfc1eaa15c7fc985dfb *tests/data/fate/matroska-h264-remux.matroska
+2036075 tests/data/fate/matroska-h264-remux.matroska
#tb 0: 1/25
#media_type 0: video
#codec_id 0: rawvideo
diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
index 8f5d7b6a22..f13d60ff2f 100644
--- a/tests/ref/fate/matroska-mastering-display-metadata
+++ b/tests/ref/fate/matroska-mastering-display-metadata
@@ -1,5 +1,5 @@
-542ababe5c088ab925ee49373d8b8a85 *tests/data/fate/matroska-mastering-display-metadata.matroska
-1669695 tests/data/fate/matroska-mastering-display-metadata.matroska
+64403411e52d7ba9081ab5692e422737 *tests/data/fate/matroska-mastering-display-metadata.matroska
+1669597 tests/data/fate/matroska-mastering-display-metadata.matroska
#extradata 0: 4, 0x040901a3
#extradata 3: 200, 0x506463a8
#tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-move-cues-to-front b/tests/ref/fate/matroska-move-cues-to-front
index 46effff53e..55a03b8c10 100644
--- a/tests/ref/fate/matroska-move-cues-to-front
+++ b/tests/ref/fate/matroska-move-cues-to-front
@@ -1,5 +1,5 @@
-ce15d8b7577933a057c413af505500df *tests/data/fate/matroska-move-cues-to-front.matroska
-23210310 tests/data/fate/matroska-move-cues-to-front.matroska
+62064edeb4a621fd0097f04c410c165c *tests/data/fate/matroska-move-cues-to-front.matroska
+23210303 tests/data/fate/matroska-move-cues-to-front.matroska
#tb 0: 1/1000
#media_type 0: audio
#codec_id 0: pcm_s24be
diff --git a/tests/ref/fate/matroska-qt-mode b/tests/ref/fate/matroska-qt-mode
index 9dc115cc0d..770d9e7e91 100644
--- a/tests/ref/fate/matroska-qt-mode
+++ b/tests/ref/fate/matroska-qt-mode
@@ -1,5 +1,5 @@
-a741bd63da27d6b8ce3a21009267703d *tests/data/fate/matroska-qt-mode.matroska
-1884278 tests/data/fate/matroska-qt-mode.matroska
+1e525172caec2bf4e191a68c97bbbc51 *tests/data/fate/matroska-qt-mode.matroska
+1884243 tests/data/fate/matroska-qt-mode.matroska
#extradata 0: 90, 0x817d0185
#tb 0: 1/1000
#media_type 0: video
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux
index adb771df88..165c2404e7 100644
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ b/tests/ref/fate/matroska-vp8-alpha-remux
@@ -1,5 +1,5 @@
-d06be833da8e8d9d00bf334e0dfe8a58 *tests/data/fate/matroska-vp8-alpha-remux.matroska
-237192 tests/data/fate/matroska-vp8-alpha-remux.matroska
+e3912762161bb6e7f9607c085b371676 *tests/data/fate/matroska-vp8-alpha-remux.matroska
+237185 tests/data/fate/matroska-vp8-alpha-remux.matroska
#tb 0: 1/1000
#media_type 0: video
#codec_id 0: vp8
diff --git a/tests/ref/fate/matroska-zero-length-block b/tests/ref/fate/matroska-zero-length-block
index e8c5decb39..924cec1e3f 100644
--- a/tests/ref/fate/matroska-zero-length-block
+++ b/tests/ref/fate/matroska-zero-length-block
@@ -1,5 +1,5 @@
-ba78b3e846d57002711bc481fa806717 *tests/data/fate/matroska-zero-length-block.matroska
-643 tests/data/fate/matroska-zero-length-block.matroska
+f37ba7e8a30eaa33c1fd0ef77447fb41 *tests/data/fate/matroska-zero-length-block.matroska
+636 tests/data/fate/matroska-zero-length-block.matroska
#tb 0: 1/1000
#media_type 0: subtitle
#codec_id 0: subrip
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index 1ef70349b7..2630265ebc 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@
-6244b8750d4155d3c9357bab26396ef9 *tests/data/fate/rgb24-mkv.matroska
-58245 tests/data/fate/rgb24-mkv.matroska
+2c7192d8b62c6a11e311a09ab3bef3b8 *tests/data/fate/rgb24-mkv.matroska
+58224 tests/data/fate/rgb24-mkv.matroska
#tb 0: 1/10
#media_type 0: video
#codec_id 0: rawvideo
diff --git a/tests/ref/fate/webm-dash-chapters b/tests/ref/fate/webm-dash-chapters
index c04fc6a3ee..c2f87b2d7c 100644
--- a/tests/ref/fate/webm-dash-chapters
+++ b/tests/ref/fate/webm-dash-chapters
@@ -1,5 +1,5 @@
-c39ad75ef516d1d2e1332d960ad1057b *tests/data/fate/webm-dash-chapters.webm
-111239 tests/data/fate/webm-dash-chapters.webm
+d3a67db17fdca71b9f8cf57c341a031b *tests/data/fate/webm-dash-chapters.webm
+111218 tests/data/fate/webm-dash-chapters.webm
#extradata 0: 3469, 0xc6769ddc
#tb 0: 1/1000
#media_type 0: audio
diff --git a/tests/ref/lavf/mka b/tests/ref/lavf/mka
index 9c0ec88637..5d4ab243c0 100644
--- a/tests/ref/lavf/mka
+++ b/tests/ref/lavf/mka
@@ -1,3 +1,3 @@
-52d2c70afe0f9ac510819f723b5ceb3b *tests/data/lavf/lavf.mka
-43583 tests/data/lavf/lavf.mka
+036f852ae7ae18cf38ddc99ea39032fb *tests/data/lavf/lavf.mka
+43576 tests/data/lavf/lavf.mka
tests/data/lavf/lavf.mka CRC=0x3a1da17e
diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv
index 6e517efede..e737cdf6ac 100644
--- a/tests/ref/lavf/mkv
+++ b/tests/ref/lavf/mkv
@@ -1,3 +1,3 @@
-c1af29ab33c9477049672b62da221552 *tests/data/lavf/lavf.mkv
-320438 tests/data/lavf/lavf.mkv
+3e37e53471f20f2b7169afd75cba70d2 *tests/data/lavf/lavf.mkv
+320424 tests/data/lavf/lavf.mkv
tests/data/lavf/lavf.mkv CRC=0xec6c3c68
diff --git a/tests/ref/lavf/mkv_attachment b/tests/ref/lavf/mkv_attachment
index 86ba4180cb..0149bf2010 100644
--- a/tests/ref/lavf/mkv_attachment
+++ b/tests/ref/lavf/mkv_attachment
@@ -1,3 +1,3 @@
-a669ae1a502ff0c487eee99753e7bef0 *tests/data/lavf/lavf.mkv_attachment
-472593 tests/data/lavf/lavf.mkv_attachment
+6a77b40186840d596bd584182ac3a283 *tests/data/lavf/lavf.mkv_attachment
+472579 tests/data/lavf/lavf.mkv_attachment
tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68
diff --git a/tests/ref/seek/lavf-mkv b/tests/ref/seek/lavf-mkv
index fc65b14cd0..37945246ab 100644
--- a/tests/ref/seek/lavf-mkv
+++ b/tests/ref/seek/lavf-mkv
@@ -1,48 +1,48 @@
-ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 686 size: 208
+ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 672 size: 208
ret: 0 st:-1 flags:0 ts:-1.000000
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 size: 27837
ret: 0 st:-1 flags:1 ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292318 size: 27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292304 size: 27834
ret: 0 st: 0 flags:0 ts: 0.788000
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292318 size: 27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292304 size: 27834
ret: 0 st: 0 flags:1 ts:-0.317000
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 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: 320159 size: 209
+ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320145 size: 209
ret: 0 st:-1 flags:0 ts: 0.365002
-ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146870 size: 27925
+ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146856 size: 27925
ret: 0 st:-1 flags:1 ts:-0.740831
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 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: 292318 size: 27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292304 size: 27834
ret: 0 st: 1 flags:0 ts:-0.058000
-ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 686 size: 208
+ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 672 size: 208
ret: 0 st: 1 flags:1 ts: 2.836000
-ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320159 size: 209
+ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320145 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: 146870 size: 27925
+ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146856 size: 27925
ret: 0 st: 0 flags:0 ts:-0.482000
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 size: 27837
ret: 0 st: 0 flags:1 ts: 2.413000
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292318 size: 27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292304 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: 686 size: 208
+ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 672 size: 208
ret: 0 st:-1 flags:0 ts:-0.904994
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 size: 27837
ret: 0 st:-1 flags:1 ts: 1.989173
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292318 size: 27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292304 size: 27834
ret: 0 st: 0 flags:0 ts: 0.883000
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292318 size: 27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292304 size: 27834
ret: 0 st: 0 flags:1 ts:-0.222000
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 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: 320159 size: 209
+ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320145 size: 209
ret: 0 st:-1 flags:0 ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146870 size: 27925
+ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146856 size: 27925
ret: 0 st:-1 flags:1 ts:-0.645825
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 902 size: 27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 888 size: 27837
More information about the ffmpeg-cvslog
mailing list