]> granicus.if.org Git - handbrake/commitdiff
WinGui: Add Support for the VCE Encoders.
authorsr55 <sr55.hb@outlook.com>
Fri, 8 Jun 2018 22:04:22 +0000 (23:04 +0100)
committersr55 <sr55.hb@outlook.com>
Fri, 8 Jun 2018 22:04:22 +0000 (23:04 +0100)
win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs
win/CS/HandBrake.Interop/Interop/Model/Encoding/VideoEncoder.cs
win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs
win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs

index c55c8a927d2ab79326bafe5a0d9eb12f696951e1..65b81c50935afdbd4785969f24f25876a3aae0bb 100644 (file)
@@ -409,6 +409,12 @@ namespace HandBrake.Interop.Interop.HbLib
         [DllImport("hb", EntryPoint = "hb_qsv_info_init", CallingConvention = CallingConvention.Cdecl)]
         public static extern int hb_qsv_info_init();
 
+        [DllImport("hb", EntryPoint = "hb_vce_h264_available", CallingConvention = CallingConvention.Cdecl)]
+        public static extern int hb_vce_h264_available();
+
+        [DllImport("hb", EntryPoint = "hb_vce_h265_available", CallingConvention = CallingConvention.Cdecl)]
+        public static extern int hb_vce_h265_available();
+
         // hb_image_t* hb_get_preview2(hb_handle_t* h, int title_idx, int picture, hb_geometry_settings_t* geo, int deinterlace);
         [DllImport("hb", EntryPoint = "hb_get_preview2", CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx,  ref hb_geometry_settings_s geo, int deinterlace);
index aacec1bcf34f7524da67db23159b0604362c0f87..dbf96aeda4313c7fba1dd333e890b3cea5f17e81 100644 (file)
@@ -51,6 +51,10 @@ namespace HandBrake.Interop.Interop.HbLib
         public const uint HB_VCODEC_QSV_H265_10BIT = 0x0000400;
         public const uint HB_VCODEC_QSV_MASK = 0x0000F00;
 
+        public const uint HB_VCODEC_FFMPEG_VCE_H264 = 0x00040000;
+        public const uint HB_VCODEC_FFMPEG_VCE_H265 = 0x00080000;
+        public const uint HB_VCODEC_FFMPEG_MASK = (0x00000F0 | HB_VCODEC_FFMPEG_VCE_H264 | HB_VCODEC_FFMPEG_VCE_H265);
+
         // Encode state
         public const int HB_STATE_IDLE = 1;
         public const int HB_STATE_SCANNING = 2;
index 68c09d0d11ae647391d167b3e758b0ea3f503933..a5aded796ea726818f935cd27e0d34fa9d58ca75 100644 (file)
@@ -28,6 +28,10 @@ namespace HandBrake.Interop.Interop.Model.Encoding
         [ShortName("qsv_h264")]
         QuickSync,
 
+        [DisplayName("H.264 (AMD VCE)")]
+        [ShortName("vce_h264")]
+        VceH264,    
+
         [DisplayName("MPEG-4")]
         [ShortName("mpeg4")]
         FFMpeg,
@@ -60,6 +64,10 @@ namespace HandBrake.Interop.Interop.Model.Encoding
         [ShortName("qsv_h265_10bit")]
         QuickSyncH26510b,
 
+        [DisplayName("H.265 (AMD VCE)")]
+        [ShortName("vce_h265")]
+        VceH265,
+
         [DisplayName("VP8")]
         [ShortName("VP8")]
         VP8,
index af0c247247c1a0af11e96f3f5d54a8ad21aa2056..a364c50ac3452ebffaaabc7d4df395420b37d3e0 100644 (file)
@@ -90,5 +90,37 @@ namespace HandBrake.Interop.Utilities
                 }
             }
         }
+
+        public static bool IsVceH264Available
+        {
+            get
+            {
+                try
+                {
+                    return HBFunctions.hb_vce_h264_available() != 0;
+                }
+                catch (Exception)
+                {
+                    // Silent failure. Typically this means the dll hasn't been built with --enable-qsv
+                    return false;
+                }
+            }
+        }
+
+        public static bool IsVceH265Available
+        {
+            get
+            {
+                try
+                {
+                    return HBFunctions.hb_vce_h265_available() != 0;
+                }
+                catch (Exception)
+                {
+                    // Silent failure. Typically this means the dll hasn't been built with --enable-qsv
+                    return false;
+                }
+            }
+        }
     }
 }
index 285b1a3732ca432982fa436a00ee161b7247b6c9..42ccf1c10048c364a2621fff6f14e4f74941a003 100644 (file)
@@ -91,6 +91,16 @@ namespace HandBrakeWPF.Converters.Video
                     encoders.Remove(VideoEncoder.QuickSyncH26510b);\r
                 }\r
 \r
+                if (!SystemInfo.IsVceH264Available)\r
+                {\r
+                    encoders.Remove(VideoEncoder.VceH264);\r
+                }\r
+\r
+                if (!SystemInfo.IsVceH265Available)\r
+                {\r
+                    encoders.Remove(VideoEncoder.VceH265);\r
+                }\r
+\r
                 return EnumHelper<VideoEncoder>.GetEnumDisplayValuesSubset(encoders);\r
             }\r
 \r
index 1ee4665defdf1a01238c8f8a7d42937b2c2a429d..8396a584f1d4a51d5ef52757ab880a630a6fadac 100644 (file)
@@ -295,7 +295,11 @@ namespace HandBrakeWPF.Services.Encode.Factories
                 }
             }
 
-            if (job.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) video.Quality = job.Quality;
+            if (job.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
+            {
+                video.Quality = job.Quality;
+            }
+
             if (job.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate)
             {
                 video.Bitrate = job.VideoBitrate;
@@ -306,7 +310,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
             video.QSV.Decode = SystemInfo.IsQsvAvailable && configuration.EnableQuickSyncDecoding;
 
             // The use of the QSV decoder is configurable for non QSV encoders.
-            if (video.QSV.Decode && job.VideoEncoder != VideoEncoder.QuickSync && job.VideoEncoder != VideoEncoder.QuickSyncH265)
+            if (video.QSV.Decode && job.VideoEncoder != VideoEncoder.QuickSync && job.VideoEncoder != VideoEncoder.QuickSyncH265 && job.VideoEncoder != VideoEncoder.QuickSyncH26510b)
             {
                 video.QSV.Decode = configuration.UseQSVDecodeForNonQSVEnc;
             }
index 18f07e06d4b3471c56579938016eb92f6811c1b8..4bd5b777d42efa78580e0b7d352a33cdde2b12e5 100644 (file)
@@ -347,6 +347,8 @@ namespace HandBrakeWPF.ViewModels
                         break;\r
                     case VideoEncoder.QuickSync:\r
                     case VideoEncoder.QuickSyncH265:\r
+                    case VideoEncoder.VceH264:\r
+                    case VideoEncoder.VceH265:\r
                         rfValue = 51.0 - value;\r
                         rfValue = Math.Round(rfValue, 0);\r
                         this.Task.Quality = rfValue;\r
@@ -588,6 +590,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 return this.displayOptimiseOptions;\r
             }\r
+\r
             set\r
             {\r
                 this.displayOptimiseOptions = value;\r
@@ -605,6 +608,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 return this.displayNonQsvControls;\r
             }\r
+\r
             set\r
             {\r
                 if (value.Equals(this.displayNonQsvControls))\r
@@ -972,7 +976,8 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 if (preset.Task.VideoEncoder == VideoEncoder.X264 || preset.Task.VideoEncoder == VideoEncoder.X264_10\r
                     || preset.Task.VideoEncoder == VideoEncoder.X265 || preset.Task.VideoEncoder == VideoEncoder.X265_10 || preset.Task.VideoEncoder == VideoEncoder.X265_12\r
-                    || preset.Task.VideoEncoder == VideoEncoder.QuickSync || preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265 || preset.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b)\r
+                    || preset.Task.VideoEncoder == VideoEncoder.QuickSync || preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265 || preset.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b\r
+                    || preset.Task.VideoEncoder == VideoEncoder.VceH264 || preset.Task.VideoEncoder == VideoEncoder.VceH265)\r
                 {\r
                     this.VideoLevel = preset.Task.VideoLevel != null ? preset.Task.VideoLevel.Clone() : this.VideoLevels.FirstOrDefault();\r
                     this.VideoProfile = preset.Task.VideoProfile != null ? preset.Task.VideoProfile.Clone() : this.VideoProfiles.FirstOrDefault();\r
@@ -1084,8 +1089,8 @@ namespace HandBrakeWPF.ViewModels
             if (this.Task.VideoEncoder == VideoEncoder.X264 || this.Task.VideoEncoder == VideoEncoder.X264_10\r
                 || this.Task.VideoEncoder == VideoEncoder.X265 || this.Task.VideoEncoder == VideoEncoder.X265_10\r
                 || this.Task.VideoEncoder == VideoEncoder.X265_12 || this.Task.VideoEncoder == VideoEncoder.QuickSync\r
-                || this.Task.VideoEncoder == VideoEncoder.QuickSyncH265\r
-                || this.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b)\r
+                || this.Task.VideoEncoder == VideoEncoder.QuickSyncH265 || this.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b\r
+                || this.Task.VideoEncoder == VideoEncoder.VceH264 || this.Task.VideoEncoder == VideoEncoder.VceH265)\r
             {\r
                 if (!Equals(preset.Task.VideoPreset, this.Task.VideoPreset))\r
                 {\r
@@ -1176,6 +1181,8 @@ namespace HandBrakeWPF.ViewModels
                     break;\r
                 case VideoEncoder.QuickSync:\r
                 case VideoEncoder.QuickSyncH265:\r
+                case VideoEncoder.VceH264:\r
+                case VideoEncoder.VceH265:\r
                     this.QualityMin = 0;\r
                     this.QualityMax = 51;\r
                     break;\r
@@ -1298,6 +1305,7 @@ namespace HandBrakeWPF.ViewModels
                         int.TryParse(quality.Value.ToString(CultureInfo.InvariantCulture), out cq);\r
                         this.RF = 63 - cq;\r
                     }\r
+\r
                     break;\r
                 case VideoEncoder.X265:\r
                 case VideoEncoder.X265_10:\r
@@ -1307,10 +1315,15 @@ namespace HandBrakeWPF.ViewModels
                 case VideoEncoder.QuickSync:\r
                 case VideoEncoder.QuickSyncH265:\r
                 case VideoEncoder.QuickSyncH26510b:\r
-                    if (this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265)\r
+                case VideoEncoder.VceH264:\r
+                case VideoEncoder.VceH265:\r
+\r
+                    if (this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265 || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b\r
+                        || this.SelectedVideoEncoder == VideoEncoder.VceH264 || this.SelectedVideoEncoder == VideoEncoder.VceH265)\r
                     {\r
                         cqStep = 1;\r
                     }\r
+\r
                     double multiplier = 1.0 / cqStep;\r
                     if (quality.HasValue)\r
                     {\r
@@ -1327,6 +1340,7 @@ namespace HandBrakeWPF.ViewModels
                     {\r
                         this.RF = (int)quality.Value;\r
                     }\r
+\r
                     break;\r
             }\r
         }\r
@@ -1426,16 +1440,27 @@ namespace HandBrakeWPF.ViewModels
             this.SetQualitySliderBounds();\r
 \r
             // Update control display\r
-            this.UseAdvancedTab = selectedEncoder != VideoEncoder.QuickSync && selectedEncoder != VideoEncoder.QuickSyncH265 && selectedEncoder != VideoEncoder.QuickSyncH26510b && this.UseAdvancedTab;\r
+            this.UseAdvancedTab = selectedEncoder != VideoEncoder.QuickSync && selectedEncoder != VideoEncoder.QuickSyncH265 && selectedEncoder != VideoEncoder.QuickSyncH26510b\r
+                               && selectedEncoder != VideoEncoder.VceH264 && selectedEncoder != VideoEncoder.VceH265  && this.UseAdvancedTab;\r
+\r
             this.DisplayOptimiseOptions = this.SelectedVideoEncoder == VideoEncoder.X264 || this.SelectedVideoEncoder == VideoEncoder.X264_10 ||\r
                                           this.SelectedVideoEncoder == VideoEncoder.X265 || this.SelectedVideoEncoder == VideoEncoder.X265_10 || this.SelectedVideoEncoder == VideoEncoder.X265_12 ||\r
                                           this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265 || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b ||\r
+                                          this.SelectedVideoEncoder == VideoEncoder.VceH264 || this.SelectedVideoEncoder == VideoEncoder.VceH265 ||\r
                                           this.SelectedVideoEncoder == VideoEncoder.VP8 || this.SelectedVideoEncoder == VideoEncoder.VP9;\r
+\r
             this.DisplayNonQSVControls = this.SelectedVideoEncoder != VideoEncoder.QuickSync && this.SelectedVideoEncoder != VideoEncoder.QuickSyncH265 && this.SelectedVideoEncoder != VideoEncoder.QuickSyncH26510b;\r
+\r
             this.DisplayTurboFirstPass = selectedEncoder == VideoEncoder.X264 || selectedEncoder == VideoEncoder.X264_10 ||\r
                                          selectedEncoder == VideoEncoder.X265 || selectedEncoder == VideoEncoder.X265_10 || selectedEncoder == VideoEncoder.X265_12;\r
-            this.DisplayTuneControls = SelectedVideoEncoder == VideoEncoder.X264 || SelectedVideoEncoder == VideoEncoder.X264_10 || SelectedVideoEncoder == VideoEncoder.X265 || SelectedVideoEncoder == VideoEncoder.X265_10 || SelectedVideoEncoder == VideoEncoder.X265_12;\r
-            this.DisplayLevelControl = SelectedVideoEncoder == VideoEncoder.X264 || SelectedVideoEncoder == VideoEncoder.X264_10 || this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265 || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b;\r
+\r
+            this.DisplayTuneControls = this.SelectedVideoEncoder == VideoEncoder.X264 || this.SelectedVideoEncoder == VideoEncoder.X264_10 || \r
+                                       this.SelectedVideoEncoder == VideoEncoder.X265 || this.SelectedVideoEncoder == VideoEncoder.X265_10 || this.SelectedVideoEncoder == VideoEncoder.X265_12;\r
+\r
+            this.DisplayLevelControl = this.SelectedVideoEncoder == VideoEncoder.X264 || this.SelectedVideoEncoder == VideoEncoder.X264_10 || \r
+                                       this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265 || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b ||\r
+                                       this.SelectedVideoEncoder == VideoEncoder.VceH264 || this.SelectedVideoEncoder == VideoEncoder.VceH265;\r
+\r
             this.DisplayProfileControl = this.SelectedVideoEncoder == VideoEncoder.X264\r
                                          || this.SelectedVideoEncoder == VideoEncoder.X264_10\r
                                          || this.SelectedVideoEncoder == VideoEncoder.X265\r
@@ -1443,7 +1468,9 @@ namespace HandBrakeWPF.ViewModels
                                          || this.SelectedVideoEncoder == VideoEncoder.X265_12\r
                                          || this.SelectedVideoEncoder == VideoEncoder.QuickSync\r
                                          || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265\r
-                                         || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b;\r
+                                         || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b\r
+                                         || this.SelectedVideoEncoder == VideoEncoder.VceH264\r
+                                         || this.SelectedVideoEncoder == VideoEncoder.VceH265;\r
 \r
             // Refresh Display\r
             this.NotifyOfPropertyChange(() => this.Rfqp);\r