frontend: add iTunes gapless playback metadata (iTunSMPB) - #177
Merged
fabiangreffrath merged 1 commit intoAug 25, 2026
Merged
Conversation
Calculate encoder priming delay and trailing padding in frontend/encode_engine.c and write standard iTunes gapless playback metadata (iTunSMPB) in frontend/mp4write.c for MP4 container outputs. Priming delay comes from a new faac_encoder_info.encoder_delay field (libfaac/faac.c), resolved per object type: one frame of MDCT overlap for LC, plus the SBR/resample pipeline's extra buffering for HE-AAC. Both values verified against decoded output (impulse test) across sample rates, bitrates, and channel counts, not derived from spec. Fix freeform atom generation in put_tag_ext() to emit a single data atom child inside ilst.----.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for iTunes-compatible gapless playback metadata (
iTunSMPB) in MP4 container outputs and exposes exact encoder delay numbers via the public API.End-User Impact
iTunSMPBtag and skip those extra samples, ensuring audio track lengths match original source files down to the exact millisecond.Technical Breakdown
Exposes Encoder Delay via Public API (
faac.h/libfaac)encoder_delaytofaac_encoder_infoto report priming delay in samples/channel at the output rate.faacEncoderDelay):FRAME_LEN).3 * FRAME_LEN - RESAMPLE_FILTER_LEN / 2).encoder_delaytofaac_encoder_infochanges the struct size. Since we are already bumping the ABI version in this release, including this public API addition now is harmless and avoids needing another ABI bump later.Frontend Gapless Calculation (
frontend/encode_engine.c)mp4_set_gapless().iTunes
iTunSMPBMetadata (frontend/mp4write.c)iTunSMPBhex strings under thecom.apple.iTunesfreeform atom inilst.----.put_tag_ext(): Corrects freeform atom structure to write a singledatachild atom insideilst.----for spec compliance.Verification