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

Git pushed a commit to branch master
in repository ffmpeg.

commit 4dfdbc94c6ca4c38c9f2111f44e6f18e76235ae5
Author:     Romain Beauxis <[email protected]>
AuthorDate: Thu Nov 19 07:55:57 2026 -0600
Commit:     Romain Beauxis <[email protected]>
CommitDate: Mon Nov 23 13:19:43 2026 +0000

    avformat/mov: count the samples an edit list skips at the sample rate
    
    mov_fix_index counted them in the track's clock, which for HE-AAC with
    explicit SBR is often the core rate, so an edit starting mid-packet
    kept the samples before it.
    
    Tracks with several sample descriptions are left alone: the sample rate
    may come from one the packets do not use.
---
 libavformat/mov.c                              | 9 +++++++++
 tests/ref/fate/mov-aac-he-core-rate-mid-packet | 2 +-
 tests/ref/fate/mov-aac-he-core-rate-priming    | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f2fb4c77a2..ba9698e73a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4944,6 +4944,15 @@ truncated:
 
     // Update av stream length, if it ends up shorter than the track's media 
duration
     st->duration = FFMIN(st->duration, edit_list_dts_entry_end - start_dts);
+    // The skipped samples are counted in the track's clock. With explicit SBR
+    // signalling, HE-AAC often keeps it at the core rate, half the output
+    // rate. A sample rate below the clock may be the core rate of implicit
+    // SBR. With several sample descriptions, the rate may come from one the
+    // packets do not use.
+    if (st->codecpar->codec_id == AV_CODEC_ID_AAC && msc->stsd_count == 1 &&
+        st->codecpar->sample_rate > msc->time_scale && msc->time_scale > 0)
+        sti->skip_samples = FFMIN(av_rescale(sti->skip_samples, 
st->codecpar->sample_rate,
+                                             msc->time_scale), INT_MAX);
     st->codecpar->initial_padding = sti->skip_samples;
 
     // Free the old index and the old CTTS structures
diff --git a/tests/ref/fate/mov-aac-he-core-rate-mid-packet 
b/tests/ref/fate/mov-aac-he-core-rate-mid-packet
index 1728ce1d9a..5f126407e2 100644
--- a/tests/ref/fate/mov-aac-he-core-rate-mid-packet
+++ b/tests/ref/fate/mov-aac-he-core-rate-mid-packet
@@ -1 +1 @@
-frame|pts=-64|nb_samples=2048
+frame|pts=0|nb_samples=1920
diff --git a/tests/ref/fate/mov-aac-he-core-rate-priming 
b/tests/ref/fate/mov-aac-he-core-rate-priming
index 8e1fceace2..58874d795a 100644
--- a/tests/ref/fate/mov-aac-he-core-rate-priming
+++ b/tests/ref/fate/mov-aac-he-core-rate-priming
@@ -1 +1 @@
-stream|sample_rate=44100|initial_padding=2048|time_base=1/22050
+stream|sample_rate=44100|initial_padding=4096|time_base=1/22050

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to