Skip to content

fix(fmp4): carry Opus pre-skip and gain through dOps - #4294

Merged
kixelated merged 4 commits into
mainfrom
quest/m1/cmaf-opus-dops
Sep 27, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m1/cmaf-opus-dops

Conversation

@kixelated

@kixelated kixelated commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The fMP4 importer built an Opus catalog entry from the sample entry alone and published no description, so a CMAF Opus track decoded natively (moq-audio) or remuxed to TS/MKV/FLV lost its pre-skip and gain. The exporter wrote dOps.output_gain as 0, and silently wrote a family 1 description as family 0 with no mapping table.

Approach

  • Import: build the OpusHead from dOps (input rate, channels, pre-skip, gain) with codec::opus::Config and publish it as the description. The catalog describes the decoder output: 48 kHz and the head's output channels, never the informational input rate or the sample entry rate. mp4-atom 0.16 already refuses a nonzero dOps mapping family at decode, so no table is dropped.
  • Export: take pre-skip, gain, and input rate from the parsed head. Refuse a head with a nonzero mapping family (opus::Error::UnsupportedMappingFamily), since mp4_atom::Dops cannot carry the table.
  • Regression: an fMP4 Opus init with 312 pre-skip, -6 dB gain, and a 44.1 kHz input rate imports to a matching head and re-exports to the identical dOps. Plus a 48 kHz catalog rate test behind a 44.1 kHz sample entry, and a family 1 refusal test on each side.

Impact

  • No public API or wire change.
  • Behavior: fMP4-imported Opus renditions now carry a catalog description (19-byte OpusHead). Catalog sample_rate is now always 48 kHz (was the sample entry rate, normally 48 kHz already).
  • Behavior: exporting a family 1+ Opus description to fMP4 now errors instead of emitting a table-less family 0 dOps.

Alternatives

  • Use the dOps input rate as the catalog sample_rate (as MKV import does with OpusHead). Rejected: the catalog must match the codec, and the input rate is informational.

Follow-ups

  • quest/m1/mp4-atom-dops-mapping.md: mp4-atom exposes the dOps mapping family and table in a release.
  • quest/m1/cmaf-opus-surround.md: carry the family 1 table through CMAF, after that and the audio-codecs line (opus::Mapping, feat(ts): import surround Opus with a family 1 OpusHead #4282).
  • quest/m1/opus-catalog-rate.md: MKV (and similar) Opus import publishes 48 kHz, not the OpusHead input rate.
  • quest/m1/js-dops-pre-skip.md: js/hang createDOpsBox stops hard-coding a 312 pre-skip.

🤖 Generated with Claude Code

(Written by Opus 5.5)

kixelated and others added 3 commits September 26, 2026 13:47
The fMP4 importer now publishes the dOps fields as an OpusHead description,
and the exporter writes the head's gain and input rate back into dOps
instead of 0. A description with a channel mapping table is refused on
export rather than written as family 0 without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The catalog describes the decoder's output, so CMAF Opus uses 48 kHz
regardless of the sample entry rate. Move the surround follow-up to m1 and
add its mp4-atom prerequisite, the Opus catalog rate alignment, and the
js/hang dOps pre-skip quests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review September 26, 2026 21:19
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 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-27T00:55:49.902988Z 5a99ec7 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.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: a5d41a5a-9596-4ab2-b804-3ed6f6d3378f

📥 Commits

Reviewing files that changed from the base of the PR and between 405ff69 and 5a99ec7.

📒 Files selected for processing (10)
  • quest/m1/README.md
  • quest/m1/cmaf-opus-dops.md
  • quest/m1/cmaf-opus-surround.md
  • quest/m1/js-dops-pre-skip.md
  • quest/m1/mp4-atom-dops-mapping.md
  • quest/m1/opus-catalog-rate.md
  • rs/moq-mux/src/container/fmp4/export_test.rs
  • rs/moq-mux/src/container/fmp4/import.rs
  • rs/moq-mux/src/container/fmp4/import_test.rs
  • rs/moq-mux/src/container/fmp4/mod.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e3a9ceeb-2544-4de4-bcfb-e78f7e01caa7

📥 Commits

Reviewing files that changed from the base of the PR and between 6493a3e and 405ff69.

📒 Files selected for processing (10)
  • quest/m1/README.md
  • quest/m1/cmaf-opus-dops.md
  • quest/m1/cmaf-opus-surround.md
  • quest/m1/js-dops-pre-skip.md
  • quest/m1/mp4-atom-dops-mapping.md
  • quest/m1/opus-catalog-rate.md
  • rs/moq-mux/src/container/fmp4/export_test.rs
  • rs/moq-mux/src/container/fmp4/import.rs
  • rs/moq-mux/src/container/fmp4/import_test.rs
  • rs/moq-mux/src/container/fmp4/mod.rs
💤 Files with no reviewable changes (1)
  • quest/m1/cmaf-opus-dops.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


Walkthrough

fMP4 Opus import now publishes a 48 kHz sample rate and an OpusHead description built from dOps. Track synthesis uses supplied description fields and rejects nonzero mapping families. Tests cover these behaviors. The quest list and plan documents also change to describe separate Opus-related tasks.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 405ff

No actionable issue is established for this change. It is ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 405ff

Opus metadata from fMP4 now reaches existing decoder and remux paths. The inspected paths retain codec validation, and no access-control bypass or broader authority change was established. Malformed-input recovery and some dependency behavior remain incompletely verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly propagated attacker-supplied metadata affects imported Opus renditions and their existing catalog consumers. The inspected change does not establish a new identity, privilege, service, or tenant boundary.

Trust Boundaries and Controls

  • observed — Imported dOps values cross into a catalog description. The importer validates the OpusHead when encoding it, and the inspected decoder and synthesizer parse the description at their consumption boundaries. The upstream atom parser’s stated mapping-family rejection was not independently verified.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: carrying Opus pre-skip and gain through fMP4 dOps.
Description check ✅ Passed The description accurately explains the fMP4 Opus import and export changes, regression coverage, impact, and follow-up work.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 4 files. (5 skipped: 5 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge check: CI green, branch clean against main, Codex review passed with no findings, CodeRabbit reported nothing actionable. No changes pushed. The fMP4 importer now publishes a dOps-derived OpusHead description at 48 kHz, and the exporter carries pre-skip, gain, and input rate while refusing mapping family 1+. Enabling auto-merge.

(Written by Claude Opus 5.5)

@kixelated
kixelated enabled auto-merge (squash) September 27, 2026 00:52
@kixelated
kixelated merged commit c9c48ed into main Sep 27, 2026
4 checks passed
@kixelated
kixelated deleted the quest/m1/cmaf-opus-dops branch September 27, 2026 01:08
This was referenced Sep 27, 2026
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