From 79825db0caa3a5d7cd6293eefdc095e7884b1b56 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 29 Jun 2018 21:23:07 +0100 Subject: WinGui: Extend the "Video" preference tab to allow the hardware encoders to be disabled. --- .../Converters/Video/VideoEncoderConverter.cs | 24 ++- .../Properties/ResourcesUI.Designer.cs | 36 ++++ win/CS/HandBrakeWPF/Properties/ResourcesUI.resx | 12 ++ win/CS/HandBrakeWPF/UserSettingConstants.cs | 212 +-------------------- win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 93 +++++++-- win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 25 +-- win/CS/HandBrakeWPF/Views/OptionsView.xaml | 8 +- win/CS/HandBrakeWPF/Views/VideoView.xaml | 1 + win/CS/HandBrakeWPF/defaultsettings.xml | 25 +++ 9 files changed, 198 insertions(+), 238 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs index 40131ddb3..12ce80eca 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.Converters.Video using HandBrake.Interop.Interop; using HandBrake.Interop.Interop.Model.Encoding; + using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.Utilities; using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask; @@ -49,8 +50,17 @@ namespace HandBrakeWPF.Converters.Video /// public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - if (values.Count() == 2) + if (values.Count() >= 2) { + IUserSettingService userSettingService = values[2] as IUserSettingService; + bool isQsvEnabled = false, isVceEnabled = false, isNvencEnabled = false; + if (userSettingService != null) + { + isQsvEnabled = userSettingService.GetUserSetting(UserSettingConstants.EnableQuickSyncEncoding); + isVceEnabled = userSettingService.GetUserSetting(UserSettingConstants.EnableVceEncoder); + isNvencEnabled = userSettingService.GetUserSetting(UserSettingConstants.EnableNvencEncoder); + } + List encoders = EnumHelper.GetEnumList().ToList(); EncodeTask task = values[1] as EncodeTask; @@ -76,12 +86,12 @@ namespace HandBrakeWPF.Converters.Video encoders.Remove(VideoEncoder.VP9); } - if (!SystemInfo.IsQsvAvailableH264) + if (!isQsvEnabled || !SystemInfo.IsQsvAvailableH264) { encoders.Remove(VideoEncoder.QuickSync); } - if (!SystemInfo.IsQsvAvailableH265) + if (!isQsvEnabled || !SystemInfo.IsQsvAvailableH265) { encoders.Remove(VideoEncoder.QuickSyncH265); encoders.Remove(VideoEncoder.QuickSyncH26510b); @@ -91,22 +101,22 @@ namespace HandBrakeWPF.Converters.Video encoders.Remove(VideoEncoder.QuickSyncH26510b); } - if (!SystemInfo.IsVceH264Available) + if (!isVceEnabled || !SystemInfo.IsVceH264Available) { encoders.Remove(VideoEncoder.VceH264); } - if (!SystemInfo.IsVceH265Available) + if (!isVceEnabled || !SystemInfo.IsVceH265Available) { encoders.Remove(VideoEncoder.VceH265); } - if (!SystemInfo.IsNVEncH264Available) + if (!isNvencEnabled || !SystemInfo.IsNVEncH264Available) { encoders.Remove(VideoEncoder.NvencH264); } - if (!SystemInfo.IsNVEncH265Available) + if (!isNvencEnabled || !SystemInfo.IsNVEncH265Available) { encoders.Remove(VideoEncoder.NvencH265); } diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index cc359053b..bbdb6e97e 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -1347,6 +1347,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Encoding. + /// + public static string Options_Encoding { + get { + return ResourceManager.GetString("Options_Encoding", resourceCulture); + } + } + /// /// Looks up a localized string similar to File Format:. /// @@ -1671,6 +1680,33 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Enable Nvidia NVENC Encoder. + /// + public static string OptionsView_EnableNvencEncoding { + get { + return ResourceManager.GetString("OptionsView_EnableNvencEncoding", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Enable Intel QuickSync Encoder. + /// + public static string OptionsView_EnableQuicksyncEncoding { + get { + return ResourceManager.GetString("OptionsView_EnableQuicksyncEncoding", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Enable AMD VCE Encoder. + /// + public static string OptionsView_EnableVceEncoding { + get { + return ResourceManager.GetString("OptionsView_EnableVceEncoding", resourceCulture); + } + } + /// /// Looks up a localized string similar to The file format entered contained invalid characters. These have been removed. . /// diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index 4e188b0ce..056a3ad67 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -1028,4 +1028,16 @@ This will not affect your current settings in the Subtitle tab. Please choose a source to encode before trying to import a subtitle file. + + Enable Nvidia NVENC Encoder + + + Enable Intel QuickSync Encoder + + + Enable AMD VCE Encoder + + + Encoding + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 9e4d37a17..cf87b6cec 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -16,255 +16,59 @@ namespace HandBrakeWPF { #region Constants and Fields - /// - /// Auto name format - /// public const string AutoNameFormat = "autoNameFormat"; - - /// - /// Autoname path - /// public const string AutoNamePath = "autoNamePath"; - - /// - /// Auto Name Remove underscore - /// public const string AutoNameRemoveUnderscore = "AutoNameRemoveUnderscore"; - - /// - /// Auto Name Title Case - /// public const string AutoNameTitleCase = "AutoNameTitleCase"; - - /// - /// Auto Naming - /// public const string AutoNaming = "autoNaming"; - - /// - /// Clear old logs - /// public const string ClearOldLogs = "clearOldLogs"; - - /// - /// Update check interval - /// public const string DaysBetweenUpdateCheck = "daysBetweenUpdateCheck"; - - /// - /// Use Default Player - /// public const string DefaultPlayer = "defaultPlayer"; - - /// - /// Last Update Check - /// public const string LastUpdateCheckDate = "lastUpdateCheckDate"; - - /// - /// Main Window Minimize - /// public const string MainWindowMinimize = "MainWindowMinimize"; - - /// - /// Min Title Length - /// public const string MinTitleLength = "MinTitleLength"; - - /// - /// Update Status - /// public const string UpdateStatus = "updateStatus"; - - /// - /// Use m4v - /// public const string UseM4v = "useM4v"; - - /// - /// Vlc Path - /// public const string VLCPath = "VLC_Path"; - - /// - /// The Instance Id - /// public const string InstanceId = "InstanceId"; - - /// - /// The X264 Stepper - /// public const string X264Step = "X264Step"; - - /// - /// The show advanced tab. - /// public const string ShowAdvancedTab = "ShowAdvancedTab"; - - /// - /// The last preview duration - /// public const string LastPreviewDuration = "LastPreviewDuration"; - - /// - /// When Complete Action - /// public const string WhenCompleteAction = "WhenCompleteAction"; - - /// - /// Send file enabled. - /// public const string SendFile = "SendFile"; - - /// - /// Send file to application path - /// public const string SendFileTo = "SendFileTo"; - - /// - /// Send file to arguments - /// public const string SendFileToArgs = "SendFileToArgs"; - - /// - /// Prevent Sleep - /// public const string PreventSleep = "PreventSleep"; - - /// - /// Pause Queue on Low Disk Space - /// public const string PauseOnLowDiskspace = "PauseOnLowDiskspace"; - - /// - /// Low Disk Space Warning Level in Bytes. - /// public const string PauseOnLowDiskspaceLevel = "LowDiskSpaceWarningLevelInBytes"; - - /// - /// The remove punctuation. - /// public const string RemovePunctuation = "RemovePunctuation"; - - /// - /// The Show Preset Panel - /// public const string ShowPresetPanel = "ShowPresetPanelOption"; - - /// - /// The reset when done action. - /// public const string ResetWhenDoneAction = "ResetWhenDoneAction"; - - /// - /// The disable lib dvd nav. - /// public const string DisableLibDvdNav = "DisableLibDvdNav"; - - /// - /// The disable quick sync decoding. - /// public const string EnableQuickSyncDecoding = "EnableQuickSyncDecoding"; - - /// - /// Setting indicating whether to use qsv decode for non qsv encoders - /// public const string UseQSVDecodeForNonQSVEnc = "UseQSVDecodeForNonQSVEnc"; - - /// - /// The scaling mode. - /// public const string ScalingMode = "ScalingMode"; - - /// - /// Preview Scan Count - /// public const string PreviewScanCount = "previewScanCount"; - - /// - /// The Verbosity - /// public const string Verbosity = "Verbosity"; - - /// - /// Min Title Scan Duration - /// public const string MinScanDuration = "MinTitleScanDuration"; - - /// - /// Process Priority - /// public const string ProcessPriority = "ProcessPriority"; - - /// - /// Save Log Directory - /// public const string SaveLogToCopyDirectory = "SaveLogToCopyDirectory"; - - /// - /// Save log with video - /// public const string SaveLogWithVideo = "SaveLogWithVideo"; - - /// - /// Save copy of the log to a directory - /// public const string SaveLogCopyDirectory = "SaveLogCopyDirectory"; - - /// - /// The clear completed from queue. - /// public const string ClearCompletedFromQueue = "ClearCompletedFromQueue"; - - /// - /// The Show Queue in-line option. - /// public const string ShowQueueInline = "ShowQueueInline"; - - /// - /// Setting to allow mid-version upgrades of presets. - /// public const string ForcePresetReset = "ForcePresetReset"; - - /// - /// Setting to record the expansion state of preset categories. - /// public const string PresetExpandedStateList = "PresetExpandedStateList"; - - /// - /// Setting to turn on/off the ability to show status in the title bar. - /// public const string ShowStatusInTitleBar = "ShowStatusInTitleBar"; - - /// - /// Setting to turn on/off the ability to show previews in the summary tab. - /// public const string ShowPreviewOnSummaryTab = "ShowPreviewOnSummaryTab"; - - /// - /// Setting to turn on/off the ability to play a sound when an encodeis done. - /// - public static string PlaySoundWhenDone = "PlaySoundWhenDone"; - - /// - /// Setting to turn on/off the ability to play a sound when a queue is completed. - /// - public static string PlaySoundWhenQueueDone = "PlaySoundWhenQueueDone"; - - /// - /// Setting to store the file to play when done. - /// - public static string WhenDoneAudioFile = "WhenDoneAudioFile"; - - /// - /// Setting to store whether we are using a Worker Process or in-process encoding. - /// - public static string RemoteServiceEnabled = "RemoteServiceEnabled"; - - /// - /// The port that the worker process is running on. - /// - public static string RemoteServicePort = "RemoteServicePort"; + public const string PlaySoundWhenDone = "PlaySoundWhenDone"; + public const string PlaySoundWhenQueueDone = "PlaySoundWhenQueueDone"; + public const string WhenDoneAudioFile = "WhenDoneAudioFile"; + public const string RemoteServiceEnabled = "RemoteServiceEnabled"; + public const string RemoteServicePort = "RemoteServicePort"; + public const string EnableQuickSyncEncoding = "EnableQuickSyncEncoding"; + public const string EnableVceEncoder = "EnableVceEncoder"; + public const string EnableNvencEncoder = "EnableNvencEncoder"; #endregion } diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 8d542a3b0..3ad88a97e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -101,6 +101,12 @@ namespace HandBrakeWPF.ViewModels private bool playSoundWhenDone; private bool playSoundWhenQueueDone; + private bool enableQuickSyncEncoding; + + private bool enableVceEncoder; + + private bool enableNvencEncoder; + #endregion #region Constructors and Destructors @@ -986,15 +992,58 @@ namespace HandBrakeWPF.ViewModels #region Video - /// - /// Gets or sets a value indicating whether disable quick sync decoding. - /// + public bool EnableQuickSyncEncoding + { + get => this.enableQuickSyncEncoding && this.IsQuickSyncAvailable; + set + { + if (value == this.enableQuickSyncEncoding) + { + return; + } + + this.enableQuickSyncEncoding = value; + this.NotifyOfPropertyChange(() => this.EnableQuickSyncEncoding); + } + } + + public bool EnableVceEncoder + { + get => this.enableVceEncoder && this.IsVceAvailable; + set + { + if (value == this.enableVceEncoder) + { + return; + } + + this.enableVceEncoder = value; + this.NotifyOfPropertyChange(() => this.EnableVceEncoder); + } + } + + public bool EnableNvencEncoder + { + get => this.enableNvencEncoder && this.IsNvencAvailable; + set + { + if (value == this.enableNvencEncoder) + { + return; + } + + this.enableNvencEncoder = value; + this.NotifyOfPropertyChange(() => this.EnableNvencEncoder); + } + } + public bool EnableQuickSyncDecoding { get { return this.enableQuickSyncDecoding; } + set { if (value.Equals(this.enableQuickSyncDecoding)) @@ -1007,14 +1056,8 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets or sets the selected scaling mode. - /// public VideoScaler SelectedScalingMode { get; set; } - /// - /// Gets a value indicating whether is quick sync available. - /// public bool IsQuickSyncAvailable { get @@ -1023,6 +1066,23 @@ namespace HandBrakeWPF.ViewModels } } + public bool IsVceAvailable + { + get + { + string foundGpu = Utilities.SystemInfo.GetGPUInfo.FirstOrDefault(g => g.Contains("AMD")); + return SystemInfo.IsVceH264Available && !string.IsNullOrEmpty(foundGpu); + } + } + + public bool IsNvencAvailable + { + get + { + return SystemInfo.IsNVEncH264Available; + } + } + /// /// Gets a value indicating whether is use qsv dec available. /// @@ -1034,15 +1094,13 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets or sets a value indicating whether to use qsv decode for non qsv encoders - /// public bool UseQSVDecodeForNonQSVEnc { get { return this.useQsvDecodeForNonQsvEnc; } + set { if (value == this.useQsvDecodeForNonQsvEnc) return; @@ -1051,9 +1109,6 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets the scaling options. - /// public BindingList ScalingOptions { get @@ -1348,6 +1403,10 @@ namespace HandBrakeWPF.ViewModels this.SelectedScalingMode = this.userSettingService.GetUserSetting(UserSettingConstants.ScalingMode); this.UseQSVDecodeForNonQSVEnc = this.userSettingService.GetUserSetting(UserSettingConstants.UseQSVDecodeForNonQSVEnc); + this.EnableQuickSyncEncoding = this.userSettingService.GetUserSetting(UserSettingConstants.EnableQuickSyncEncoding); + this.EnableVceEncoder = this.userSettingService.GetUserSetting(UserSettingConstants.EnableVceEncoder); + this.EnableNvencEncoder = this.userSettingService.GetUserSetting(UserSettingConstants.EnableNvencEncoder); + // ############################# // CLI // ############################# @@ -1484,6 +1543,10 @@ namespace HandBrakeWPF.ViewModels this.userSettingService.SetUserSetting(UserSettingConstants.ScalingMode, this.SelectedScalingMode); this.userSettingService.SetUserSetting(UserSettingConstants.UseQSVDecodeForNonQSVEnc, this.UseQSVDecodeForNonQSVEnc); + this.userSettingService.SetUserSetting(UserSettingConstants.EnableQuickSyncEncoding, this.EnableQuickSyncEncoding); + this.userSettingService.SetUserSetting(UserSettingConstants.EnableVceEncoder, this.EnableVceEncoder); + this.userSettingService.SetUserSetting(UserSettingConstants.EnableNvencEncoder, this.EnableNvencEncoder); + /* System and Logging */ userSettingService.SetUserSetting(UserSettingConstants.ProcessPriority, this.SelectedPriority); userSettingService.SetUserSetting(UserSettingConstants.PreventSleep, this.PreventSleep); diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 74ac53a85..7c14e1594 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -101,6 +101,8 @@ namespace HandBrakeWPF.ViewModels #region Public Properties + public IUserSettingService UserSettingService => this.userSettingService; + /// /// Gets or sets the current Encode Task. /// @@ -530,17 +532,6 @@ namespace HandBrakeWPF.ViewModels } } - private void HandleRFChange() - { - double displayRF = this.DisplayRF; - if (displayRF > this.QualityMax || displayRF < this.QualityMin) - { - displayRF = this.qualityMax / 2; - } - - this.SetRF(displayRF); - } - /// /// Gets or sets a value indicating whether ShowPeakFramerate. /// @@ -1279,6 +1270,7 @@ namespace HandBrakeWPF.ViewModels if (e.Key == UserSettingConstants.ShowAdvancedTab) { this.NotifyOfPropertyChange(() => this.IsAdvancedTabOptionEnabled); + this.NotifyOfPropertyChange(() => this.VideoEncoders); } } @@ -1507,5 +1499,16 @@ namespace HandBrakeWPF.ViewModels string result; this.ExtraArguments = this.encoderOptions.TryGetValue(EnumHelper.GetShortName(selectedEncoder), out result) ? result : string.Empty; } + + private void HandleRFChange() + { + double displayRF = this.DisplayRF; + if (displayRF > this.QualityMax || displayRF < this.QualityMin) + { + displayRF = this.qualityMax / 2; + } + + this.SetRF(displayRF); + } } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index cf2c877e5..aa728d6c3 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -237,8 +237,14 @@ - + + + + + + + diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml index ac615b18b..8c55b293a 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml @@ -52,6 +52,7 @@ + diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index 853cf5396..d9f47ac91 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -536,4 +536,29 @@ 8080 + + + + EnableQuickSyncEncoding + + + true + + + + + EnableVceEncoder + + + true + + + + + EnableNvencEncoder + + + true + + \ No newline at end of file -- cgit v1.2.3