-
Notifications
You must be signed in to change notification settings - Fork 13
add support for btrt box in uncompressed audio #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAn optional Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (3)**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/moov/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (3)📚 Learning: 2025-08-31T04:06:57.364ZApplied to files:
📚 Learning: 2025-08-31T04:06:57.364ZApplied to files:
📚 Learning: 2025-08-31T04:06:57.364ZApplied to files:
🧬 Code graph analysis (1)src/moov/trak/mdia/minf/stbl/stsd/pcm.rs (1)
🔇 Additional comments (6)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs (2)
126-139: Consider reusingencode_fieldsto eliminate duplication.This method duplicates the encoding logic already present in
encode_fields. Both encode the same fields in the same order. Consider delegating to avoid divergence if encoding logic changes.🔎 Proposed refactor
pub fn encode_with_fourcc<B: BufMut>(&self, buf: &mut B) -> Result<()> { - self.audio.encode(buf)?; - self.pcmc.encode(buf)?; - - if let Some(ref chnl) = self.chnl { - chnl.encode(buf)?; - } - - if let Some(ref btrt) = self.btrt { - btrt.encode(buf)?; - } - - Ok(()) + Self::encode_fields(&self.audio, &self.pcmc, self.chnl.as_ref(), self.btrt.as_ref(), buf) }
474-479: Simplify the type annotation.The explicit type annotation is verbose. Consider simplifying for clarity.
🔎 Proposed simplification
#[test] fn test_ipcm_decode() { - let buf: &mut std::io::Cursor<&&[u8]> = &mut std::io::Cursor::new(&ENCODED_IPCM); + let mut buf = std::io::Cursor::new(ENCODED_IPCM); let ipcm = Ipcm::decode(buf).expect("failed to decode ipcm"); assert_eq!(ipcm, decoded_ipcm()); }
Cursor::newcan take&[u8]directly sinceENCODED_IPCMis already&'static [u8].
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Code must be clippy-clean (cargo clippy --all-targets --all-features -- -D warnings)
Code must be formatted with rustfmt (cargo fmt) and pass formatting checks (cargo fmt -- --check)
Write unit tests inline within modules using #[cfg(test)]
Files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
src/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
src/**/*.rs: Each MP4 atom type must implement the Atom trait with KIND, decode_body(), and encode_body()
Use Header::read_from() to handle large atoms without loading entire contents into memory
All operations should return Result using custom error types defined in error.rs
Use the custom Buf/BufMut traits for contiguous byte slices instead of ad-hoc buffer handling
Files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
src/moov/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place movie metadata atom implementations under src/moov/ (and its hierarchy: trak/mdia/minf/stbl/stsd)
Files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
🧠 Learnings (4)
📚 Learning: 2025-08-31T04:06:57.364Z
Learnt from: CR
Repo: kixelated/mp4-atom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-31T04:06:57.364Z
Learning: Applies to src/any.rs : Register new atom types in the Any enum (src/any.rs) to enable flexible decoding
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
📚 Learning: 2025-08-31T04:06:57.364Z
Learnt from: CR
Repo: kixelated/mp4-atom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-31T04:06:57.364Z
Learning: Applies to src/**/*.rs : Use Header::read_from() to handle large atoms without loading entire contents into memory
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
📚 Learning: 2025-08-31T04:06:57.364Z
Learnt from: CR
Repo: kixelated/mp4-atom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-31T04:06:57.364Z
Learning: Applies to src/**/*.rs : Each MP4 atom type must implement the Atom trait with KIND, decode_body(), and encode_body()
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
📚 Learning: 2025-08-31T04:06:57.364Z
Learnt from: CR
Repo: kixelated/mp4-atom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-31T04:06:57.364Z
Learning: Applies to src/buf.rs : Define and maintain contiguous byte-slice buffer behavior via custom Buf and BufMut traits in buf.rs
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs
🧬 Code graph analysis (1)
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs (1)
src/moov/trak/mdia/minf/stbl/stsd/mod.rs (1)
decode(115-144)
🔇 Additional comments (5)
src/moov/trak/mdia/minf/stbl/stsd/pcm.rs (5)
46-54: LGTM!The
btrtfield addition follows the same pattern as the existingchnlfield, appropriately usingOption<Btrt>to represent the optional nature of the btrt box.
57-76: LGTM!The
encode_fieldsfunction correctly handles the optionalbtrtparameter using the same pattern aschnl, maintaining consistency in the encoding order.
78-124: LGTM!The decoding logic correctly integrates
btrthandling viaAny::decode_atom, following the same pattern aspcmc. Unlikechnl, which requireschannel_countcontext,btrtcan be decoded through the standard path.
142-177: LGTM!The macro correctly propagates the
btrtfield through both decode and encode paths, ensuring all PCM sample entry types (Sowt, Twos, Lpcm, Ipcm, Fpcm, In24, In32, Fl32, Fl64, S16l) gain btrt support.
434-472: Good test coverage for btrt support.The test data and helper function provide comprehensive verification of IPCM encoding/decoding with the btrt box. The raw bytes in
ENCODED_IPCMcorrectly include the btrt atom (identifiable by the0x62, 0x74, 0x72, 0x74/ "btrt" fourcc at offset 75-78).
af64347 to
309af8f
Compare
|
Yes, LGTM. |
Builds on recent work on uncompressed audio (ISO/IEC 23000-5).
@SanchayanMaity does this work for you?