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

Git pushed a commit to branch master
in repository ffmpeg.

commit 44d7755f7ec894dd52076cc37fca78c82556bb73
Author:     James Almer <[email protected]>
AuthorDate: Sun Jun 14 15:55:59 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Tue Jun 16 09:18:24 2026 -0300

    avformat/mov: export initial padding
    
    Some muxers, like Matroska, use it to write priming samples.
    
    fate-segment-adts-to-mkv no longer uses the ref file from
    fate-segment-adts-to-mkv-header-all as it's demuxed through the hls demuxer
    and this commit exposed a bug where initial padding is not being propagated.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavformat/isom.h                                 |  1 -
 libavformat/mov.c                                  | 21 +++----
 tests/fate/segment.mak                             |  1 -
 ...-adts-to-mkv-header-all => segment-adts-to-mkv} |  2 +-
 tests/ref/fate/segment-adts-to-mkv-header-000      | 30 +++++-----
 tests/ref/fate/segment-adts-to-mkv-header-001      | 32 +++++-----
 tests/ref/fate/segment-adts-to-mkv-header-002      |  6 +-
 tests/ref/fate/segment-adts-to-mkv-header-all      | 68 +++++++++++-----------
 8 files changed, 78 insertions(+), 83 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 4e7f22b338..e02af09aaa 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -241,7 +241,6 @@ typedef struct MOVStreamContext {
     uint32_t tmcd_flags;  ///< tmcd track flags
     uint8_t tmcd_nb_frames;  ///< tmcd number of frames per tick / second
     int64_t track_end;    ///< used for dts generation in fragmented movie 
files
-    int start_pad;        ///< amount of samples to skip due to enc-dec delay
     unsigned int rap_group_count;
     MOVSbgp *rap_group;
     unsigned int sync_group_count;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a24a7571cf..7513b3ccc1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4459,7 +4459,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
         }
         found_non_empty_edit = 1;
 
-        // If we encounter a non-negative edit list reset the 
skip_samples/start_pad fields and set them
+        // If we encounter a non-negative edit list reset the 
skip_samples/initial_padding fields and set them
         // according to the edit list below.
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             if (first_non_zero_audio_edit < 0) {
@@ -4469,7 +4469,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
             }
 
             if (first_non_zero_audio_edit > 0)
-                sti->skip_samples = msc->start_pad = 0;
+                sti->skip_samples = st->codecpar->initial_padding = 0;
         }
 
         // While reordering frame index according to edit list we must handle 
properly
@@ -4663,7 +4663,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 
     // 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);
-    msc->start_pad = sti->skip_samples;
+    st->codecpar->initial_padding = sti->skip_samples;
 
     // Free the old index and the old CTTS structures
     av_free(e_old);
@@ -4881,7 +4881,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 
         if (!multiple_edits && !mov->advanced_editlist &&
             st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)
-            sc->start_pad = av_rescale_q(start_time, st->time_base,
+            st->codecpar->initial_padding = av_rescale_q(start_time, 
st->time_base,
                     (AVRational){1, st->codecpar->sample_rate});
     }
 
@@ -5518,12 +5518,10 @@ static int mov_read_custom(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
     int i;
     int ret = 0;
     AVStream *st;
-    MOVStreamContext *sc;
 
     if (c->fc->nb_streams < 1)
         return 0;
     st = c->fc->streams[c->fc->nb_streams-1];
-    sc = st->priv_data;
 
     for (i = 0; i < 3; i++) {
         uint8_t **p;
@@ -5572,8 +5570,8 @@ static int mov_read_custom(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
             int priming, remainder, samples;
             if(sscanf(val, "%*X %X %X %X", &priming, &remainder, &samples) == 
3){
                 if(priming>0 && priming<16384)
-                    sc->start_pad = priming = av_rescale_q(priming, 
st->time_base,
-                                                           (AVRational){ 1, 
st->codecpar->sample_rate });
+                    st->codecpar->initial_padding = priming = 
av_rescale_q(priming, st->time_base,
+                                                                           
(AVRational){ 1, st->codecpar->sample_rate });
                 if (remainder > 0) {
                     int64_t duration = av_rescale_q(st->duration, 
st->time_base,
                                                     (AVRational){ 1, 
st->codecpar->sample_rate });
@@ -11322,7 +11320,7 @@ static int mov_read_header(AVFormatContext *s)
 
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
             st->codecpar->codec_id   == AV_CODEC_ID_AAC) {
-            sti->skip_samples = sc->start_pad;
+            sti->skip_samples = st->codecpar->initial_padding;
         }
         if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && 
sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0)
             av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
@@ -12026,7 +12024,6 @@ static int mov_seek_stream(AVFormatContext *s, AVStream 
*st, int64_t timestamp,
 
 static int64_t mov_get_skip_samples(AVStream *st, int sample)
 {
-    MOVStreamContext *sc = st->priv_data;
     FFStream *const sti = ffstream(st);
     int64_t first_ts = sti->index_entries[0].timestamp;
     int64_t ts = sti->index_entries[sample].timestamp;
@@ -12035,10 +12032,10 @@ static int64_t mov_get_skip_samples(AVStream *st, int 
sample)
     if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
         return 0;
 
-    /* compute skip samples according to stream start_pad, seek ts and first 
ts */
+    /* compute skip samples according to stream initial_padding, seek ts and 
first ts */
     off = av_rescale_q(ts - first_ts, st->time_base,
                        (AVRational){1, st->codecpar->sample_rate});
-    return FFMAX(sc->start_pad - off, 0);
+    return FFMAX(st->codecpar->initial_padding - off, 0);
 }
 
 static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t 
sample_time, int flags)
diff --git a/tests/fate/segment.mak b/tests/fate/segment.mak
index 343af73b10..8537462762 100644
--- a/tests/fate/segment.mak
+++ b/tests/fate/segment.mak
@@ -40,7 +40,6 @@ FATE_SEGMENT-$(call FRAMECRC, MOV HLS MATROSKA, H264, 
H264_PARSER H264_MP4TOANNE
 FATE_SEGMENT += fate-segment-adts-to-mkv
 fate-segment-adts-to-mkv: tests/data/adts-to-mkv.m3u8
 fate-segment-adts-to-mkv: CMD = framecrc -flags +bitexact -i 
$(TARGET_PATH)/tests/data/adts-to-mkv.m3u8 -c copy
-fate-segment-adts-to-mkv: REF = 
$(SRC_PATH)/tests/ref/fate/segment-adts-to-mkv-header-all
 FATE_SEGMENT-$(call FRAMECRC, AAC HLS MATROSKA, AAC, AAC_ADTSTOASC_BSF 
MATROSKA_MUXER SEGMENT_MUXER) += fate-segment-adts-to-mkv
 
 FATE_SEGMENT_ALLPARTS = $(FATE_SEGMENT_PARTS)
diff --git a/tests/ref/fate/segment-adts-to-mkv-header-all 
b/tests/ref/fate/segment-adts-to-mkv
similarity index 95%
copy from tests/ref/fate/segment-adts-to-mkv-header-all
copy to tests/ref/fate/segment-adts-to-mkv
index 125b684c03..2c9d5e8b36 100644
--- a/tests/ref/fate/segment-adts-to-mkv-header-all
+++ b/tests/ref/fate/segment-adts-to-mkv
@@ -4,7 +4,7 @@
 #codec_id 0: aac
 #sample_rate 0: 16000
 #channel_layout_name 0: mono
-0,          0,          0,       64,        4, 0x02f70117
+0,          0,          0,       64,        4, 0x02f70117, S=1, Skip Samples,  
     10, 0x02c80048
 0,         64,         64,       64,      163, 0xd5f85007
 0,        128,        128,       64,      127, 0x66484065
 0,        192,        192,       64,       94, 0x55222bd6
diff --git a/tests/ref/fate/segment-adts-to-mkv-header-000 
b/tests/ref/fate/segment-adts-to-mkv-header-000
index 91729811fc..d638b7fe5b 100644
--- a/tests/ref/fate/segment-adts-to-mkv-header-000
+++ b/tests/ref/fate/segment-adts-to-mkv-header-000
@@ -4,18 +4,18 @@
 #codec_id 0: aac
 #sample_rate 0: 16000
 #channel_layout_name 0: mono
-0,          0,          0,       64,        4, 0x02f70117
-0,         64,         64,       64,      163, 0xd5f85007
-0,        128,        128,       64,      127, 0x66484065
-0,        192,        192,       64,       94, 0x55222bd6
-0,        256,        256,       64,      314, 0x3c7e923a
-0,        320,        320,       64,      207, 0x1efc5d1b
-0,        384,        384,       64,      119, 0xb2a13601
-0,        448,        448,       64,      184, 0xcafc6091
-0,        512,        512,       64,      132, 0xddd33c0b
-0,        576,        576,       64,      152, 0x83935031
-0,        640,        640,       64,      227, 0x32a86bc4
-0,        704,        704,       64,      122, 0xd04e3571
-0,        768,        768,       64,      163, 0x57d44d16
-0,        832,        832,       64,      147, 0x226043d7
-0,        896,        896,       64,      119, 0x8ad931ed
+0,       -132,       -132,       64,        4, 0x02f70117, S=1, Skip Samples,  
     10, 0x02c80048
+0,        -68,        -68,       64,      163, 0xd5f85007
+0,         -4,         -4,       64,      127, 0x66484065
+0,         60,         60,       64,       94, 0x55222bd6
+0,        124,        124,       64,      314, 0x3c7e923a
+0,        188,        188,       64,      207, 0x1efc5d1b
+0,        252,        252,       64,      119, 0xb2a13601
+0,        316,        316,       64,      184, 0xcafc6091
+0,        380,        380,       64,      132, 0xddd33c0b
+0,        444,        444,       64,      152, 0x83935031
+0,        508,        508,       64,      227, 0x32a86bc4
+0,        572,        572,       64,      122, 0xd04e3571
+0,        636,        636,       64,      163, 0x57d44d16
+0,        700,        700,       64,      147, 0x226043d7
+0,        764,        764,       64,      119, 0x8ad931ed
diff --git a/tests/ref/fate/segment-adts-to-mkv-header-001 
b/tests/ref/fate/segment-adts-to-mkv-header-001
index e24282e3e4..c9e33e89ff 100644
--- a/tests/ref/fate/segment-adts-to-mkv-header-001
+++ b/tests/ref/fate/segment-adts-to-mkv-header-001
@@ -4,19 +4,19 @@
 #codec_id 0: aac
 #sample_rate 0: 16000
 #channel_layout_name 0: mono
-0,          0,          0,       64,      153, 0xbb6e432f
-0,         64,         64,       64,      185, 0xa01f4ff3
-0,        128,        128,       64,      126, 0x85503ce6
-0,        192,        192,       64,      246, 0x652c7b59
-0,        256,        256,       64,      162, 0xc9f04da0
-0,        320,        320,       64,      135, 0x71fa3be0
-0,        384,        384,       64,      246, 0x7a6f7788
-0,        448,        448,       64,      262, 0xd3097781
-0,        512,        512,       64,       60, 0x09a118f5
-0,        576,        576,       64,      255, 0xbab5793c
-0,        640,        640,       64,      153, 0x6b6a44fb
-0,        704,        704,       64,      160, 0x550e4530
-0,        768,        768,       64,      215, 0x7fe66144
-0,        832,        832,       64,      144, 0xcd723f7d
-0,        896,        896,       64,      187, 0x2a0b5c1b
-0,        960,        960,       64,      177, 0xb8c355d5
+0,       -132,       -132,       64,      153, 0xbb6e432f, S=1, Skip Samples,  
     10, 0x02c80048
+0,        -68,        -68,       64,      185, 0xa01f4ff3
+0,         -4,         -4,       64,      126, 0x85503ce6
+0,         60,         60,       64,      246, 0x652c7b59
+0,        124,        124,       64,      162, 0xc9f04da0
+0,        188,        188,       64,      135, 0x71fa3be0
+0,        252,        252,       64,      246, 0x7a6f7788
+0,        316,        316,       64,      262, 0xd3097781
+0,        380,        380,       64,       60, 0x09a118f5
+0,        444,        444,       64,      255, 0xbab5793c
+0,        508,        508,       64,      153, 0x6b6a44fb
+0,        572,        572,       64,      160, 0x550e4530
+0,        636,        636,       64,      215, 0x7fe66144
+0,        700,        700,       64,      144, 0xcd723f7d
+0,        764,        764,       64,      187, 0x2a0b5c1b
+0,        828,        828,       64,      177, 0xb8c355d5
diff --git a/tests/ref/fate/segment-adts-to-mkv-header-002 
b/tests/ref/fate/segment-adts-to-mkv-header-002
index 919fedd476..9e3e8d38e9 100644
--- a/tests/ref/fate/segment-adts-to-mkv-header-002
+++ b/tests/ref/fate/segment-adts-to-mkv-header-002
@@ -4,6 +4,6 @@
 #codec_id 0: aac
 #sample_rate 0: 16000
 #channel_layout_name 0: mono
-0,          0,          0,       64,      156, 0x867d4f3a
-0,         64,         64,       64,      201, 0x62745ff9
-0,        128,        128,       64,      137, 0x90c639e0, S=1, Skip Samples,  
     10, 0x048a00c2
+0,       -132,       -132,       64,      156, 0x867d4f3a, S=1, Skip Samples,  
     10, 0x02c80048
+0,        -68,        -68,       64,      201, 0x62745ff9
+0,         -4,         -4,       64,      137, 0x90c639e0, S=1, Skip Samples,  
     10, 0x048a00c2
diff --git a/tests/ref/fate/segment-adts-to-mkv-header-all 
b/tests/ref/fate/segment-adts-to-mkv-header-all
index 125b684c03..a262acf910 100644
--- a/tests/ref/fate/segment-adts-to-mkv-header-all
+++ b/tests/ref/fate/segment-adts-to-mkv-header-all
@@ -4,37 +4,37 @@
 #codec_id 0: aac
 #sample_rate 0: 16000
 #channel_layout_name 0: mono
-0,          0,          0,       64,        4, 0x02f70117
-0,         64,         64,       64,      163, 0xd5f85007
-0,        128,        128,       64,      127, 0x66484065
-0,        192,        192,       64,       94, 0x55222bd6
-0,        256,        256,       64,      314, 0x3c7e923a
-0,        320,        320,       64,      207, 0x1efc5d1b
-0,        384,        384,       64,      119, 0xb2a13601
-0,        448,        448,       64,      184, 0xcafc6091
-0,        512,        512,       64,      132, 0xddd33c0b
-0,        576,        576,       64,      152, 0x83935031
-0,        640,        640,       64,      227, 0x32a86bc4
-0,        704,        704,       64,      122, 0xd04e3571
-0,        768,        768,       64,      163, 0x57d44d16
-0,        832,        832,       64,      147, 0x226043d7
-0,        896,        896,       64,      119, 0x8ad931ed
-0,        960,        960,       64,      153, 0xbb6e432f
-0,       1024,       1024,       64,      185, 0xa01f4ff3
-0,       1088,       1088,       64,      126, 0x85503ce6
-0,       1152,       1152,       64,      246, 0x652c7b59
-0,       1216,       1216,       64,      162, 0xc9f04da0
-0,       1280,       1280,       64,      135, 0x71fa3be0
-0,       1344,       1344,       64,      246, 0x7a6f7788
-0,       1408,       1408,       64,      262, 0xd3097781
-0,       1472,       1472,       64,       60, 0x09a118f5
-0,       1536,       1536,       64,      255, 0xbab5793c
-0,       1600,       1600,       64,      153, 0x6b6a44fb
-0,       1664,       1664,       64,      160, 0x550e4530
-0,       1728,       1728,       64,      215, 0x7fe66144
-0,       1792,       1792,       64,      144, 0xcd723f7d
-0,       1856,       1856,       64,      187, 0x2a0b5c1b
-0,       1920,       1920,       64,      177, 0xb8c355d5
-0,       1984,       1984,       64,      156, 0x867d4f3a
-0,       2048,       2048,       64,      201, 0x62745ff9
-0,       2112,       2112,       64,      137, 0x90c639e0, S=1, Skip Samples,  
     10, 0x048a00c2
+0,       -132,       -132,       64,        4, 0x02f70117, S=1, Skip Samples,  
     10, 0x02c80048
+0,        -68,        -68,       64,      163, 0xd5f85007
+0,         -4,         -4,       64,      127, 0x66484065
+0,         60,         60,       64,       94, 0x55222bd6
+0,        124,        124,       64,      314, 0x3c7e923a
+0,        188,        188,       64,      207, 0x1efc5d1b
+0,        252,        252,       64,      119, 0xb2a13601
+0,        316,        316,       64,      184, 0xcafc6091
+0,        380,        380,       64,      132, 0xddd33c0b
+0,        444,        444,       64,      152, 0x83935031
+0,        508,        508,       64,      227, 0x32a86bc4
+0,        572,        572,       64,      122, 0xd04e3571
+0,        636,        636,       64,      163, 0x57d44d16
+0,        700,        700,       64,      147, 0x226043d7
+0,        764,        764,       64,      119, 0x8ad931ed
+0,        828,        828,       64,      153, 0xbb6e432f
+0,        892,        892,       64,      185, 0xa01f4ff3
+0,        956,        956,       64,      126, 0x85503ce6
+0,       1020,       1020,       64,      246, 0x652c7b59
+0,       1084,       1084,       64,      162, 0xc9f04da0
+0,       1148,       1148,       64,      135, 0x71fa3be0
+0,       1212,       1212,       64,      246, 0x7a6f7788
+0,       1276,       1276,       64,      262, 0xd3097781
+0,       1340,       1340,       64,       60, 0x09a118f5
+0,       1404,       1404,       64,      255, 0xbab5793c
+0,       1468,       1468,       64,      153, 0x6b6a44fb
+0,       1532,       1532,       64,      160, 0x550e4530
+0,       1596,       1596,       64,      215, 0x7fe66144
+0,       1660,       1660,       64,      144, 0xcd723f7d
+0,       1724,       1724,       64,      187, 0x2a0b5c1b
+0,       1788,       1788,       64,      177, 0xb8c355d5
+0,       1852,       1852,       64,      156, 0x867d4f3a
+0,       1916,       1916,       64,      201, 0x62745ff9
+0,       1980,       1980,       64,      137, 0x90c639e0, S=1, Skip Samples,  
     10, 0x048a00c2

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

Reply via email to