Repository navigation
fix(aac): check that the NewADTSHeader arguments fit the ADTS header, accept AAC Main - #690
Merged
Merged
Conversation
… accept AAC Main NewADTSHeader now checks every value against its field in adts_fixed_header (ISO/IEC 14496-3:2019 Table 1.A.6): - channelConfig must be at most 7, since channel_configuration has 3 bits. Before, Encode silently wrote only the low 3 bits, so 13 became 5. - plLen must be at most 8184, since frame_length has 13 bits and includes the 7-byte header. Before, Encode wrapped larger values, so 8185 gave frame length 0. A valid AAC frame stays below this anyway: the decoder input buffer is 6144 bits per channel, so channel configurations 1-7 give at most 6144 bytes. - objectType may also be AAC Main, which the 2-bit profile field signals as 0 and which DecodeADTSHeader already returns as object type 1. HE-AAC is still rejected, since ADTS sends it as AAC-LC with implicit SBR signaling. TestNewADTSHeader tests each limit at its boundary values, plus a middle value, and decodes every accepted header again. This replaces PR #689, which checked only the payload length and tested all 65,536 lengths at each sample rate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EagxH7ENAVwUPJWTRiw1wQ
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.
aac.NewADTSHeadernow checks every argument against its field inadts_fixed_header(ISO/IEC 14496-3:2019 Table 1.A.6), instead of lettingEncodesilently truncate the value:channelConfigmust be at most 7, becausechannel_configurationhas 3 bits. Today 13 is written as 5.plLenmust be at most 8184, because the 13-bitframe_lengthincludes the 7-byte header. Today 8185 is written as frame length 0. A valid AAC frame never gets that large: the decoder input buffer is 6144 bits per channel, so channel configurations 1–7 give at most 6144 bytes.objectTypemay also beAACMain(profile 0), whichDecodeADTSHeaderalready returns as object type 1. This follows the AAC Main support of Implement Main profile and additional ASC support; add SetAACDescriptorFromConfig #657. HE-AAC is still rejected, since ADTS sends it as AAC-LC with implicit SBR signaling.Encodeis unchanged and writes the fields as they are; its doc comment now says so.Replaces #689, which checked only the payload length.
Tests
TestNewADTSHeaderis one table that tests each limit at its boundary values: payload 0, 4096, 8184 accepted and 8185, 65535 rejected; channel configurations 0, 7 accepted and 8 rejected; object types Main and LC accepted, 0 and HE-AAC rejected; and a sampling frequency without an index. Each accepted header is encoded and decoded again.🤖 Generated with Claude Code
https://claude.ai/code/session_01EagxH7ENAVwUPJWTRiw1wQ