-
Notifications
You must be signed in to change notification settings - Fork 14
tx3g: implement ftab box #100
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
This comes up in a couple of the MPEG file format conformance files as the tx3g codec under decoding. See 3GPP TS 26.245 or ETSI TS 126 245 Section 5.1 Its not clear that the box has to be there, so made it an Option.
WalkthroughAdds support for a font table box ( 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 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 (1)📚 Learning: 2025-08-31T04:06:57.364ZApplied to files:
🧬 Code graph analysis (1)src/moov/trak/mdia/minf/stbl/stsd/ftab.rs (3)
🔇 Additional comments (7)
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: 2
🤖 Fix all issues with AI agents
In @src/moov/trak/mdia/minf/stbl/stsd/ftab.rs:
- Around line 31-62: The code reads font_bytes[0] and font_bytes[1] for BOM
detection without ensuring font_name_length is large enough; add an upfront
bounds check on font_name_length (e.g., ensure it's >= 1 or >= 2 as appropriate)
before decoding/inspecting font_bytes and return Error::InvalidSize for
too-small lengths (handle zero-length and <2 cases before the BOM branches that
reference font_bytes[0] and font_bytes[1]); update the logic around font_bytes,
font_name_length, and the Error::InvalidSize return so BOM checks occur only
after confirming sufficient length.
In @src/moov/trak/mdia/minf/stbl/stsd/tx3g.rs:
- Around line 75-81: The match arm incorrectly uses atom.into() to assign to
ftab; replace that with wrapping the value in Some(...) so ftab = Some(atom)
(i.e., set ftab to Some of the Ftab struct) in the Any::Ftab(branch), leaving
the unknown branch as-is and keeping the surrounding decoding loop intact.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/any.rssrc/moov/trak/mdia/minf/stbl/stsd/ftab.rssrc/moov/trak/mdia/minf/stbl/stsd/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/tx3g.rs
🧰 Additional context used
📓 Path-based instructions (4)
**/*.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/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/ftab.rssrc/any.rssrc/moov/trak/mdia/minf/stbl/stsd/tx3g.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/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/ftab.rssrc/any.rssrc/moov/trak/mdia/minf/stbl/stsd/tx3g.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/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/ftab.rssrc/moov/trak/mdia/minf/stbl/stsd/tx3g.rs
src/any.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Register new atom types in the Any enum (src/any.rs) to enable flexible decoding
Files:
src/any.rs
🧠 Learnings (2)
📚 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/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/ftab.rssrc/any.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/any.rs : Register new atom types in the Any enum (src/any.rs) to enable flexible decoding
Applied to files:
src/any.rssrc/moov/trak/mdia/minf/stbl/stsd/tx3g.rs
🧬 Code graph analysis (2)
src/moov/trak/mdia/minf/stbl/stsd/ftab.rs (3)
src/moov/trak/mdia/minf/stbl/stsd/tx3g.rs (2)
decode_body(54-93)encode_body(95-115)src/moov/trak/mdia/minf/stbl/stsd/mod.rs (1)
decode(119-150)src/coding.rs (1)
decode_exact(11-26)
src/moov/trak/mdia/minf/stbl/stsd/tx3g.rs (3)
src/atom.rs (3)
decode_maybe(46-73)decode_unknown(13-15)decode(40-42)src/error.rs (1)
decode_unknown(73-78)src/moov/trak/mdia/minf/stbl/stsd/mod.rs (1)
decode(119-150)
🔇 Additional comments (8)
src/any.rs (1)
285-285: LGTM! Ftab atom properly registered.The addition follows the established pattern and correctly places Ftab in the stsd hierarchy after Tx3g, enabling flexible decoding through the Any enum.
src/moov/trak/mdia/minf/stbl/stsd/mod.rs (1)
11-11: LGTM! Module properly integrated.The ftab module declaration and public re-export follow the established pattern and maintain alphabetical ordering.
Also applies to: 34-34
src/moov/trak/mdia/minf/stbl/stsd/ftab.rs (2)
3-19: LGTM! Well-documented data structures.The FontEntry and Ftab structs are appropriately designed with proper serde support and clear documentation referencing the 3GPP TS 26.245 specification.
69-89: LGTM! Encoding implementation is clean.The encode_body implementation correctly handles size conversions with proper error handling. The decision to always encode as UTF-8 (noted in the comment on line 78) simplifies the implementation while maintaining compatibility.
src/moov/trak/mdia/minf/stbl/stsd/tx3g.rs (4)
3-19: LGTM! Documentation and struct updated appropriately.The documentation references the correct specification, and the optional
ftabfield aligns with the PR objective to support font table boxes that may not always be present.
31-48: LGTM! Default implementation updated correctly.The Default trait implementation properly initializes
ftabtoNone, which is appropriate for an optional field.
95-115: LGTM! Encoding correctly handles optional ftab.The encode_body implementation properly encodes the optional
ftabfield, relying on theEncodetrait implementation forOption<T>.
147-242: Excellent test coverage with MPEG-09 conformance data.The addition of MPEG-09 conformance test cases provides valuable real-world validation of the ftab implementation. The round-trip encode/decode tests ensure correctness, and the included JSON documentation aids maintainability.
This comes up in a couple of the MPEG file format conformance files as the tx3g codec under decoding.
See 3GPP TS 26.245 or ETSI TS 126 245 Section 5.1
Its not clear that the box has to be there, so made it an Option.