This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit bec16c0bd309194bbbaf028e7ffb5b126371de6a
Author:     James Almer <[email protected]>
AuthorDate: Fri Jan 30 21:16:53 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Mon Feb 2 12:52:02 2026 -0300

    avformat/cafdec: export Opus extradata
    
    Given the contents of the Opus kuki are not fully clear, generate it
    using know values from the desc and pakt chunks.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavformat/cafdec.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 300e661dfc..656b473140 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -228,12 +228,26 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t 
size)
         if (!last)
             av_log(s, AV_LOG_WARNING, "non-STREAMINFO FLACMetadataBlock(s) 
ignored\n");
     } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
-        // The data layout for Opus is currently unknown, so we do not export
-        // extradata at all. Multichannel streams are not supported.
+        // The data layout for Opus is currently unknown, so we generate
+        // extradata using known sane values. Multichannel streams are not 
supported.
         if (st->codecpar->ch_layout.nb_channels > 2) {
             avpriv_request_sample(s, "multichannel Opus in CAF");
             return AVERROR_PATCHWELCOME;
         }
+
+        ret = ff_alloc_extradata(st->codecpar, 19);
+        if (ret < 0)
+            return ret;
+
+        AV_WB32A(st->codecpar->extradata, MKBETAG('O','p','u','s'));
+        AV_WB32A(st->codecpar->extradata + 4, MKBETAG('H','e','a','d'));
+        AV_WB8(st->codecpar->extradata + 8, 1); /* OpusHead version */
+        AV_WB8(st->codecpar->extradata + 9, 
st->codecpar->ch_layout.nb_channels);
+        AV_WL16A(st->codecpar->extradata + 10, st->codecpar->initial_padding);
+        AV_WL32A(st->codecpar->extradata + 12, st->codecpar->sample_rate);
+        AV_WL16A(st->codecpar->extradata + 16, 0);
+        AV_WB8(st->codecpar->extradata + 18, 0);
+
         avio_skip(pb, size);
     } else if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) {
         return ret;
@@ -268,6 +282,9 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
     st->nb_frames += priming;
     st->nb_frames += caf->remainder;
 
+    if (st->codecpar->codec_id == AV_CODEC_ID_OPUS && 
st->codecpar->extradata_size)
+        AV_WL16A(st->codecpar->extradata + 10, st->codecpar->initial_padding);
+
     if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) {
         if (!num_packets) {
             if (caf->data_size < 0)

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

Reply via email to