Skip to content

vpcc: decode chroma_subsampling as 3 bits, not 1#168

Merged
bradh merged 1 commit into
kixelated:mainfrom
AdrianEddy:fix-vpcc-chroma-mask
Jul 6, 2026
Merged

vpcc: decode chroma_subsampling as 3 bits, not 1#168
bradh merged 1 commit into
kixelated:mainfrom
AdrianEddy:fix-vpcc-chroma-mask

Conversation

@AdrianEddy

Copy link
Copy Markdown
Contributor

Problem

In the vpcC (VPCodecConfigurationRecord) decoder, the byte holding bitDepth (4) | chromaSubsampling (3) | videoFullRangeFlag (1) is decoded with (b >> 1) & 0x01 for chromaSubsampling — masking only 1 of the 3 bits. Per the VP9 Codec ISO Media File Format Binding, chromaSubsampling is 3 bits with defined values 0–3 (4:2:0 vertical / 4:2:0 colocated / 4:2:2 / 4:4:4).

The corruption is value-only and asymmetric: the encoder writes all 3 bits correctly, so a decode→encode round trip through this crate silently rewrites 4:2:2 (2) and 4:4:4 (3) streams as 4:2:0 variants (0/1).

Change

One-line decode fix: & 0x01& 0x07.

Tests

Round-trip tests for chroma_subsampling 2 and 3 (both fail against the old mask), plus a decode of raw record bytes asserting the value survives. cargo test --all-features, clippy -D warnings, and fmt --check are green.

🤖 Generated with Claude Code

chromaSubsampling in the VPCodecConfigurationRecord is a 3-bit field
(0/1 = 4:2:0, 2 = 4:2:2, 3 = 4:4:4) but decode masked it with 0x01,
so 4:2:2 parsed as 0 and 4:4:4 as 1. The encode side already writes
all 3 bits, so a decode/encode round-trip silently rewrote a
4:2:2/4:4:4 vpcC as 4:2:0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 59 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: bf7f4b8e-d5f8-47a5-b306-9e9ff8924bb0

📥 Commits

Reviewing files that changed from the base of the PR and between 02462c1 and 728312f.

📒 Files selected for processing (1)
  • src/moov/trak/mdia/minf/stbl/stsd/vp9/vpcc.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@bradh bradh left a comment

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.

LGTM

@bradh bradh merged commit 0ad4b7e into kixelated:main Jul 6, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Jul 6, 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