Skip to content

fix(mux): TS export carries an AAC track's program config element - #4178

Merged
kixelated merged 3 commits into
quest/m1/audio-codecs/READMEfrom
quest/m1/audio-codecs/ts-export-pce
Sep 25, 2026
Merged

kixelated merged 3 commits into
quest/m1/audio-codecs/READMEfrom
quest/m1/audio-codecs/ts-export-pce

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Completes the audio-codecs/ts-export-pce quest.

What

The MPEG-TS export now takes an AAC track's ADTS channel_config from its AudioSpecificConfig description instead of deriving it from the channel count. When that is 0 (a program config element describes the layout), the export writes the element once, leading the first raw data block, as ffmpeg's ADTS muxer does. Before this, ffmpeg's quad fixture exported as channel_config 4, a different (and for quad, wrong) layout.

  • aac::in_band_channels is the inverse of aac::in_band_config: it splits an AudioSpecificConfig into the ADTS channel_config and, for 0, the PCE framed for a raw data block. Both share a new read_header pulled out of Config::parse.
  • The TS import now moves the PCE out of the first frame for real (the comments already said "moves"), as ffmpeg's aac_adtstoasc does, so frames carry no in-band PCE whatever the source and the export never writes it twice.
  • A description with channelConfiguration 11 to 14 now fails the TS export instead of being mislabeled: ADTS has only 3 bits. Tracks without a description keep the count-derived fallback.

Tests

  • aac_program_config_roundtrip: aac_quad.ts imports, exports, and re-imports with the same description, 4 channels, and identical frames; the exported first raw data block matches ffmpeg's byte for byte, and its ADTS header carries channel_config 0. It fails without the fix (the header says 4).
  • Unit tests in codec::aac round-trip ffmpeg's own PCE through in_band_channels and in_band_config.
  • Checked by hand: ffprobe reads the export as 48 kHz quad, and ffmpeg -f null decodes it with no warnings.

Public API / wire

  • Public API: none. The new function and the changed in_band_config signature are pub(crate).
  • Wire / catalog: none. TS output changes only for AAC tracks whose description has channelConfiguration 0 (now correct) or 11 to 14 (now refused).
  • Behavior: a TS import of a PCE-described AAC stream no longer keeps the PCE in its first frame. The description already carried it.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

@kixelated
kixelated marked this pull request as ready for review September 25, 2026 19:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T22:36:52.690812Z 668d6a7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

kixelated and others added 3 commits September 25, 2026 15:30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ADTS channel_config now comes from the track's AudioSpecificConfig
instead of its channel count. For channelConfiguration 0, the program
config element leads the first raw data block, as ffmpeg writes it. The
TS import moves the element out of the first frame so it is never
written twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
config.into() is ambiguous at the binary snapshot and stream calls on
this quest base. Name Config::from(config).

Co-Authored-By: Grok 4.7 <noreply@x.ai>

kixelated commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Landing the AAC TS export fix on quest/m1/audio-codecs/README.

The export takes an AAC track's ADTS channel_config from its AudioSpecificConfig. When that is 0, the program config element leads the first raw data block, and the import moves it out of that frame so it is not written twice.

Rebased onto the current quest base. That base still has the ambiguous config.into() in moq-ffi (the main fix is #4157 / #4171, not on this branch yet), so this also names moq_mux::binary::Config::from at the binary snapshot and stream calls. No review comments. Local just check passed. Squash-merged after Check and Test went green.

(Written by Grok 4.7)

@kixelated
kixelated merged commit 057bdec into quest/m1/audio-codecs/README Sep 25, 2026
18 checks passed
@kixelated
kixelated deleted the quest/m1/audio-codecs/ts-export-pce branch September 25, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant