-
Notifications
You must be signed in to change notification settings - Fork 13
fiel: implement box #85
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
WalkthroughA new Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (12)
🚧 Files skipped from review as they are similar to previous changes (7)
🧰 Additional context used📓 Path-based instructions (5)**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/moov/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/any.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/test/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (4)📓 Common learnings📚 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/hevc/hev1.rs (2)
🔇 Additional comments (8)
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 (4)
src/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs (1)
65-67: Consider simplifying the encode pattern.Since
Option<T>implementsEncodein this codebase, you can simplify this to:- if self.fiel.is_some() { - self.fiel.encode(buf)? - } + self.fiel.encode(buf)?;This pattern is used elsewhere in the codebase and is more concise.
🔎 Proposed simplification
- if self.fiel.is_some() { - self.fiel.encode(buf)? - } + self.fiel.encode(buf)?;src/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rs (1)
66-68: Consider simplifying the encode pattern.Similar to the suggestion in
hev1.rs, this can be simplified sinceOption<T>implementsEncode:- if self.fiel.is_some() { - self.fiel.encode(buf)?; - } + self.fiel.encode(buf)?;🔎 Proposed simplification
- if self.fiel.is_some() { - self.fiel.encode(buf)?; - } + self.fiel.encode(buf)?;src/moov/trak/mdia/minf/stbl/stsd/fiel.rs (2)
11-16: Constructor returnsResultbut never fails.The
new()method returnsResult<Self>but has no error path. Either returnSelfdirectly for a simple constructor, or add validation forfield_countandfield_orderif there are invalid values per the MP4/QuickTime specification.🔎 Proposed fix to return Self directly
- pub fn new(field_count: u8, field_order: u8) -> Result<Self> { - Ok(Fiel { + pub fn new(field_count: u8, field_order: u8) -> Self { + Fiel { field_count, field_order, - }) + } }
22-30: Consider validation for field_count and field_order values.The
fielatom is a QuickTime extension (not part of ISO/IEC 14496-12). According to QuickTime/FFmpeg specifications,field_counthas valid values 0 (progressive), 1 or 2 (interlaced), andfield_orderuses specific bit-mapped values (e.g., 0x06 = BB field order). The current decode accepts anyu8without validation. While the codebase pattern (e.g.,pasp.rs) doesn't validate in decode functions, adding validation here could improve robustness if invalid values should be rejected.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
src/any.rssrc/moov/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.rssrc/moov/trak/mdia/minf/stbl/stsd/mod.rssrc/test/bbb.rssrc/test/esds.rssrc/test/h264.rssrc/test/hevc.rs
🧰 Additional context used
📓 Path-based instructions (5)
**/*.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/test/bbb.rssrc/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/test/h264.rssrc/any.rssrc/test/esds.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/test/hevc.rssrc/moov/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.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/test/bbb.rssrc/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/test/h264.rssrc/any.rssrc/test/esds.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/test/hevc.rssrc/moov/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.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/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/moov/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs
src/test/**
📄 CodeRabbit inference engine (CLAUDE.md)
Put integration tests under src/test/ with sample MP4 files for different codecs
Files:
src/test/bbb.rssrc/test/h264.rssrc/test/esds.rssrc/test/hevc.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 (5)
📓 Common learnings
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
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()
📚 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/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/any.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.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/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/any.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.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/moov/** : Place movie metadata atom implementations under src/moov/ (and its hierarchy: trak/mdia/minf/stbl/stsd)
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/fiel.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/hevc/hvc1.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs
🧬 Code graph analysis (4)
src/moov/trak/mdia/minf/stbl/stsd/fiel.rs (4)
src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs (2)
decode_body(18-48)encode_body(50-69)src/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs (2)
decode_body(18-48)encode_body(50-69)src/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rs (2)
decode_body(19-49)encode_body(51-70)src/moov/trak/mdia/minf/stbl/stsd/mod.rs (1)
decode(117-146)
src/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rs (2)
src/atom.rs (1)
decode_maybe(41-68)src/coding.rs (1)
decode_maybe(31-31)
src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs (2)
src/atom.rs (1)
decode_maybe(41-68)src/coding.rs (1)
decode_maybe(31-31)
src/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs (2)
src/atom.rs (1)
decode_maybe(41-68)src/coding.rs (1)
decode_maybe(31-31)
🔇 Additional comments (18)
src/test/bbb.rs (1)
273-273: LGTM!Test data correctly updated to include the new
fielfield initialized toNone, consistent with other optional fields in the structure.src/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.rs (1)
176-176: LGTM!Test correctly updated to include the new
fielfield.src/moov/trak/mdia/minf/stbl/stsd/mod.rs (2)
9-9: LGTM!Module declaration follows the alphabetical ordering convention used in this file.
31-31: LGTM!Public re-export correctly placed in alphabetical order, making the
Fieltype available to consumers of this module.src/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs (2)
12-12: LGTM!New
fielfield correctly added as an optional field, consistent with other optional metadata fields in the structure.
26-34: LGTM!Decode logic correctly handles the new
Fielatom variant, following the established pattern for optional child atoms.src/test/h264.rs (1)
262-262: LGTM!Test data correctly updated to include the new
fielfield.src/test/esds.rs (1)
202-202: LGTM!Test correctly updated with the new
fielfield.src/any.rs (1)
278-278: LGTM - Fiel atom correctly registered.The
Fielvariant is properly added to theAnyenum's basic atoms list. This macro invocation will automatically generate all necessary conversion traits (From,TryFrom,AnyAtom) and encode/decode logic for the new atom type, following the established pattern in this codebase.Based on learnings: Each MP4 atom type must be registered in the Any enum to enable flexible decoding.
src/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rs (2)
13-13: LGTM!The
fielfield is correctly added as optional metadata, maintaining consistency with other optional fields in the structure.
27-35: LGTM!Decode logic properly handles the
Fielatom, following the established pattern for decoding optional child atoms.src/moov/trak/mdia/minf/stbl/stsd/fiel.rs (1)
39-72: LGTM!The test coverage is appropriate, with both decode and encode paths tested. The test data is well-structured with a constant for the encoded representation.
src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs (4)
12-12: LGTM!The new
fielfield follows the established pattern for optional codec metadata atoms (btrt, colr, pasp, taic).
26-46: LGTM!The decode logic correctly handles the new
Any::Fielvariant and constructs the struct with the optionalfielfield. This follows the same pattern as other optional atoms.
65-67: LGTM!The encode logic conditionally writes the fiel atom when present, consistent with other optional fields.
106-106: LGTM!Test coverage includes both cases:
fiel: Nonein the basic test andfiel: Some(Fiel { ... })in the extended test. This validates both encoding/decoding paths.Also applies to: 158-161
src/moov/mod.rs (1)
222-222: LGTM!The test expectation correctly includes
fiel: Noneto match the decoded structure, as the encoded test data doesn't contain a fiel atom.src/test/hevc.rs (1)
569-572: LGTM!The test expectation correctly includes the fiel atom with
field_count: 1andfield_order: 0, which matches the encoded test data in the byte array (lines 175-176 contain the fiel atom: size 10 bytes, type "fiel", followed by 0x01, 0x00).
cc20b86 to
606e453
Compare
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/fiel.rs (2)
5-8: Consider adding documentation for the Fiel struct and its fields.The
field_countandfield_orderfields lack documentation explaining their purpose and valid value ranges according to the MP4 specification.
10-17: Simplify the constructor to returnSelfdirectly.The
newmethod returnsResult<Self>but never returns an error. Since no validation is performed, the constructor can simply returnSelfinstead of wrapping it inOk().🔎 Proposed simplification
impl Fiel { - pub fn new(field_count: u8, field_order: u8) -> Result<Self> { - Ok(Fiel { + pub fn new(field_count: u8, field_order: u8) -> Self { + Fiel { field_count, field_order, - }) + } } }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
src/any.rssrc/moov/mod.rssrc/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rssrc/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.rssrc/moov/trak/mdia/minf/stbl/stsd/mod.rssrc/test/bbb.rssrc/test/esds.rssrc/test/h264.rssrc/test/hevc.rs
🚧 Files skipped from review as they are similar to previous changes (7)
- src/moov/trak/mdia/minf/stbl/stsd/mod.rs
- src/any.rs
- src/test/h264.rs
- src/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs
- src/moov/mod.rs
- src/moov/trak/mdia/minf/stbl/stsd/hevc/hvc1.rs
- src/moov/trak/mdia/minf/stbl/stsd/hevc/hvcc.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/test/esds.rssrc/test/hevc.rssrc/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/test/bbb.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/test/esds.rssrc/test/hevc.rssrc/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rssrc/test/bbb.rs
src/test/**
📄 CodeRabbit inference engine (CLAUDE.md)
Put integration tests under src/test/ with sample MP4 files for different codecs
Files:
src/test/esds.rssrc/test/hevc.rssrc/test/bbb.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/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs
🧠 Learnings (6)
📓 Common learnings
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
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()
📚 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/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.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/moov/trak/mdia/minf/stbl/stsd/fiel.rssrc/moov/trak/mdia/minf/stbl/stsd/h264/avc1.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: Place top-level atoms (e.g., ftyp, mdat, free) at the top-level of src/
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/fiel.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/moov/** : Place movie metadata atom implementations under src/moov/ (and its hierarchy: trak/mdia/minf/stbl/stsd)
Applied to files:
src/moov/trak/mdia/minf/stbl/stsd/fiel.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/h264/avc1.rs
🧬 Code graph analysis (2)
src/moov/trak/mdia/minf/stbl/stsd/fiel.rs (1)
src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs (2)
decode_body(18-48)encode_body(50-69)
src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs (2)
src/atom.rs (1)
decode_maybe(41-68)src/coding.rs (1)
decode_maybe(31-31)
🔇 Additional comments (8)
src/moov/trak/mdia/minf/stbl/stsd/fiel.rs (1)
19-37: LGTM! Atom trait implementation is correct.The decode and encode logic correctly handles the two u8 fields in sequence.
src/test/esds.rs (1)
202-202: LGTM! Test fixture correctly updated.The addition of
fiel: Nonealigns with the newfielfield in theAvc1struct.src/test/hevc.rs (1)
569-572: LGTM! Test fixture correctly reflects encoded fiel atom.The test expectation matches the encoded fiel atom in the ENCODED constant at line 175 (bytes:
0x00, 0x00, 0x00, 0x0A, 0x66, 0x69, 0x65, 0x6C, 0x01, 0x00), which decodes to field_count=1 and field_order=0.src/test/bbb.rs (1)
273-273: LGTM! Test fixture correctly updated.The addition of
fiel: Nonealigns with the newfielfield in theAvc1struct.src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs (4)
12-12: LGTM! Fiel field addition follows the pattern of other optional atoms.The new
fielfield is correctly declared asOption<Fiel>consistent with other optional atoms likebtrt,colr,pasp, andtaic.
26-34: LGTM! Decode logic correctly handles the Fiel atom.The decode implementation properly initializes
fieltoNone, matches onAny::Fiel, and assigns the atom when present.
65-67: LGTM! Encode logic correctly handles the optional Fiel atom.The encode implementation follows the same pattern as other optional atoms, checking for presence before encoding.
106-106: LGTM! Tests properly cover both None and Some cases for fiel.The basic test (
test_avc1) verifiesfiel: None, while the extended test (test_avc1_with_extras) verifiesfiel: Some(...)with field_count=2 and field_order=0.Also applies to: 158-161
606e453 to
86ccf1b
Compare
implement field ordering box.