Repository navigation
Conversation
DDP-Atmos (E-AC-3 + JOC) tracks stream-copy bit-exact through the loopback, but presented as plain E-AC-3 5.1: the vendored FFmpeg 7.1 muxer records the dependent substream in dec3 (num_dep_sub, chan_loc) yet never writes the ETSI TS 103 420 JOC extension (flag_ec3_extension_type_a + complexity_index_type_a) — the field AVFoundation keys on to classify a track as Dolby Atmos. FFmpeg gained the extension write in a later release, which is why the identical copy path works in engines shipping FFmpeg 8.x. Net effect today: no Atmos over HDMI/eARC from any DDP-Atmos source. The writer now detects the source condition at stream selection (codecpar.profile == AV_PROFILE_EAC3_DDP_ATMOS) and writeInitSegment patches the extension into the dec3 via ISOBoxSurgery, next to the existing dvvC surgery. The extension is bit-packed after the substream loop — before the alignment padding, not byte-appended — so the payload is re-emitted through a small bit reader/writer, with ancestor box sizes fixed the way injectDvvC does. complexity_index_type_a=16 (the standard streaming-Atmos object count; 7.1's parser does not expose the true value). The surgery no-ops on non-JOC streams and on already-extended dec3 boxes, so a future FFmpeg >= 8 bump degrades it to a no-op automatically. Covered by ISOBoxSurgeryDec3Tests with hand-computed bit vectors.
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3deee184a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if let fps = sessionSpec.sourceVideoFrameRate, fps > 0 { | ||
| inf += ",FRAME-RATE=\(String(format: "%.3f", fps))" | ||
| } |
There was a problem hiding this comment.
Emit fallback FRAME-RATE when fps metadata is missing
For PQ/Dolby Vision loopback sessions where the server does not provide a parsable video frameRate, sourceVideoFrameRate is nil (ApplePlaybackRoutePlanner.loopbackSourceFrameRate and the PlayerViewModel equivalent both return nil in that case), so this conditional omits FRAME-RATE from the master variant. This commit now starts AVPlayer from master.m3u8, and the surrounding comments note that VIDEO-RANGE=PQ variants without FRAME-RATE are rejected before the media playlist is fetched; those files will therefore fall back/fail even though playback could use the same 24 fps default already used for display criteria.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the latest push: FRAME-RATE is now always emitted on the master variant, defaulting to 23.976 (the same film cadence the display-criteria path uses) when the server provides no parsable frame rate.
Media-direct start was a historical retreat from a master rejection,
but Apple grants premium format claims (Dolby Atmos MAT output for
EAC3-JOC) at master-variant level — media-direct start meant Atmos
could never engage regardless of sample-entry signalling. Three fixes
make the master surface acceptable:
1. Start from master.m3u8 (the multivariant manifest was already
emitted for artifact inspection).
2. Emit RESOLUTION and FRAME-RATE in the stream-inf. FRAME-RATE is
load-bearing: AVFoundation's variant filter silently drops a
VIDEO-RANGE=PQ variant with no FRAME-RATE (isolated locally via
AVAsset.variants against on-device artifacts: PQ without FRAME-RATE
= zero variants = NSURLError -1002 before the variant playlist is
ever fetched — the actual mechanism behind the historical master
rejection).
3. Declare Main tier in the CODECS string ("hvc1.2.4.L150"), never
High tier with constraint bytes: the variant filter also drops a
faithful "hvc1.2.4.H150.B0" declaration. Declaration only feeds
variant selection; the bitstream is untouched.
Device-verified end to end: master accepted, variant fetched, AVPlayer
owns the session, and with the dec3 JOC extension in place the AVR reports Dolby Atmos for a streaming WEB-DL DDP-Atmos episode.
tvOS 26.5 validates a variant's VIDEO-RANGE against the panel's current mode synchronously, before fetching the init segment. Display criteria were applied but the AVPlayerItem was created while the panel was still mid-switch (isDisplayModeSwitchInProgress=1 at item-ready on every measured session; the panel takes ~2.9 s to settle), so the master-start path failed with -11868 (underlying -17223) and silently dropped to the PlayerCore fallback. Two-stage settle wait: up to 1 s for the switch to begin (the handshake starts asynchronously after preferredDisplayCriteria is written), then up to 5 s for it to clear. Media-direct start never tripped this because with no master there is no variant validation — which is also why the retreat to media-direct "worked" while quietly costing Atmos.
DDP-Atmos (E-AC-3 + JOC) stream-copied bit-exact through the loopback was classified by AVFoundation as plain E-AC-3 5.1, so Atmos never engaged. Five stacked fixes, adapted from the retracted PR #64 after validating each against FFmpeg sources and AetherEngine's shipping Atmos path: - Rewrite the init segment's dec3 box into the ETSI TS 102 366 layout and append the TS 103 420 JOC extension AVFoundation keys on. The vendored FFmpeg 7.1 muxer writes 5 reserved bits where the spec has 3 and no extension (verified against n7.1 vs n8.1 mov_write_eac3_tag; output pinned byte-identical to FFmpeg 8.1's). Gated on copy-mode E-AC-3 with codecpar.profile == AV_PROFILE_EAC3_DDP_ATMOS. - Start AVPlayer from the master playlist: Atmos MAT output is a master-variant-level grant. Kill switch back to media-direct: player.apple.loopback_master_start_enabled = NO. - Emit RESOLUTION and always emit FRAME-RATE on the master variant (AVFoundation drops a PQ variant with no FRAME-RATE, -1002). - Clamp the HEVC CODECS declaration to Main tier with no constraint suffix; a faithful High-tier string is variant-filtered. - Extend the pre-item display-mode settle wait to fresh DV criteria applies: tvOS 26.5 validates the master's VIDEO-RANGE against the panel's current mode synchronously (-11868 mid-switch). Also declares setSupportsMultichannelContent(true) on the playback audio session (AetherEngine parity; PlayerCore already does). 7 new tests pin the dec3 rewrite bit-for-bit, including the FFmpeg 8.1 ground-truth vector for the on-device streaming-Atmos payload. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RdnjmQmP9WuJdCKa4yKt6L
Summary
Makes DDP-Atmos (E-AC-3 + JOC) actually reach the AVR/soundbar as Dolby Atmos on the local Dolby Vision loopback route. Previously these tracks stream-copied bit-exact but AVFoundation classified them as plain E-AC-3 5.1, so Atmos never engaged. Device-verified end to end: an AVR reports "Dolby Atmos" for a streaming WEB-DL DDP-Atmos episode.
Five stacked defects had to be fixed; each was necessary, none sufficient alone:
dec3without the ETSI TS 103 420 JOC extension (flag_ec3_extension_type_a+complexity_index_type_a), the field AVFoundation keys on for Atmos. It also emits a non-ETSI 5-reserved-bit substream layout where the spec has 3.ISOBoxSurgerynow rewritesdec3into the ETSI layout with the extension, gated oncodecpar.profile == AV_PROFILE_EAC3_DDP_ATMOS. Ground truth: byte-identical to what FFmpeg 8.1 emits for the same stream (pinned in tests).FRAME-RATEon the PQ variant — AVFoundation silently drops aVIDEO-RANGE=PQvariant with noFRAME-RATE(-1002before the variant playlist is even fetched; isolated viaAVAsset.variants).CODECS— a faithful High-tierhvc1.2.4.H150.B0is also variant-filtered; declaringL150is accepted (declaration only feeds selection; bitstream untouched).VIDEO-RANGEagainst the panel's current mode; creating the item mid-switch fails-11868. Two-stage settle wait before item creation.Verification
Builds clean on
SiloTV;ISOBoxSurgeryDec3Tests(7) pin the dec3 rewrite bit-for-bit. On-device: DV Profile 8 + E-AC-3 JOC through the loopback → AVR shows Dolby Atmos; DV picture unaffected.Authored with Claude Code.