libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add 
them to ogg stream new_metadata.
This is pretty straight forward and taps into a mechanism already in place in
libavformat/oggdec.c

---
 libavformat/oggparseflac.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index f25ed9cc15..3810806112 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -78,6 +78,32 @@ flac_header (AVFormatContext * s, int idx)
     return 1;
 }
 
+static int
+flac_packet (AVFormatContext * s, int idx)
+{
+    struct ogg *ogg = s->priv_data;
+    struct ogg_stream *os = ogg->streams + idx;
+    AVDictionary *new_metadata = NULL;
+    int ret;
+
+    if (os->psize > 0 && os->buf[os->pstart] &&
+        (os->buf[os->pstart] & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
+        ret = ff_vorbis_comment(s, &new_metadata, os->buf + os->pstart + 4,
+                                os->psize - 4, 1);
+
+        if (ret < 0)
+            return ret;
+
+        os->new_metadata = av_packet_pack_dictionary(new_metadata, 
&os->new_metadata_size);
+        av_dict_free(&new_metadata);
+
+        if (!os->new_metadata)
+            return AVERROR(ENOMEM);
+    }
+
+    return 0;
+}
+
 static int
 old_flac_header (AVFormatContext * s, int idx)
 {
@@ -130,6 +156,7 @@ const struct ogg_codec ff_flac_codec = {
     .magic = "\177FLAC",
     .magicsize = 5,
     .header = flac_header,
+    .packet = flac_packet,
     .nb_header = 2,
 };
 
@@ -137,5 +164,6 @@ const struct ogg_codec ff_old_flac_codec = {
     .magic = "fLaC",
     .magicsize = 4,
     .header = old_flac_header,
+    .packet = flac_packet,
     .nb_header = 0,
 };
-- 
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".

Reply via email to