Repository navigation
fix(playback): scale QSV tone-map frames before OpenCL, not after - #2448
Conversation
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]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Please publish the before-and-after captures of the same affected frame to the private Evidence page and add its link under Evidence, identifying the build or commit for each capture. The comparison table reports fewer corrupted frames, but the PR currently has no visual artifact showing the playback change. |
|
Published the before-and-after captures of frame 95 (full frame and an enlarged crop) at https://evidence.siloserver.org/r/silo-server/pr-2448/ and linked it under Evidence. Each capture names its commit: main 6144c45 before, this branch f0156f3 after, both run in the build-1382 image on the Arrow Lake host. |
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]>
Quick104
left a comment
There was a problem hiding this comment.
Review of f0156f3. The graph change itself checks out; one merge blocker.
Medium: the branch conflicts with main. #2444 merged a new test, TestSoftwareAndQSVToneMapsPinTheSourcePeak, into internal/tonemap/tonemap_test.go at the same spot as TestQSVFilterScalesHDRBeforeOpenCL, and it calls QSVFilter(kind) with the old one-argument signature. GitHub can't merge the PR until that's resolved, and a plain textual resolution wouldn't compile. The fix keeps both tests and passes 0 as the height in #2444's test. I'm pushing a merge of main that does this, so there's no need to change it yourself. #2449 gets the same merge on top.
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]>
Review summaryReviewed f0156f3; current head f3349b4 adds only a merge of Addressed
Checked, no change needed
Remaining
Validated features: no passed case reaches this code. The PR body now reads User manual: unaffected. The playback page doesn't describe the filter graph. Apple/Android: no client change. Server-side transcode graph only; jellycompat uses the same graph. Cross-provider round: GPT-6.1-Sol (xhigh), one round over both PRs. It found nothing, and its FFmpeg source checks confirmed the passthrough and the reverse-map behaviour. Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green)
|
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]>
Note
Stacked PR 1 of 2. Merge this before #2449 (PR 2 of 2).
#2449 is built on this branch's commit (
f0156f3ea) and reuses the tone-map graph split it introduces. Changing this commit means rebuilding #2449. This branch now also carries a merge ofmainthat resolves a test conflict with #2444; #2449 includes it.Problem
Closes #2446
Related issue: #2447
Validation tasks: unblocks #1173 C3
QSV tone-mapped transcodes on Intel Arrow Lake come out corrupted during motion: blocks of the picture shift against their neighbours, often in a staircase. The cause is the
scale_vaapithat downscales thetonemap_opencloutput, a VAAPI read of an OpenCL surface that this hardware does not order correctly. This change resizes before tone mapping instead, so nothing between the tone mapper and the encoder reads the surface.On the reporting deployment, Silo's own command corrupted 23 and 28 of the first 148 frames of a Dolby Vision 8.1 episode on two runs, and 27 of the first 722. With this change, no frame was corrupted in four 6-second runs or over the 30 seconds.
Approach
QSVFilternow takes the output height. HDR kinds resize in thescale_vaapithat already ran beforehwmapto OpenCL. After the reverse map, the transcode graph ends withQSVInteropFilter(), whosescale_vaapi=format=nv12is a passthrough, so the encoder is the only reader of the tone-mapped surface and holds it until the encode completes. SDR base layers do not use OpenCL and keep resizing after colour conversion, as before. This is also the order Jellyfin's Intel VAAPI graph uses, and the tone mapper now processes a 1080p frame instead of a 4K one.Unchanged:
overlay_vaapiafter the tone mapper and is affected the same way. It needs a different fix and is tracked in [bug] QSV tone-mapped transcodes with burned-in bitmap subtitles corrupt frames #2447.FFmpeg creates the OpenCL context with
CL_CONTEXT_INTEROP_USER_SYNC=CL_FALSE, so the driver should order these accesses itself; this is a graph-level workaround for that not happening.scale_vaapipasses frames through untouched when the size, format and colour options don't change, which is the case after the reverse map; that behaviour is in FFmpeg 6.1 and later, and the image bundles 8.1.3.Validation
gofmt,go vet,make lint-changed,make verify-playback-fixtures,make verify-local-paths: pass.make test-go: every package passes exceptinternal/librarymonitor(its remount test needsmount, which the sandbox denies) andinternal/routeinventory(a Go export-data version mismatch in the local build cache). Both fail the same way onmain.tonemap_opencl, with hardware and software decode, and end in the passthrough interop with nothing else after the tone mapper. The playback test fails with the old order.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2448/
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
libx264encode of the 4K-tone-mapped frames (0.997).hdr_to_sdr_tonemaprecipe version stays at 1, as with earlier tone-map graph changes. Prepared downloads already transcoded through the old graph stay cached, and a node on an older build keeps producing the old graph until it is upgraded.Checklist
AI Disclosure
scale_vaapipassthrough andhwmapcode, and checked every caller. It found no defect. Its suggestions led to the exact passthrough tail and its test, the note onQSVInteropFilter, the software-decode hardware run, and narrower comment wording.🤖 Generated with Claude Code
Note
Scale QSV tone-map frames before OpenCL tone mapping
tonemap.QSVFilterin tonemap.go now takes a target-height parameter. HDR graphs resize before the OpenCL tone mapper; SDR graphs resize after VAAPI conversion; zero height leaves the source size unchanged.QSVFilterand drops its separate post-hoc scaling helper.QSVInteropFilterdocs now state it must not resize or do color processing.Macroscope summarized f3349b4.