]> granicus.if.org Git - handbrake/commitdiff
Interop: Support for rotation and reflection.
authorrandomengy <david.rickard@gmail.com>
Fri, 11 Apr 2014 06:54:33 +0000 (06:54 +0000)
committerrandomengy <david.rickard@gmail.com>
Fri, 11 Apr 2014 06:54:33 +0000 (06:54 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6161 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs [new file with mode: 0644]

index e97343852c2030c3eeb94c47024b13334bc3edf4..bfd0c44de4d7a2793371b03f4182fb644b986ad3 100644 (file)
@@ -16,6 +16,7 @@ namespace HandBrake.Interop
     using System.Linq;\r
     using System.Runtime.InteropServices;\r
     using System.Text;\r
+    using System.Windows.Media;\r
     using System.Windows.Media.Imaging;\r
 \r
     using HandBrake.Interop.EventArgs;\r
@@ -1502,6 +1503,48 @@ namespace HandBrake.Interop
                 }\r
             }\r
 \r
+                       // Rotate\r
+               if (profile.FlipHorizontal || profile.FlipVertical || profile.Rotation != PictureRotation.None)\r
+               {\r
+                       bool rotate90 = false;\r
+                       bool flipHorizontal = profile.FlipHorizontal;\r
+                       bool flipVertical = profile.FlipVertical;\r
+\r
+                       switch (profile.Rotation)\r
+                       {\r
+                               case PictureRotation.Clockwise90:\r
+                                       rotate90 = true;\r
+                                       break;\r
+                               case PictureRotation.Clockwise180:\r
+                                       flipHorizontal = !flipHorizontal;\r
+                                       flipVertical = !flipVertical;\r
+                                       break;\r
+                               case PictureRotation.Clockwise270:\r
+                                       rotate90 = true;\r
+                                       flipHorizontal = !flipHorizontal;\r
+                                       flipVertical = !flipVertical;\r
+                                       break;\r
+                       }\r
+\r
+                       int rotateSetting = 0;\r
+                               if (flipVertical)\r
+                       {\r
+                               rotateSetting |= 1;\r
+                       }\r
+\r
+                               if (flipHorizontal)\r
+                       {\r
+                               rotateSetting |= 2;\r
+                       }\r
+\r
+                               if (rotate90)\r
+                       {\r
+                               rotateSetting |= 4;\r
+                       }\r
+\r
+                               this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_ROTATE, rotateSetting.ToString(CultureInfo.InvariantCulture), allocatedMemory);\r
+               }\r
+\r
             // Construct final filter list\r
             nativeJob.list_filter = this.ConvertFilterListToNative(filterList, allocatedMemory).Ptr;\r
 \r
index bb4bd48cff2198de1d54782f30051c1ea1b15bfb..d86da1833880a112e79b9e41a7201f996221e0c8 100644 (file)
     <Compile Include="HbLib\NativeConstants.cs" />\r
     <Compile Include="Interfaces\IHandBrakeInstance.cs" />\r
     <Compile Include="Helpers\InteropUtilities.cs" />\r
+    <Compile Include="Model\Encoding\PictureRotation.cs" />\r
     <Compile Include="Model\Encoding\x265\x265Preset.cs" />\r
     <Compile Include="Model\Encoding\x265\x265Profile.cs" />\r
     <Compile Include="Model\Encoding\x265\x265Tune.cs" />\r
index 257c324d7a8784acf8e9cf2456abbe860a67a3e2..2dea5624bd88b86ef9f16649079ff30aa748815b 100644 (file)
@@ -130,6 +130,21 @@ namespace HandBrake.Interop.Model.Encoding
         /// Gets or sets the modulus.\r
         /// </summary>\r
         public int Modulus { get; set; }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the rotation.\r
+               /// </summary>\r
+               public PictureRotation Rotation { get; set; }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a value indicating whether the picture should be flipped horizontally.\r
+               /// </summary>\r
+               public bool FlipHorizontal { get; set; }\r
+\r
+               /// <summary>\r
+               /// Gets or sets a value indicating whether the picture should be flipped vertically.\r
+               /// </summary>\r
+               public bool FlipVertical { get; set; }\r
         #endregion\r
 \r
         #region Filters\r
@@ -180,7 +195,7 @@ namespace HandBrake.Interop.Model.Encoding
         public int Deblock { get; set; }\r
 \r
         /// <summary>\r
-        /// Gets or sets a value indicating whether grayscale.\r
+        /// Gets or sets a value indicating whether the grayscale filter will be applied.\r
         /// </summary>\r
         public bool Grayscale { get; set; }\r
         #endregion\r
@@ -307,6 +322,9 @@ namespace HandBrake.Interop.Model.Encoding
                 PixelAspectX = this.PixelAspectX,\r
                 PixelAspectY = this.PixelAspectY,\r
                 Modulus = this.Modulus,\r
+                               Rotation = this.Rotation,\r
+                               FlipHorizontal = this.FlipHorizontal,\r
+                               FlipVertical = this.FlipVertical,\r
 \r
                 Deinterlace = this.Deinterlace,\r
                 CustomDeinterlace = this.CustomDeinterlace,\r
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs
new file mode 100644 (file)
index 0000000..0476b16
--- /dev/null
@@ -0,0 +1,19 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="Rotation.cs" company="HandBrake Project (http://handbrake.fr)">\r
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.Interop.Model.Encoding\r
+{\r
+       /// <summary>\r
+       /// Possible picture rotations.\r
+       /// </summary>\r
+       public enum PictureRotation\r
+       {\r
+               None = 0,\r
+               Clockwise90,\r
+               Clockwise180,\r
+               Clockwise270\r
+       }\r
+}\r