summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-07-18 16:58:39 +0100
committersr55 <[email protected]>2020-07-18 16:58:51 +0100
commit0014ddb8b4a559e07beffd70bc712511e8c9d881 (patch)
treee7875019e84db0e916ed95ce80016d3a4385b8fd /win/CS/HandBrake.Interop
parent2513a7306223c71a199bacc2502b8227272bec4f (diff)
WinGui: Make QSV hardware detection APIs information available to the UI for use and refactor the video tab preset defaulting behaviour. Better defaults for Nvidia, AMD and VCE hardware based on current generation hardware.
Diffstat (limited to 'win/CS/HandBrake.Interop')
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs6
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs10
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs4
-rw-r--r--win/CS/HandBrake.Interop/Utilities/SystemInfo.cs41
4 files changed, 49 insertions, 12 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
index 742f63aea..c3b99c735 100644
--- a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
@@ -301,5 +301,11 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_filter_get_tunes_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_filter_get_tunes_json(int filter_id);
+
+ [DllImport("hb", EntryPoint = "hb_get_cpu_platform", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int hb_get_cpu_platform();
+
+ [DllImport("hb", EntryPoint = "qsv_hardware_generation", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int qsv_hardware_generation(int cpu_platform);
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs
index b98794d5d..7a892dc22 100644
--- a/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs
@@ -497,5 +497,15 @@ namespace HandBrake.Interop.Interop.HbLib.Wrappers
{
return HBFunctions.hb_filter_get_tunes_json(filter_id);
}
+
+ public int hb_get_cpu_platform()
+ {
+ return HBFunctions.hb_get_cpu_platform();
+ }
+
+ public int qsv_hardware_generation(int cpu_platform)
+ {
+ return HBFunctions.qsv_hardware_generation(cpu_platform);
+ }
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs
index b876c9f16..01c8e614b 100644
--- a/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs
@@ -211,5 +211,9 @@ namespace HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces
IntPtr hb_filter_get_presets_json(int filter_id);
IntPtr hb_filter_get_tunes_json(int filter_id);
+
+ int hb_get_cpu_platform();
+
+ int qsv_hardware_generation(int cpu_platform);
}
}
diff --git a/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs b/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
index b22e16d6c..6a0c72283 100644
--- a/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
+++ b/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
@@ -10,6 +10,7 @@
namespace HandBrake.Interop.Utilities
{
using System;
+ using System.Diagnostics;
using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Providers;
@@ -17,9 +18,6 @@ namespace HandBrake.Interop.Utilities
using Interop.HbLib;
- /// <summary>
- /// The System Information.
- /// </summary>
public class SystemInfo
{
private static bool? isNvencH264Available; // Local cache to prevent log spam.
@@ -33,9 +31,9 @@ namespace HandBrake.Interop.Utilities
hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
}
- /// <summary>
- /// Gets a value indicating whether is qsv available.
- /// </summary>
+
+ /* QuickSync Support */
+
public static bool IsQsvAvailable
{
get
@@ -52,9 +50,6 @@ namespace HandBrake.Interop.Utilities
}
}
- /// <summary>
- /// Gets a value indicating whether is qsv available.
- /// </summary>
public static bool IsQsvAvailableH264
{
get
@@ -71,9 +66,6 @@ namespace HandBrake.Interop.Utilities
}
}
- /// <summary>
- /// Gets a value indicating whether is qsv available.
- /// </summary>
public static bool IsQsvAvailableH265
{
get
@@ -90,6 +82,26 @@ namespace HandBrake.Interop.Utilities
}
}
+ public static int QsvHardwareGeneration
+ {
+ get
+ {
+ try
+ {
+ int cpu_platform = hbFunctions.hb_get_cpu_platform();
+ int hardware = hbFunctions.qsv_hardware_generation(cpu_platform);
+ return hardware;
+ }
+ catch (Exception exc)
+ {
+ // Silent failure. -1 means unsupported.
+ Debug.WriteLine(exc);
+ return -1;
+ }
+ }
+ }
+
+
public static bool IsQsvAvailableH26510bit
{
get
@@ -106,6 +118,9 @@ namespace HandBrake.Interop.Utilities
}
}
+
+ /* AMD VCE Support */
+
public static bool IsVceH264Available
{
get
@@ -138,6 +153,8 @@ namespace HandBrake.Interop.Utilities
}
}
+ /* Nvidia NVEnc Support */
+
public static bool IsNVEncH264Available
{
get