Skip to content

fix(tonemap): transcode HLG files tagged with BT.709 primaries - #2531

Merged
Quick104 merged 1 commit into
mainfrom
fix/issue-2528-hlg-bt709
Oct 15, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/issue-2528-hlg-bt709

Conversation

@Quick104

@Quick104 Quick104 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2528
Related issue: N/A
Validation tasks: none

The server could not transcode HLG files tagged with BT.709 primaries, a format some cameras record. Any client that needed the server to convert one, such as a browser on an SDR display, got "Failed to start the playback transport." This change classifies those files as BT.709-gamut HLG, so the tone-mapped transcode starts and converts them with their own primaries.

tonemap.ResolveSource mapped every HLG source to SourceHLG, the BT.2020 kind, without reading the primaries. The file's tags then contradicted that kind, so the start ran the source preflight, which rejected the BT.709 frames it decoded (decoded frame metadata does not match hlg fallback) and ended the start with transcode_start_failed.

Approach

The HLG branch of ResolveSource now chooses the existing SourceHLGBT709 kind when both the primaries and the matrix are tagged BT.709. Dolby Vision compatibility id 3 and sourceKindFromColorMetadata already use this kind for BT.709-gamut HLG, and every executor's capability probe already covers it. Native playback, jellycompat transcodes, HDR-to-SDR downloads and seek-preview sheets all classify sources through ResolveSource, so all four pick up the change.

The matrix has to match too because SourceHLGBT709 declares a BT.709 matrix to the converter, while its metadata check, and the preflight's frame check, also accept a BT.2020 matrix. Any other mix (an untagged, BT.2020 or BT.601 matrix) keeps the BT.2020 kind and its preflight, which rejects the file as it does today, rather than decoding it with the wrong matrix. Every HLG file that is not tagged BT.709 for both resolves exactly as before.

One sentence in docs/architecture/playback-protocol-v3.md records the rule. There is no API contract change, so the Apple and Android apps need nothing.

Validation

  • Reproduced on a dev deployment built from main with 20-second 1080p HLG clips (AV1 10-bit and VP9 Profile 2, BT.709 primaries and matrix). A start that needed a transcode failed for both with transcode_start_failed and the log line from the issue. The same clips with BT.2020 primaries played.
  • After the fix, on the same deployment and media, all four clips start as tone-mapped HLS transcodes. The BT.709 clips declare BT.709 primaries and matrix to the tone mapper; the BT.2020 clips still declare BT.2020. In the web app, each clip played past four seconds with no console errors.
  • The new resolver test fails on main only for the fully BT.709-tagged case; its BT.2020, untagged, unknown and mixed-tag cases resolve the same as on main. The mixed tags are covered by this test only, not by a live file.
  • Go gate on Linux: gofmt, go vet, make lint-changed, make test-go and make verify-local-paths pass. No web files changed.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2528/

Risks

  • Seek-preview sheets generated for these files since fix(trickplay): correct HDR previews, decode on NVIDIA, and repair missed cells #2412 used the BT.2020 conversion and are oversaturated. New sheets are correct; this change does not requeue existing ones.
  • An executor whose capability probe passed BT.2020 HLG but failed BT.709 HLG now refuses these files at planning with hdr_transcode_unsupported, where before they failed at start.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code with review subagents; Playwright (headless Chromium) for the web check; Codex for the background review
  • Model(s): claude-opus-5-5 (implementation and review); Claude Sonnet through Claude Code's sonnet alias (two review subagents, exact version not reported); gpt-6.1-sol (background review)
  • Involvement: Fully AI-generated. No human has verified it yet.
  • Adversarial review: The plan round was skipped because the fix is a few lines where the bug starts and adds nothing. A multi-agent code review of the diff found that the first version, which keyed on the primaries alone, let HLG files with BT.709 primaries and a BT.2020 matrix skip the preflight and be decoded with the wrong matrix, and that an untagged matrix could reach the same result through the preflight. Requiring a BT.709 matrix as well closes both, with test cases for each mix. The review also replaced a test check that only repeated the metadata check. A background adversarial review by gpt-6.1-sol of 341c412 compared the resolver's output with main across the color-tag combinations and checked every caller, node capability and cache identity path; it found nothing to report.

🤖 Generated with Claude Code

ResolveSource classified every HLG source as SourceHLG, the BT.2020
kind. An HLG file tagged with BT.709 primaries then failed the metadata
check, the start ran the source preflight, and the preflight rejected
the decoded BT.709 frames, so the transcode never started.

Choose SourceHLGBT709 when both the primaries and the matrix are tagged
BT.709. That kind declares a BT.709 matrix to the converter, and its
preflight also accepts frames with a BT.2020 matrix, so any other mix
keeps the BT.2020 kind and the preflight that rejects it, as before.

Closes #2528

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

silo-kody Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 15, 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 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20d9872d-c418-4381-be1c-f5eb3eb33bb6
📥 Commits

Reviewing files that changed from the base of the PR and between c1c4b92 and 341c412.

📒 Files selected for processing: 3
  • docs/architecture/playback-protocol-v3.md
  • internal/tonemap/tonemap.go
  • internal/tonemap/tonemap_test.go
  • 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.

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P1 Core-path bug; painful workaround — next after P0 labels Oct 15, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 15, 2026

Copy link
Copy Markdown

The four listed C3 cases in #1172–#1175 are all Not run, not failed or blocked, so this PR cannot report them as unblocked. No recorded validation result is affected.

Suggested correction:
Validation tasks: none

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104
Quick104 merged commit 685344a into main Oct 15, 2026
16 checks passed
@Quick104
Quick104 deleted the fix/issue-2528-hlg-bt709 branch October 15, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P1 Core-path bug; painful workaround — next after P0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] HLG files with BT.709 primaries can't be transcoded: the tone-map preflight treats them as BT.2020

1 participant