WinGui: Starting work on more API cleanup in ApplicationServices library.
authorScott <sr55@users.noreply.github.com>
Fri, 18 Sep 2015 20:41:57 +0000 (21:41 +0100)
committerScott <sr55@users.noreply.github.com>
Fri, 18 Sep 2015 20:41:57 +0000 (21:41 +0100)
win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs
win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs
win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs

index 5c49c507311cfafcfe0939e6199ee61f79e60821..35ec20ba97c2f28780fc553ce2ad4f0e261cd7fd 100644 (file)
@@ -16,7 +16,6 @@ namespace HandBrake.ApplicationServices.Interop.Factories
     using HandBrake.ApplicationServices.Interop.Model;\r
     using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
     using HandBrake.ApplicationServices.Interop.Model.Preview;\r
-    using HandBrake.ApplicationServices.Services.Encode.Model;\r
 \r
     /// <summary>\r
     /// The anamorphic factory.\r
@@ -28,79 +27,34 @@ namespace HandBrake.ApplicationServices.Interop.Factories
         /// </summary>\r
         public enum KeepSetting\r
         {\r
-            HB_KEEP_WIDTH = 0x01,\r
-            HB_KEEP_HEIGHT = 0x02,\r
+            /// <summary>\r
+            /// The h b_ kee p_ width.\r
+            /// </summary>\r
+            HB_KEEP_WIDTH = 0x01, \r
+\r
+            /// <summary>\r
+            /// The h b_ kee p_ height.\r
+            /// </summary>\r
+            HB_KEEP_HEIGHT = 0x02, \r
+\r
+            /// <summary>\r
+            /// The h b_ kee p_ displa y_ aspect.\r
+            /// </summary>\r
             HB_KEEP_DISPLAY_ASPECT = 0x04\r
         }\r
 \r
         /// <summary>\r
-        /// The create geometry.\r
+        /// Finds output geometry for the given preview settings and title.\r
         /// </summary>\r
-        /// <param name="job">\r
-        /// The job.\r
+        /// <param name="settings">\r
+        /// The preview settings.\r
         /// </param>\r
         /// <param name="title">\r
-        /// The current title.\r
-        /// </param>\r
-        /// <param name="keepWidthOrHeight">\r
-        /// Keep Width or Height. (Not Display Aspect)\r
+        /// Information on the title to consider.\r
         /// </param>\r
         /// <returns>\r
-        /// The <see cref="Geometry"/>.\r
+        /// Geometry Information\r
         /// </returns>\r
-        public static Geometry CreateGeometry(EncodeTask job, SourceVideoInfo title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.\r
-        {\r
-            int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);\r
-\r
-            // Sanitize the Geometry First.\r
-            AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry\r
-            {\r
-                SourceGeometry = new Geometry\r
-                                 {\r
-                                    Width = title.Resolution.Width,\r
-                                    Height = title.Resolution.Height,\r
-                                    PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }\r
-                                 },\r
-                DestSettings = new DestSettings\r
-                               {\r
-                                    AnamorphicMode = (int)job.Anamorphic,\r
-                                    Geometry =\r
-                                    {\r
-                                        Width = job.Width ?? 0,\r
-                                        Height = job.Height ?? 0,\r
-                                        PAR = new PAR\r
-                                              {\r
-                                                  Num = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : job.PixelAspectX,\r
-                                                  Den = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : job.PixelAspectY,\r
-                                              }\r
-                                    },\r
-                                    Keep = settingMode,\r
-                                    Crop = new List<int> { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right },\r
-                                    Modulus = job.Modulus ?? 16,\r
-                                    MaxWidth = job.MaxWidth ?? 0,\r
-                                    MaxHeight = job.MaxHeight ?? 0,\r
-                                    ItuPAR = false\r
-                               }\r
-            };\r
-\r
-            if (job.Anamorphic == Anamorphic.Custom)\r
-            {\r
-                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = job.PixelAspectX, Den = job.PixelAspectY };\r
-            }\r
-            else\r
-            {\r
-                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height };\r
-            }\r
-\r
-            return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Finds output geometry for the given preview settings and title.\r
-        /// </summary>\r
-        /// <param name="settings">The preview settings.</param>\r
-        /// <param name="title">Information on the title to consider.</param>\r
-        /// <returns>Geometry Information</returns>\r
         public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title)\r
         {\r
             int settingMode = settings.KeepDisplayAspect ? 0x04 : 0;\r
@@ -110,28 +64,28 @@ namespace HandBrake.ApplicationServices.Interop.Factories
             {\r
                 SourceGeometry = new Geometry\r
                 {\r
-                    Width = title.Resolution.Width,\r
-                    Height = title.Resolution.Height,\r
+                    Width = title.Resolution.Width, \r
+                    Height = title.Resolution.Height, \r
                     PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }\r
-                },\r
+                }, \r
                 DestSettings = new DestSettings\r
                 {\r
-                    AnamorphicMode = (int)settings.Anamorphic,\r
+                    AnamorphicMode = (int)settings.Anamorphic, \r
                     Geometry =\r
                     {\r
-                        Width = settings.Width,\r
-                        Height = settings.Height,\r
+                        Width = settings.Width, \r
+                        Height = settings.Height, \r
                         PAR = new PAR\r
                         {\r
-                            Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,\r
-                            Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,\r
+                            Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX, \r
+                            Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY, \r
                         }\r
-                    },\r
-                    Keep = settingMode,\r
-                    Crop = new List<int> { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },\r
-                    Modulus = settings.Modulus ?? 16,\r
-                    MaxWidth = settings.MaxWidth,\r
-                    MaxHeight = settings.MaxHeight,\r
+                    }, \r
+                    Keep = settingMode, \r
+                    Crop = new List<int> { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right }, \r
+                    Modulus = settings.Modulus ?? 16, \r
+                    MaxWidth = settings.MaxWidth, \r
+                    MaxHeight = settings.MaxHeight, \r
                     ItuPAR = false\r
                 }\r
             };\r
index 8cf266d7e1ad874382b94d13f0de6443941fcd1b..d413e003bdc1c2500f4752684c33f819d9089f23 100644 (file)
@@ -10,7 +10,6 @@
 namespace HandBrake.ApplicationServices.Interop.Model.Preview\r
 {\r
     using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
-    using HandBrake.ApplicationServices.Services.Encode.Model;\r
 \r
     /// <summary>\r
     /// The preview settings.\r
@@ -24,25 +23,6 @@ namespace HandBrake.ApplicationServices.Interop.Model.Preview
         {\r
         }\r
 \r
-        /// <summary>\r
-        /// Initializes a new instance of the <see cref="PreviewSettings"/> class.\r
-        /// </summary>\r
-        /// <param name="task">The task.</param>\r
-        public PreviewSettings(EncodeTask task)\r
-        {\r
-            this.Cropping = new Cropping(task.Cropping);\r
-            this.MaxWidth = task.MaxWidth ?? 0;\r
-            this.MaxHeight = task.MaxHeight ?? 0;\r
-            this.KeepDisplayAspect = task.KeepDisplayAspect;\r
-            this.TitleNumber = task.Title;\r
-            this.Anamorphic = task.Anamorphic;\r
-            this.Modulus = task.Modulus;\r
-            this.Width = task.Width ?? 0;\r
-            this.Height = task.Height ?? 0;\r
-            this.PixelAspectX = task.PixelAspectX;\r
-            this.PixelAspectY = task.PixelAspectY;\r
-        }\r
-\r
         /// <summary>\r
         /// Gets or sets the cropping.\r
         /// </summary>\r
index b675138264ab673bbcba0b626b928e062f45d3c3..c7a97fa42fede1a57c15a517d286650f80fd6a61 100644 (file)
@@ -272,7 +272,21 @@ namespace HandBrake.ApplicationServices.Services.Scan
             BitmapImage bitmapImage = null;\r
             try\r
             {\r
-                PreviewSettings settings = new PreviewSettings(job);\r
+                PreviewSettings settings = new PreviewSettings\r
+                                               {\r
+                                                   Cropping = new Cropping(job.Cropping),\r
+                                                   MaxWidth = job.MaxWidth ?? 0,\r
+                                                   MaxHeight = job.MaxHeight ?? 0,\r
+                                                   KeepDisplayAspect = job.KeepDisplayAspect,\r
+                                                   TitleNumber = job.Title,\r
+                                                   Anamorphic = job.Anamorphic,\r
+                                                   Modulus = job.Modulus,\r
+                                                   Width = job.Width ?? 0,\r
+                                                   Height = job.Height ?? 0,\r
+                                                   PixelAspectX = job.PixelAspectX,\r
+                                                   PixelAspectY = job.PixelAspectY\r
+                                               };\r
+\r
                 bitmapImage = this.instance.GetPreview(settings, preview);\r
             }\r
             catch (AccessViolationException e)\r