Skip to content

fix!: read version 0 trun composition offsets as unsigned - #258

Merged
bradh merged 1 commit into
mainfrom
trun-v0-cts
Oct 30, 2026
Merged

bradh merged 1 commit into
mainfrom
trun-v0-cts

Conversation

@kixelated

Copy link
Copy Markdown
Owner

Summary

ISO/IEC 14496-12 §8.8.8 stores sample_composition_time_offset as an unsigned int(32) in a version 0 trun and as a signed int(32) in version 1. The decoder always read it as signed, so a version 0 offset above i32::MAX came back negative.

  • TrunEntry.cts widens from Option<i32> to Option<i64>, so both ranges are representable.
  • Decode reads the offset as u32 in version 0 and as i32 in version 1.
  • Encode still writes version 1 (byte-identical to today) unless an offset only fits version 0. It writes version 0 then, and refuses offsets that fit neither, such as a mix of negative and above-i32::MAX values, with Error::InvalidCombination.

This is the remaining item from #186, after kixelated/mp4-atom#160 and kixelated/mp4-atom#254. It's the narrow follow-up promised when closing kixelated/mp4-atom#212.

Public API

Breaking: the type of TrunEntry.cts. It belongs in the pending 0.17.0 release (kixelated/mp4-atom#247), which already breaks Trun.

Testing

  • cargo test --all-features (adds cts_version_roundtrip, cts_version_0_is_unsigned, and cts_out_of_range_is_refused)
  • cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --check

Closes #186.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

TrunEntry.cts widens to i64 so both ranges fit. Encode keeps version 1
unless an offset only fits version 0, and refuses offsets that fit
neither.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 97710972-8a9b-448b-8c4b-7d3e507471c4
Commits

Reviewing files that changed from the base of the PR and between 683310c and df5c886.

Files selected for processing: 1
  • src/moof/traf/trun.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T19:46:02.916405Z df5c886 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@bradh
bradh merged commit b1dd794 into main Oct 30, 2026
2 checks passed
@bradh
bradh deleted the trun-v0-cts branch October 30, 2026 06:02
@github-actions github-actions Bot mentioned this pull request Oct 30, 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.

trun: first_sample_flags lost on re-encode; mixed per-sample fields silently dropped; v0 cts read as signed

2 participants