Repository navigation
Fix Atmos frames being written to the wrong reel when a reel has no Atmos - #10
Merged
Merged
Conversation
…tmos. Writer::write() for Atmos frames keeps a cursor on the reel that is receiving frames, and moved it to the next reel only when the frame's time was exactly the end of the current reel. When a reel in between had no Atmos at all, the next frame arrived later than that, the cursor stayed where it was and the frames of a later reel were written to the earlier one. The earlier reel ended up with too much Atmos, the later one with none, and verification failed with "All assets in a reel do not have the same duration". Advance the cursor past every reel that ends at or before the frame. For consecutive reels this is the same as before. Add a test with three reels and Atmos in the first and last only. Claude-Session: https://claude.ai/code/session_011HCUWvPpbN7e6hcwuWBJjs
This was referenced Oct 23, 2026
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.
Problem
If a DCP has several reels and some of them have no Atmos, the Atmos frames of a later reel are
written into an earlier one. The reel that should have the Atmos ends up without it, and the earlier
reel gets too much.
dcp::verifythen reportsand the DCP is wrong.
Why it matters
SMPTE ST 429-19:2019 (DCP Operational Constraints for Immersive Audio), section 6.2, says "Each
reel of an Immersive Audio Composition should contain an Immersive Audio element". It is a "should"
(recommended) rather than a "shall". In practice, a DCP in which some reels have Atmos and others do
not is a problem for some processors. I saw this at the Phenomena Experience cinema in Barcelona
(https://phenomena-experience.com) with the Spanish version of John Wick: Chapter 4 (2023): a reel 0
with added title cards had been put in front of the feature without Atmos, and the Dolby CP850
stayed in the "reverted" (to PCM) state instead of playing the Atmos.
The bug fixed here hits exactly the DCPs that follow that recommendation only partly, and turns them
into DCPs where the wrong reel has Atmos. This patch does not add Atmos to reels that have none; it
only stops the Atmos frames that do exist from being written to the wrong reel.
Cause
Writer::write()for Atmos frames keeps a cursor (_atmos_reel) on the reel that is receivingframes. It moved the cursor to the next reel only when the frame's time was exactly the end of the
current reel (
src/lib/writer.cc):With Atmos in reel 1 (0-10 s) and reel 3 (20-30 s) and none in reel 2, the first frame of reel 3
arrives at 20 s. The cursor is still on reel 1, whose end is 10 s, so
10 s == 20 sis false, thecursor does not move, and the frames of reel 3 are written to reel 1.
Fix
Move the cursor past every reel that ends at or before the frame:
For consecutive reels this is the same as before: the loop runs once, then stops because the next
reel ends after the frame.
Test
atmos_multi_reel_gap_test(intest/atmos_test.cc) makes three 10 s reels fromtest/data/flat_red.png(at 0, 10 and 20 s) withtest/data/atmos_0.mxfat 0 s and at 20 s, so themiddle reel has no Atmos. It checks that reels 1 and 3 have Atmos, reel 2 does not, and that each
Atmos asset is 240 frames. It uses only files from the public test data, the same Atmos file as
atmos_multi_reel_test.Before the fix (
writer.ccunchanged, test added):After the fix:
atmos_multi_reel_test(three consecutive reels, each with Atmos) passes both before and after.Also run on this branch, all without errors (45 test cases; two disabled ones are skipped):
atmos_*,reels_*,reel_*,vf_*,multi_reel*,encrypt_only_*andencrypted_dcp_with_no_kdm_gives_no_butler_error, includingatmos_encrypted_passthrough_test,atmos_passthrough_testandatmos_trim_test. The branch also builds on Ubuntu 24.04 (the fork'sCI, which builds but does not run the tests).
Scope and risk
Writer::write(shared_ptr<const dcp::AtmosFrame>, ...); nothing else changes.case that used to produce a wrong DCP.
DCPOMATIC_ASSERTfails (aProgrammingError), as it alreadydid for a frame exactly at the end of the last reel. Before, such a frame was written silently to
the wrong reel.
What was not checked
make_and_verify_dcpruns on Linux (
dcp_inspect,clairmeta, the asdcplib tools) were not run.🤖 Generated with Claude Code
https://claude.ai/code/session_011HCUWvPpbN7e6hcwuWBJjs