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

@ -95,5 +95,8 @@ func buildTranscodeRuntime(ctx context.Context, cfg config.Config) engine.Transc
// Tonemap HDR→SDR only when this ffmpeg build has zscale; otherwise the
// filter would error and break playback, so HDR plays untonemapped.
TonemapHDR: engine.FFmpegSupportsZscale(ffmpegPath),
// libplacebo (GPU) is preferred over zscale when present — checked here so
// the per-session arg builder can pick it for HDR sources.
HasLibplacebo: engine.FFmpegSupportsLibplacebo(ffmpegPath),
}
}