WinGui: Updates to the latest JSON API. This enables hardware decode / encode options...
authorsr55 <sr55.hb@outlook.com>
Sun, 5 Apr 2015 13:40:13 +0000 (13:40 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 5 Apr 2015 13:40:13 +0000 (13:40 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7053 b64f7644-9d1e-0410-96f1-a4d463321fa5

12 files changed:
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/QSV.cs [new file with mode: 0644]
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Range.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Video.cs
win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs
win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs

index e0bf5cd97b9d7bba1c9d5150b116f7ae6bcce3f8..91b8dfea8aa2087a48277a3e4e456697f1d9b260 100644 (file)
     <Compile Include="Interop\Interfaces\IHandBrakeInstance.cs" />\r
     <Compile Include="Interop\Json\Anamorphic\AnamorphicGeometry.cs" />\r
     <Compile Include="Interop\Json\Anamorphic\DestSettings.cs" />\r
+    <Compile Include="Interop\Json\Encode\QSV.cs" />\r
     <Compile Include="Interop\Json\Shared\PAR.cs" />\r
     <Compile Include="Interop\Json\Encode\Audio.cs" />\r
     <Compile Include="Interop\Json\Encode\AudioList.cs" />\r
index 5a2c9706654341f12489db22f7ba2fa9678e5d2f..ce1c69c9c9797d6c9bba6c6852b822bc609cd711 100644 (file)
@@ -24,7 +24,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets the copy mask.\r
         /// </summary>\r
-        public int CopyMask { get; set; }\r
+        public string[] CopyMask { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the fallback encoder.\r
index 9e1af92dfd81658ff8dae3825fe2ea3afebc95c1..2f79ec7e66e9343dd9bfc442b8701c8c534fe9c8 100644 (file)
@@ -68,5 +68,10 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// Gets or sets the track.\r
         /// </summary>\r
         public int Track { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the dither method.\r
+        /// </summary>\r
+        public int DitherMethod { get; set; }\r
     }\r
 }
\ No newline at end of file
index b6b12a7ebcc69392ede8608a25cd80e98e8f0096..9de1b83411eb8d028f2e068f8c021e1b363e4730 100644 (file)
@@ -29,7 +29,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets the filter.\r
         /// </summary>\r
-        public Filters Filter { get; set; }\r
+        public Filters Filters { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the PAR\r
@@ -39,7 +39,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets the meta data.\r
         /// </summary>\r
-        public MetaData MetaData { get; set; }\r
+        public MetaData Metadata { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the sequence id.\r
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/QSV.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/QSV.cs
new file mode 100644 (file)
index 0000000..0ca1206
--- /dev/null
@@ -0,0 +1,27 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="QSV.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
+// <summary>\r
+//   The qsv.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.ApplicationServices.Interop.Json.Encode\r
+{\r
+    /// <summary>\r
+    /// The qsv.\r
+    /// </summary>\r
+    public class QSV\r
+    {\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether decode.\r
+        /// </summary>\r
+        public bool Decode { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the async depth.\r
+        /// </summary>\r
+        public int AsyncDepth { get; set; }\r
+    }\r
+}\r
index 50b874501e41bad2a4503144f6db60ca4a9f12af..1fb42f1dbc138c783c9d61d1976ea017202187b6 100644 (file)
@@ -16,38 +16,19 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
     {\r
         /// <summary>\r
         /// Gets or sets the chapter end.\r
+        /// Type is "chapter", "time", "frame", or "preview".\r
         /// </summary>\r
-        public int? ChapterEnd { get; set; }\r
+        public string Type { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the chapter start.\r
         /// </summary>\r
-        public int? ChapterStart { get; set; }\r
+        public int? Start { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the frame to start.\r
         /// </summary>\r
-        public int? FrameToStart { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the frame to stop.\r
-        /// </summary>\r
-        public int? FrameToStop { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the pts to start.\r
-        /// </summary>\r
-        public int? PtsToStart { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the pts to stop.\r
-        /// </summary>\r
-        public int? PtsToStop { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets the start at preview.\r
-        /// </summary>\r
-        public int? StartAtPreview { get; set; }\r
+        public int? End { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the seek points.\r
index 99781bf29fb342347ebc56ed92fc9759f5bee7fd..71814c9e1cc5c8b1fcfb09b7f08d2bc39cfa23de 100644 (file)
@@ -27,7 +27,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// <summary>\r
         /// Gets or sets a value indicating whether force.\r
         /// </summary>\r
-        public bool Force { get; set; }\r
+        public bool Forced { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the id.\r
index 957f3dfb801f2bbd5ce7efa6bc29d2073b4e3cef..6844eaf0df62b1032a7d906277e0d680698c7743 100644 (file)
@@ -9,17 +9,23 @@
 \r
 namespace HandBrake.ApplicationServices.Interop.Json.Encode\r
 {\r
-    using System;\r
-\r
     /// <summary>\r
     /// The video.\r
     /// </summary>\r
     public class Video\r
     {\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="Video"/> class.\r
+        /// </summary>\r
+        public Video()\r
+        {\r
+            this.QSV = new QSV();\r
+        }\r
+\r
         /// <summary>\r
         /// Gets or sets the codec.\r
         /// </summary>\r
-        public int Codec { get; set; }\r
+        public int Encoder { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets the level.\r
@@ -70,5 +76,20 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
         /// Gets or sets the tune.\r
         /// </summary>\r
         public string Tune { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether open cl.\r
+        /// </summary>\r
+        public bool OpenCL { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether hw decode.\r
+        /// </summary>\r
+        public bool HWDecode { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the qsv.\r
+        /// </summary>\r
+        public QSV QSV { get; set; }\r
     }\r
 }
\ No newline at end of file
index 2ec14a1e20a8be87ff3b0bc17e8b5381dbef1dca..52fc9636a177fe10db94d1d9379a3354a6c6e45f 100644 (file)
@@ -57,12 +57,12 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                     SequenceID = 0, \r
                     Audio = CreateAudio(job), \r
                     Destination = CreateDestination(job), \r
-                    Filter = CreateFilter(job), \r
+                    Filters = CreateFilter(job), \r
                     PAR = CreatePAR(job), \r
-                    MetaData = CreateMetaData(job),\r
+                    Metadata = CreateMetaData(job),\r
                     Source = CreateSource(job, configuration), \r
-                    Subtitle = CreateSubtitle(job), \r
-                    Video = CreateVideo(job)\r
+                    Subtitle = CreateSubtitle(job),\r
+                    Video = CreateVideo(job, configuration)\r
                 };\r
 \r
             return encode;\r
@@ -86,21 +86,25 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
             switch (job.PointToPointMode)\r
             {\r
                 case PointToPointMode.Chapters:\r
-                    range.ChapterEnd = job.EndPoint;\r
-                    range.ChapterStart = job.StartPoint;\r
+                    range.Type = "chapter";\r
+                    range.End = job.EndPoint;\r
+                    range.Start = job.StartPoint;\r
                     break;\r
                 case PointToPointMode.Seconds:\r
-                    range.PtsToStart = job.StartPoint * 90000;\r
-                    range.PtsToStop = (job.EndPoint - job.StartPoint) * 90000; \r
+                    range.Type = "time";\r
+                    range.Start = job.StartPoint * 90000;\r
+                    range.End = (job.EndPoint - job.StartPoint) * 90000; \r
                     break;\r
                 case PointToPointMode.Frames:\r
-                    range.FrameToStart = job.StartPoint;\r
-                    range.FrameToStop = job.EndPoint; \r
+                    range.Type = "frame";\r
+                    range.Start = job.StartPoint;\r
+                    range.End = job.EndPoint; \r
                     break;\r
                 case PointToPointMode.Preview:\r
-                    range.StartAtPreview = job.PreviewEncodeStartAt;\r
+                    range.Type = "preview";\r
+                    range.Start = job.PreviewEncodeStartAt;\r
                     range.SeekPoints = configuration.PreviewScanCount;\r
-                    range.PtsToStop = job.PreviewEncodeDuration * 90000; \r
+                    range.End = job.PreviewEncodeDuration * 90000; \r
                     break;\r
             }\r
 \r
@@ -202,7 +206,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                     }\r
                     else\r
                     {\r
-                        SubtitleList track = new SubtitleList { Burn = item.Burned, Default = item.Default, Force = item.Forced, ID = item.SourceTrack.TrackNumber, Track = (item.SourceTrack.TrackNumber - 1) };\r
+                        SubtitleList track = new SubtitleList { Burn = item.Burned, Default = item.Default, Forced = item.Forced, ID = item.SourceTrack.TrackNumber, Track = (item.SourceTrack.TrackNumber - 1) };\r
                         subtitle.SubtitleList.Add(track);\r
                     }\r
                 }\r
@@ -236,10 +240,13 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         /// <param name="job">\r
         /// The job.\r
         /// </param>\r
+        /// <param name="configuration">\r
+        /// The configuration.\r
+        /// </param>\r
         /// <returns>\r
         /// The <see cref="Video"/>.\r
         /// </returns>\r
-        private static Video CreateVideo(EncodeTask job)\r
+        private static Video CreateVideo(EncodeTask job, HBConfiguration configuration)\r
         {\r
             Video video = new Video();\r
 \r
@@ -247,7 +254,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
             Validate.NotNull(videoEncoder, "Video encoder " + job.VideoEncoder + " not recognized.");\r
             if (videoEncoder != null)\r
             {\r
-                video.Codec = videoEncoder.Id;\r
+                video.Encoder = videoEncoder.Id;\r
             }\r
 \r
             string advancedOptions = job.ShowAdvancedTab ? job.AdvancedEncoderOptions : string.Empty;\r
@@ -279,6 +286,10 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
                 }\r
             }\r
 \r
+            video.OpenCL = configuration.ScalingMode == VideoScaler.BicubicCl;\r
+            video.HWDecode = configuration.EnableDxva;\r
+            video.QSV.Decode = !configuration.DisableQuickSyncDecoding;\r
+\r
             return video;\r
         }\r
 \r
@@ -295,17 +306,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
         {\r
             Audio audio = new Audio();\r
 \r
-            int copyMask = 0;\r
-            if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMask = (int)NativeConstants.HB_ACODEC_AAC_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMask |= (int)NativeConstants.HB_ACODEC_AC3_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMask |= (int)NativeConstants.HB_ACODEC_DCA_HD_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMask |= (int)NativeConstants.HB_ACODEC_DCA_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMask |= (int)NativeConstants.HB_ACODEC_EAC3_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMask |= (int)NativeConstants.HB_ACODEC_FLAC_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMask |= (int)NativeConstants.HB_ACODEC_MP3_PASS;\r
-            if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMask |= (int)NativeConstants.HB_ACODEC_TRUEHD_PASS;\r
-\r
-            audio.CopyMask = copyMask; \r
+            List<string> copyMaskList = new List<string>();\r
+            if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add("copy:aac");\r
+            if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add("copy:ac3");\r
+            if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add("copy:dtshd");\r
+            if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMaskList.Add("copy:dts");\r
+            if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMaskList.Add("copy:eac3");\r
+            if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add("copy:flac");\r
+            if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add("copy:mp3");\r
+            if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add("copy:truehd");\r
+            audio.CopyMask = copyMaskList.ToArray(); \r
+\r
             HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback));\r
             audio.FallbackEncoder = audioEncoder.Id;\r
 \r
index d74a8f72ab955879e396fe9dd972cbdce7d65d6b..2e8e3f05f64a869b6c2e3388dc0686e8f2520cc1 100644 (file)
@@ -49,22 +49,6 @@ namespace HandBrake.ApplicationServices.Utilities
             }\r
         }\r
 \r
-        /// <summary>\r
-        /// Gets a value indicating whether is lib hb present.\r
-        /// </summary>\r
-        public static bool IsLibHbPresent\r
-        {\r
-            get\r
-            {\r
-                if (isLibHbPresent == null)\r
-                {\r
-                    isLibHbPresent = File.Exists(Path.Combine(Application.StartupPath, "hb.dll"));\r
-                }\r
-\r
-                return isLibHbPresent.Value;\r
-            }\r
-        }\r
-\r
         #endregion\r
 \r
         #region Public Methods\r
index fc05244a4974f3a8205a217cc60ec0efaf833908..ffe00d679f25c6f6299a3da20632dd21c8a9f0e7 100644 (file)
@@ -71,11 +71,6 @@ namespace HandBrake.ApplicationServices.Utilities
             {\r
                 try\r
                 {\r
-                    if (!GeneralUtilities.IsLibHbPresent)\r
-                    {\r
-                        return false; // Feature is disabled.\r
-                    }\r
-\r
                     return HBFunctions.hb_qsv_available() == 1;\r
                 }\r
                 catch (Exception)\r
index 5f1193cc79119cccbb435565375dd1769c7c0e61..14ff6cd7026419ed3153bd459aa50c62dc1c36f9 100644 (file)
@@ -1033,11 +1033,6 @@ namespace HandBrakeWPF.ViewModels
         /// </returns>\r
         private string GetActualx264Query()\r
         {\r
-            if (!GeneralUtilities.IsLibHbPresent)\r
-            {\r
-                return string.Empty; // Feature is disabled.\r
-            }\r
-\r
             string preset = this.VideoPreset != null ? this.VideoPreset.ShortName : string.Empty;\r
             string profile = this.VideoProfile != null ? this.VideoProfile.ShortName : string.Empty; \r
 \r