The branch, master has been updated
       via  cb4052beae1e347e0c357a5b7ab860328aa01dd4 (commit)
       via  45d7d5d3e2aa260785432736bcc394e4f3eb2c82 (commit)
       via  7dbf7d2a4571c6f88c7ac441ec259609951c519e (commit)
       via  cebbb6ae8a096d93dc6f09e3cbd1bde551a5291a (commit)
       via  de8d57e4c576e7ef31c199caf12cbbe755634933 (commit)
      from  5511641365b83afa6449ae0b89d01b78556d941d (commit)


- Log -----------------------------------------------------------------
commit cb4052beae1e347e0c357a5b7ab860328aa01dd4
Author:     Romain Beauxis <[email protected]>
AuthorDate: Mon Feb 10 11:48:03 2025 -0600
Commit:     Yalda <[email protected]>
CommitDate: Wed Oct 1 14:20:55 2025 +0000

    libavformat/oggparseopus.c: Parse comments from secondary chained streams 
header packet.

diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 65b93b4053..ae4ff22c53 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -154,6 +154,11 @@ static int opus_packet(AVFormatContext *avf, int idx)
     }
 
     if (os->psize > 8 && !memcmp(packet, "OpusTags", 8)) {
+        ret = ff_vorbis_update_metadata(avf, st, os->buf + os->pstart + 8,
+                                        os->psize - 8);
+        if (ret < 0)
+            return ret;
+
         priv->need_comments = 0;
         return 1;
     }
diff --git a/tests/ref/fate/ogg-opus-chained-meta.txt 
b/tests/ref/fate/ogg-opus-chained-meta.txt
index addc41c1eb..aad9b83700 100644
--- a/tests/ref/fate/ogg-opus-chained-meta.txt
+++ b/tests/ref/fate/ogg-opus-chained-meta.txt
@@ -13,7 +13,8 @@ Stream ID: 0, frame PTS: 3528, metadata: N/A
 Stream ID: 0, packet PTS: 4488, packet DTS: 4488
 Stream ID: 0, frame PTS: 4488, metadata: N/A
 Stream ID: 0, packet PTS: -312, packet DTS: -312
-Stream ID: 0, frame PTS: -312, metadata: N/A
+Stream ID: 0, new metadata: encoder=Lavc61.19.100 libopus:title=Second Stream
+Stream ID: 0, frame PTS: -312, metadata: encoder=Lavc61.19.100 
libopus:title=Second Stream
 Stream ID: 0, packet PTS: 648, packet DTS: 648
 Stream ID: 0, frame PTS: 648, metadata: N/A
 Stream ID: 0, packet PTS: 1608, packet DTS: 1608

commit 45d7d5d3e2aa260785432736bcc394e4f3eb2c82
Author:     Romain Beauxis <[email protected]>
AuthorDate: Tue Feb 4 07:03:49 2025 -0500
Commit:     Yalda <[email protected]>
CommitDate: Wed Oct 1 14:20:55 2025 +0000

    libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add 
them to ogg stream
    new_metadata.

diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index d66b85b09e..e81e4021a1 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -85,6 +85,8 @@ flac_packet (AVFormatContext * s, int idx)
 {
     struct ogg *ogg = s->priv_data;
     struct ogg_stream *os = ogg->streams + idx;
+    AVStream *st = s->streams[idx];
+    int ret;
 
     if (os->psize > OGG_FLAC_MAGIC_SIZE &&
         !memcmp(
@@ -95,6 +97,11 @@ flac_packet (AVFormatContext * s, int idx)
 
     if (os->psize > 0 &&
         ((os->buf[os->pstart] & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT)) {
+        ret = ff_vorbis_update_metadata(s, st, os->buf + os->pstart + 4,
+                                        os->psize - 4);
+        if (ret < 0)
+            return ret;
+
         return 1;
     }
 
diff --git a/tests/ref/fate/ogg-flac-chained-meta.txt 
b/tests/ref/fate/ogg-flac-chained-meta.txt
index 28e22aa29e..5abf37dcee 100644
--- a/tests/ref/fate/ogg-flac-chained-meta.txt
+++ b/tests/ref/fate/ogg-flac-chained-meta.txt
@@ -5,6 +5,7 @@ Stream ID: 0, frame PTS: 0, metadata: N/A
 Stream ID: 0, packet PTS: 4608, packet DTS: 4608
 Stream ID: 0, frame PTS: 4608, metadata: N/A
 Stream ID: 0, packet PTS: 0, packet DTS: 0
-Stream ID: 0, frame PTS: 0, metadata: N/A
+Stream ID: 0, new metadata: encoder=Lavc61.19.100 flac:title=Second Stream
+Stream ID: 0, frame PTS: 0, metadata: encoder=Lavc61.19.100 flac:title=Second 
Stream
 Stream ID: 0, packet PTS: 4608, packet DTS: 4608
 Stream ID: 0, frame PTS: 4608, metadata: N/A

commit 7dbf7d2a4571c6f88c7ac441ec259609951c519e
Author:     Romain Beauxis <[email protected]>
AuthorDate: Fri Feb 14 09:39:45 2025 -0600
Commit:     Yalda <[email protected]>
CommitDate: Wed Oct 1 14:20:55 2025 +0000

    libavformat/oggdec.c: Use AV_PKT_DATA_STRINGS_METADATA to pass metadata 
updates.

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 9dc2c62035..9f3a92a5ea 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -880,7 +880,7 @@ retry:
     }
 
     if (os->new_metadata) {
-        ret = av_packet_add_side_data(pkt, AV_PKT_DATA_METADATA_UPDATE,
+        ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
                                       os->new_metadata, os->new_metadata_size);
         if (ret < 0)
             return ret;
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 6776782ddf..b051b651e3 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -164,7 +164,7 @@ int ff_vorbis_stream_comment(AVFormatContext *as, AVStream 
*st,
  * 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
+ * packet as AV_PKT_DATA_STRINGS_METADATA
  *
  * @note  The buffer will be temporarily modified by this function,
  *        so it needs to be writable. Furthermore it must be padded
diff --git a/tests/ref/fate/ogg-vorbis-chained-meta.txt 
b/tests/ref/fate/ogg-vorbis-chained-meta.txt
index 1206f86c1f..60d9aeb9fa 100644
--- a/tests/ref/fate/ogg-vorbis-chained-meta.txt
+++ b/tests/ref/fate/ogg-vorbis-chained-meta.txt
@@ -7,7 +7,7 @@ Stream ID: 0, packet PTS: 704, packet DTS: 704
 Stream ID: 0, frame PTS: 704, metadata: N/A
 Stream ID: 0, packet PTS: 0, packet DTS: 0
 Stream ID: 0, new metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream
-Stream ID: 0, frame PTS: 0, metadata: N/A
+Stream ID: 0, frame PTS: 0, metadata: encoder=Lavc61.19.100 
libvorbis:title=Second Stream
 Stream ID: 0, packet PTS: 128, packet DTS: 128
 Stream ID: 0, frame PTS: 128, metadata: N/A
 Stream ID: 0, packet PTS: 704, packet DTS: 704

commit cebbb6ae8a096d93dc6f09e3cbd1bde551a5291a
Author:     Romain Beauxis <[email protected]>
AuthorDate: Tue Feb 18 22:32:03 2025 -0600
Commit:     Yalda <[email protected]>
CommitDate: Wed Oct 1 14:20:55 2025 +0000

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

diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 256a17c5e3..6776782ddf 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 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)
 {
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 1af2f21a82..7c4f7624f8 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -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;

commit de8d57e4c576e7ef31c199caf12cbbe755634933
Author:     Romain Beauxis <[email protected]>
AuthorDate: Mon Aug 4 09:00:28 2025 -0500
Commit:     Yalda <[email protected]>
CommitDate: Wed Oct 1 14:20:55 2025 +0000

    ogg/vorbis: implement header packet skip in chained ogg bitstreams.

diff --git a/doc/APIchanges b/doc/APIchanges
index 9d629f766f..6e7f5d2037 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2025-03-28
 
 API changes, most recent first:
 
+2025-08-xx - xxxxxxxxxx - lavf 62.6.100 - oggparsevorbis.h oggparseopus.h 
oggparseflac.h
+  Drop header packets from secondary chained ogg/{flac, opus, vorbis} streams
+  from demuxer output.
+
 2025-09-xx - xxxxxxxxxx - lavu 60.13.100 - hwcontext_d3d12va.h
   Add resource_flags and heap_flags to AVD3D12VADeviceContext
   Add heap_flags to AVD3D12VAFramesContext
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 62cc2da6de..1af2f21a82 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -215,6 +215,12 @@ struct oggvorbis_private {
     AVVorbisParseContext *vp;
     int64_t final_pts;
     int final_duration;
+    uint8_t *header;
+    int header_size;
+    uint8_t *comment;
+    int comment_size;
+    uint8_t *setup;
+    int setup_size;
 };
 
 static int fixup_vorbis_headers(AVFormatContext *as,
@@ -260,6 +266,10 @@ static void vorbis_cleanup(AVFormatContext *s, int idx)
         av_vorbis_parse_free(&priv->vp);
         for (i = 0; i < 3; i++)
             av_freep(&priv->packet[i]);
+
+        av_freep(&priv->header);
+        av_freep(&priv->comment);
+        av_freep(&priv->setup);
     }
 }
 
@@ -434,6 +444,9 @@ static int vorbis_packet(AVFormatContext *s, int idx)
     struct ogg_stream *os = ogg->streams + idx;
     struct oggvorbis_private *priv = os->private;
     int duration, flags = 0;
+    int skip_packet = 0;
+    int ret, new_extradata_size;
+    PutByteContext pb;
 
     if (!priv->vp)
         return AVERROR_INVALIDDATA;
@@ -496,10 +509,50 @@ static int vorbis_packet(AVFormatContext *s, int idx)
         if (duration < 0) {
             os->pflags |= AV_PKT_FLAG_CORRUPT;
             return 0;
-        } else if (flags & VORBIS_FLAG_COMMENT) {
-            vorbis_update_metadata(s, idx);
+        }
+
+        if (flags & VORBIS_FLAG_HEADER) {
+            ret = vorbis_parse_header(s, s->streams[idx], os->buf + 
os->pstart, os->psize);
+            if (ret < 0)
+                return ret;
+
+            ret = av_reallocp(&priv->header, os->psize);
+            if (ret < 0)
+                return ret;
+
+            memcpy(priv->header, os->buf + os->pstart, os->psize);
+            priv->header_size = os->psize;
+
+            skip_packet = 1;
+        }
+
+        if (flags & VORBIS_FLAG_COMMENT) {
+            ret = vorbis_update_metadata(s, idx);
+            if (ret < 0)
+                return ret;
+
+            ret = av_reallocp(&priv->comment, os->psize);
+            if (ret < 0)
+                return ret;
+
+            memcpy(priv->comment, os->buf + os->pstart, os->psize);
+            priv->comment_size = os->psize;
+
             flags = 0;
+            skip_packet = 1;
+        }
+
+        if (flags & VORBIS_FLAG_SETUP) {
+            ret = av_reallocp(&priv->setup, os->psize);
+            if (ret < 0)
+                return ret;
+
+            memcpy(priv->setup, os->buf + os->pstart, os->psize);
+            priv->setup_size = os->psize;
+
+            skip_packet = 1;
         }
+
         os->pduration = duration;
     }
 
@@ -521,7 +574,31 @@ static int vorbis_packet(AVFormatContext *s, int idx)
         priv->final_duration += os->pduration;
     }
 
-    return 0;
+    if (priv->header && priv->comment && priv->setup) {
+        new_extradata_size = priv->header_size + priv->comment_size + 
priv->setup_size + 6;
+
+        ret = av_reallocp(&os->new_extradata, new_extradata_size);
+        if (ret < 0)
+            return ret;
+
+        os->new_extradata_size = new_extradata_size;
+        bytestream2_init_writer(&pb, os->new_extradata, new_extradata_size);
+        bytestream2_put_be16(&pb, priv->header_size);
+        bytestream2_put_buffer(&pb, priv->header, priv->header_size);
+        bytestream2_put_be16(&pb, priv->comment_size);
+        bytestream2_put_buffer(&pb, priv->comment, priv->comment_size);
+        bytestream2_put_be16(&pb, priv->setup_size);
+        bytestream2_put_buffer(&pb, priv->setup, priv->setup_size);
+
+        av_freep(&priv->header);
+        priv->header_size = 0;
+        av_freep(&priv->comment);
+        priv->comment_size = 0;
+        av_freep(&priv->setup);
+        priv->setup_size = 0;
+    }
+
+    return skip_packet;
 }
 
 const struct ogg_codec ff_vorbis_codec = {
diff --git a/tests/ref/fate/ogg-vorbis-chained-meta.txt 
b/tests/ref/fate/ogg-vorbis-chained-meta.txt
index b7a97c90e2..1206f86c1f 100644
--- a/tests/ref/fate/ogg-vorbis-chained-meta.txt
+++ b/tests/ref/fate/ogg-vorbis-chained-meta.txt
@@ -6,10 +6,7 @@ Stream ID: 0, frame PTS: 128, metadata: N/A
 Stream ID: 0, packet PTS: 704, packet DTS: 704
 Stream ID: 0, frame PTS: 704, metadata: N/A
 Stream ID: 0, packet PTS: 0, packet DTS: 0
-Stream ID: 0, packet PTS: 0, packet DTS: 0
 Stream ID: 0, new metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream
-Stream ID: 0, packet PTS: 0, packet DTS: 0
-Stream ID: 0, packet PTS: 0, packet DTS: 0
 Stream ID: 0, frame PTS: 0, metadata: N/A
 Stream ID: 0, packet PTS: 128, packet DTS: 128
 Stream ID: 0, frame PTS: 128, metadata: N/A

-----------------------------------------------------------------------

Summary of changes:
 doc/APIchanges                             |   4 ++
 libavformat/oggdec.c                       |   2 +-
 libavformat/oggdec.h                       |  14 ++++
 libavformat/oggparseflac.c                 |   7 ++
 libavformat/oggparseopus.c                 |   5 ++
 libavformat/oggparsevorbis.c               | 108 ++++++++++++++++++++++++++---
 tests/ref/fate/ogg-flac-chained-meta.txt   |   3 +-
 tests/ref/fate/ogg-opus-chained-meta.txt   |   3 +-
 tests/ref/fate/ogg-vorbis-chained-meta.txt |   5 +-
 9 files changed, 133 insertions(+), 18 deletions(-)


hooks/post-receive
-- 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to