This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 135daa576bddeadfa932dcd41f25bd49ce8dff05 Author: Romain Beauxis <[email protected]> AuthorDate: Thu Nov 19 22:12:31 2026 -0600 Commit: Romain Beauxis <[email protected]> CommitDate: Tue Nov 24 14:22:04 2026 +0000 avformat/mp3dec: add the decoder delay to the iTunSMPB priming Like the LAME tag, iTunSMPB stores the encoder delay and padding without the 528 + 1 samples of decoder delay. Core Audio decodes gapless/gapless-itunes.mp3 (priming 528) to the 418950 samples of its sample count starting 1057 samples in, and FFmpeg's output now matches Core Audio's to 1 LSB over the whole file. It used to start 529 samples early and cut the last 529. --- libavformat/demux.h | 11 +++++++---- libavformat/mp3dec.c | 8 +++++--- tests/ref/fate/gapless-mp3-itunes | 10 +++++----- tests/ref/fate/gapless-mp3-itunes-remux | 4 ++-- tests/ref/fate/gapless-mp3-itunes-side-data | 8 ++++---- tests/ref/fate/id3v2-reenc-delete-metadata | 4 ++-- tests/ref/fate/id3v2-reenc-delete-metadata-keep | 4 ++-- tests/ref/fate/id3v2-reenc-delete-metadata-keep-format | 4 ++-- tests/ref/fate/id3v2-reenc-delete-metadata-keep-stream | 4 ++-- tests/ref/fate/id3v2-reenc-delete-metadata-map-metadata | 4 ++-- tests/ref/fate/id3v2-reenc-remux-keep | 2 +- tests/ref/fate/preroll-mp3-itunes-declared | 2 +- tests/ref/fate/preroll-mp3-itunes-decode | 13 ++++++------- tests/ref/fate/preroll-mp3-itunes-decode-noaccurate | 12 ++++++------ 14 files changed, 47 insertions(+), 43 deletions(-) diff --git a/libavformat/demux.h b/libavformat/demux.h index 37d08fb2ca..146c702494 100644 --- a/libavformat/demux.h +++ b/libavformat/demux.h @@ -400,15 +400,18 @@ int ff_find_stream_index(const AVFormatContext *s, int id); * * <reserved> <priming> <remainder> <valid samples> * - * The decoded stream holds the three sample counts back to back, the priming - * and remainder samples being encoder artifacts. + * The encoded frames hold the three sample counts back to back, the priming + * and remainder samples being encoder artifacts. The counts are returned as + * the tag stores them: a caller whose decoder adds a delay of its own, as the + * MP3 one does, shifts the valid samples later by that delay, adding it to + * the priming and subtracting it from the remainder. * * The counts are returned small enough to be added and rescaled without * overflowing. * * @param value tag contents - * @param priming number of samples to discard at the start of the stream - * @param remainder number of samples to discard at the end of the stream + * @param priming samples the encoder added at the start of the stream + * @param remainder samples the encoder added at the end of the stream * @param samples number of valid samples between the two * @return >= 0 if OK, AVERROR_INVALIDDATA if the tag could not be parsed or * holds counts too large to be sample counts diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 8a3c7bdfaf..5b19445625 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -421,9 +421,11 @@ static void mp3_parse_itunes_smpb(AVFormatContext *s, AVStream *st, priming + samples + remainder != mp3->frames * (int64_t)spf) return; - /* Contrary to the LAME tag, the priming count covers the decoder delay. */ - sti->start_skip_samples = priming; - sti->first_discard_sample = priming + samples; + /* As in the LAME tag, priming and remainder exclude the 528 + 1 samples of + * decoder delay: Core Audio (afconvert) outputs the sample count starting + * that far past the priming. */ + sti->start_skip_samples = priming + 528 + 1; + sti->first_discard_sample = priming + 528 + 1 + samples; sti->last_discard_sample = priming + samples + remainder; st->duration = av_rescale_q(samples, (AVRational){ 1, c->sample_rate }, diff --git a/tests/ref/fate/gapless-mp3-itunes b/tests/ref/fate/gapless-mp3-itunes index 5f768064fe..7b54f83e7d 100644 --- a/tests/ref/fate/gapless-mp3-itunes +++ b/tests/ref/fate/gapless-mp3-itunes @@ -1,5 +1,5 @@ -defc98cd62163e01f501b6221158af47 *tests/data/fate/gapless-mp3-itunes.out-1 -81cf1a5d04e513c4f17fffa6c0427665 -b9c05e4d68c1b435611e798aff2aeac0 *tests/data/fate/gapless-mp3-itunes.out-2 -81cf1a5d04e513c4f17fffa6c0427665 -749b5b5b9ff0cc42e6a776639c2c9675 *tests/data/fate/gapless-mp3-itunes.out-3 +8408f2c327bb3638dec1c4960b415325 *tests/data/fate/gapless-mp3-itunes.out-1 +b9457926804b147dfac408c7c378fe2c +9441edbe1d4bd5daff13e86bfd880f0a *tests/data/fate/gapless-mp3-itunes.out-2 +b9457926804b147dfac408c7c378fe2c +54fd7cf57d333c5fe76f71896e38f748 *tests/data/fate/gapless-mp3-itunes.out-3 diff --git a/tests/ref/fate/gapless-mp3-itunes-remux b/tests/ref/fate/gapless-mp3-itunes-remux index ed52801ef6..e2cac0192b 100644 --- a/tests/ref/fate/gapless-mp3-itunes-remux +++ b/tests/ref/fate/gapless-mp3-itunes-remux @@ -1,3 +1,3 @@ -4e886ae5b38188d171a61c19deabac0a *tests/data/fate/gapless-mp3-itunes-remux.mp3 +ef52f48db87bab99e0151f7f6f18de50 *tests/data/fate/gapless-mp3-itunes-remux.mp3 192081 tests/data/fate/gapless-mp3-itunes-remux.mp3 -stream|start_pts=169280|duration_ts=134063680 +stream|start_pts=338240|duration_ts=134064000 diff --git a/tests/ref/fate/gapless-mp3-itunes-side-data b/tests/ref/fate/gapless-mp3-itunes-side-data index b76dc567cd..958ec2048d 100644 --- a/tests/ref/fate/gapless-mp3-itunes-side-data +++ b/tests/ref/fate/gapless-mp3-itunes-side-data @@ -1,4 +1,4 @@ -packet|pts=0|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=528|side_datum/skip_samples:discard_padding=0|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 +packet|pts=0|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=1057|side_datum/skip_samples:discard_padding=0|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 packet|pts=368640 packet|pts=737280 packet|pts=1105920 @@ -362,7 +362,7 @@ packet|pts=132710400 packet|pts=133079040 packet|pts=133447680 packet|pts=133816320 -packet|pts=134184960|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=0|side_datum/skip_samples:discard_padding=1002|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 +packet|pts=134184960|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=0|side_datum/skip_samples:discard_padding=473|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 packet|pts=134553600|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=0|side_datum/skip_samples:discard_padding=1152|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 -stream|codec_name=mp3|start_pts=168960|start_time=0.011973|duration_ts=134064000|duration=9.500000|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata [...] -format|start_time=0.011973|duration=9.500000|tag:title=7rk|tag:comment-iTunPGAP-eng=0|tag:encoded_by=iTunes 12.7.0.166|tag:comment-iTunNORM-eng= 00000362 000004C0 0000308F 00003CC5 00000DAC 00000DAC 00007D14 00007AC9 000007C1 0000175E|tag:comment-iTunSMPB-eng= 00000000 00000210 0000086A 0000000000066486 00000000 0002DA9D 00000000 00000000 00000000 00000000 00000000 00000000 +stream|codec_name=mp3|start_pts=338240|start_time=0.023968|duration_ts=134064000|duration=9.500000|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata [...] +format|start_time=0.023968|duration=9.500000|tag:title=7rk|tag:comment-iTunPGAP-eng=0|tag:encoded_by=iTunes 12.7.0.166|tag:comment-iTunNORM-eng= 00000362 000004C0 0000308F 00003CC5 00000DAC 00000DAC 00007D14 00007AC9 000007C1 0000175E|tag:comment-iTunSMPB-eng= 00000000 00000210 0000086A 0000000000066486 00000000 0002DA9D 00000000 00000000 00000000 00000000 00000000 00000000 diff --git a/tests/ref/fate/id3v2-reenc-delete-metadata b/tests/ref/fate/id3v2-reenc-delete-metadata index 5da30d724d..baed25cdae 100644 --- a/tests/ref/fate/id3v2-reenc-delete-metadata +++ b/tests/ref/fate/id3v2-reenc-delete-metadata @@ -1,5 +1,5 @@ -b8a8450e6cca1ac5097a41f081584618 *tests/data/fate/id3v2-reenc-delete-metadata.nut -2716 tests/data/fate/id3v2-reenc-delete-metadata.nut +e1c21dd54a7a51637364943f223c2e7b *tests/data/fate/id3v2-reenc-delete-metadata.nut +2558 tests/data/fate/id3v2-reenc-delete-metadata.nut [FORMAT] TAG:title=7rk [/FORMAT] diff --git a/tests/ref/fate/id3v2-reenc-delete-metadata-keep b/tests/ref/fate/id3v2-reenc-delete-metadata-keep index a2edc8e1ff..6846dcb30b 100644 --- a/tests/ref/fate/id3v2-reenc-delete-metadata-keep +++ b/tests/ref/fate/id3v2-reenc-delete-metadata-keep @@ -1,5 +1,5 @@ -dc08127e67c9284a11dde0cefd31177e *tests/data/fate/id3v2-reenc-delete-metadata-keep.nut -2856 tests/data/fate/id3v2-reenc-delete-metadata-keep.nut +3d0288acc22662a38e8200f4f77a77cd *tests/data/fate/id3v2-reenc-delete-metadata-keep.nut +2698 tests/data/fate/id3v2-reenc-delete-metadata-keep.nut [FORMAT] TAG:title=7rk TAG:comment-iTunSMPB-eng= 00000000 00000210 0000086A 0000000000066486 00000000 0002DA9D 00000000 00000000 00000000 00000000 00000000 00000000 diff --git a/tests/ref/fate/id3v2-reenc-delete-metadata-keep-format b/tests/ref/fate/id3v2-reenc-delete-metadata-keep-format index 1b0e6ec891..f8a93b9ae1 100644 --- a/tests/ref/fate/id3v2-reenc-delete-metadata-keep-format +++ b/tests/ref/fate/id3v2-reenc-delete-metadata-keep-format @@ -1,5 +1,5 @@ -dc08127e67c9284a11dde0cefd31177e *tests/data/fate/id3v2-reenc-delete-metadata-keep-format.nut -2856 tests/data/fate/id3v2-reenc-delete-metadata-keep-format.nut +3d0288acc22662a38e8200f4f77a77cd *tests/data/fate/id3v2-reenc-delete-metadata-keep-format.nut +2698 tests/data/fate/id3v2-reenc-delete-metadata-keep-format.nut [FORMAT] TAG:title=7rk TAG:comment-iTunSMPB-eng= 00000000 00000210 0000086A 0000000000066486 00000000 0002DA9D 00000000 00000000 00000000 00000000 00000000 00000000 diff --git a/tests/ref/fate/id3v2-reenc-delete-metadata-keep-stream b/tests/ref/fate/id3v2-reenc-delete-metadata-keep-stream index d9988c16b7..0c3a4b6911 100644 --- a/tests/ref/fate/id3v2-reenc-delete-metadata-keep-stream +++ b/tests/ref/fate/id3v2-reenc-delete-metadata-keep-stream @@ -1,5 +1,5 @@ -b8a8450e6cca1ac5097a41f081584618 *tests/data/fate/id3v2-reenc-delete-metadata-keep-stream.nut -2716 tests/data/fate/id3v2-reenc-delete-metadata-keep-stream.nut +e1c21dd54a7a51637364943f223c2e7b *tests/data/fate/id3v2-reenc-delete-metadata-keep-stream.nut +2558 tests/data/fate/id3v2-reenc-delete-metadata-keep-stream.nut [FORMAT] TAG:title=7rk [/FORMAT] diff --git a/tests/ref/fate/id3v2-reenc-delete-metadata-map-metadata b/tests/ref/fate/id3v2-reenc-delete-metadata-map-metadata index 2baca102ed..36b0ee5ad4 100644 --- a/tests/ref/fate/id3v2-reenc-delete-metadata-map-metadata +++ b/tests/ref/fate/id3v2-reenc-delete-metadata-map-metadata @@ -1,5 +1,5 @@ -b8a8450e6cca1ac5097a41f081584618 *tests/data/fate/id3v2-reenc-delete-metadata-map-metadata.nut -2716 tests/data/fate/id3v2-reenc-delete-metadata-map-metadata.nut +e1c21dd54a7a51637364943f223c2e7b *tests/data/fate/id3v2-reenc-delete-metadata-map-metadata.nut +2558 tests/data/fate/id3v2-reenc-delete-metadata-map-metadata.nut [FORMAT] TAG:title=7rk [/FORMAT] diff --git a/tests/ref/fate/id3v2-reenc-remux-keep b/tests/ref/fate/id3v2-reenc-remux-keep index 5c2def69e8..5a62d7aeb9 100644 --- a/tests/ref/fate/id3v2-reenc-remux-keep +++ b/tests/ref/fate/id3v2-reenc-remux-keep @@ -1,4 +1,4 @@ -4e886ae5b38188d171a61c19deabac0a *tests/data/fate/id3v2-reenc-remux-keep.mp3 +ef52f48db87bab99e0151f7f6f18de50 *tests/data/fate/id3v2-reenc-remux-keep.mp3 192081 tests/data/fate/id3v2-reenc-remux-keep.mp3 [FORMAT] TAG:title=7rk diff --git a/tests/ref/fate/preroll-mp3-itunes-declared b/tests/ref/fate/preroll-mp3-itunes-declared index e111f6c9fb..4093c04fe0 100644 --- a/tests/ref/fate/preroll-mp3-itunes-declared +++ b/tests/ref/fate/preroll-mp3-itunes-declared @@ -1 +1 @@ -stream|codec_name=mp3|sample_rate=44100|initial_padding=528|seek_preroll=0 +stream|codec_name=mp3|sample_rate=44100|initial_padding=1057|seek_preroll=0 diff --git a/tests/ref/fate/preroll-mp3-itunes-decode b/tests/ref/fate/preroll-mp3-itunes-decode index 7c29cc513d..875ed2cd2a 100644 --- a/tests/ref/fate/preroll-mp3-itunes-decode +++ b/tests/ref/fate/preroll-mp3-itunes-decode @@ -3,10 +3,9 @@ #codec_id 0: pcm_s16le #sample_rate 0: 44100 #channel_layout_name 0: stereo -0, 0, 0, 291, 1164, 0x00000000 -0, 291, 291, 1152, 4608, 0x00000000 -0, 1443, 1443, 1152, 4608, 0x00000000 -0, 2595, 2595, 1152, 4608, 0x00000000 -0, 3747, 3747, 1152, 4608, 0x00000000 -0, 4899, 4899, 1152, 4608, 0x00000000 -0, 6051, 6051, 564, 2256, 0x00000000 +0, 0, 0, 914, 3656, 0x00000000 +0, 914, 914, 1152, 4608, 0x00000000 +0, 2066, 2066, 1152, 4608, 0x00000000 +0, 3218, 3218, 1152, 4608, 0x00000000 +0, 4370, 4370, 1152, 4608, 0x00000000 +0, 5522, 5522, 1093, 4372, 0x00000000 diff --git a/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate b/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate index 960cd66525..e9207503bd 100644 --- a/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate +++ b/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate @@ -3,9 +3,9 @@ #codec_id 0: pcm_s16le #sample_rate 0: 44100 #channel_layout_name 0: stereo -0, -861, -861, 1152, 4608, 0x00000000 -0, 291, 291, 1152, 4608, 0x00000000 -0, 1443, 1443, 1152, 4608, 0x00000000 -0, 2595, 2595, 1152, 4608, 0x00000000 -0, 3747, 3747, 1152, 4608, 0x00000000 -0, 4899, 4899, 855, 3420, 0x00000000 +0, -238, -238, 1152, 4608, 0x00000000 +0, 914, 914, 1152, 4608, 0x00000000 +0, 2066, 2066, 1152, 4608, 0x00000000 +0, 3218, 3218, 1152, 4608, 0x00000000 +0, 4370, 4370, 1152, 4608, 0x00000000 +0, 5522, 5522, 855, 3420, 0x00000000 -- 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]
