Skip to content

fix(playback): composite QSV HDR bitmap subtitles on OpenCL - #2449

Merged
Quick104 merged 6 commits into
Silo-Server:mainfrom
neurekadev:fix/qsv-tonemap-bitmap-subtitles-opencl
Oct 14, 2026
Merged

Quick104 merged 6 commits into
Silo-Server:mainfrom
neurekadev:fix/qsv-tonemap-bitmap-subtitles-opencl

Conversation

@neurekadev

@neurekadev neurekadev commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Note

Stacked on #2448, which is now merged. This PR's own changes are 8aeccec6b and the probe gate commit 26089503a.

Problem

Closes #2447
Related issue: #2446
Validation tasks: unblocks #1173 C3

QSV tone-mapped transcodes that burn in bitmap subtitles (PGS, VOBSUB, DVB) corrupt frames on Intel Arrow Lake: blocks of the picture shift, and at shot cuts a frame shows the next shot. overlay_vaapi reads the tonemap_opencl output the same unsynchronised way the downscale did in #2446. This change composites and scales on the OpenCL device instead, so the encoder is the only thing that reads the tone-mapped frame.

This builds on #2448, which it needs for the tone-map graph split.

Approach

For HDR sources, the QSV bitmap burn-in graph now keeps the tone-mapped frame on OpenCL. The subtitle is converted to YUVA with the BT.709 matrix, uploaded to the same OpenCL device, and composited with overlay_opencl, and the result is scaled with scale_opencl. It then goes back to VAAPI and on to the encoder through the passthrough interop. The subtitle is still composited at the source resolution before the scale, so its placement does not change. SDR base layers never reach OpenCL and keep overlay_vaapi.

scale_opencl, overlay_opencl's eof_action and YUVA overlays, and the shared OpenCL device for hwupload and hwmap come from Jellyfin FFmpeg. The QSV tone-map path already requires it, because stock tonemap_opencl has no bt2390 curve, and the image bundles jellyfin-ffmpeg 8.1.3. Moving the composite to the CPU was rejected in #465 for throughput, and this graph is faster than the current one.

The QSV probe's listing gate now also requires overlay_opencl and scale_opencl, so an FFmpeg build without them advertises only software tone mapping instead of failing HDR bitmap burn-in at transcode start.

Validation

  • Go build, gofmt, go vet, make lint-changed, make verify-playback-fixtures, make verify-local-paths: pass.
  • make test-go: every package passes except internal/librarymonitor (its remount test needs mount, which the sandbox denies) and internal/routeinventory (a Go export-data version mismatch in the local build cache). Both fail the same way on main.
  • TestQSVListingGateRequiresOpenCLBitmapSubtitleFilters checks that the QSV listing gate rejects a build missing either OpenCL bitmap filter.
  • The new test pins the exact graph and checks every HDR kind, with and without scaling and with software decode: composite and scale on OpenCL, in that order, then only the passthrough interop. It fails against the current graph.
  • Hardware, Intel Arrow Lake (Arc 130T/140T iGPU), iHD 26.3.5, jellyfin-ffmpeg 8.1.3, inside Silo's image, on a 4K HDR10 title with 1920×1080 PGS tracks. Each graph was compared frame by frame against a software tone map of the same frames:
Graph Span Frames below SSIM 0.95
Current, real PGS track 8 s, 192 frames 21
This branch, real PGS track 8 s, 192 frames 0
Current, transparent overlay (3 runs) 6 s, 148 frames 3, 2, 2
This branch, transparent overlay (3 runs) 6 s, 148 frames 0, 0, 0
This branch, software decode, real PGS track 8 s, 192 frames 0
  • Subtitles appeared and cleared on the same frames with both graphs, at the same position. Without a target resolution the graph produced 4K output with the subtitle composited.
  • Throughput over 20 s of the same title at 1080p, second run of each so the source was cached: 3.95× realtime with the current graph, 5.93× with this branch. The host was serving other streams at the time.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2449/

Surface and build: transcoded H.264 from Silo's QSV graph on the author's Intel Arrow Lake host, build-1382 image with this branch's graph.

Risks

  • Coloured PGS subtitles may look slightly different at the edges: the subtitle is converted to 4:2:0 YUVA on the CPU, where overlay_vaapi let the driver convert RGB.
  • Bitmap burn-in for HDR sources on QSV now depends on scale_opencl and on overlay_opencl options that only Jellyfin FFmpeg has. The probe checks that both filters exist but not which options overlay_opencl accepts, so a custom FFmpeg with an older overlay_opencl would still fail at transcode start. That combination already needs a Jellyfin FFmpeg build for tonemap_opencl.
  • A 1920×1080 PGS track on a 4K source is still composited unscaled, so it lands in the upper-left quarter of the frame. That behaviour predates this change and is unchanged by it.

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, GitHub CLI, jellyfin-ffmpeg 8.1.3, PoCL

  • Model(s): claude-opus-5-5

  • Involvement: Fully AI-generated at the author's direction; the author has not yet reviewed the diff. The hardware runs were made on the author's server with their permission.

  • Adversarial review: A separate Claude Code agent (claude-opus-5-5) read the change against Jellyfin FFmpeg's overlay_opencl, scale_opencl, hwmap and framesync sources and checked every input the bitmap path receives. It found no defect. Its notes led to the throughput measurement, the comment on the Jellyfin FFmpeg dependency, corrected comment wording, and the exact-graph and ordering tests.

  • Maintainer review: Claude Code (claude-opus-5-5) in T3 Code reviewed both PRs with a GPT-6.1-Sol cross-check, merged main into both branches, and wrote the probe gate commit.

🤖 Generated with Claude Code

Note

Fix QSV HDR bitmap subtitle compositing to use OpenCL overlay

QSV HDR bitmap-subtitle transcodes previously applied overlay_vaapi to an OpenCL tone-mapped surface, which does not composite correctly. HDR sources now build a dedicated OpenCL graph in qsvOpenCLBitmapSubtitleGraph (transcode.go): tone-map to OpenCL, convert and upload the subtitle with BT.709 limited-range metadata, overlay, optionally scale, then map back to VAAPI and strip HDR metadata. SDR sources keep the existing overlay_vaapi graph.

  • Refactors QSVFilter in tonemap.go into QSVOpenCLToneMapFilter and QSVOpenCLReturnFilter helpers; the full HDR graph sequence is unchanged.
  • QSV hardware probing in probe.go now requires overlay_opencl and scale_opencl in the FFmpeg inventory.
  • Risk: QSV devices whose FFmpeg lacks overlay_opencl or scale_opencl will no longer be listed as QSV-capable.

Macroscope summarized 5d0fb2b.

neurekadev and others added 2 commits October 14, 2026 00:16
QSV tone-mapped transcodes on Intel Arrow Lake came out with shifted
blocks during motion. The corruption appears when scale_vaapi resizes
the tonemap_opencl output, which it releases back to the tone mapper's
pool without waiting for the GPU. Resize before tone mapping and hand
the OpenCL output straight to the encoder, which holds each surface
until the encode completes.

Closes Silo-Server#2446

Co-Authored-By: Claude Opus 5.5 <[email protected]>
QSV tone-mapped transcodes that burned in bitmap subtitles corrupted
frames on Intel Arrow Lake: overlay_vaapi read the tonemap_opencl output
the same way the downscale did in Silo-Server#2446. Overlay and scale on the OpenCL
device with overlay_opencl and scale_opencl, then hand the frame straight
to the encoder. The subtitle still goes on at the source resolution before
the scale, so its placement does not change.

Closes Silo-Server#2447

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 14, 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 14, 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: a765766a-9d45-4432-b04a-ba7db356b645
📥 Commits

Reviewing files that changed from the base of the PR and between 2608950 and 5d0fb2b.

📒 Files selected for processing: 3
  • internal/playback/transcode.go
  • internal/playback/transcode_args_test.go
  • internal/tonemap/tonemap.go

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

📝 Walkthrough

QSV tone-mapped playback now composites non-SDR bitmap subtitles and scales frames on OpenCL before QSV interop. SDR bitmap subtitles retain the VAAPI overlay path. QSV filter probing now checks for the OpenCL overlay and scaling filters.

Changes: QSV tone mapping

Layer / File(s) Summary
QSV filter scaling and return paths
internal/tonemap/tonemap.go, internal/tonemap/tonemap_test.go, internal/tonemap/probe.go
QSVFilter combines separate OpenCL tone-mapping and VAAPI return stages. An optional height controls resizing. Tests cover resize placement for HDR and SDR input. The QSV smoke graph passes a height of 0.
QSV bitmap-subtitle graph
internal/playback/transcode.go, internal/playback/transcode_args_test.go, internal/tonemap/probe.go, internal/tonemap/probe_test.go, internal/tonemap/tonemap_test.go
Non-SDR QSV sources use OpenCL tone mapping, subtitle overlay, and optional scaling before QSV interop. SDR sources retain VAAPI overlay. Tests cover graph ordering and source kinds. QSV probing requires overlay_opencl and scale_opencl.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to 5d0fb

No actionable issue is established for this change; it is mergeable after the stated prerequisite and normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Linked Issues check Passed The changes satisfy #2447. HDR QSV bitmap-subtitle paths keep tone-mapped frames on OpenCL, convert subtitles to YUVA, use overlay_opencl, scale with scale_opencl, and return through VAAPI/QSV int…
Out of Scope Changes check Passed The changes remain within #2447. The filter split, caller updates, probe requirements, fixtures, and regression tests support the required HDR bitmap-subtitle graph and its fallback behavior. No unrel…
Docstring Coverage Passed Docstring coverage is 91.30% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 7 files.
Title check Passed The title clearly and concisely describes the main change: moving QSV HDR bitmap subtitle compositing to OpenCL.
Description check Passed The description directly explains the frame-corruption problem, OpenCL compositing approach, probe-gate changes, validation results, and known risks.
✨ 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 evidence-required Needs before-and-after evidence before the Evidence check passes 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 14, 2026
@silo-triage

silo-triage Bot commented Oct 14, 2026

Copy link
Copy Markdown

The measurements report fewer corrupt frames, but there are no captures showing the visible fix. Please add matching before-and-after frames and a short comparison recording covering a shot transition and subtitle appearance/clearing, with each build or commit identified. Use public-domain test media or link a private page on evidence.siloserver.org rather than attaching private media here.

@neurekadev

Copy link
Copy Markdown
Contributor Author

Published at https://evidence.siloserver.org/r/silo-server/pr-2449/ and linked under Evidence: before-and-after frames 126 (shifted blocks under a subtitle) and 35 (shot cut), a software reference for frame 35, and recordings of source frames 25–95 covering the cut at frame 35 and the subtitle appearing at frame 38 and clearing after frame 78, including a labelled half-speed side-by-side. Before is main 6144c45, after is this branch 8aeccec, both run in the build-1382 image.

Quick104 and others added 3 commits October 14, 2026 12:59
Resolve the tonemap_test.go conflict with Silo-Server#2444 by keeping both tests and
passing QSVFilter's new height argument in the source-peak test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in Silo-Server#2448's branch merged with main, which resolves the
tonemap_test.go conflict with Silo-Server#2444.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…V tone mapping

HDR bitmap subtitle burn-in on QSV now composites with overlay_opencl and
scales with scale_opencl. The QSV listing gate only checked tonemap_opencl,
hwmap and scale_vaapi, so an FFmpeg build without the OpenCL bitmap filters
advertised hardware tone mapping and then failed those transcodes at start.
Check for both filters so such a build falls back to software tone mapping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of 8aeccec, the second commit (the first is covered on #2448). Two findings: one in this commit's graph, and the main conflict it inherits from #2448, which I'm resolving with a merge of #2448's merged branch.

Comment thread internal/playback/transcode.go Resolved
@silo-kody

silo-kody Bot commented Oct 14, 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 ❌

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed 8aeccec; current head 2608950.

Addressed

  • Probe gate (thread resolved): HDR bitmap burn-in on QSV needs overlay_opencl and scale_opencl, but the QSV listing gate didn't check for them. 2608950 adds both to hardwareProbeAvailable, with a regression test and updated fixtures, so a build without them falls back to software tone mapping.
  • Conflict with main: 88decaf merges fix(playback): scale QSV tone-map frames before OpenCL, not after #2448's merged branch.
  • go test passes for internal/tonemap, internal/playback, internal/jellycompat and internal/api/handlers.

Checked, no change needed

  • The subtitle hwupload=derive_device=opencl and the video hwmap=derive_device=opencl resolve to the same OpenCL context. Silo initializes opencl=ocl@va, and Jellyfin FFmpeg reuses derived devices.
  • overlay_opencl allocates its output frames, including after the subtitle stream ends with eof_action=pass. The reverse map therefore never receives a borrowed input buffer.
  • The composite runs before the scale, so subtitle placement matches overlay_vaapi.

Remaining

Validated features: no passed case reaches this code. The PR body now reads Validation tasks: unblocks #1173 C3.

User manual: unaffected. The playback page says hardware tone mapping is used once Silo has tested it, and the stricter gate keeps that true.

Apple/Android: no client change.

Cross-provider round: GPT-6.1-Sol (xhigh), one round over both PRs. It found nothing and raised the unchecked filters as a disclosed limitation, which this review then fixed.

Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green)

@macroscopeapp

macroscopeapp Bot commented Oct 14, 2026

Copy link
Copy Markdown

The #1159 C4 comment reports server-burned PGS, but does not identify an HDR/QSV run; this PR rewrites that QSV HDR burn-in graph. Please explain why this validated output path changes and revalidate C4 against QSV/HDR after merge. The unblocks #1173 C3 entry is supported by #2447.

Suggested fix: No diff — update the line to:

Validation tasks: changes #1159 C4; unblocks #1173 C3

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

Posted via Macroscope — v1 validation impact

main now carries Silo-Server#2448 as squash commit 009b47d, whose tree matches
f3349b4 already on this branch, so this branch's tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 merged commit bbef279 into Silo-Server:main Oct 14, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] QSV tone-mapped transcodes with burned-in bitmap subtitles corrupt frames

2 participants