]> granicus.if.org Git - handbrake/commitdiff
WinGui: Detect newer hardware and use 3 point QSV slider, and 2 point for IvyBridge...
authorsr55 <sr55.hb@outlook.com>
Wed, 22 May 2013 20:32:14 +0000 (20:32 +0000)
committersr55 <sr55.hb@outlook.com>
Wed, 22 May 2013 20:32:14 +0000 (20:32 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5500 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
win/CS/HandBrakeWPF/Views/VideoView.xaml

index 85ce9d40b1b93a31d34667d18ebc10071694039e..19276344b2ce4f8ac0bfedeae4094b6f9c5837fe 100644 (file)
@@ -952,17 +952,36 @@ namespace HandBrake.ApplicationServices.Utilities
                 if (task.VideoEncoder == VideoEncoder.QuickSync)\r
                 {\r
                     string qsvPreset;\r
-                    switch (task.QsvPreset)\r
+\r
+                    if (SystemInfo.IsHswOrNewer)\r
                     {\r
-                        case QsvPreset.Speed:\r
-                            qsvPreset = "7";\r
-                            break;\r
-                        case QsvPreset.Balanced:\r
-                            qsvPreset = "4";\r
-                            break;\r
-                        default:\r
-                            qsvPreset = "2";\r
-                            break;\r
+                        switch (task.QsvPreset)\r
+                        {\r
+                            case QsvPreset.Speed:\r
+                                qsvPreset = "6";\r
+                                break;\r
+                            case QsvPreset.Balanced:\r
+                                qsvPreset = "4";\r
+                                break;\r
+                            default:\r
+                                qsvPreset = "2";\r
+                                break;\r
+                        }\r
+                    }\r
+                    else\r
+                    {\r
+                        switch (task.QsvPreset)\r
+                        {\r
+                            case QsvPreset.Speed:\r
+                                qsvPreset = "4";\r
+                                break;\r
+                            case QsvPreset.Balanced:\r
+                                qsvPreset = "2";\r
+                                break;\r
+                            default:\r
+                                qsvPreset = "2";\r
+                                break;\r
+                        }\r
                     }\r
 \r
                     query += string.IsNullOrEmpty(task.AdvancedEncoderOptions)\r
index 32328ab47e63b2cc799a69390e46d2a1fe6bcf41..adf4cc9ddc896434486c7fa00ffe50f5fc7a790a 100644 (file)
@@ -9,6 +9,7 @@
 \r
 namespace HandBrake.ApplicationServices.Utilities\r
 {\r
+    using System.Text.RegularExpressions;\r
     using System.Windows.Forms;\r
 \r
     using Microsoft.Win32;\r
@@ -48,6 +49,35 @@ namespace HandBrake.ApplicationServices.Utilities
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets a value indicating whether is hsw or newer.\r
+        /// </summary>\r
+        public static bool IsHswOrNewer\r
+        {\r
+            get\r
+            {\r
+                string cpu = GetCpuCount.ToString();\r
+                if (cpu.Contains("Intel"))\r
+                {\r
+                    Match match = Regex.Match(cpu, "([0-9]{4})");\r
+                    if (match.Success)\r
+                    {\r
+                        string cpuId = match.Groups[0].ToString();\r
+                        int cpuNumber;\r
+                        if (int.TryParse(cpuId, out cpuNumber))\r
+                        {\r
+                            if (cpuNumber > 4000)\r
+                            {\r
+                                return true;\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+\r
+                return false;\r
+            }\r
+        }\r
+\r
         /// <summary>\r
         /// Gets the System screen size information.\r
         /// </summary>\r
index 6833dfc36980c1b20ce20a86175309bd6cac73bf..4c55da366dd9e910e511d1d98c1d154336cc8744 100644 (file)
@@ -197,20 +197,20 @@ namespace HandBrake.Interop
                                throw new ArgumentException("height must be positive.");\r
                        }\r
 \r
-                   HBFunctions.hb_init(0, 0);\r
-            IntPtr ptr = HBFunctions.hb_x264_param_unparse(\r
-                               preset,\r
-                               string.Join(",", tunes),\r
-                               extraOptions,\r
-                               profile,\r
-                               level,\r
-                               width,\r
-                               height);\r
+            //HBFunctions.hb_init(0, 0);\r
+            //IntPtr ptr = HBFunctions.hb_x264_param_unparse(\r
+            //    preset,\r
+            //    string.Join(",", tunes),\r
+            //    extraOptions,\r
+            //    profile,\r
+            //    level,\r
+            //    width,\r
+            //    height);\r
 \r
-                   string x264Settings = Marshal.PtrToStringAnsi(ptr);\r
+            //string x264Settings = Marshal.PtrToStringAnsi(ptr);\r
 \r
 \r
-            return x264Settings;\r
+            return "";\r
                }\r
 \r
                /// <summary>\r
index f17bd1f601630985f0f54995bf3a655d27e3664b..6355bd9457ef06729547fd494e218cd984cae60b 100644 (file)
@@ -844,6 +844,17 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets the qsv slider max.\r
+        /// </summary>\r
+        public int QsvSliderMax\r
+        {\r
+            get\r
+            {\r
+                return SystemInfo.IsHswOrNewer ? 2 : 1;\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Public Methods\r
@@ -957,7 +968,7 @@ namespace HandBrakeWPF.ViewModels
 \r
                 this.QsvPresetValue = preset.Task.VideoEncoder == VideoEncoder.QuickSync\r
                                            ? (int)preset.Task.QsvPreset\r
-                                           : (int)QsvPreset.Quality;\r
+                                           : SystemInfo.IsHswOrNewer ? (int)QsvPreset.Quality : (int)QsvPreset.Balanced;\r
 \r
                 this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab;\r
             }\r
index fd196fb56074183bd8a657de938f4d2fda8c4d3b..0c8fb0c3d1ad79e291d14be3054c45a47c1aad23 100644 (file)
                                Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" />\r
                     <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal"\r
                                 Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" >\r
-                        <Slider Minimum="0" Maximum="2" Width="150" Value="{Binding QsvPresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}" \r
+                        <Slider Minimum="0" Maximum="{Binding QsvSliderMax}" Width="150" Value="{Binding QsvPresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}" \r
                             IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" />\r
                         <TextBlock Text="{Binding QsvPreset, Converter={StaticResource enumComboConverter}}" Margin="5,0,0,0" />\r
                     </StackPanel>\r