-
Notifications
You must be signed in to change notification settings - Fork 14
sgpd: add support for the refs sample groups #106
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 is from ISO/IEC 23008-12:2025 Section 7.4. Its used in HEIF image sequences. This fixes the parsing of the several of the old HEIF samples in the MPEG File Format Conformance suite. Without this change, we get OverDecode errors for `sgpd`.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe change adds support for the "refs" grouping type in the SGPD box handler. When the grouping_type equals "refs", a DirectReferenceSampleList structure is decoded consisting of a sample ID and a list of direct reference samples (capped at 16 entries). The corresponding encoder handles serialization of this structure. A new enum variant 🚥 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 nitpick comments
📜 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:
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting 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 |
@coderabbitai can you explain the cap of 16 statement further? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Length of output: 10185
Looking at the decode path (lines 143-150): let num_direct_reference_samples = u8::decode(buf)? as usize; // Can be 0-255
let mut direct_reference_samples =
Vec::with_capacity(std::cmp::min(num_direct_reference_samples, 16)); // Capacity capped at 16
for _ in 0..num_direct_reference_samples { // But loop runs the full count
direct_reference_samples.push(u32::decode(buf)?);
}The code pre-allocates capacity for at most 16 elements (via
So the "16" is only limiting memory pre-allocation, not the actual number of items decoded. Looking at the encode path (lines 165-169): let num_direct_reference_samples: u8 = direct_reference_samples
.len()
.try_into()
.map_err(|_| Error::TooLarge(REFS_4CC))?;This only checks that the count fits in a The inconsistency is that the decode side implies 16 is a special limit (by capping capacity), while the encode side only enforces the u8 limit of 255. My comment was asking whether:
Does the spec specify a maximum number of direct reference samples? |
@coderabbitai The limit is 255, the 16 is just to avoid overallocation. Note this pattern in other boxes. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Length of output: 1841
This is a defensive memory allocation pattern to avoid excessive pre-allocation when parsing untrusted input. The specific cap value (8, 16, or 128) appears to be chosen based on the expected typical size for that particular structure. Thank you for the clarification! ✏️ Learnings added
|
This is from ISO/IEC 23008-12:2025 Section 7.4. Its used in HEIF image sequences.
This fixes the parsing of the several of the old HEIF samples in the MPEG File Format Conformance suite. Without this change, we get OverDecode errors for
sgpd.