Fix intel Xe kernel driver cannot be used with QSV (#12691)

pull/12695/head
Nyanmisaka 4 months ago committed by GitHub
parent 8a456bf895
commit a0204ada2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -72,6 +72,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly Version _minFFmpegAlteredVaVkInterop = new Version(7, 0, 1); private readonly Version _minFFmpegAlteredVaVkInterop = new Version(7, 0, 1);
private readonly Version _minFFmpegQsvVppTonemapOption = new Version(7, 0, 1); private readonly Version _minFFmpegQsvVppTonemapOption = new Version(7, 0, 1);
private readonly Version _minFFmpegQsvVppOutRangeOption = new Version(7, 0, 1); private readonly Version _minFFmpegQsvVppOutRangeOption = new Version(7, 0, 1);
private readonly Version _minFFmpegVaapiDeviceVendorId = new Version(7, 0, 1);
private static readonly Regex _validationRegex = new(ValidationRegex, RegexOptions.Compiled); private static readonly Regex _validationRegex = new(ValidationRegex, RegexOptions.Compiled);
@ -872,13 +873,15 @@ namespace MediaBrowser.Controller.MediaEncoding
options); options);
} }
private string GetVaapiDeviceArgs(string renderNodePath, string driver, string kernelDriver, string srcDeviceAlias, string alias) private string GetVaapiDeviceArgs(string renderNodePath, string driver, string kernelDriver, string vendorId, string srcDeviceAlias, string alias)
{ {
alias ??= VaapiAlias; alias ??= VaapiAlias;
var haveVendorId = !string.IsNullOrEmpty(vendorId)
&& _mediaEncoder.EncoderVersion >= _minFFmpegVaapiDeviceVendorId;
// 'renderNodePath' has higher priority than 'kernelDriver' // Priority: 'renderNodePath' > 'vendorId' > 'kernelDriver'
var driverOpts = string.IsNullOrEmpty(renderNodePath) var driverOpts = string.IsNullOrEmpty(renderNodePath)
? (string.IsNullOrEmpty(kernelDriver) ? string.Empty : ",kernel_driver=" + kernelDriver) ? (haveVendorId ? $",vendor_id={vendorId}" : (string.IsNullOrEmpty(kernelDriver) ? string.Empty : $",kernel_driver={kernelDriver}"))
: renderNodePath; : renderNodePath;
// 'driver' behaves similarly to env LIBVA_DRIVER_NAME // 'driver' behaves similarly to env LIBVA_DRIVER_NAME
@ -913,7 +916,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (OperatingSystem.IsLinux()) if (OperatingSystem.IsLinux())
{ {
// derive qsv from vaapi device // derive qsv from vaapi device
return GetVaapiDeviceArgs(renderNodePath, "iHD", "i915", null, VaapiAlias) + arg + "@" + VaapiAlias; return GetVaapiDeviceArgs(renderNodePath, "iHD", "i915", "0x8086", null, VaapiAlias) + arg + "@" + VaapiAlias;
} }
if (OperatingSystem.IsWindows()) if (OperatingSystem.IsWindows())
@ -1008,14 +1011,14 @@ namespace MediaBrowser.Controller.MediaEncoding
if (_mediaEncoder.IsVaapiDeviceInteliHD) if (_mediaEncoder.IsVaapiDeviceInteliHD)
{ {
args.Append(GetVaapiDeviceArgs(options.VaapiDevice, "iHD", null, null, VaapiAlias)); args.Append(GetVaapiDeviceArgs(options.VaapiDevice, "iHD", null, null, null, VaapiAlias));
} }
else if (_mediaEncoder.IsVaapiDeviceInteli965) else if (_mediaEncoder.IsVaapiDeviceInteli965)
{ {
// Only override i965 since it has lower priority than iHD in libva lookup. // Only override i965 since it has lower priority than iHD in libva lookup.
Environment.SetEnvironmentVariable("LIBVA_DRIVER_NAME", "i965"); Environment.SetEnvironmentVariable("LIBVA_DRIVER_NAME", "i965");
Environment.SetEnvironmentVariable("LIBVA_DRIVER_NAME_JELLYFIN", "i965"); Environment.SetEnvironmentVariable("LIBVA_DRIVER_NAME_JELLYFIN", "i965");
args.Append(GetVaapiDeviceArgs(options.VaapiDevice, "i965", null, null, VaapiAlias)); args.Append(GetVaapiDeviceArgs(options.VaapiDevice, "i965", null, null, null, VaapiAlias));
} }
var filterDevArgs = string.Empty; var filterDevArgs = string.Empty;
@ -1039,7 +1042,7 @@ namespace MediaBrowser.Controller.MediaEncoding
&& Environment.OSVersion.Version >= _minKernelVersionAmdVkFmtModifier) && Environment.OSVersion.Version >= _minKernelVersionAmdVkFmtModifier)
{ {
args.Append(GetDrmDeviceArgs(options.VaapiDevice, DrmAlias)); args.Append(GetDrmDeviceArgs(options.VaapiDevice, DrmAlias));
args.Append(GetVaapiDeviceArgs(null, null, null, DrmAlias, VaapiAlias)); args.Append(GetVaapiDeviceArgs(null, null, null, null, DrmAlias, VaapiAlias));
args.Append(GetVulkanDeviceArgs(0, null, DrmAlias, VulkanAlias)); args.Append(GetVulkanDeviceArgs(0, null, DrmAlias, VulkanAlias));
// libplacebo wants an explicitly set vulkan filter device. // libplacebo wants an explicitly set vulkan filter device.
@ -1047,7 +1050,7 @@ namespace MediaBrowser.Controller.MediaEncoding
} }
else else
{ {
args.Append(GetVaapiDeviceArgs(options.VaapiDevice, null, null, null, VaapiAlias)); args.Append(GetVaapiDeviceArgs(options.VaapiDevice, null, null, null, null, VaapiAlias));
filterDevArgs = GetFilterHwDeviceArgs(VaapiAlias); filterDevArgs = GetFilterHwDeviceArgs(VaapiAlias);
if (doOclTonemap) if (doOclTonemap)

Loading…
Cancel
Save