]> granicus.if.org Git - handbrake/commitdiff
WinGui: use libhb presets for QSV.
authorRodeo <tdskywalker@gmail.com>
Fri, 8 Nov 2013 23:04:44 +0000 (23:04 +0000)
committerRodeo <tdskywalker@gmail.com>
Fri, 8 Nov 2013 23:04:44 +0000 (23:04 +0000)
This replaces the built-in QSV presets.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5889 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs
win/CS/HandBrakeWPF/Views/VideoView.xaml.cs

index f034cb68243985e51d69f51a9a2be78c3fce3de8..3ddb1ff51b84842936c371588b587773d05c5e1d 100644 (file)
@@ -276,13 +276,13 @@ namespace HandBrake.ApplicationServices.Utilities
             if (parsed.FastDecode)\r
             {\r
                 tune = tune == "none" ? "fastdecode" : tune + ",fastdecode";\r
-            }\r
-            AddEncodeElement(xmlWriter, "x264Tune", "string", tune);\r
-            AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0");\r
-            AddEncodeElement(xmlWriter, "QsvPreset", "string", parsed.QsvPreset.ToString());\r
-\r
-            int videoQualityType = 0;\r
-            if (parsed.VideoBitrate != null) videoQualityType = 1;\r
+            }
+            AddEncodeElement(xmlWriter, "x264Tune", "string", tune);
+            AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0");
+            AddEncodeElement(xmlWriter, "qsvPreset", "string", parsed.QsvPreset.ToString().ToLower());
+
+            int videoQualityType = 0;
+            if (parsed.VideoBitrate != null) videoQualityType = 1;
             else if (parsed.Quality != null) videoQualityType = 2;\r
 \r
             AddEncodeElement(xmlWriter, "VideoQualityType", "integer", videoQualityType.ToString());\r
index 13be725279d38b6b0fcd8bd2cd0fc75767dfcadc..5dee884263629d85e87d8545fabc4942f20ac9bd 100644 (file)
@@ -957,12 +957,24 @@ namespace HandBrake.ApplicationServices.Utilities
                     {\r
                         query += string.Format(" -x {0}", task.ExtraAdvancedArguments);\r
                     }\r
-                }\r
-            }\r
-\r
-            // Options that apply to both x264 and QuickSync\r
-            if (task.VideoEncoder == VideoEncoder.QuickSync || task.VideoEncoder == VideoEncoder.X264)\r
-            {\r
+                }
+            }
+
+            // QSV Only
+            if (task.VideoEncoder == VideoEncoder.QuickSync)
+            {
+                query += string.Format(" --qsv-preset={0}", task.QsvPreset.ToString().ToLower());
+            }
+
+            // options that apply to all encoders
+            if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))
+            {
+                query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
+            }
+
+            // Options that apply to both x264 and QuickSync
+            if (task.VideoEncoder == VideoEncoder.QuickSync || task.VideoEncoder == VideoEncoder.X264)
+            {
                 // when using x264 with the advanced panel, the H.264 profile/level widgets are disabled\r
                 if (!(task.VideoEncoder == VideoEncoder.X264 && task.ShowAdvancedTab))\r
                 {\r
@@ -973,61 +985,15 @@ namespace HandBrake.ApplicationServices.Utilities
                     if (task.H264Profile != x264Profile.None)\r
                     {\r
                         query += string.Format(\r
-                            " --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));\r
-                    }\r
-                }\r
-\r
-                if (task.VideoEncoder == VideoEncoder.QuickSync)\r
-                {\r
-                    string qsvPreset;\r
-\r
-                    if (SystemInfo.IsHswOrNewer)\r
-                    {\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
-                                 ? string.Format(" -x target-usage={0}", qsvPreset)\r
-                                 : string.Format(" -x target-usage={0}:{1}", qsvPreset, task.AdvancedEncoderOptions);\r
-                }\r
-                else if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))  // Not a H.264 encode\r
-                {\r
-                    query += string.Format(" -x {0}", task.AdvancedEncoderOptions);\r
-                }\r
-\r
-                return query;\r
-            }\r
-\r
-            return string.IsNullOrEmpty(task.AdvancedEncoderOptions) ? string.Empty : string.Format(" -x {0}", task.AdvancedEncoderOptions);\r
-        }\r
-\r
-        /// <summary>\r
+                            " --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));
+                    }
+                }
+            }
+
+            return query;
+        }
+
+        /// <summary>
         /// Generate the Command Line Arguments for any additional advanced options.\r
         /// </summary>\r
         /// <param name="verbosity">\r
index d7ae4e498528b6e90455a331b21ccc0adaceafae..f7968fcb40d06c3bb76298bfeb37875428742c57 100644 (file)
@@ -30,13 +30,12 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Initializes a new instance of the <see cref="EncoderOptionsViewModel"/> class.\r
         /// </summary>\r
-        public EncoderOptionsViewModel()\r
-        {\r
-            this.Task = new EncodeTask();\r
-            cachedOptions.Add(VideoEncoder.QuickSync, "async-depth=4");\r
-        }\r
-\r
-        /// <summary>\r
+        public EncoderOptionsViewModel()
+        {
+            this.Task = new EncodeTask();
+        }
+
+        /// <summary>
         /// Gets or sets the task.\r
         /// </summary>\r
         public EncodeTask Task { get; set; }\r
index a285e490b770b8db9182bee52fef1d1b44489dd4..e9d54d4ce59ebf804d15571b0081aff92a24145c 100644 (file)
@@ -43,40 +43,14 @@ namespace HandBrakeWPF.Views
 \r
         private void qsv_preset_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)\r
         {\r
-            VideoViewModel mvm = ((VideoViewModel)this.DataContext);\r
-            EncodeTask task = mvm.Task;\r
-\r
-            string addon = "";\r
-\r
-            if (SystemInfo.IsHswOrNewer)\r
-            {\r
-                if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)\r
-                {\r
-                    if (task.QsvPreset == QsvPreset.Balanced ||\r
-                        task.QsvPreset == QsvPreset.Speed)\r
-                        addon = "num-ref-frame=1";\r
-                }\r
-                if (task.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate)\r
-                {\r
-                    if (task.QsvPreset == QsvPreset.Quality)\r
-                        addon = "lookahead=1:gop-ref-dist=3";\r
-                    else\r
-                        if (task.QsvPreset == QsvPreset.Balanced)\r
-                        {\r
-                            addon = "num-ref-frame=1:gop-ref-dist=1";\r
-                        }\r
-                        else\r
-                            if (task.QsvPreset == QsvPreset.Speed)\r
-                                addon = "gop-ref-dist=1";\r
-                }\r
-            }\r
-\r
-\r
-            string full_string = addon + ":";\r
-\r
-            IDictionary<string, string> newOptions = new Dictionary<string, string>();\r
-            string[] existingSegments = full_string.Split(':');\r
-            foreach (string existingSegment in existingSegments)\r
+            VideoViewModel mvm = ((VideoViewModel)this.DataContext);
+            EncodeTask task = mvm.Task;
+
+            string full_string = "";
+
+            IDictionary<string, string> newOptions = new Dictionary<string, string>();
+            string[] existingSegments = full_string.Split(':');
+            foreach (string existingSegment in existingSegments)
             {\r
                 string optionName = existingSegment;\r
                 string optionValue = string.Empty;\r