Commit 65862f57 authored by Paul Arzelier's avatar Paul Arzelier Committed by Michael Niedermayer

avformat: Ignore ID3v2 tags if other tags are present e.g. vorbis

Reviewed-by: 's avatarwm4 <nfxjfg@googlemail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent dce86342
......@@ -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 {
......
......@@ -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);
......
......@@ -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);
......
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