Skip to content

fix(playback): honor source color range fallback - #97

Merged
Quick104 merged 2 commits into
mainfrom
codex/native-color-range
Jul 22, 2026
Merged

Quick104 merged 2 commits into
mainfrom
codex/native-color-range

Conversation

@Quick104

@Quick104 Quick104 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • decode the additive color_range video-track field from the native server API
  • pass an unambiguous range hint into PlayerCore
  • map FFmpeg tv to limited range and pc to full range only when local libav stream/frame metadata is unspecified
  • skip the fallback for multi-video-track files because the current plan does not identify a selected video stream

Why

Silo preserves the source bytes, but files whose local decoder metadata is unspecified can still need the server-probed FFmpeg range to configure the output pixel format correctly. Explicit local FFmpeg signaling remains authoritative.

Testing

  • xcodebuild test -project Silo.xcodeproj -scheme Silo -destination "platform=iOS Simulator,name=iPhone 17 Pro" -derivedDataPath /Volumes/NVMe/Xcode/DerivedData/native-color-range-apple CODE_SIGNING_ALLOWED=NO -only-testing:SiloTests/SoftwareVideoOutputFormatTests -only-testing:SiloTests/DetailVersionSelectionTests (30 tests passed)
  • autoreview clean

Coordination

Depends on Silo-Server/silo-server#447.

Part of Silo-Server/silo-server#446

AI use

Implemented with OpenAI Codex. The generated patch was reviewed, focused tests were run, and review findings were addressed before publication.

Summary by CodeRabbit

  • Bug Fixes
    • Improved video color-range detection during playback by honoring explicit color-range metadata when available and using a safer fallback when it isn’t.
    • Refined full-range handling and pixel format selection for both compressed and software-decoded video paths (standard and high bit depth).
    • Ensured codec-provided color range continues to take priority over fallback metadata.
  • Tests
    • Added/expanded test coverage for metadata precedence, full-range selection, and unambiguous-vs-ambiguous multi-track behavior.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2203168d-a5bd-42c0-98ce-21865dd7131a

📥 Commits

Reviewing files that changed from the base of the PR and between a756d83 and b68f538.

📒 Files selected for processing (5)
  • iosApp/Tests/DetailVersionSelectionTests.swift
  • iosApp/Tests/SoftwareVideoOutputFormatTests.swift
  • iosApp/iosApp/Screens/Player/CoreMedia/VideoColorMetadata.swift
  • iosApp/iosApp/Screens/Player/PlaybackEngine.swift
  • iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift
🚧 Files skipped from review as they are similar to previous changes (4)
  • iosApp/iosApp/Screens/Player/CoreMedia/VideoColorMetadata.swift
  • iosApp/iosApp/Screens/Player/PlaybackEngine.swift
  • iosApp/Tests/SoftwareVideoOutputFormatTests.swift
  • iosApp/Tests/DetailVersionSelectionTests.swift

📝 Walkthrough

Walkthrough

Changes

The playback pipeline now decodes video color_range, propagates unambiguous values through playback planning, and uses codec metadata or normalized hints to determine full-range handling across video format and software pixel-buffer paths.

Video color-range playback

Layer / File(s) Summary
Color-range metadata propagation
iosApp/iosApp/Networking/Models.swift, iosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swift, iosApp/iosApp/Screens/Player/ApplePlaybackRoutePlanner.swift, iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift, iosApp/iosApp/Screens/Player/PlaybackEngine.swift
VideoTrack and PlaybackSourceMetadata carry optional color-range values; route planning supplies unambiguous metadata, and direct or remux delivery forwards it to PlayerCore.
Color-range resolution in CoreMedia
iosApp/iosApp/Screens/Player/CoreMedia/VideoColorMetadata.swift, iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift
Color-range hints are normalized, codec values take precedence when known, and the resolved range controls compressed, high-bit-depth, and planar YUV pixel-buffer formats.
Color-range decoding and resolution tests
iosApp/Tests/DetailVersionSelectionTests.swift, iosApp/Tests/SoftwareVideoOutputFormatTests.swift, iosApp/Tests/HDRDisplayCriteriaPolicyTests.swift
Tests cover metadata decoding, unambiguous and ambiguous track selection, local-versus-server precedence, fallback values, and updated VideoTrack construction.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RoutePlanner
  participant PlaybackEngine
  participant PlayerCore
  participant VideoColorMetadata
  participant CodecParameters
  RoutePlanner->>PlaybackEngine: provide PlaybackSourceMetadata.colorRange
  PlaybackEngine->>PlayerCore: load with colorRangeHint
  PlayerCore->>VideoColorMetadata: normalize hint
  PlayerCore->>CodecParameters: read codec color range
  PlayerCore->>VideoColorMetadata: resolve full-range status
  VideoColorMetadata-->>PlayerCore: return range classification
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: using source color-range fallback in playback.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/native-color-range

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a756d83606

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@iosApp/iosApp/Screens/Player/CoreMedia/VideoColorMetadata.swift`:
- Around line 31-36: Update VideoColorMetadata.isFullRange so fallbackName is
consulted only when range equals AVCOL_RANGE_UNSPECIFIED; preserve the local
color-range result for every other value, including unmapped ranges, and
continue returning whether the resolved name is "pc".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a6bc783-84d6-405a-96df-e5baaa29f3e7

📥 Commits

Reviewing files that changed from the base of the PR and between 7d9e7b4 and a756d83.

📒 Files selected for processing (9)
  • iosApp/Tests/DetailVersionSelectionTests.swift
  • iosApp/Tests/HDRDisplayCriteriaPolicyTests.swift
  • iosApp/Tests/SoftwareVideoOutputFormatTests.swift
  • iosApp/iosApp/Networking/Models.swift
  • iosApp/iosApp/Screens/Player/ApplePlaybackRoutePlanner.swift
  • iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift
  • iosApp/iosApp/Screens/Player/CoreMedia/VideoColorMetadata.swift
  • iosApp/iosApp/Screens/Player/PlaybackEngine.swift
  • iosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swift

@Quick104
Quick104 merged commit a66312e into main Jul 22, 2026
1 check passed
@Quick104
Quick104 deleted the codex/native-color-range branch July 22, 2026 13:45
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.

1 participant