Commit 769105da7b for ffmpeg
commit 769105da7bc3e88b07c18b3c2ed01a2e877ca94a
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sat Oct 31 09:27:28 2026 -0500
avcodec/vorbisdec: take new headers from packet side data
A chained Ogg Vorbis link has its own setup header, which the demuxer
passes as AV_PKT_DATA_NEW_EXTRADATA while the decoder keeps the first
link's codebooks.
Parse the new headers before the packet that carries them, and treat
that packet as the first of a fresh stream, whose samples only prime
the overlap.
The second link of chained-setup now matches that link decoded on its
own, and the chained-meta tags of the second link move to its first
frame actually output.
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index e952af825c..6c5b9c5228 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -1797,10 +1797,23 @@ static int vorbis_decode_frame(AVCodecContext *avctx, AVFrame *frame,
vorbis_context *vc = avctx->priv_data;
GetBitContext *gb = &vc->gb;
float *channel_ptrs[255];
+ const uint8_t *new_headers;
+ size_t new_headers_size;
int i, len, ret;
ff_dlog(NULL, "packet length %d \n", buf_size);
+ new_headers = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+ &new_headers_size);
+ if (new_headers) {
+ if (new_headers_size > INT_MAX)
+ return AVERROR_INVALIDDATA;
+ vorbis_free(vc);
+ vc->first_frame = 0;
+ if ((ret = vorbis_parse_headers(avctx, new_headers, new_headers_size)) < 0)
+ return ret;
+ }
+
if (*buf == 1 && buf_size > 7) {
if ((ret = init_get_bits8(gb, buf + 1, buf_size - 1)) < 0)
return ret;
diff --git a/tests/ref/fate/ogg-vorbis-chained-meta.txt b/tests/ref/fate/ogg-vorbis-chained-meta.txt
index 84feb88ddd..f46532b6f8 100644
--- a/tests/ref/fate/ogg-vorbis-chained-meta.txt
+++ b/tests/ref/fate/ogg-vorbis-chained-meta.txt
@@ -7,8 +7,7 @@ Stream ID: 0, packet PTS: 576, packet DTS: 576
Stream ID: 0, frame PTS: 576, metadata: N/A
Stream ID: 0, packet PTS: 1600, packet DTS: 1600
Stream ID: 0, new metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream
-Stream ID: 0, frame PTS: 1600, metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream
Stream ID: 0, packet PTS: 1728, packet DTS: 1728
-Stream ID: 0, frame PTS: 1728, metadata: N/A
+Stream ID: 0, frame PTS: 1728, metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream
Stream ID: 0, packet PTS: 2304, packet DTS: 2304
Stream ID: 0, frame PTS: 2304, metadata: N/A
diff --git a/tests/ref/fate/ogg-vorbis-chained-setup b/tests/ref/fate/ogg-vorbis-chained-setup
index b36c826bd7..4be3e37008 100644
--- a/tests/ref/fate/ogg-vorbis-chained-setup
+++ b/tests/ref/fate/ogg-vorbis-chained-setup
@@ -1,5 +1,4 @@
-21
-21
--51
--49
--45
+-21
+-21