diff options
author | Ben Boeckel <mathstuf@gmail.com> | 2014-02-05 12:10:54 -0500 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-02-05 22:36:42 +0100 |
commit | 7eb84f2c3b30e562e346204a13412c31a07e13ed (patch) | |
tree | 44602005e2da9291a6c6ad3ff8b04de43ab8ef5f | |
parent | 129e24f78e5dd2166211156346872ee92545b8a4 (diff) | |
download | ffmpeg-7eb84f2c3b30e562e346204a13412c31a07e13ed.tar.gz |
ogg: allow streams to update metadata
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/oggdec.c | 14 | ||||
-rw-r--r-- | libavformat/oggdec.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index efb8f04a9c..66eb605b2f 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -78,6 +78,8 @@ static int ogg_save(AVFormatContext *s) struct ogg_stream *os = ogg->streams + i; os->buf = av_mallocz(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(os->buf, ost->streams[i].buf, os->bufpos); + os->new_metadata = NULL; + os->new_metadata_size = 0; } ogg->state = ost; @@ -144,6 +146,8 @@ static int ogg_reset(AVFormatContext *s) os->lastpts = 0; } os->end_trimming = 0; + av_freep(&os->new_metadata); + os->new_metadata_size = 0; } ogg->page_pos = -1; @@ -641,6 +645,7 @@ static int ogg_read_close(AVFormatContext *s) ogg->streams[i].codec->cleanup(s, i); } av_freep(&ogg->streams[i].private); + av_freep(&ogg->streams[i].new_metadata); } av_freep(&ogg->streams); return 0; @@ -789,6 +794,15 @@ retry: os->end_trimming = 0; } + if (os->new_metadata) { + uint8_t *side_data = av_packet_new_side_data(pkt, + AV_PKT_DATA_METADATA_UPDATE, + os->new_metadata_size); + memcpy(side_data, os->new_metadata, os->new_metadata_size); + av_freep(&os->new_metadata); + os->new_metadata_size = 0; + } + return psize; } diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index c6214b3ba2..231b583770 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -85,6 +85,8 @@ struct ogg_stream { int got_data; ///< 1 if the stream got some data (non-initial packets), 0 otherwise int nb_header; ///< set to the number of parsed headers int end_trimming; ///< set the number of packets to drop from the end + uint8_t *new_metadata; + unsigned int new_metadata_size; void *private; }; |