summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavformat/flacdec.c5
-rw-r--r--libavformat/oggdec.h3
-rw-r--r--libavformat/oggparsecelt.c2
-rw-r--r--libavformat/oggparseflac.c2
-rw-r--r--libavformat/oggparseogm.c2
-rw-r--r--libavformat/oggparseopus.c2
-rw-r--r--libavformat/oggparsespeex.c2
-rw-r--r--libavformat/oggparsetheora.c2
-rw-r--r--libavformat/oggparsevorbis.c20
9 files changed, 30 insertions, 10 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index c4f9d86a8b..c291393954 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -138,8 +138,11 @@ static int flac_read_header(AVFormatContext *s)
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
- if (ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1)) {
+ ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1);
+ if (ret < 0) {
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
+ } else if (ret > 0) {
+ s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
/* parse the channels mask if present */
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 22647e131f..7dc7716036 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -132,6 +132,9 @@ extern const struct ogg_codec ff_vp8_codec;
int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
const uint8_t *buf, int size, int parse_picture);
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size);
+
static inline int
ogg_find_stream (struct ogg * ogg, int serial)
{
diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c
index 51ebc35e19..2c0c511c7b 100644
--- a/libavformat/oggparsecelt.c
+++ b/libavformat/oggparsecelt.c
@@ -74,7 +74,7 @@ static int celt_header(AVFormatContext *s, int idx)
} else if (priv && priv->extra_headers_left) {
/* Extra headers (vorbiscomment) */
- ff_vorbis_comment(s, &st->metadata, p, os->psize, 1);
+ ff_vorbis_stream_comment(s, st, p, os->psize);
priv->extra_headers_left--;
return 1;
} else {
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index 875de2a3b4..9f0f808b37 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -68,7 +68,7 @@ flac_header (AVFormatContext * s, int idx)
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
- ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4, 1);
+ ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize - 4);
}
return 1;
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index 508a0dc541..54024e0a0a 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -111,7 +111,7 @@ ogm_header(AVFormatContext *s, int idx)
} else if (bytestream2_peek_byte(&p) == 3) {
bytestream2_skip(&p, 7);
if (bytestream2_get_bytes_left(&p) > 1)
- ff_vorbis_comment(s, &st->metadata, p.buffer, bytestream2_get_bytes_left(&p) - 1, 1);
+ ff_vorbis_stream_comment(s, st, p.buffer, bytestream2_get_bytes_left(&p) - 1);
}
return 1;
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 7dfb13d5d2..c8b02fab4d 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -78,7 +78,7 @@ static int opus_header(AVFormatContext *avf, int idx)
if (priv->need_comments) {
if (os->psize < 8 || memcmp(packet, "OpusTags", 8))
return AVERROR_INVALIDDATA;
- ff_vorbis_comment(avf, &st->metadata, packet + 8, os->psize - 8, 1);
+ ff_vorbis_stream_comment(avf, st, packet + 8, os->psize - 8);
priv->need_comments--;
return 1;
}
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 69dd62dfdc..9b5c65f453 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -83,7 +83,7 @@ static int speex_header(AVFormatContext *s, int idx) {
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else
- ff_vorbis_comment(s, &st->metadata, p, os->psize, 1);
+ ff_vorbis_stream_comment(s, st, p, os->psize);
spxp->seq++;
return 1;
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 4a8005f108..91c70dfec9 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -116,7 +116,7 @@ static int theora_header(AVFormatContext *s, int idx)
}
break;
case 0x81:
- ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 7, 1);
+ ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7, os->psize - 7);
case 0x82:
if (!thp->version)
return AVERROR_INVALIDDATA;
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 8103d9dbb1..5e34be5378 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -71,12 +71,25 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
return 1;
}
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size)
+{
+ int updates = ff_vorbis_comment(as, &st->metadata, buf, size, 1);
+
+ if (updates > 0) {
+ st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
+ }
+
+ return updates;
+}
+
int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
const uint8_t *buf, int size,
int parse_picture)
{
const uint8_t *p = buf;
const uint8_t *end = buf + size;
+ int updates = 0;
unsigned n, j;
int s;
@@ -158,6 +171,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
continue;
}
} else if (!ogm_chapter(as, tt, ct)) {
+ updates++;
if (av_dict_get(*m, tt, NULL, 0)) {
av_dict_set(m, tt, ";", AV_DICT_APPEND);
}
@@ -178,7 +192,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
- return 0;
+ return updates;
}
/*
@@ -256,8 +270,8 @@ static int vorbis_update_metadata(AVFormatContext *s, int idx)
/* New metadata packet; release old data. */
av_dict_free(&st->metadata);
- ret = ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7,
- os->psize - 8, 1);
+ ret = ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7,
+ os->psize - 8);
if (ret < 0)
return ret;