From 2412d4a92123b2f20b43987a65a4fbd645be1443 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 5 Jul 2014 14:37:53 +0000 Subject: WinGui: Adding support for Nlmeans to the front-end. Plist keys still tbd. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6227 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Factories/PlistPresetFactory.cs | 6 ++ .../HandBrake.ApplicationServices.csproj | 1 + .../Model/EncodeTask.cs | 12 +++ .../Utilities/PlistUtility.cs | 81 +++++++++++++----- .../Utilities/QueryGeneratorUtility.cs | 74 +++++++++++++---- .../Utilities/QueryParserUtility.cs | 50 ++++++++++- .../HandBrakeInterop/HandBrakeInstance.cs | 12 +-- .../HandBrakeInterop/HandBrakeInterop.csproj | 3 + .../HandBrakeInterop/Model/Encoding/Denoise.cs | 6 +- .../Model/Encoding/DenoisePreset.cs | 37 +++++++++ .../HandBrakeInterop/Model/Encoding/DenoiseTune.cs | 34 ++++++++ .../Model/Encoding/EncodingProfile.cs | 10 +++ win/CS/HandBrake.Server/HandBrake.Server.csproj | 1 + .../Converters/Filters/DenoisePresetConverter.cs | 86 +++++++++++++++++++ win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 2 + win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 97 +++++++++++++++++++++- win/CS/HandBrakeWPF/Views/FiltersView.xaml | 47 ++++++++--- 17 files changed, 496 insertions(+), 63 deletions(-) create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs create mode 100644 win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs (limited to 'win/CS') diff --git a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs index e6b59c31d..8f7e84e6c 100644 --- a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs @@ -161,6 +161,12 @@ namespace HandBrake.ApplicationServices.Factories case "PictureDenoise": preset.Task.Denoise = (Denoise)kvp.Value; break; + case "DenoisePreset": + preset.Task.DenoisePreset = (DenoisePreset)kvp.Value; // TODO to be confirmed. + break; + case "DenoiseTune": + preset.Task.DenoiseTune = (DenoiseTune)kvp.Value; // TODO to be confirmed. + break; case "PictureDenoiseCustom": preset.Task.CustomDenoise = kvp.Value; break; diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 39596c222..0f082f0f3 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -35,6 +35,7 @@ x64 bin\Debug\ TRACE;DEBUG + true x64 diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index 6a519a382..be719701b 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -98,6 +98,8 @@ namespace HandBrake.ApplicationServices.Model this.Decomb = task.Decomb; this.Deinterlace = task.Deinterlace; this.Denoise = task.Denoise; + this.DenoisePreset = task.DenoisePreset; + this.DenoiseTune = task.DenoiseTune; this.Destination = task.Destination; this.Detelecine = task.Detelecine; this.DisplayWidth = task.DisplayWidth; @@ -313,6 +315,16 @@ namespace HandBrake.ApplicationServices.Model /// public Denoise Denoise { get; set; } + /// + /// Gets or sets the denoise preset. + /// + public DenoisePreset DenoisePreset { get; set; } + + /// + /// Gets or sets the denoise tune. + /// + public DenoiseTune DenoiseTune { get; set; } + /// /// Gets or sets CustomDenoise. /// diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 7448f4bc5..9c6713b30 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -199,28 +199,67 @@ namespace HandBrake.ApplicationServices.Utilities break; } - switch (parsed.Denoise) + + if (parsed.Denoise == Denoise.hqdn3d) { - case Denoise.Off: - AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "0"); - AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); - break; - case Denoise.Weak: - AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "2"); - AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); - break; - case Denoise.Medium: - AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "3"); - AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); - break; - case Denoise.Strong: - AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "4"); - AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); - break; - case Denoise.Custom: - AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "1"); - AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.CustomDenoise); - break; + switch (parsed.DenoisePreset) + { + case DenoisePreset.Weak: + AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "2"); + AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); + break; + case DenoisePreset.Medium: + AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "3"); + AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); + break; + case DenoisePreset.Strong: + AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "4"); + AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); + break; + case DenoisePreset.Custom: + AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "1"); + AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.CustomDenoise); + break; + } + } + + // These keys are still TBD. TODO Update these + if (parsed.Denoise == Denoise.NlMeans) + { + switch (parsed.DenoisePreset) + { + case DenoisePreset.Ultralight: + AddEncodeElement(xmlWriter, "DenoisePreset", "integer", "1"); + break; + case DenoisePreset.Light: + AddEncodeElement(xmlWriter, "DenoisePreset", "integer", "2"); + break; + case DenoisePreset.Medium: + AddEncodeElement(xmlWriter, "DenoisePreset", "integer", "3"); + break; + case DenoisePreset.Strong: + AddEncodeElement(xmlWriter, "DenoisePreset", "integer", "4"); + break; + } + + switch (parsed.DenoiseTune) + { + case DenoiseTune.None: + AddEncodeElement(xmlWriter, "DenoiseTune", "integer", "0"); + break; + case DenoiseTune.Animation: + AddEncodeElement(xmlWriter, "DenoiseTune", "integer", "1"); + break; + case DenoiseTune.Film: + AddEncodeElement(xmlWriter, "DenoiseTune", "integer", "2"); + break; + case DenoiseTune.Grain: + AddEncodeElement(xmlWriter, "DenoiseTune", "integer", "3"); + break; + case DenoiseTune.HighMotion: + AddEncodeElement(xmlWriter, "DenoiseTune", "integer", "4"); + break; + } } int detelecine = 0; diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 8fe7cd3ac..046661058 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -372,23 +372,65 @@ namespace HandBrake.ApplicationServices.Utilities break; } - switch (task.Denoise) // Denoise + if (task.Denoise == Denoise.hqdn3d) { - case Denoise.Weak: - query += " --denoise=\"weak\""; - break; - case Denoise.Medium: - query += " --denoise=\"medium\""; - break; - case Denoise.Strong: - query += " --denoise=\"strong\""; - break; - case Denoise.Custom: - query += string.Format(" --denoise=\"{0}\"", task.CustomDenoise); - break; - default: - query += string.Empty; - break; + switch (task.DenoisePreset) // Denoise + { + case DenoisePreset.Weak: + query += " --denoise=\"weak\""; + break; + case DenoisePreset.Medium: + query += " --denoise=\"medium\""; + break; + case DenoisePreset.Strong: + query += " --denoise=\"strong\""; + break; + case DenoisePreset.Custom: + query += string.Format(" --denoise=\"{0}\"", task.CustomDenoise); + break; + } + } + + // NL Means + if (task.Denoise == Denoise.NlMeans) + { + switch (task.DenoisePreset) // Denoise + { + case DenoisePreset.Light: + query += " --nlmeans=\"light\""; + break; + case DenoisePreset.Ultralight: + query += " --nlmeans=\"ultralight\""; + break; + case DenoisePreset.Medium: + query += " --nlmeans=\"medium\""; + break; + case DenoisePreset.Strong: + query += " --nlmeans=\"strong\""; + break; + default: + query += string.Empty; + break; + } + + switch (task.DenoiseTune) + { + case DenoiseTune.Animation: + query += " --nlmeans-tune=\"animation\""; + break; + case DenoiseTune.Film: + query += " --nlmeans-tune=\"film\""; + break; + case DenoiseTune.Grain: + query += " --nlmeans-tune=\"grain\""; + break; + case DenoiseTune.HighMotion: + query += " --nlmeans-tune=\"highmotion\""; + break; + default: + query += string.Empty; + break; + } } if (task.Deblock > 4) diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index 2b39c74a5..b3619c7dd 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -77,6 +77,8 @@ namespace HandBrake.ApplicationServices.Utilities Match decombValue = Regex.Match(input, @" --decomb=([a-zA-Z0-9.:""\\]*)"); Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z0-9.:]*)\"""); Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z0-9.:]*)\"""); + Match nlmeans = Regex.Match(input, @"--nlmeans=\""([a-zA-Z0-9.:]*)\"""); + Match nlmeansTune = Regex.Match(input, @"--nlmeans-tune=\""([a-zA-Z0-9.:]*)\"""); Match deblock = Regex.Match(input, @"--deblock=([0-9:]*)"); Match detelecine = Regex.Match(input, @"--detelecine"); Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\"""); @@ -273,24 +275,64 @@ namespace HandBrake.ApplicationServices.Utilities parsed.Denoise = Denoise.Off; if (denoise.Success) { + parsed.Denoise = Denoise.hqdn3d; switch (denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty)) { case "weak": - parsed.Denoise = Denoise.Weak; + parsed.DenoisePreset = DenoisePreset.Weak; break; case "medium": - parsed.Denoise = Denoise.Medium; + parsed.DenoisePreset = DenoisePreset.Medium; break; case "strong": - parsed.Denoise = Denoise.Strong; + parsed.DenoisePreset = DenoisePreset.Strong; break; default: - parsed.Denoise = Denoise.Custom; + parsed.DenoisePreset = DenoisePreset.Custom; parsed.CustomDenoise = denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty); break; } } + if (nlmeans.Success) + { + parsed.Denoise = Denoise.NlMeans; + switch (nlmeans.ToString().Replace("--nlmeans=", string.Empty).Replace("\"", string.Empty)) + { + case "ultralight": + parsed.DenoisePreset = DenoisePreset.Ultralight; + break; + case "light": + parsed.DenoisePreset = DenoisePreset.Light; + break; + case "medium": + parsed.DenoisePreset = DenoisePreset.Medium; + break; + case "strong": + parsed.DenoisePreset = DenoisePreset.Strong; + break; + } + + if (nlmeansTune.Success) + { + switch (nlmeansTune.ToString().Replace("--nlmeans-tune=", string.Empty).Replace("\"", string.Empty)) + { + case "animation": + parsed.DenoiseTune = DenoiseTune.Animation; + break; + case "film": + parsed.DenoiseTune = DenoiseTune.Film; + break; + case "grain": + parsed.DenoiseTune = DenoiseTune.Grain; + break; + case "highmotion": + parsed.DenoiseTune = DenoiseTune.HighMotion; + break; + } + } + } + parsed.Deblock = 0; if (deblock.Success) { diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index 597e8cbe7..0e484794c 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -1213,24 +1213,26 @@ namespace HandBrake.Interop if (profile.Denoise != Denoise.Off) { string settings = null; - switch (profile.Denoise) + switch (profile.DenoisePreset) { - case Denoise.Weak: + case DenoisePreset.Weak: settings = "2:1:1:2:3:3"; break; - case Denoise.Medium: + case DenoisePreset.Medium: settings = "3:2:2:2:3:3"; break; - case Denoise.Strong: + case DenoisePreset.Strong: settings = "7:7:7:5:5:5"; break; - case Denoise.Custom: + case DenoisePreset.Custom: settings = profile.CustomDenoise; break; + // TODO Add new Presets. default: break; } + // TODO Add Tunes this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DENOISE, settings, allocatedMemory); } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index 720f64395..a1f1b076b 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -50,6 +50,7 @@ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules false false + true bin\x64\Release\ @@ -173,6 +174,8 @@ + + diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs index a2ab0f0a4..500547a24 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs @@ -15,9 +15,7 @@ namespace HandBrake.Interop.Model.Encoding public enum Denoise { Off = 0, - Weak = 2, - Medium = 3, - Strong = 4, - Custom = 1 + hqdn3d = 1, + NlMeans = 2, } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs new file mode 100644 index 000000000..b26635052 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the DenoisePreset type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Model.Encoding +{ + using System.ComponentModel.DataAnnotations; + + /// + /// The denoise preset. + /// + public enum DenoisePreset + { + [Display(Name = "Weak")] + Weak = 0, + + [Display(Name = "Medium")] + Medium, + + [Display(Name = "Strong")] + Strong, + + [Display(Name = "Custom")] + Custom, + + [Display(Name = "Ultralight")] // NLMeans only + Ultralight, + + [Display(Name = "Light")] // NLMeans only + Light, + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs new file mode 100644 index 000000000..35b5843a8 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs @@ -0,0 +1,34 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the DenoiseTune type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Model.Encoding +{ + using System.ComponentModel.DataAnnotations; + + /// + /// The denoise tune. + /// + public enum DenoiseTune + { + [Display(Name = "None")] + None = 0, + + [Display(Name = "Film")] + Film, + + [Display(Name = "Grain")] + Grain, + + [Display(Name = "High Motion")] + HighMotion, + + [Display(Name = "Animation")] + Animation, + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs index 2dea5624b..834ef5576 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs @@ -184,6 +184,16 @@ namespace HandBrake.Interop.Model.Encoding /// public Denoise Denoise { get; set; } + /// + /// Gets or sets the denoise preset. + /// + public DenoisePreset DenoisePreset { get; set; } + + /// + /// Gets or sets the denoise tune. + /// + public DenoiseTune DenoiseTune { get; set; } + /// /// Gets or sets the custom denoise. /// diff --git a/win/CS/HandBrake.Server/HandBrake.Server.csproj b/win/CS/HandBrake.Server/HandBrake.Server.csproj index 7e202d4c2..98f2548d5 100644 --- a/win/CS/HandBrake.Server/HandBrake.Server.csproj +++ b/win/CS/HandBrake.Server/HandBrake.Server.csproj @@ -36,6 +36,7 @@ x64 bin\Debug\ + true x64 diff --git a/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs b/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs new file mode 100644 index 000000000..bb0ec1b7e --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs @@ -0,0 +1,86 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the DenoisePresetConverter type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Converters.Filters +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using System.Windows.Data; + + using HandBrake.Interop.Model.Encoding; + + /// + /// The denoise preset converter. + /// + public class DenoisePresetConverter : IMultiValueConverter + { + /// + /// The convert. + /// + /// + /// The values. + /// + /// + /// The target type. + /// + /// + /// The parameter. + /// + /// + /// The culture. + /// + /// + /// The . + /// + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Any() && values.Count() == 2) + { + Denoise denoiseChoice = (Denoise)values[1]; + + if (denoiseChoice == Denoise.hqdn3d) + { + return new List { DenoisePreset.Weak, DenoisePreset.Medium, DenoisePreset.Strong, DenoisePreset.Custom }; + } + + if (denoiseChoice == Denoise.NlMeans) + { + return new List { DenoisePreset.Ultralight, DenoisePreset.Light, DenoisePreset.Medium, DenoisePreset.Strong }; + } + } + + return Enumerable.Empty(); + } + + /// + /// The convert back. Not used + /// + /// + /// The value. + /// + /// + /// The target types. + /// + /// + /// The parameter. + /// + /// + /// The culture. + /// + /// + /// The Nothing. Not used + /// + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 64752b39d..dcd4a42bb 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -62,6 +62,7 @@ prompt true true + true bin\Release\ @@ -149,6 +150,7 @@ + diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index e5d825ba4..70921b23f 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -10,12 +10,12 @@ namespace HandBrakeWPF.ViewModels { using System.Collections.Generic; + using System.Globalization; using Caliburn.Micro; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Parsing; - using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.ApplicationServices.Utilities; using HandBrake.Interop.Model.Encoding; @@ -145,7 +145,7 @@ namespace HandBrakeWPF.ViewModels { get { - return this.DeblockValue == 4 ? "Off" : this.DeblockValue.ToString(); + return this.DeblockValue == 4 ? "Off" : this.DeblockValue.ToString(CultureInfo.InvariantCulture); } } @@ -295,8 +295,13 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.SelectedDenoise); // Show / Hide the Custom Control - this.ShowDenoiseCustom = this.CurrentTask.Denoise == Denoise.Custom; + this.ShowDenoiseCustom = this.CurrentTask.Denoise == Denoise.hqdn3d && this.CurrentTask.DenoisePreset == DenoisePreset.Custom; this.NotifyOfPropertyChange(() => this.ShowDenoiseCustom); + + 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); } } @@ -378,6 +383,90 @@ namespace HandBrakeWPF.ViewModels /// public string DeinterlaceControlText { get; set; } + /// + /// Gets or sets the selected denoise tune. + /// + public DenoiseTune SelectedDenoiseTune + { + get + { + return this.CurrentTask.DenoiseTune; + } + + set + { + this.CurrentTask.DenoiseTune = value; + this.NotifyOfPropertyChange(() => this.SelectedDenoiseTune); + } + } + + /// + /// Gets or sets the selected denoise preset. + /// + public DenoisePreset SelectedDenoisePreset + { + get + { + return this.CurrentTask.DenoisePreset; + } + + set + { + this.CurrentTask.DenoisePreset = value; + this.NotifyOfPropertyChange(() => this.SelectedDenoisePreset); + + // Show / Hide the Custom Control + this.ShowDenoiseCustom = this.CurrentTask.Denoise == Denoise.hqdn3d && this.CurrentTask.DenoisePreset == DenoisePreset.Custom; + this.NotifyOfPropertyChange(() => this.ShowDenoiseCustom); + this.NotifyOfPropertyChange(() => this.ShowDenoiseOptions); + this.NotifyOfPropertyChange(() => this.ShowDenoiseTune); + } + } + + /// + /// Gets the denoise presets. + /// + public IEnumerable DenoisePresets + { + get + { + return EnumHelper.GetEnumList(); + } + } + + /// + /// Gets the denoise tunes. + /// + public IEnumerable DenoiseTunes + { + get + { + return EnumHelper.GetEnumList(); + } + } + + /// + /// Gets a value indicating whether show denoise options. + /// + public bool ShowDenoiseOptions + { + get + { + return this.SelectedDenoise != Denoise.Off; + } + } + + /// + /// Gets a value indicating whether show denoise tune. + /// + public bool ShowDenoiseTune + { + get + { + return this.SelectedDenoise == Denoise.NlMeans; + } + } + #endregion #region Implemented Interfaces @@ -406,6 +495,8 @@ namespace HandBrakeWPF.ViewModels this.SelectedDetelecine = preset.Task.Detelecine; this.Grayscale = preset.Task.Grayscale; this.DeblockValue = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock; + this.SelectedDenoisePreset = preset.Task.DenoisePreset; + this.SelectedDenoiseTune = preset.Task.DenoiseTune; // Custom Values this.CustomDecomb = preset.Task.CustomDecomb; diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml index ed5993def..70488d5da 100644 --- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml +++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml @@ -3,11 +3,14 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:Converters="clr-namespace:HandBrakeWPF.Converters" mc:Ignorable="d" > + xmlns:Converters="clr-namespace:HandBrakeWPF.Converters" + xmlns:filters="clr-namespace:HandBrakeWPF.Converters.Filters" + mc:Ignorable="d" > + @@ -45,7 +48,7 @@ - @@ -53,7 +56,7 @@ - + - - - + SelectedItem="{Binding SelectedDenoise, Converter={StaticResource boolComboConverter}}" Grid.Column="1" + HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,10" /> + + + + + + + + + + + + + + + + + + + + + + + - + -- cgit v1.2.3