From ffe98ff1f158264ac7b3840ae50a6aeaf2ca304e Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 22 May 2013 20:32:14 +0000 Subject: [PATCH] WinGui: Detect newer hardware and use 3 point QSV slider, and 2 point for IvyBridge and earlier. git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5500 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Utilities/QueryGeneratorUtility.cs | 39 ++++++++++++++----- .../Utilities/SystemInfo.cs | 30 ++++++++++++++ .../HandBrakeInterop/HandBrakeUtils.cs | 22 +++++------ .../HandBrakeWPF/ViewModels/VideoViewModel.cs | 13 ++++++- win/CS/HandBrakeWPF/Views/VideoView.xaml | 2 +- 5 files changed, 83 insertions(+), 23 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 85ce9d40b..19276344b 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -952,17 +952,36 @@ namespace HandBrake.ApplicationServices.Utilities if (task.VideoEncoder == VideoEncoder.QuickSync) { string qsvPreset; - switch (task.QsvPreset) + + if (SystemInfo.IsHswOrNewer) { - case QsvPreset.Speed: - qsvPreset = "7"; - break; - case QsvPreset.Balanced: - qsvPreset = "4"; - break; - default: - qsvPreset = "2"; - break; + switch (task.QsvPreset) + { + case QsvPreset.Speed: + qsvPreset = "6"; + break; + case QsvPreset.Balanced: + qsvPreset = "4"; + break; + default: + qsvPreset = "2"; + break; + } + } + else + { + switch (task.QsvPreset) + { + case QsvPreset.Speed: + qsvPreset = "4"; + break; + case QsvPreset.Balanced: + qsvPreset = "2"; + break; + default: + qsvPreset = "2"; + break; + } } query += string.IsNullOrEmpty(task.AdvancedEncoderOptions) diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs b/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs index 32328ab47..adf4cc9dd 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs @@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Utilities { + using System.Text.RegularExpressions; using System.Windows.Forms; using Microsoft.Win32; @@ -48,6 +49,35 @@ namespace HandBrake.ApplicationServices.Utilities } } + /// + /// Gets a value indicating whether is hsw or newer. + /// + public static bool IsHswOrNewer + { + get + { + string cpu = GetCpuCount.ToString(); + if (cpu.Contains("Intel")) + { + Match match = Regex.Match(cpu, "([0-9]{4})"); + if (match.Success) + { + string cpuId = match.Groups[0].ToString(); + int cpuNumber; + if (int.TryParse(cpuId, out cpuNumber)) + { + if (cpuNumber > 4000) + { + return true; + } + } + } + } + + return false; + } + } + /// /// Gets the System screen size information. /// diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 6833dfc36..4c55da366 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -197,20 +197,20 @@ namespace HandBrake.Interop throw new ArgumentException("height must be positive."); } - HBFunctions.hb_init(0, 0); - IntPtr ptr = HBFunctions.hb_x264_param_unparse( - preset, - string.Join(",", tunes), - extraOptions, - profile, - level, - width, - height); + //HBFunctions.hb_init(0, 0); + //IntPtr ptr = HBFunctions.hb_x264_param_unparse( + // preset, + // string.Join(",", tunes), + // extraOptions, + // profile, + // level, + // width, + // height); - string x264Settings = Marshal.PtrToStringAnsi(ptr); + //string x264Settings = Marshal.PtrToStringAnsi(ptr); - return x264Settings; + return ""; } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index f17bd1f60..6355bd945 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -844,6 +844,17 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets the qsv slider max. + /// + public int QsvSliderMax + { + get + { + return SystemInfo.IsHswOrNewer ? 2 : 1; + } + } + #endregion #region Public Methods @@ -957,7 +968,7 @@ namespace HandBrakeWPF.ViewModels this.QsvPresetValue = preset.Task.VideoEncoder == VideoEncoder.QuickSync ? (int)preset.Task.QsvPreset - : (int)QsvPreset.Quality; + : SystemInfo.IsHswOrNewer ? (int)QsvPreset.Quality : (int)QsvPreset.Balanced; this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab; } diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml index fd196fb56..0c8fb0c3d 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml @@ -180,7 +180,7 @@ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" /> - -- 2.40.0