--- libavformat/oggdec.h | 14 ++++++++++++++ libavformat/oggparsevorbis.c | 25 +++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index c15fbe738e..d10a9b1a89 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -160,6 +160,20 @@ int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, const uint8_t *buf, int size); +/** + * Parse Vorbis comments, add metadata to an AVStream + * + * This function also attaches the metadata to the next decoded + * packet as AV_PKT_DATA_METADATA_UPDATE + * + * @note The buffer will be temporarily modifed by this function, + * so it needs to be writable. Furthermore it must be padded + * by a single byte (not counted in size). + * All changes will have been reverted upon return. + */ +int ff_vorbis_update_metadata(AVFormatContext *s, AVStream *st, + const uint8_t *buf, int size); + static inline int ogg_find_stream (struct ogg * ogg, int serial) { diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 7e812846fe..7b7c76a3e0 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -263,20 +263,16 @@ static void vorbis_cleanup(AVFormatContext *s, int idx) } } -static int vorbis_update_metadata(AVFormatContext *s, int idx) +int ff_vorbis_update_metadata(AVFormatContext *s, AVStream *st, + const uint8_t *buf, int size) { struct ogg *ogg = s->priv_data; - struct ogg_stream *os = ogg->streams + idx; - AVStream *st = s->streams[idx]; + struct ogg_stream *os = ogg->streams + st->index; int ret; - if (os->psize <= 8) - return 0; - /* New metadata packet; release old data. */ av_dict_free(&st->metadata); - ret = ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7, - os->psize - 8); + ret = ff_vorbis_stream_comment(s, st, buf, size); if (ret < 0) return ret; @@ -349,6 +345,19 @@ static int vorbis_parse_header(AVFormatContext *s, AVStream *st, return 1; } +static int vorbis_update_metadata(AVFormatContext *s, int idx) +{ + struct ogg *ogg = s->priv_data; + struct ogg_stream *os = ogg->streams + idx; + AVStream *st = s->streams[idx]; + + if (os->psize <= 8) + return 0; + + return ff_vorbis_update_metadata(s, st, os->buf + os->pstart + 7, + os->psize - 8); +} + static int vorbis_header(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; -- 2.39.5 (Apple Git-154) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".