aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Arzelier <paul.arzelier@free.fr>2017-01-28 17:25:27 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-01-28 23:08:42 +0100
commit65862f57ad2f7f49d715f334a9d892e0b20d42f1 (patch)
treebc7d703dd79cbf22da92d2492f412b2faa57fa2d
parentdce863421b64d4d00c1384997b826ffe3c945620 (diff)
downloadffmpeg-65862f57ad2f7f49d715f334a9d892e0b20d42f1.tar.gz
avformat: Ignore ID3v2 tags if other tags are present e.g. vorbis
Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/internal.h5
-rw-r--r--libavformat/mp3dec.c3
-rw-r--r--libavformat/utils.c17
3 files changed, 24 insertions, 1 deletions
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9d614fb12c..63a1724cfa 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -140,6 +140,11 @@ struct AVFormatInternal {
* Whether or not avformat_init_output fully initialized streams
*/
int streams_initialized;
+
+ /**
+ * ID3v2 tag useful for MP3 demuxing
+ */
+ AVDictionary *id3v2_meta;
};
struct AVStreamInternal {
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 099ca57d24..b45a066686 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -349,6 +349,9 @@ static int mp3_read_header(AVFormatContext *s)
int ret;
int i;
+ s->metadata = s->internal->id3v2_meta;
+ s->internal->id3v2_meta = NULL;
+
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d5dfca7dec..0711310792 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -588,12 +588,26 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
/* e.g. AVFMT_NOFILE formats will not have a AVIOContext */
if (s->pb)
- ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, 0);
+ ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
+
if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
if ((ret = s->iformat->read_header(s)) < 0)
goto fail;
+ if (!s->metadata) {
+ s->metadata = s->internal->id3v2_meta;
+ s->internal->id3v2_meta = NULL;
+ } else if (s->internal->id3v2_meta) {
+ int level = AV_LOG_WARNING;
+ if (s->error_recognition & AV_EF_COMPLIANT)
+ level = AV_LOG_ERROR;
+ av_log(s, level, "Discarding ID3 tags because more suitable tags were found.\n");
+ av_dict_free(&s->internal->id3v2_meta);
+ if (s->error_recognition & AV_EF_EXPLODE)
+ return AVERROR_INVALIDDATA;
+ }
+
if (id3v2_extra_meta) {
if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
!strcmp(s->iformat->name, "tta")) {
@@ -4178,6 +4192,7 @@ void avformat_free_context(AVFormatContext *s)
}
av_freep(&s->chapters);
av_dict_free(&s->metadata);
+ av_dict_free(&s->internal->id3v2_meta);
av_freep(&s->streams);
av_freep(&s->internal);
flush_packet_queue(s);