Skip to content

Preserve unknown stsd codec bodies - #204

Open
kixelated wants to merge 1 commit into
mainfrom
codex/preserve-unknown-stsd-codecs
Open

Preserve unknown stsd codec bodies#204
kixelated wants to merge 1 commit into
mainfrom
codex/preserve-unknown-stsd-codecs

Conversation

@kixelated

Copy link
Copy Markdown
Owner

Fixes #194.

Summary

  • preserve the body bytes of unknown stsd sample entries in Codec::Unknown
  • encode unknown codecs as complete size/FourCC/body boxes
  • retain valid box structure for atom kinds known elsewhere but unsupported as sample entries
  • add a byte-for-byte dvh1 round-trip regression test

Root cause

Codec::decode discarded the body of unrecognized sample entries, and Codec::encode wrote only their FourCC. The FourCC was consequently interpreted as the next box's size field, corrupting the stsd structure during a decode/re-encode cycle.

Impact

In non-strict builds, unsupported sample entries now round-trip without losing their payload or corrupting the enclosing stsd. The public Codec::Unknown variant now carries both its FourCC and raw body bytes.

Validation

  • cargo test --all-targets (237 tests passed)
  • cargo check --all-targets --all-features
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check

@kixelated
kixelated marked this pull request as ready for review July 17, 2026 22:40
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kixelated, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3637c9c5-1de5-41ce-bbb9-b21bbf673fc0

📥 Commits

Reviewing files that changed from the base of the PR and between ac798db and 153f611.

📒 Files selected for processing (2)
  • src/moov/trak/mdia/minf/stbl/stsd/mod.rs
  • tests/stsd.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/preserve-unknown-stsd-codecs

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.

Any::S16l(atom) => atom.into(),
Any::Wvtt(atom) => atom.into(),
Any::Samr(atom) => atom.into(),
unknown @ Any::Unknown(..) => {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

wtf is this syntax?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

https://doc.rust-lang.org/book/ch19-03-pattern-syntax.html#using--bindings

I think the code is using unknown in two different ways, which probably means it needs a rewrite.

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.

stsd: Codec::Unknown re-encodes as a bare FourCC, corrupting the box

2 participants