1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-10-06 05:47:18 +02:00

libavformat/oggdec.h, libavformat/oggparsevorbis.c: Factor out vorbis metadata update mechanism.

This commit is contained in:
Romain Beauxis
2025-02-18 22:32:03 -06:00
committed by Yalda
parent de8d57e4c5
commit cebbb6ae8a
2 changed files with 31 additions and 8 deletions

View File

@@ -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 modified 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)
{

View File

@@ -273,20 +273,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;
@@ -359,6 +355,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;