The branch, master has been updated
       via  d3e80837e72bab37a610edd0c1b0307a1db39c31 (commit)
      from  c0044ec9c4e5eacb5aa58a75f67b1ad857147437 (commit)


- Log -----------------------------------------------------------------
commit d3e80837e72bab37a610edd0c1b0307a1db39c31
Author:     Zhao Zhili <[email protected]>
AuthorDate: Fri Nov 21 20:43:56 2025 +0800
Commit:     James Almer <[email protected]>
CommitDate: Sun Nov 23 12:13:07 2025 +0000

    avformat/mov: fix incorrect sample rate by parse srat box

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a3e1ba0a31..8aac4a7d7a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1075,6 +1075,40 @@ fail:
 }
 #endif
 
+static int mov_read_srat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+    AVStream *st;
+    int32_t sample_rate;
+
+    if (atom.size < 8 || c->fc->nb_streams < 1)
+        return 0;
+
+    st = c->fc->streams[c->fc->nb_streams-1];
+    if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
+        av_log(c->fc, AV_LOG_WARNING, "'srat' within non-audio sample entry, 
skip\n");
+        return 0;
+    }
+
+    if (!c->isom) {
+        av_log(c->fc, AV_LOG_WARNING, "'srat' within non-isom, skip\n");
+        return 0;
+    }
+
+    avio_skip(pb, 4); // version+flags
+    sample_rate = avio_rb32(pb);
+    if (sample_rate > 0) {
+        av_log(c->fc, AV_LOG_DEBUG,
+               "overwrite sample rate from %d to %d by 'srat'\n",
+               st->codecpar->sample_rate, sample_rate);
+        st->codecpar->sample_rate = sample_rate;
+    } else {
+        av_log(c->fc, AV_LOG_WARNING,
+               "ignore invalid sample rate %d in 'srat'\n", sample_rate);
+    }
+
+    return 0;
+}
+
 static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     AVStream *st;
@@ -9489,6 +9523,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 #if CONFIG_IAMFDEC
 { MKTAG('i','a','c','b'), mov_read_iacb },
 #endif
+{ MKTAG('s','r','a','t'), mov_read_srat },
 { 0, NULL }
 };
 

-----------------------------------------------------------------------

Summary of changes:
 libavformat/mov.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)


hooks/post-receive
-- 

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

Reply via email to