Commit 77243d1995 for ffmpeg
commit 77243d19958077f81f954bb9978527483b6c0060
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sat Oct 31 09:27:28 2026 -0500
avcodec/vorbisdec: factor out parsing the headers
Move parsing the identification and setup headers out of initialization,
so that headers arriving later can be parsed the same way.
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 111fe44318..e952af825c 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -1057,26 +1057,15 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
// Process the extradata using the functions above (identification header, setup header)
-static av_cold int vorbis_decode_init(AVCodecContext *avctx)
+static int vorbis_parse_headers(AVCodecContext *avctx,
+ const uint8_t *headers, int headers_len)
{
vorbis_context *vc = avctx->priv_data;
- uint8_t *headers = avctx->extradata;
- int headers_len = avctx->extradata_size;
const uint8_t *header_start[3];
int header_len[3];
GetBitContext *gb = &vc->gb;
int hdr_type, ret;
- vc->avctx = avctx;
- ff_vorbisdsp_init(&vc->dsp);
-
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
- if (!headers_len) {
- av_log(avctx, AV_LOG_ERROR, "Extradata missing.\n");
- return AVERROR_INVALIDDATA;
- }
-
if ((ret = avpriv_split_xiph_headers(headers, headers_len, 30, header_start, header_len)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Extradata corrupt.\n");
return ret;
@@ -1120,6 +1109,23 @@ static av_cold int vorbis_decode_init(AVCodecContext *avctx)
return 0;
}
+static av_cold int vorbis_decode_init(AVCodecContext *avctx)
+{
+ vorbis_context *vc = avctx->priv_data;
+
+ vc->avctx = avctx;
+ ff_vorbisdsp_init(&vc->dsp);
+
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+
+ if (!avctx->extradata_size) {
+ av_log(avctx, AV_LOG_ERROR, "Extradata missing.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ return vorbis_parse_headers(avctx, avctx->extradata, avctx->extradata_size);
+}
+
// Decode audiopackets -------------------------------------------------
// Read and decode floor