feat(stream): GPU HDR tonemap via libplacebo

Prefer the single-pass Vulkan libplacebo filter over the CPU zscale chain
for HDR->SDR tonemapping when the agent ffmpeg has it. One GPU pass does
tonemap + BT.709 primaries/transfer/matrix + 8-bit yuv420p, replacing the
four-stage zscale chain and its trailing format=/setparams. Higher quality,
far cheaper than the CPU path, and present on builds that lack zscale.

- FFmpegSupportsLibplacebo probe (cached, mirrors FFmpegSupportsZscale)
- HasLibplacebo on TranscodeRuntime, wired from buildTranscodeRuntime
- hls.go: videoTail picks libplacebo when present (not h264_vaapi), else
  keeps the zscale tonemap + format chain
- test: libplacebo replaces the zscale chain, never runs alongside it
This commit is contained in:
Deivid Soto 2026-06-03 09:29:55 +02:00
parent 325c11c1eb
commit 005a4380dd
5 changed files with 90 additions and 11 deletions

View file

@ -18,6 +18,10 @@ type TranscodeRuntime struct {
// Set only when the ffmpeg build has zscale (FFmpegSupportsZscale); without
// it the tonemap filter would error and break playback, so it stays off.
TonemapHDR bool
// HasLibplacebo: the ffmpeg build has the libplacebo filter (GPU HDR tonemap).
// Preferred over the zscale chain for HDR sources — one GPU pass, higher
// quality, and present where zscale is missing.
HasLibplacebo bool
}
// qualityCap maps a session's Quality label to a (MaxHeight, VideoBitrate)