This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 68e479d1dca720ef2b6191c27fd60905186b8324 Author: Romain Beauxis <[email protected]> AuthorDate: Thu Nov 19 22:13:34 2026 -0600 Commit: Romain Beauxis <[email protected]> CommitDate: Tue Nov 24 14:22:04 2026 +0000 avcodec/mpegaudio: name the layer III decoder delay The LAME tag and iTunSMPB conversions each spelled it out as 528 + 1. --- libavcodec/libmp3lame.c | 2 +- libavcodec/mpegaudio.h | 6 ++++++ libavformat/mp3dec.c | 14 +++++++------- libavformat/mp3enc.c | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index b84cfa8b4d..defa2c8baf 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -157,7 +157,7 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx) } /* get encoder delay */ - avctx->initial_padding = lame_get_encoder_delay(s->gfp) + 528 + 1; + avctx->initial_padding = lame_get_encoder_delay(s->gfp) + MP3_DECODER_DELAY; ff_af_queue_init(avctx, &s->afq); avctx->frame_size = lame_get_framesize(s->gfp); diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index 74590a8e8b..cd9fa4809a 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -39,6 +39,12 @@ /* max compressed frame size */ #define MPA_MAX_CODED_FRAME_SIZE 1792 +/** + * Delay of the layer III synthesis filterbank, in samples. The LAME tag and + * iTunSMPB store the encoder delay and padding without it. + */ +#define MP3_DECODER_DELAY (528 + 1) + #define MPA_MAX_CHANNELS 2 #define SBLIMIT 32 /* number of subbands */ diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 5b19445625..7adf1f8ec1 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -313,9 +313,9 @@ static int mp3_parse_info_tag(AVFormatContext *s, AVStream *st, mp3->start_pad = v>>12; mp3-> end_pad = v&4095; - sti->start_skip_samples = mp3->start_pad + 528 + 1; + sti->start_skip_samples = mp3->start_pad + MP3_DECODER_DELAY; if (mp3->frames) { - sti->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf; + sti->first_discard_sample = -mp3->end_pad + MP3_DECODER_DELAY + mp3->frames * (int64_t)spf; sti->last_discard_sample = mp3->frames * (int64_t)spf; } av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3-> end_pad); @@ -421,11 +421,11 @@ static void mp3_parse_itunes_smpb(AVFormatContext *s, AVStream *st, priming + samples + remainder != mp3->frames * (int64_t)spf) return; - /* 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; + /* As in the LAME tag, priming and remainder exclude the decoder delay: + * Core Audio (afconvert) outputs the sample count starting that far past + * the priming. */ + sti->start_skip_samples = priming + MP3_DECODER_DELAY; + sti->first_discard_sample = priming + MP3_DECODER_DELAY + samples; sti->last_discard_sample = priming + samples + remainder; st->duration = av_rescale_q(samples, (AVRational){ 1, c->sample_rate }, diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 4ea54f72c3..6a60e325c4 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -393,7 +393,7 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt) /* Padding longer than a frame is spread over several packets. */ mp3->padding = discard_padding ? mp3->padding + discard_padding : 0; if (!mp3->delay) - mp3->delay = FFMAX((int64_t)AV_RL32(side_data) - 528 - 1, 0); + mp3->delay = FFMAX((int64_t)AV_RL32(side_data) - MP3_DECODER_DELAY, 0); } else { mp3->padding = 0; } @@ -510,7 +510,7 @@ static void mp3_update_xing(AVFormatContext *s) /* write encoder delay/padding */ if (mp3->padding) - mp3->padding += 528 + 1; + mp3->padding += MP3_DECODER_DELAY; if (mp3->delay >= 1 << 12) { mp3->delay = (1 << 12) - 1; av_log(s, AV_LOG_WARNING, "Too many samples of initial padding.\n"); -- 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]
