summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-23 11:24:20 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-28 15:25:18 +0200
commitb10a8a30dbf605fb0761c9ee64cfbe8cb87ba710 (patch)
treeb7cac5504141838ff42e63891e7aabce6ea5a168 /libavformat/oggdec.h
parentf1d89d6dd0aa825d48e9be13837d77e8c1964fe8 (diff)
downloadffmpeg-b10a8a30dbf605fb0761c9ee64cfbe8cb87ba710.tar.gz
avformat/oggparsevorbis: Avoid tmp bufs when parsing VorbisComment
A single VorbisComment consists of a length field and a non-NUL-terminated string of the form "key=value". Up until now, when parsing such a VorbisComment, zero-terminated duplicates of key and value would be created. This is wasteful if these duplicates are freed shortly afterwards, as happens in particular in case of attached pictures: In this case value is base64 encoded and only needed to decode the actual data. Therefore this commit changes this: The buffer is temporarily modified so that both key and value are zero-terminated. Then the data is used in-place and restored to its original state afterwards. This requires that the buffer has at least one byte of padding. All buffers currently have AV_INPUT_BUFFER_PADDING_SIZE bytes padding, so this is ok. Finally, this also fixes weird behaviour from ogm_chapter(): It sometimes freed given to it, leaving the caller with dangling pointers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/oggdec.h')
-rw-r--r--libavformat/oggdec.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 4cce53de41..1d28e50aa8 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -130,9 +130,25 @@ extern const struct ogg_codec ff_theora_codec;
extern const struct ogg_codec ff_vorbis_codec;
extern const struct ogg_codec ff_vp8_codec;
+/**
+ * Parse Vorbis comments
+ *
+ * @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_comment(AVFormatContext *ms, AVDictionary **m,
const uint8_t *buf, int size, int parse_picture);
+/**
+ * Parse Vorbis comments and add metadata to an AVStream
+ *
+ * @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_stream_comment(AVFormatContext *as, AVStream *st,
const uint8_t *buf, int size);