Skip to content

Conversation

@bradh
Copy link
Collaborator

@bradh bradh commented Jan 7, 2026

This is from ISO/IEC 14496-12:2022 Section 8.16.5, and is useful in CMAF and DASH. We already had a test file that includes it, but the checking was manual.

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

Adds a new PRFT atom implementation and integrates it into the public API. Introduces src/prft.rs with a public Prft struct (fields: reference_track_id: u32, ntp_timestamp: u64, media_time: u64, utc_time_semantics: ReferenceTime) and a ReferenceTime enum (six variants). Implements AtomExt for Prft with V0/V1 handling and flag-to-semantics mapping. Exposes the module via pub use prft::*; in lib.rs. Extends the Any enum with a Prft variant and updates tests to assert concrete Prft decoding/encoding behavior.

Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'implement prft box' accurately and concisely describes the main change: adding support for the PRFT (Producer Reference Time) box to the codebase.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of implementing the prft box per ISO/IEC 14496-12:2022 Section 8.16.5 and its use in CMAF and DASH.

✏️ Tip: You can configure your own custom Pre-merge Checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6363a04 and f910bc0.

📒 Files selected for processing (4)
  • src/any.rs
  • src/lib.rs
  • src/prft.rs
  • src/test/h264.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/lib.rs
  • src/any.rs
  • src/test/h264.rs
  • src/prft.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/lib.rs
  • src/any.rs
  • src/test/h264.rs
  • src/prft.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
src/test/**

📄 CodeRabbit inference engine (CLAUDE.md)

Put integration tests under src/test/ with sample MP4 files for different codecs

Files:

  • src/test/h264.rs
🧠 Learnings (3)
📓 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/any.rs : Register new atom types in the Any enum (src/any.rs) to enable flexible decoding

Applied to files:

  • src/any.rs
  • src/test/h264.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/any.rs
  • src/test/h264.rs
  • src/prft.rs
🔇 Additional comments (8)
src/lib.rs (1)

155-155: LGTM!

The new prft module declaration and public re-export follow the established pattern used by other atom modules in this crate.

Also applies to: 174-174

src/any.rs (1)

334-334: LGTM!

Prft is correctly registered in the Any enum's basic list, enabling flexible decoding as per the crate conventions. Based on learnings, this is the required registration step for new atom types.

src/prft.rs (5)

18-51: LGTM!

The ReferenceTime enum now includes the serde derives gated by the serde feature, addressing the previous build failure. The enum variants are well-documented and align with ISO/IEC 14496-12 Section 8.16.5 semantics.


53-60: LGTM!

The Prft struct correctly models the Producer Reference Time box fields per the ISO specification, with appropriate derives and feature-gated serde support.


67-99: LGTM!

The decoding logic correctly handles:

  • Flag-to-semantics mapping with appropriate precedence
  • Version-based media_time size (32-bit for V0, 64-bit for V1)

101-134: LGTM!

The encoding logic is well-structured:

  • Flag derivation is symmetric with the decoding priority
  • Version selection (V0 for values ≤ u32::MAX, V1 otherwise) ensures minimal encoding size

137-215: LGTM!

Solid test coverage including:

  • V0 and V1 version handling
  • Multiple ReferenceTime semantics (Input, Written, RealTime)
  • Round-trip encode/decode verification
  • Conformance suite test data for validation
src/test/h264.rs (1)

655-668: LGTM!

The test correctly validates end-to-end integration: PRFT boxes are now decoded as concrete Prft instances rather than Unknown, with proper field assertions matching the encoded data.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @src/prft.rs:
- Around line 18-50: ReferenceTime is missing serde derives causing Prft (which
derives Serialize/Deserialize under the serde feature) to fail; add conditional
serde derives to the ReferenceTime enum using cfg_attr(feature = "serde",
derive(serde::Serialize, serde::Deserialize)) so the enum is
serializable/deserializable when the serde feature is enabled, keeping its
existing Debug/Clone/PartialEq/Eq/Default derives intact; update the
ReferenceTime definition (the enum symbol ReferenceTime) to include this
cfg_attr so the build succeeds with the serde feature.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4400aa and e35bb6e.

📒 Files selected for processing (4)
  • src/any.rs
  • src/lib.rs
  • src/prft.rs
  • src/test/h264.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/lib.rs
  • src/any.rs
  • src/prft.rs
  • src/test/h264.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/lib.rs
  • src/any.rs
  • src/prft.rs
  • src/test/h264.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
src/test/**

📄 CodeRabbit inference engine (CLAUDE.md)

Put integration tests under src/test/ with sample MP4 files for different codecs

Files:

  • src/test/h264.rs
🧠 Learnings (3)
📓 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/**/*.rs : Each MP4 atom type must implement the Atom trait with KIND, decode_body(), and encode_body()
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
📚 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.rs
  • src/test/h264.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/any.rs
  • src/prft.rs
  • src/test/h264.rs
🪛 GitHub Actions: PR
src/prft.rs

[error] 53-53: the trait bound prft::ReferenceTime: Serialize is not satisfied.

🪛 GitHub Check: build
src/prft.rs

[failure] 53-53:
the trait bound prft::ReferenceTime: Deserialize<'_> is not satisfied


[failure] 53-53:
the trait bound ReferenceTime: Deserialize<'_> is not satisfied


[failure] 58-58:
the trait bound prft::ReferenceTime: Deserialize<'_> is not satisfied


[failure] 58-58:
the trait bound ReferenceTime: Deserialize<'_> is not satisfied


[failure] 58-58:
the trait bound prft::ReferenceTime: Deserialize<'_> is not satisfied


[failure] 58-58:
the trait bound ReferenceTime: Deserialize<'_> is not satisfied


[failure] 53-53:
the trait bound ReferenceTime: Serialize is not satisfied


[failure] 53-53:
the trait bound prft::ReferenceTime: Serialize is not satisfied

🔇 Additional comments (7)
src/prft.rs (4)

6-16: LGTM!

The ext! macro invocation correctly defines the PRFT extension with version support (V0/V1) and the appropriate flag bits matching the ISO/IEC 14496-12 specification.


66-98: LGTM!

The decoding logic correctly handles:

  • Field order (reference_track_id, ntp_timestamp, then version-dependent media_time)
  • Flag precedence for utc_time_semantics derivation
  • V0/V1 version selection for 32-bit vs 64-bit media_time

100-133: LGTM!

The encoding logic correctly:

  • Maps ReferenceTime variants to the appropriate flag combinations
  • Auto-selects V0/V1 based on whether media_time fits in a u32
  • Maintains symmetry with the decode path

136-213: LGTM!

The test suite provides good coverage:

  • V1 decode/encode with conformance data
  • V0 round-trip at the boundary (u32::MAX)
  • RealTime semantics with combined flags
src/lib.rs (1)

155-155: LGTM!

The module declaration and public re-export follow the existing crate conventions. Based on learnings, this correctly integrates the new PRFT atom type into the crate's public API.

Also applies to: 174-174

src/any.rs (1)

332-332: LGTM!

The Prft variant is correctly registered in the Any enum's basic list, enabling flexible decoding. As per coding guidelines, new atom types should be registered in the Any enum in src/any.rs.

src/test/h264.rs (1)

653-666: LGTM!

The test correctly validates the new Prft decoding path with concrete field assertions, replacing the previous Unknown variant handling. This confirms the end-to-end integration of the PRFT box implementation.

@bradh
Copy link
Collaborator Author

bradh commented Jan 7, 2026

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@bradh
Copy link
Collaborator Author

bradh commented Jan 7, 2026

@coderabbitai pause

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

✅ Actions performed

Reviews paused.

bradh added 2 commits January 7, 2026 15:40
This is from ISO/IEC 14496-12:2022 Section 8.16.5, and is useful in
CMAF and DASH. We already had a test file that includes it, but
the checking was manual.
@bradh
Copy link
Collaborator Author

bradh commented Jan 7, 2026

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

✅ Actions performed

Full review triggered.

@bradh bradh merged commit 8a20a22 into kixelated:main Jan 7, 2026
1 check passed
@bradh bradh deleted the prft_2026-01-07 branch January 7, 2026 08:21
@github-actions github-actions bot mentioned this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants