Commit 799f1dfaf7 for ffmpeg

commit 799f1dfaf701c57a282ba022ec6e3985cbd8b997
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date:   Sat Oct 31 09:21:58 2026 -0500

    avformat/oggparseflac: pass a later link's STREAMINFO to the decoder

    When a chained stream moves to a new link, the decoder is still set
    up from the first link's STREAMINFO.

    Attach the new link's STREAMINFO to its first packet as
    AV_PKT_DATA_NEW_EXTRADATA, as the vorbis parser already does with
    its headers.

    The second link of both chained FLAC tests now decodes, with or
    without frame threads, and matches that link decoded on its own.

diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index e81e4021a1..31dd1439da 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -19,6 +19,7 @@
  */

 #include <stdlib.h>
+#include "libavutil/mem.h"
 #include "libavcodec/avcodec.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/flac.h"
@@ -29,6 +30,7 @@
 #define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
 #define OGG_FLAC_MAGIC "\177FLAC"
 #define OGG_FLAC_MAGIC_SIZE sizeof(OGG_FLAC_MAGIC)-1
+#define OGG_FLAC_STREAMINFO_OFFSET (OGG_FLAC_MAGIC_SIZE + 1 + 1 + 2 + 4 + 4)

 static int
 flac_header (AVFormatContext * s, int idx)
@@ -92,8 +94,18 @@ flac_packet (AVFormatContext * s, int idx)
         !memcmp(
             os->buf + os->pstart,
             OGG_FLAC_MAGIC,
-            OGG_FLAC_MAGIC_SIZE))
+            OGG_FLAC_MAGIC_SIZE)) {
+        /* A later link's STREAMINFO: the decoder is still set up for the previous one. */
+        if (os->psize >= OGG_FLAC_STREAMINFO_OFFSET + FLAC_STREAMINFO_SIZE) {
+            av_freep(&os->new_extradata);
+            os->new_extradata = av_memdup(os->buf + os->pstart + OGG_FLAC_STREAMINFO_OFFSET,
+                                          FLAC_STREAMINFO_SIZE);
+            if (!os->new_extradata)
+                return AVERROR(ENOMEM);
+            os->new_extradata_size = FLAC_STREAMINFO_SIZE;
+        }
         return 1;
+    }

     if (os->psize > 0 &&
         ((os->buf[os->pstart] & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT)) {
diff --git a/tests/ref/fate/ogg-flac-chained-blocksize b/tests/ref/fate/ogg-flac-chained-blocksize
index 0fb6fa8292..c7aa24eab9 100644
--- a/tests/ref/fate/ogg-flac-chained-blocksize
+++ b/tests/ref/fate/ogg-flac-chained-blocksize
@@ -25,3 +25,9 @@
 0,      19456,      19456,     1024,     2048, 0x950ef0eb
 0,      20480,      20480,     1024,     2048, 0x9b51fada
 0,      21504,      21504,      546,     1092, 0x60af340b
+0,      22050,      22050,     4096,     8192, 0x6fc0e872
+0,      26146,      26146,     4096,     8192, 0x6f80f031
+0,      30242,      30242,     4096,     8192, 0x6f75f855
+0,      34338,      34338,     4096,     8192, 0x9866f00b
+0,      38434,      38434,     4096,     8192, 0xfb4def68
+0,      42530,      42530,     1570,     3140, 0xb6d32de8
diff --git a/tests/ref/fate/ogg-flac-chained-bps b/tests/ref/fate/ogg-flac-chained-bps
index 291e7d9cf5..84b16132a8 100644
--- a/tests/ref/fate/ogg-flac-chained-bps
+++ b/tests/ref/fate/ogg-flac-chained-bps
@@ -25,3 +25,25 @@
 0,      19456,      19456,     1024,     4096, 0x3b94f0eb
 0,      20480,      20480,     1024,     4096, 0x3973fada
 0,      21504,      21504,      546,     2184, 0x7e55340b
+0,      22050,      22050,     1024,     4096, 0x22f2f151
+0,      23074,      23074,     1024,     4096, 0x7736f949
+0,      24098,      24098,     1024,     4096, 0x24480657
+0,      25122,      25122,     1024,     4096, 0xfc05f763
+0,      26146,      26146,     1024,     4096, 0x4b8eff25
+0,      27170,      27170,     1024,     4096, 0x21510055
+0,      28194,      28194,     1024,     4096, 0x1ee7f371
+0,      29218,      29218,     1024,     4096, 0x11f0fd28
+0,      30242,      30242,     1024,     4096, 0xf7c60713
+0,      31266,      31266,     1024,     4096, 0x4853fa2d
+0,      32290,      32290,     1024,     4096, 0x6a78f34f
+0,      33314,      33314,     1024,     4096, 0x54ae03b7
+0,      34338,      34338,     1024,     4096, 0x4c11fc94
+0,      35362,      35362,     1024,     4096, 0xf16bf999
+0,      36386,      36386,     1024,     4096, 0xad13042e
+0,      37410,      37410,     1024,     4096, 0xfa29f592
+0,      38434,      38434,     1024,     4096, 0x3885f74a
+0,      39458,      39458,     1024,     4096, 0x3c0a094a
+0,      40482,      40482,     1024,     4096, 0xe169fd1c
+0,      41506,      41506,     1024,     4096, 0x18aaf19a
+0,      42530,      42530,     1024,     4096, 0xc892ffaa
+0,      43554,      43554,      546,     2184, 0xc3e22e2f