diff options
author | James Almer <jamrial@gmail.com> | 2013-07-17 03:10:16 -0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-07-17 12:18:27 +0200 |
commit | 088ed5314694031e07e02e9d364c9d486a60e704 (patch) | |
tree | a7430287ff2751715fe70448bb55bcb07f506e2d /libavformat/matroskaenc.c | |
parent | b4fe41c981de403a65cdf62eac23dd38234d5562 (diff) | |
download | ffmpeg-088ed5314694031e07e02e9d364c9d486a60e704.tar.gz |
lavf/matroskaenc: Check for valid metadata before creating tags
Tags must have at least one SimpleTag element to be spec conformant.
Updated lavf-mkv and seek-lavf-mkv FATE references as the tests were affected by
this.
Fixes ticket #2785
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 968467c730..2c414e8c2f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -869,6 +869,18 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme return 0; } +static int mkv_check_tag(AVDictionary *m) +{ + AVDictionaryEntry *t = NULL; + int ret = 0; + + while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) + if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) + ret++; + + return ret; +} + static int mkv_write_tags(AVFormatContext *s) { ebml_master tags = {0}; @@ -876,7 +888,7 @@ static int mkv_write_tags(AVFormatContext *s) ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL); - if (av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + if (mkv_check_tag(s->metadata)) { ret = mkv_write_tag(s, s->metadata, 0, 0, &tags); if (ret < 0) return ret; } @@ -884,7 +896,7 @@ static int mkv_write_tags(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - if (!av_dict_get(st->metadata, "", 0, AV_DICT_IGNORE_SUFFIX)) + if (!mkv_check_tag(st->metadata)) continue; ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, &tags); @@ -894,7 +906,7 @@ static int mkv_write_tags(AVFormatContext *s) for (i = 0; i < s->nb_chapters; i++) { AVChapter *ch = s->chapters[i]; - if (!av_dict_get(ch->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) + if (!mkv_check_tag(ch->metadata)) continue; ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id, &tags); |