Fix CRT shader VAAPI path: use reverse=1 instead of hwdownload+hwupload

hwdownload+hwupload produced output with no video. Switch back to
hwmap reverse=1 to VAAPI (then hwmap to QSV). Now that scale_opencl is
gone and the shader processes NV12 natively, the OpenCL frames remain
in the VAAPI-linked pool so reverse=1 is viable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mani
2026-02-27 01:18:15 +01:00
parent f63a22e65e
commit 0da3d7e29a

View File

@@ -4925,23 +4925,19 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (IsCrtShaderEnabled(state))
{
// VAAPI → OpenCL → CRT (NV12) → CPU → QSV.
// program_opencl outputs NV12 frames into its own pool; we cannot
// rely on hwmap reverse=1 back to VAAPI from those new frames.
// hwdownload then hwupload (-filter_hw_device qsv) is the safe path.
// VAAPI → OpenCL → CRT (NV12) → VAAPI (reverse=1) → QSV.
// Shader now works in NV12 throughout (no scale_opencl format break),
// so program_opencl output stays in the VAAPI-linked OpenCL pool.
// reverse=1 to VAAPI mirrors the doOclTonemap+isVaInVaOut path.
mainFilters.Add("hwmap=derive_device=opencl:mode=read");
mainFilters.AddRange(GetCrtShaderOclFilters(state));
mainFilters.Add("hwdownload");
mainFilters.Add("format=nv12");
mainFilters.Add("hwupload");
mainFilters.Add("format=qsv");
}
else
{
// VAAPI → QSV (zero-copy, shared libva surface)
mainFilters.Add("hwmap=derive_device=qsv");
mainFilters.Add("format=qsv");
mainFilters.Add("hwmap=derive_device=vaapi:mode=write:reverse=1");
mainFilters.Add("format=vaapi");
}
// VAAPI → QSV (zero-copy, shared libva surface) [both paths]
mainFilters.Add("hwmap=derive_device=qsv");
mainFilters.Add("format=qsv");
}
else if (isQsvDecoder)
{