Commit 915a2f32b8 for ffmpeg

commit 915a2f32b8a738fe1693d5935bb2b00b890c4168
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date:   Sat Oct 31 09:16:23 2026 -0500

    avcodec/flacdec: split frame header and subframe decoding

    Request the output buffer once the frame header has given the block
    size, before decoding the subframes.

    With frame threading, all the state a frame header sets can then be
    handed to the next thread before the costly part of the frame starts.

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index b3e56df0a0..d269e6b432 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -599,9 +599,9 @@ static inline int decode_subframe(FLACContext *s, int channel)
     return 0;
 }

-static int decode_frame(FLACContext *s)
+static int decode_frame_header(FLACContext *s)
 {
-    int i, ret;
+    int ret;
     GetBitContext *gb = &s->gb;
     FLACFrameInfo fi;

@@ -670,6 +670,14 @@ static int decode_frame(FLACContext *s)

 //    dump_headers(s->avctx, &s->stream_info);

+    return 0;
+}
+
+static int decode_subframes(FLACContext *s)
+{
+    int i, ret;
+    GetBitContext *gb = &s->gb;
+
     /* subframes */
     for (i = 0; i < s->stream_info.channels; i++) {
         if ((ret = decode_subframe(s, i)) < 0)
@@ -743,7 +751,17 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     /* decode frame */
     if ((ret = init_get_bits8(&s->gb, buf, buf_size)) < 0)
         return ret;
-    if ((ret = decode_frame(s)) < 0) {
+    if ((ret = decode_frame_header(s)) < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
+        return ret;
+    }
+
+    /* get output buffer */
+    frame->nb_samples = s->blocksize;
+    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+        return ret;
+
+    if ((ret = decode_subframes(s)) < 0) {
         av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
         return ret;
     }
@@ -757,11 +775,6 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
             return AVERROR_INVALIDDATA;
     }

-    /* get output buffer */
-    frame->nb_samples = s->blocksize;
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
-        return ret;
-
     if (s->stream_info.bps == 32 && s->ch_mode > 0) {
         decorrelate_33bps(s->ch_mode, s->decoded, s->decoded_33bps, s->blocksize);
         s->dsp.decorrelate[0](frame->data, s->decoded, s->stream_info.channels,