Skip to content

fix(tonemap): preflight VAAPI software decode with the upload playback uses - #2732

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
blurbery:fix/tonemap-vaapi-preflight-upload
Oct 21, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
blurbery:fix/tonemap-vaapi-preflight-upload

Conversation

@blurbery

@blurbery blurbery commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2269
Related issue: #1171
Validation tasks: changes #1174 C3 (not run yet)

On a VAAPI executor that decodes in software, the tone-map source preflight tests a different conversion from the one playback runs. It uploads HDR frames to the GPU as 8-bit nv12, while playback uploads them as 10-bit p010le. The preflight is there to prove the frozen recipe works before the first manifest is published, so depending on the driver it could reject a file playback would convert correctly, or pass one without testing the 10-bit path.

Approach

The upload is now built in one place, tonemap.SoftwareUploadFilter: nv12 for SDR sources and p010le for HDR ones, as playback already did. The preflight's tonemap_vaapi path uses it, intelOpenCLPreflightUpload (added in #2734 for QSV and Intel VAAPI on OpenCL, which already uploaded p010le) now calls it instead of repeating the choice, and softwareToneMapUploadFilter in playback uses it too, so preflight and playback can't drift apart again.

Validation

  • go test ./internal/tonemap/: passes. The VAAPI preflight test now checks PQ, HLG and SDR uploads; the PQ and HLG cases fail on main.
  • go test ./internal/playback/ -run 'Upload|SoftwareDecode|SoftwareVideoDecode|ToneMap': passes apart from TestPrepareFileDoesNotDropHardwareToneMapGraphOnSoftwareRetry, which fails the same way on main on macOS (its fake ffmpeg script never writes its invocation log there). Left to CI on Linux.
  • go vet on both packages: clean. Lint: left to CI.
  • Not run on VAAPI hardware.

Evidence

The start of the preflight's video filter for a PQ source on a VAAPI executor with software decode, on main (365e3d4) and this branch (9c76b58):

main          format=nv12,hwupload,setparams=...,tonemap_vaapi=...
this branch   format=p010le,hwupload,setparams=...,tonemap_vaapi=...

Nothing else in the command changes, and the runtime graph was already p010le. A viewer only sees a difference when the preflight's answer changes for a file, which I haven't reproduced on hardware.

Risks

Since #2734, Intel VAAPI tone maps HDR on OpenCL, whose preflight already uploaded p010le. This change covers the remaining tonemap_vaapi path, mostly AMD/Mesa VAAPI, where 10-bit uploads haven't been checked on hardware either. A driver that can't take a p010le upload now fails the preflight instead of passing it, which is the point: playback would have failed on the same upload.

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 (Claude desktop app)
  • Tool(s): Claude Code, Claude Code subagents for investigation, GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: AI-assisted with Claude Opus. I directed the task and designed the work.
  • Adversarial review: a separate Claude Code subagent reviewed the branch through git. It checked that SoftwareUploadFilter matches the old runtime choice for every source kind, that the QSV preflight order is unchanged, that every VAAPI and QSV software-decode graph in playback goes through the shared helper, and that the new subtests fail on main. It found no correctness problem.

Note

Fix software-decoded VAAPI preflight to use 10-bit upload format for HDR

Adds tonemap.SoftwareUploadFilter, a shared helper that picks the 8-bit upload format for SDR sources and the 10-bit format for non-SDR sources, then builds the hardware-upload filter. Previously the software-decoded VAAPI preflight graph always used the 8-bit format; playback and the Intel OpenCL preflight now share the same helper instead of local copies.

  • Adds the shared helper in tonemap.go and uses it in preflight.go and transcode.go
  • Expands preflight_test.go with subtests for PQ, HLG, and SDR BT.709 sources checking the upload format sits right before the VAAPI filter
  • Behavioral Change: software-decoded VAAPI preflight now uses the 10-bit upload format for HDR sources instead of the 8-bit format; playback and Intel OpenCL format selection is unchanged

Macroscope summarized 53957b2.

…k uses

On a VAAPI executor that decodes in software, the tone-map source
preflight uploaded HDR frames as 8-bit nv12, while playback uploads them
as 10-bit p010le, so it checked a conversion playback never runs. The
upload is now chosen in one place, tonemap.SoftwareUploadFilter, which
the preflight and the runtime graph both use: nv12 for SDR sources and
p010le for HDR ones.
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 19, 2026
@silo-kody

silo-kody Bot commented Oct 19, 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 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab65dac6-123b-41ea-ac6a-ae8de2c36ea0
📥 Commits

Reviewing files that changed from the base of the PR and between 9c76b58 and 53957b2.

📒 Files selected for processing: 2
  • internal/playback/transcode.go
  • internal/tonemap/preflight.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Software-decoded QSV and VAAPI tone-map paths now share source-kind-based upload selection. SDR sources use nv12; other source kinds use p010le. Preflight tests cover SDR, PQ, and HLG.

Changes: Software-decoded tone-map uploads

Layer / File(s) Summary
Shared upload format and preflight
internal/tonemap/tonemap.go, internal/tonemap/preflight.go, internal/tonemap/preflight_test.go
SoftwareUploadFilter selects nv12 for SDR and p010le for other source kinds. Preflight uses the shared selector. VAAPI tests check SDR, PQ, and HLG upload formats.
Playback upload integration
internal/playback/transcode.go
Playback delegates software-decoded QSV and VAAPI upload-filter selection to SoftwareUploadFilter.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to 53957

The shared upload-format behavior is aligned across preflight and playback. Hardware validation remains follow-up work but does not establish a merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the main change: aligning VAAPI software-decode preflight uploads with the upload format used by playback.
Description check Passed The description directly explains the VAAPI upload-format mismatch, the shared helper, affected paths, validation, and risks.
Linked Issues check Passed Issue [#2269] requires VAAPI software-decode preflight to use nv12 for SDR sources and p010le for other source kinds. SoftwareUploadFilter implements this rule. VAAPI preflight and playback use …
Out of Scope Changes check Passed The changes remain within [#2269]. The shared helper removes duplicated format selection, updates QSV preflight without changing its behavior, updates playback to prevent drift, and adds focused regre…
Docstring Coverage Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files.
Full details: Linked Issues check

Explanation

Issue [#2269] requires VAAPI software-decode preflight to use nv12 for SDR sources and p010le for other source kinds. SoftwareUploadFilter implements this rule. VAAPI preflight and playback use the helper. The updated test covers PQ, HLG, and SDR BT.709 uploads before tonemap_vaapi. No coding requirement remains unmet.

Full details: Out of Scope Changes check

Explanation

The changes remain within [#2269]. The shared helper removes duplicated format selection, updates QSV preflight without changing its behavior, updates playback to prevent drift, and adds focused regression coverage. These changes directly support consistent preflight and playback uploads. No unrelated change is demonstrated.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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: P2 Limited scope, workaround exists, or polish labels Oct 19, 2026
…reflight-upload

# Conflicts:
#	internal/tonemap/preflight.go
@Quick104

Copy link
Copy Markdown
Contributor

Review summary (reviewed 53957b2)

I found no defects. The VAAPI software-decode preflight now uploads HDR frames as p010le and SDR frames as nv12, matching playback, and both preflight paths and playback build the upload from one helper, tonemap.SoftwareUploadFilter. Playback and the Intel OpenCL preflight produce the same strings as before.

What I checked

  • The upload choice for each source kind (PQ, both HLG kinds, SDR BT.709 and BT.2020, Dolby Vision base layers) matches between preflight and playback. The preflight request takes its source kind and software-decode flag from the same options playback uses.
  • go test ./internal/tonemap/ and the focused playback tests pass on the head.
  • The PQ and HLG subtests of TestSourceConversionPreflightMirrorsSoftwareDecodeForVAAPI fail on the base because the base uploads nv12. The SDR subtest passes on both, as expected.
  • Playback still adds scaling and subtitle stages that the preflight leaves out. That predates this PR, which aligns only the upload, as its description says.
  • A cross-provider review (Codex, gpt-6.1-sol, one round) found nothing. On an AMD/Mesa machine it confirmed that an 8-bit HLG frame converted to p010le uploads and downloads byte-for-byte. It could not run tonemap_vaapi itself because that driver reports no HDR support, so the full tone-map path on VAAPI hardware is still unverified.

Validated features: #1174 C3 (VAAPI HDR-to-SDR on the hardware path) is not run yet, so this PR doesn't change a passed case. When C3 is run on AMD/Mesa, it covers this change.

User manual: unaffected. The change is internal to the preflight.

Apple/Android: no client-visible change; jellycompat is unaffected.

Remaining for maintainers: nothing blocking. The path is still untested on real VAAPI tone-mapping hardware, and the description says so.

Fit: 9/10 · Readiness: 9/10 — ready

  • Fit: this is a correctness fix that makes the preflight test the conversion playback actually runs, which is what the preflight exists for. It also removes a duplicate copy of the upload choice and adds no settings or API surface.
  • Readiness: the change is small and the regression test fails on the base. The only gap is the hardware run, which C3 will cover.

@Quick104
Quick104 merged commit 8a8b32f into Silo-Server:main Oct 21, 2026
16 checks passed
@blurbery
blurbery deleted the fix/tonemap-vaapi-preflight-upload branch November 6, 2026 00:01
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: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] VAAPI tone-map preflight tests an 8-bit upload that playback never uses

2 participants