From e3a2f723adc662f1ba5707cdeeea62449c70fd7d Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 8 Jul 2018 18:23:50 +0100 Subject: WinGui: Simplify the Deinterlace / Decomb / Interlace Detection Tab and associated code. Tweak the layout of the deinterlace controls to match the Mac/Linux UI's. Pull Presets from libhb. --- win/CS/HandBrake.Interop/HandBrake.Interop.csproj | 6 +- .../Interop/Model/Encoding/Decomb.cs | 34 -- .../Interop/Model/Encoding/Deinterlace.cs | 31 -- .../Interop/Model/Encoding/HBPresetTune.cs | 46 +-- .../HandBrakeWPF/Converters/EnumComboConverter.cs | 24 -- .../Services/Encode/Factories/EncodeTaskFactory.cs | 4 +- .../Services/Encode/Model/EncodeTask.cs | 20 +- .../Presets/Factories/JsonPresetFactory.cs | 71 +--- win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 362 +++++++-------------- win/CS/HandBrakeWPF/Views/FiltersView.xaml | 73 ++--- 10 files changed, 179 insertions(+), 492 deletions(-) delete mode 100644 win/CS/HandBrake.Interop/Interop/Model/Encoding/Decomb.cs delete mode 100644 win/CS/HandBrake.Interop/Interop/Model/Encoding/Deinterlace.cs diff --git a/win/CS/HandBrake.Interop/HandBrake.Interop.csproj b/win/CS/HandBrake.Interop/HandBrake.Interop.csproj index f7e9aa9b6..f279c9123 100644 --- a/win/CS/HandBrake.Interop/HandBrake.Interop.csproj +++ b/win/CS/HandBrake.Interop/HandBrake.Interop.csproj @@ -114,6 +114,8 @@ + + @@ -136,10 +138,6 @@ - - - - diff --git a/win/CS/HandBrake.Interop/Interop/Model/Encoding/Decomb.cs b/win/CS/HandBrake.Interop/Interop/Model/Encoding/Decomb.cs deleted file mode 100644 index 1fe70b421..000000000 --- a/win/CS/HandBrake.Interop/Interop/Model/Encoding/Decomb.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// Defines the Decomb type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.Interop.Interop.Model.Encoding -{ - using HandBrake.Interop.Attributes; - - /// - /// The decomb. - /// - public enum Decomb - { - [ShortName("default")] - Default, - - [ShortName("bob")] - Bob, - - [ShortName("custom")] - Custom, - - [ShortName("eedi2")] - EEDI2, - - [ShortName("eedi2bob")] - EEDI2Bob - } -} diff --git a/win/CS/HandBrake.Interop/Interop/Model/Encoding/Deinterlace.cs b/win/CS/HandBrake.Interop/Interop/Model/Encoding/Deinterlace.cs deleted file mode 100644 index 07c519a35..000000000 --- a/win/CS/HandBrake.Interop/Interop/Model/Encoding/Deinterlace.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// Defines the Deinterlace type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.Interop.Interop.Model.Encoding -{ - using HandBrake.Interop.Attributes; - - /// - /// The deinterlace. - /// - public enum Deinterlace - { - [ShortName("custom")] - Custom, - - [ShortName("default")] - Default, - - [ShortName("skip-spatial")] - SkipSpatialCheck, - - [ShortName("bob")] - Bob - } -} diff --git a/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBPresetTune.cs b/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBPresetTune.cs index 2954128d7..8f62b30ac 100644 --- a/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBPresetTune.cs +++ b/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBPresetTune.cs @@ -3,40 +3,44 @@ // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // -// Defines the HBPresetTune type. +// An object represetning the key and name of a Filter Preset or Tune option. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrake.Interop.Interop.Model.Encoding { - /// - /// The hb preset tune. - /// public class HBPresetTune { - /// - /// Initializes a new instance of the class. - /// - /// - /// The name. - /// - /// - /// The short Name. - /// + public HBPresetTune() + { + } + public HBPresetTune(string name, string shortName) { this.Name = name; this.ShortName = shortName; } - /// - /// Gets the name. - /// - public string Name { get; private set; } + public string Name { get; set; } + + public string ShortName { get; set; } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return this.Equals((HBPresetTune)obj); + } + + public override int GetHashCode() + { + return this.ShortName != null ? this.ShortName.GetHashCode() : 0; + } - /// - /// Gets the short name. - /// - public string ShortName { get; private set; } + protected bool Equals(HBPresetTune other) + { + return string.Equals(this.ShortName, other.ShortName); + } } } diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs index ff6f71156..644417b26 100644 --- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -59,14 +59,6 @@ namespace HandBrakeWPF.Converters { return EnumHelper.GetEnumDisplayValues(typeof(PresetPictureSettingsMode)); } - if (value is IEnumerable) - { - return EnumHelper.GetEnumDisplayValues(typeof(Decomb)); - } - if (value is IEnumerable) - { - return EnumHelper.GetEnumDisplayValues(typeof(Deinterlace)); - } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(Detelecine)); @@ -105,18 +97,10 @@ namespace HandBrakeWPF.Converters { return EnumHelper.GetDisplay((PresetPictureSettingsMode)value); } - if (targetType == typeof(Deinterlace) || value.GetType() == typeof(Deinterlace)) - { - return EnumHelper.GetDisplay((Deinterlace)value); - } if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine)) { return EnumHelper.GetDisplay((Detelecine)value); } - if (targetType == typeof(Decomb) || value.GetType() == typeof(Decomb)) - { - return EnumHelper.GetDisplay((Decomb)value); - } if (targetType == typeof(Denoise) || value.GetType() == typeof(Denoise)) { return EnumHelper.GetDisplay((Denoise)value); @@ -187,14 +171,6 @@ namespace HandBrakeWPF.Converters { return EnumHelper.GetValue(value.ToString()); } - if (targetType == typeof(Decomb) || value.GetType() == typeof(Decomb)) - { - return EnumHelper.GetValue(value.ToString()); - } - if (targetType == typeof(Deinterlace) || value.GetType() == typeof(Deinterlace)) - { - return EnumHelper.GetValue(value.ToString()); - } if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine)) { return EnumHelper.GetValue(value.ToString()); diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs index cd21d7b47..e938f8b5a 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -426,7 +426,7 @@ namespace HandBrakeWPF.Services.Encode.Factories // Deinterlace if (job.DeinterlaceFilter == DeinterlaceFilter.Yadif) { - IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEINTERLACE, EnumHelper.GetShortName(job.Deinterlace), null, job.CustomDeinterlace); + IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEINTERLACE, job.DeinterlacePreset?.ShortName, null, job.CustomDeinterlaceSettings); string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr); if (!string.IsNullOrEmpty(unparsedJson)) { @@ -440,7 +440,7 @@ namespace HandBrakeWPF.Services.Encode.Factories // Decomb if (job.DeinterlaceFilter == DeinterlaceFilter.Decomb) { - IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DECOMB, EnumHelper.GetShortName(job.Decomb), null, job.CustomDecomb); + IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DECOMB, job.DeinterlacePreset?.ShortName, null, job.CustomDeinterlaceSettings); string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr); if (!string.IsNullOrEmpty(unparsedJson)) { diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index c40c6c0b9..a57b2e43b 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -90,15 +90,13 @@ namespace HandBrakeWPF.Services.Encode.Model this.AlignAVStart = task.AlignAVStart; this.ChapterMarkersFilePath = task.ChapterMarkersFilePath; this.Cropping = new Cropping(task.Cropping); - this.CustomDecomb = task.CustomDecomb; - this.CustomDeinterlace = task.CustomDeinterlace; + this.CustomDeinterlaceSettings = task.CustomDeinterlaceSettings; this.CustomDenoise = task.CustomDenoise; this.CustomDetelecine = task.CustomDetelecine; this.CustomCombDetect = task.CustomCombDetect; this.CombDetect = task.CombDetect; this.Deblock = task.Deblock; - this.Decomb = task.Decomb; - this.Deinterlace = task.Deinterlace; + this.DeinterlacePreset = task.DeinterlacePreset; this.DeinterlaceFilter = task.DeinterlaceFilter; this.Denoise = task.Denoise; this.DenoisePreset = task.DenoisePreset; @@ -297,17 +295,7 @@ namespace HandBrakeWPF.Services.Encode.Model /// /// Gets or sets Deinterlace. /// - public Deinterlace Deinterlace { get; set; } - - /// - /// Gets or sets CustomDeinterlace. - /// - public string CustomDeinterlace { get; set; } - - /// - /// Gets or sets Decomb. - /// - public Decomb Decomb { get; set; } + public HBPresetTune DeinterlacePreset { get; set; } /// /// Gets or sets the comb detect. @@ -317,7 +305,7 @@ namespace HandBrakeWPF.Services.Encode.Model /// /// Gets or sets CustomDecomb. /// - public string CustomDecomb { get; set; } + public string CustomDeinterlaceSettings { get; set; } /// /// Gets or sets the custom comb detect. diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs index cdb815d32..3f86e1aa5 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs @@ -136,77 +136,30 @@ namespace HandBrakeWPF.Services.Presets.Factories switch (importedPreset.PictureDeinterlaceFilter) { case "decomb": - preset.Task.Decomb = Decomb.Default; - preset.Task.Deinterlace = Deinterlace.Default; preset.Task.DeinterlaceFilter = DeinterlaceFilter.Decomb; break; case "yadif": - preset.Task.Decomb = Decomb.Default; - preset.Task.Deinterlace = Deinterlace.Default; preset.Task.DeinterlaceFilter = DeinterlaceFilter.Yadif; break; default: - preset.Task.Decomb = Decomb.Default; - preset.Task.Deinterlace = Deinterlace.Default; preset.Task.DeinterlaceFilter = DeinterlaceFilter.Off; break; } if (preset.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb) { - switch (importedPreset.PictureDeinterlacePreset) - { - case "custom": - preset.Task.Decomb = Decomb.Custom; - break; - case "default": - preset.Task.Decomb = Decomb.Default; - break; - case "bob": - preset.Task.Decomb = Decomb.Bob; - break; - case "eedi2": - preset.Task.Decomb = Decomb.EEDI2; - break; - case "eedi2bob": - preset.Task.Decomb = Decomb.EEDI2Bob; - break; - default: - preset.Task.Decomb = Decomb.Default; - break; - } - - if (preset.Task.Decomb == Decomb.Custom) - { - preset.Task.CustomDecomb = importedPreset.PictureDeinterlaceCustom; - } + List filterPresets = HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DECOMB); + HBPresetTune presetTune = filterPresets.FirstOrDefault(f => f.ShortName == importedPreset.PictureDeinterlacePreset); + preset.Task.DeinterlacePreset = presetTune ?? new HBPresetTune("Default", "default"); + preset.Task.CustomDeinterlaceSettings = importedPreset.PictureDeinterlaceCustom; } if (preset.Task.DeinterlaceFilter == DeinterlaceFilter.Yadif) { - switch (importedPreset.PictureDeinterlacePreset) - { - case "custom": - preset.Task.Deinterlace = Deinterlace.Custom; - break; - case "bob": - preset.Task.Deinterlace = Deinterlace.Bob; - break; - case "skip-spatial": - preset.Task.Deinterlace = Deinterlace.SkipSpatialCheck; - break; - case "default": - preset.Task.Deinterlace = Deinterlace.Default; - break; - default: - preset.Task.Deinterlace = Deinterlace.Default; - break; - } - - if (preset.Task.Deinterlace == Deinterlace.Custom) - { - preset.Task.CustomDeinterlace = importedPreset.PictureDeinterlaceCustom; - } + List filterPresets = HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEINTERLACE); + HBPresetTune presetTune = filterPresets.FirstOrDefault(f => f.ShortName == importedPreset.PictureDeinterlacePreset); + preset.Task.DeinterlacePreset = presetTune ?? new HBPresetTune("Default", "default"); + preset.Task.CustomDeinterlaceSettings = importedPreset.PictureDeinterlaceCustom; } if (preset.Task.DeinterlaceFilter == DeinterlaceFilter.Yadif || preset.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb) @@ -650,12 +603,8 @@ namespace HandBrakeWPF.Services.Presets.Factories preset.PictureDeinterlaceFilter = export.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb ? "decomb" : export.Task.DeinterlaceFilter == DeinterlaceFilter.Yadif ? "yadif" : "off"; - preset.PictureDeinterlacePreset = export.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb - ? EnumHelper.GetShortName(export.Task.Decomb) - : export.Task.DeinterlaceFilter == DeinterlaceFilter.Yadif ? EnumHelper.GetShortName(export.Task.Deinterlace) : string.Empty; - preset.PictureDeinterlaceCustom = export.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb - ? export.Task.CustomDecomb - : export.Task.DeinterlaceFilter == DeinterlaceFilter.Yadif ? export.Task.CustomDeinterlace : string.Empty; + preset.PictureDeinterlacePreset = export.Task.DeinterlacePreset?.ShortName; + preset.PictureDeinterlaceCustom = export.Task.CustomDeinterlaceSettings; preset.PictureCombDetectPreset = EnumHelper.GetShortName(export.Task.CombDetect); preset.PictureCombDetectCustom = export.Task.CustomCombDetect; diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index 86df91094..8d2c47e87 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -69,42 +69,6 @@ namespace HandBrakeWPF.ViewModels /// public EncodeTask CurrentTask { get; private set; } - /// - /// Gets or sets CustomDecomb. - /// - public string CustomDecomb - { - get - { - return this.CurrentTask.CustomDecomb; - } - - set - { - this.CurrentTask.CustomDecomb = value; - this.NotifyOfPropertyChange(() => this.CustomDecomb); - this.OnTabStatusChanged(null); - } - } - - /// - /// Gets or sets CustomDeinterlace. - /// - public string CustomDeinterlace - { - get - { - return this.CurrentTask.CustomDeinterlace; - } - - set - { - this.CurrentTask.CustomDeinterlace = value; - this.NotifyOfPropertyChange(() => this.CustomDeinterlace); - this.OnTabStatusChanged(null); - } - } - /// /// Gets or sets CustomDenoise. /// @@ -141,17 +105,6 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets DeInterlaceOptions. - /// - public IEnumerable DeInterlaceOptions - { - get - { - return EnumHelper.GetEnumList(); - } - } - /// /// Gets DeblockText. /// @@ -182,17 +135,6 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets DecombOptions. - /// - public IEnumerable DecombOptions - { - get - { - return EnumHelper.GetEnumList(); - } - } - /// /// Gets DenoiseOptions. /// @@ -215,28 +157,6 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets DeinterlaceFilterOptions. - /// - public IEnumerable DeinterlaceFilterOptions - { - get - { - return EnumHelper.GetEnumList(); - } - } - - /// - /// Comb Detection Presets - /// - public IEnumerable CombDetectPresets - { - get - { - return EnumHelper.GetEnumList(); - } - } - /// /// Gets or sets a value indicating whether Grayscale. /// @@ -255,31 +175,24 @@ namespace HandBrakeWPF.ViewModels } } + #region Interlace Detection + /// - /// Gets or sets SelectedDeInterlace. + /// Comb Detection Presets /// - public Deinterlace SelectedDeInterlace + public IEnumerable CombDetectPresets { get { - return this.CurrentTask.Deinterlace; - } - - set - { - this.CurrentTask.Deinterlace = value; - this.NotifyOfPropertyChange(() => this.SelectedDeInterlace); - - if (value != Deinterlace.Custom) this.CustomDeinterlace = string.Empty; - - // Show / Hide the Custom Control - this.NotifyOfPropertyChange(() => this.ShowDecombCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceDecombCustom); - this.OnTabStatusChanged(null); + return EnumHelper.GetEnumList(); } } + /// + /// Show the CombDetect Custom Box. + /// + public bool ShowCombDetectCustom => this.SelectedCombDetectPreset == CombDetect.Custom; + /// /// Gets or sets the selected comb detect preset. /// @@ -303,11 +216,6 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Show the CombDetect Custom Box. - /// - public bool ShowCombDetectCustom => this.SelectedCombDetectPreset == CombDetect.Custom; - /// /// Gets or sets the custom comb detect. /// @@ -326,57 +234,103 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets or sets SelectedDecomb. - /// - public Decomb SelectedDecomb + #endregion + + #region Deinterlace and Decomb + + public IEnumerable DeinterlaceFilterOptions => EnumHelper.GetEnumList(); + + public DeinterlaceFilter SelectedDeinterlaceFilter { get { - return this.CurrentTask.Decomb; + return this.deinterlaceFilter; } set { - this.CurrentTask.Decomb = value; - this.NotifyOfPropertyChange(() => this.SelectedDecomb); + if (value == this.deinterlaceFilter) + { + return; + } - if (value != Decomb.Custom) this.CustomDecomb = string.Empty; + this.deinterlaceFilter = value; + this.CurrentTask.DeinterlaceFilter = value; - // Show / Hide the Custom Control - this.NotifyOfPropertyChange(() => this.ShowDecombCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceDecombCustom); + this.NotifyOfPropertyChange(() => this.SelectedDeinterlaceFilter); + this.NotifyOfPropertyChange(() => this.ShowCustomDeinterlace); + this.NotifyOfPropertyChange(() => this.DeinterlacePresets); + this.NotifyOfPropertyChange(() => this.IsDeinterlaceEnabled); + + if (!this.DeinterlacePresets.Contains(this.SelectedDeInterlacePreset)) + { + this.SelectedDeInterlacePreset = this.DeinterlacePresets.FirstOrDefault(p => p.ShortName == "default"); + } + this.OnTabStatusChanged(null); } } - /// - /// Gets or sets SelectedDenoise. - /// - public Denoise SelectedDenoise + public IEnumerable DeinterlacePresets { get { - return this.CurrentTask.Denoise; + switch (this.SelectedDeinterlaceFilter) + { + case DeinterlaceFilter.Yadif: + return new BindingList(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEINTERLACE)); + case DeinterlaceFilter.Decomb: + return new BindingList(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DECOMB)); + default: + return new BindingList(); + } + } + } + + public HBPresetTune SelectedDeInterlacePreset + { + get + { + return this.CurrentTask.DeinterlacePreset; } set { - this.CurrentTask.Denoise = value; - this.NotifyOfPropertyChange(() => this.SelectedDenoise); + this.CurrentTask.DeinterlacePreset = value; + this.NotifyOfPropertyChange(() => this.SelectedDeInterlacePreset); + + if (value?.ShortName == "custom") this.CustomDeinterlaceSettings = string.Empty; // Show / Hide the Custom Control - this.NotifyOfPropertyChange(() => this.ShowDenoiseCustom); + this.NotifyOfPropertyChange(() => this.ShowCustomDeinterlace); + this.OnTabStatusChanged(null); + } + } + + public bool IsDeinterlaceEnabled => this.CurrentTask.DeinterlaceFilter != DeinterlaceFilter.Off; - this.SelectedDenoisePreset = this.CurrentTask.Denoise == Denoise.hqdn3d ? DenoisePreset.Weak : DenoisePreset.Ultralight; // Default so we don't have an invalid preset. + public bool ShowCustomDeinterlace => this.IsDeinterlaceEnabled && this.CurrentTask.DeinterlacePreset?.ShortName == "custom"; - this.NotifyOfPropertyChange(() => this.ShowDenoiseOptions); - this.NotifyOfPropertyChange(() => this.ShowDenoiseTune); + /// + /// Gets or sets CustomDecomb. + /// + public string CustomDeinterlaceSettings + { + get + { + return this.CurrentTask.CustomDeinterlaceSettings; + } + + set + { + this.CurrentTask.CustomDeinterlaceSettings = value; + this.NotifyOfPropertyChange(() => this.CustomDeinterlaceSettings); this.OnTabStatusChanged(null); } } + #endregion + /// /// Gets or sets SelectedDetelecine. /// @@ -399,76 +353,40 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets or sets a value indicating whether ShowDecombCustom. - /// - public bool ShowDecombCustom => this.SelectedDeinterlaceFilter == DeinterlaceFilter.Decomb && this.SelectedDecomb == Decomb.Custom; - - /// - /// Gets or sets a value indicating whether ShowDeinterlaceDecombCustom. - /// - public bool ShowDeinterlaceDecombCustom => (this.SelectedDeinterlaceFilter == DeinterlaceFilter.Decomb && this.SelectedDecomb == Decomb.Custom) || (this.SelectedDeinterlaceFilter == DeinterlaceFilter.Yadif && this.SelectedDeInterlace == Deinterlace.Custom); - - /// - /// Gets or sets a value indicating whether ShowDelelecineCustom. - /// - public bool ShowDeinterlaceCustom => this.SelectedDeinterlaceFilter == DeinterlaceFilter.Yadif && this.SelectedDeInterlace == Deinterlace.Custom; - - /// - /// Gets or sets a value indicating whether ShowDenoiseCustom. - /// - public bool ShowDenoiseCustom => this.CurrentTask.DenoisePreset == DenoisePreset.Custom; - /// /// Gets or sets a value indicating whether ShowDetelecineCustom. /// public bool ShowDetelecineCustom => this.CurrentTask.Detelecine == Detelecine.Custom; + + #region Denoise + /// - /// Gets or sets the selected deinterlace filter mode. + /// Gets or sets SelectedDenoise. /// - public DeinterlaceFilter SelectedDeinterlaceFilter + public Denoise SelectedDenoise { get { - return this.deinterlaceFilter; + return this.CurrentTask.Denoise; } + set { - if (value == this.deinterlaceFilter) - { - return; - } + this.CurrentTask.Denoise = value; + this.NotifyOfPropertyChange(() => this.SelectedDenoise); - this.deinterlaceFilter = value; - this.CurrentTask.DeinterlaceFilter = value; + // Show / Hide the Custom Control + this.NotifyOfPropertyChange(() => this.ShowDenoiseCustom); - this.NotifyOfPropertyChange(() => this.SelectedDeinterlaceFilter); - this.NotifyOfPropertyChange(() => this.IsDeinterlaceMode); - this.NotifyOfPropertyChange(() => this.IsDecombMode); - this.NotifyOfPropertyChange(() => this.IsDeinterlaceDecomb); - this.NotifyOfPropertyChange(() => this.ShowDecombCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceDecombCustom); + this.SelectedDenoisePreset = this.CurrentTask.Denoise == Denoise.hqdn3d ? DenoisePreset.Weak : DenoisePreset.Ultralight; // Default so we don't have an invalid preset. + + this.NotifyOfPropertyChange(() => this.ShowDenoiseOptions); + this.NotifyOfPropertyChange(() => this.ShowDenoiseTune); this.OnTabStatusChanged(null); } } - /// - /// Gets or sets a value indicating whether is deinterlace mode. - /// - public bool IsDeinterlaceMode => this.deinterlaceFilter == DeinterlaceFilter.Yadif; - - /// - /// Gets or sets a value indicating whether is decomb mode. - /// - public bool IsDecombMode => this.deinterlaceFilter == DeinterlaceFilter.Decomb; - - /// - /// Gets or sets a value indicating whether is deinterlace or decomb mode. - /// - public bool IsDeinterlaceDecomb => this.SelectedDeinterlaceFilter != DeinterlaceFilter.Off; - /// /// Gets or sets the selected denoise tune. /// @@ -514,46 +432,20 @@ namespace HandBrakeWPF.ViewModels /// /// Gets the denoise presets. /// - public IEnumerable DenoisePresets - { - get - { - return EnumHelper.GetEnumList(); - } - } + public IEnumerable DenoisePresets => EnumHelper.GetEnumList(); /// /// Gets the denoise tunes. /// - public IEnumerable DenoiseTunes - { - get - { - return EnumHelper.GetEnumList(); - } - } + public IEnumerable DenoiseTunes => EnumHelper.GetEnumList(); - /// - /// Gets a value indicating whether show denoise options. - /// - public bool ShowDenoiseOptions - { - get - { - return this.SelectedDenoise != Denoise.Off; - } - } + public bool ShowDenoiseOptions => this.SelectedDenoise != Denoise.Off; - /// - /// Gets a value indicating whether show denoise tune. - /// - public bool ShowDenoiseTune - { - get - { - return this.SelectedDenoise == Denoise.NLMeans && this.SelectedDenoisePreset != DenoisePreset.Custom; - } - } + public bool ShowDenoiseTune => this.SelectedDenoise == Denoise.NLMeans && this.SelectedDenoisePreset != DenoisePreset.Custom; + + public bool ShowDenoiseCustom => this.CurrentTask.DenoisePreset == DenoisePreset.Custom; + + #endregion /// /// The rotation options. @@ -727,20 +619,8 @@ namespace HandBrakeWPF.ViewModels this.SelectedDenoise = preset.Task.Denoise; this.SelectedDetelecine = preset.Task.Detelecine; - this.SelectedDecomb = preset.Task.Decomb; - this.SelectedDeInterlace = preset.Task.Deinterlace; - if (preset.Task.DeinterlaceFilter == DeinterlaceFilter.Yadif) - { - this.SelectedDeinterlaceFilter = DeinterlaceFilter.Yadif; - } - else if (preset.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb) - { - this.SelectedDeinterlaceFilter = DeinterlaceFilter.Decomb; - } - else - { - this.SelectedDeinterlaceFilter = DeinterlaceFilter.Off; - } + this.SelectedDeinterlaceFilter = preset.Task.DeinterlaceFilter; + this.SelectedDeInterlacePreset = preset.Task.DeinterlacePreset; this.SelectedCombDetectPreset = preset.Task.CombDetect; @@ -756,9 +636,8 @@ namespace HandBrakeWPF.ViewModels this.CustomSharpen = preset.Task.SharpenCustom; // Custom Values - this.CustomDecomb = preset.Task.CustomDecomb; + this.CustomDeinterlaceSettings = preset.Task.CustomDeinterlaceSettings; this.CustomCombDetect = preset.Task.CustomCombDetect; - this.CustomDeinterlace = preset.Task.CustomDeinterlace; this.CustomDetelecine = preset.Task.CustomDetelecine; this.CustomDenoise = preset.Task.CustomDenoise; @@ -769,8 +648,7 @@ namespace HandBrakeWPF.ViewModels { // Default everything to off this.SelectedDenoise = Denoise.Off; - this.SelectedDecomb = Decomb.Default; - this.SelectedDeInterlace = Deinterlace.Default; + this.SelectedDeinterlaceFilter = DeinterlaceFilter.Off; this.SelectedDetelecine = Detelecine.Off; this.Grayscale = false; this.DeblockValue = 0; @@ -791,8 +669,8 @@ namespace HandBrakeWPF.ViewModels this.CurrentTask = task; this.NotifyOfPropertyChange(() => this.SelectedDenoise); - this.NotifyOfPropertyChange(() => this.SelectedDecomb); - this.NotifyOfPropertyChange(() => this.SelectedDeInterlace); + this.NotifyOfPropertyChange(() => this.SelectedDeinterlaceFilter); + this.NotifyOfPropertyChange(() => this.SelectedDeInterlacePreset); this.NotifyOfPropertyChange(() => this.SelectedDetelecine); this.NotifyOfPropertyChange(() => this.Grayscale); this.NotifyOfPropertyChange(() => this.DeblockValue); @@ -805,24 +683,18 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.FlipVideo); this.NotifyOfPropertyChange(() => this.SelectedRotation); - this.NotifyOfPropertyChange(() => this.CustomDecomb); - this.NotifyOfPropertyChange(() => this.CustomDeinterlace); + this.NotifyOfPropertyChange(() => this.CustomDeinterlaceSettings); this.NotifyOfPropertyChange(() => this.CustomDetelecine); this.NotifyOfPropertyChange(() => this.CustomDenoise); this.NotifyOfPropertyChange(() => this.CustomSharpen); this.NotifyOfPropertyChange(() => this.CustomCombDetect); - this.NotifyOfPropertyChange(() => this.IsDeinterlaceMode); - this.NotifyOfPropertyChange(() => this.IsDecombMode); - this.NotifyOfPropertyChange(() => this.IsDeinterlaceDecomb); this.NotifyOfPropertyChange(() => this.ShowDenoiseOptions); this.NotifyOfPropertyChange(() => this.ShowDenoiseCustom); this.NotifyOfPropertyChange(() => this.ShowDenoiseTune); - this.NotifyOfPropertyChange(() => this.ShowDecombCustom); + this.NotifyOfPropertyChange(() => this.ShowCustomDeinterlace); this.NotifyOfPropertyChange(() => this.ShowCombDetectCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceDecombCustom); - this.NotifyOfPropertyChange(() => this.ShowDeinterlaceCustom); this.NotifyOfPropertyChange(() => this.ShowDetelecineCustom); this.NotifyOfPropertyChange(() => this.ShowSharpenCustom); this.NotifyOfPropertyChange(() => this.ShowSharpenOptions); @@ -846,12 +718,12 @@ namespace HandBrakeWPF.ViewModels return false; } - if (preset.Task.Deinterlace != this.SelectedDeInterlace) + if (preset.Task.DeinterlacePreset != this.SelectedDeInterlacePreset) { return false; } - if (preset.Task.Decomb != this.SelectedDecomb) + if (preset.Task.CustomDeinterlaceSettings != this.CustomDeinterlaceSettings) { return false; } @@ -861,16 +733,6 @@ namespace HandBrakeWPF.ViewModels return false; } - if ((preset.Task.CustomDecomb ?? string.Empty) != (this.CustomDecomb ?? string.Empty)) - { - return false; - } - - if ((preset.Task.CustomDeinterlace ?? string.Empty) != (this.CustomDeinterlace ?? string.Empty)) - { - return false; - } - if ((preset.Task.CustomCombDetect ?? string.Empty) != (this.CustomCombDetect ?? string.Empty)) { return false; diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml index 3dbc38ea5..7c323869f 100644 --- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml +++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml @@ -40,6 +40,7 @@ + @@ -57,63 +58,37 @@ - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + - -