summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-06-02 22:03:16 +0100
committersr55 <[email protected]>2017-06-02 22:03:16 +0100
commit27f366140509b18897f0dc54194a1a0d55cf0bb6 (patch)
tree62fc39ba1edd10fc4d5914177760df318eb4a25c /win/CS
parent844a0bf724abc56edcad0390d82bf92eae219144 (diff)
WinGui: Support for the new sharpen filter.
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/Sharpen.cs28
-rw-r--r--win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs13
-rw-r--r--win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs58
-rw-r--r--win/CS/HandBrakeWPF/Converters/Filters/SharpenTuneConverter.cs58
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj4
-rw-r--r--win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs53
-rw-r--r--win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs53
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs54
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx36
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs9
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.resx3
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs19
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs13
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs37
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs136
-rw-r--r--win/CS/HandBrakeWPF/Views/FiltersView.xaml58
19 files changed, 626 insertions, 14 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index c5f5555e9..a14159890 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -128,6 +128,7 @@
<Compile Include="Interop\Model\Encoding\CombDetect.cs" />
<Compile Include="Interop\Model\Encoding\DeinterlaceFilter.cs" />
<Compile Include="Interop\Model\Encoding\HBPresetTune.cs" />
+ <Compile Include="Interop\Model\Encoding\Sharpen.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" />
<Compile Include="Interop\Json\Scan\SourceChapter.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs
index 76059fe8b..63e279410 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs
@@ -27,6 +27,8 @@ namespace HandBrake.ApplicationServices.Interop.HbLib
HB_FILTER_NLMEANS,
HB_FILTER_RENDER_SUB,
HB_FILTER_CROP_SCALE,
+ HB_FILTER_LAPSHARP,
+ HB_FILTER_UNSHARP,
HB_FILTER_ROTATE,
HB_FILTER_GRAYSCALE,
HB_FILTER_PAD,
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs
index 7e1e94697..6ddb9c0c2 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs
@@ -166,6 +166,11 @@ namespace HandBrake.ApplicationServices.Interop.Json.Presets
/// </summary>
public string PictureDenoiseTune { get; set; }
+ public string PictureSharpenCustom { get; set; }
+ public string PictureSharpenFilter { get; set; }
+ public string PictureSharpenPreset { get; set; }
+ public string PictureSharpenTune { get; set; }
+
/// <summary>
/// Gets or sets the picture detelecine.
/// </summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/Sharpen.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/Sharpen.cs
new file mode 100644
index 000000000..7f5b9e75a
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/Sharpen.cs
@@ -0,0 +1,28 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Sharpen.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the Sharpen type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Model.Encoding
+{
+ using HandBrake.ApplicationServices.Attributes;
+
+ /// <summary>
+ /// The Sharpen.
+ /// </summary>
+ public enum Sharpen
+ {
+ [ShortName("off")]
+ Off,
+
+ [ShortName("unsharp")]
+ UnSharp,
+
+ [ShortName("lapsharp")]
+ LapSharp
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
index 91c30311a..c9afb8c14 100644
--- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
+++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
@@ -91,6 +91,10 @@ namespace HandBrakeWPF.Converters
{
return EnumHelper<CombDetect>.GetEnumDisplayValues(typeof(CombDetect));
}
+ if (value is IEnumerable<Sharpen>)
+ {
+ return EnumHelper<Sharpen>.GetEnumDisplayValues(typeof(Sharpen));
+ }
// Single Items
if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))
@@ -140,6 +144,10 @@ namespace HandBrakeWPF.Converters
{
return EnumHelper<CombDetect>.GetDisplay((CombDetect)value);
}
+ if (targetType == typeof(Sharpen) || value.GetType() == typeof(Sharpen))
+ {
+ return EnumHelper<Sharpen>.GetDisplay((Sharpen)value);
+ }
return null;
}
@@ -210,6 +218,11 @@ namespace HandBrakeWPF.Converters
{
return EnumHelper<CombDetect>.GetValue(value.ToString());
}
+
+ if (targetType == typeof(Sharpen) || value.GetType() == typeof(Sharpen))
+ {
+ return EnumHelper<Sharpen>.GetValue(value.ToString());
+ }
return null;
}
}
diff --git a/win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs b/win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs
new file mode 100644
index 000000000..417b0d155
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs
@@ -0,0 +1,58 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SharpenPresetConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// A converter to fetch the sharpen presets
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Filters
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.HbLib;
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+
+ using HandBrakeWPF.Model.Filters;
+
+ public class SharpenPresetConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values.Length == 2)
+ {
+ Sharpen selectedSharpen = (Sharpen)values[1];
+ if (selectedSharpen == Sharpen.LapSharp)
+ {
+ BindingList<FilterPreset> presets = new BindingList<FilterPreset>();
+ foreach (HBPresetTune preset in HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_LAPSHARP))
+ {
+ presets.Add(new FilterPreset(preset));
+ }
+ return presets;
+ }
+ else if (selectedSharpen == Sharpen.UnSharp)
+ {
+ BindingList<FilterPreset> presets = new BindingList<FilterPreset>();
+ foreach (HBPresetTune preset in HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_UNSHARP))
+ {
+ presets.Add(new FilterPreset(preset));
+ }
+ return presets;
+ }
+ }
+
+ return new BindingList<FilterPreset>();
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Converters/Filters/SharpenTuneConverter.cs b/win/CS/HandBrakeWPF/Converters/Filters/SharpenTuneConverter.cs
new file mode 100644
index 000000000..72d40e3ae
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Converters/Filters/SharpenTuneConverter.cs
@@ -0,0 +1,58 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SharpenTuneConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// A converter to fetch the sharpen tunes
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Filters
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.HbLib;
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+
+ using HandBrakeWPF.Model.Filters;
+
+ public class SharpenTuneConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values.Length == 2)
+ {
+ Sharpen selectedSharpen = (Sharpen)values[1];
+ if (selectedSharpen == Sharpen.LapSharp)
+ {
+ BindingList<FilterTune> tunes = new BindingList<FilterTune>();
+ foreach (HBPresetTune tune in HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_LAPSHARP))
+ {
+ tunes.Add(new FilterTune(tune));
+ }
+ return tunes;
+ }
+ else if (selectedSharpen == Sharpen.UnSharp)
+ {
+ BindingList<FilterTune> tunes = new BindingList<FilterTune>();
+ foreach (HBPresetTune tune in HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_UNSHARP))
+ {
+ tunes.Add(new FilterTune(tune));
+ }
+ return tunes;
+ }
+ }
+
+ return new BindingList<HBPresetTune>();
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index 44c58bc0f..393bba2a4 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -155,6 +155,8 @@
<Compile Include="Converters\Audio\AudioTrackDefaultBehaviourConverter.cs" />
<Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />
<Compile Include="Converters\Filters\DenoisePresetConverter.cs" />
+ <Compile Include="Converters\Filters\SharpenTuneConverter.cs" />
+ <Compile Include="Converters\Filters\SharpenPresetConverter.cs" />
<Compile Include="Converters\Options\FileSizeConverter.cs" />
<Compile Include="Converters\Options\LogLevelConverter.cs" />
<Compile Include="Converters\PresetsMenuConverter.cs" />
@@ -178,6 +180,8 @@
<Compile Include="Model\Audio\AudioBehaviourModes.cs" />
<Compile Include="Model\Audio\AudioBehaviours.cs" />
<Compile Include="Model\DriveInformation.cs" />
+ <Compile Include="Model\Filters\FilterTune.cs" />
+ <Compile Include="Model\Filters\FilterPreset.cs" />
<Compile Include="Model\Picture\PresetPictureSettingsMode.cs" />
<Compile Include="Model\Subtitles\SubtitleBurnInBehaviourModes.cs" />
<Compile Include="Model\Subtitles\SubtitleBehaviourModes.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs b/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs
new file mode 100644
index 000000000..8745e68f6
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs
@@ -0,0 +1,53 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="FilterPreset.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Preset Filter
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Model.Filters
+{
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+
+ public class FilterPreset
+ {
+ public FilterPreset()
+ {
+ }
+
+ public FilterPreset(string displayName, string key)
+ {
+ this.DisplayName = displayName;
+ this.Key = key;
+ }
+
+ public FilterPreset(HBPresetTune presetTune)
+ {
+ this.DisplayName = presetTune.Name;
+ this.Key = presetTune.ShortName;
+ }
+
+ public string DisplayName { get; set; }
+ public string Key { get; set; }
+
+ protected bool Equals(FilterPreset other)
+ {
+ return string.Equals(this.Key, other.Key);
+ }
+
+ 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 Equals((FilterPreset)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (this.Key != null ? this.Key.GetHashCode() : 0);
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs b/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs
new file mode 100644
index 000000000..6f804a551
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs
@@ -0,0 +1,53 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="FilterTune.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Preset Tune
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Model.Filters
+{
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+
+ public class FilterTune
+ {
+ public FilterTune()
+ {
+ }
+
+ public FilterTune(string displayName, string key)
+ {
+ this.DisplayName = displayName;
+ this.Key = key;
+ }
+
+ public FilterTune(HBPresetTune presetTune)
+ {
+ this.DisplayName = presetTune.Name;
+ this.Key = presetTune.ShortName;
+ }
+
+ public string DisplayName { get; set; }
+ public string Key { get; set; }
+
+ protected bool Equals(FilterTune other)
+ {
+ return string.Equals(this.Key, other.Key);
+ }
+
+ 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 Equals((FilterTune)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return this.Key != null ? this.Key.GetHashCode() : 0;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs
index ca1faa57d..5f16110fe 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs
@@ -76,6 +76,23 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Custom Sharpen parameters.
+ ///
+ ///Unsharp syntax: y-strength=y:y-size=y:cb-strength=c:cb-size=c:cr-strength=c:cr-size=c
+ ///
+ ///Unsharp default: y-strength=0.25:y-size=7:cb-strength=0.25:cb-size=7
+ ///
+ ///Lapsharp syntax: y-strength=y:y-kernel=y:cb-strength=c:cb-kernel=c:cr-strength=c:cr-kernel=c
+ ///
+ ///Lapsharp default: y-strength=0.2:y-kernel=isolap:cb-strength=0.2:cb-kernel=isolap.
+ /// </summary>
+ public static string FilterView_CustomSharpenParams {
+ get {
+ return ResourceManager.GetString("FilterView_CustomSharpenParams", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Deblock reduces blocky artifacts caused by low quality video compression..
/// </summary>
public static string FilterView_Deblock {
@@ -249,6 +266,43 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Sharpening enhances the appearance of detail, especially edges. Overly strong Sharpen settings may damage picture quality and by creating ringing artifacts and enhancing noise, which can reduce compression efficiency.
+ ///
+ ///Unsharp is a general purpose unsharp masking filter. It sharpens by blurring, then calculating the difference between the blurred picture and the original.
+ ///
+ ///Lapsharp sharpens by using convolution kernels approximating Laplacian edge filters, sometimes producing higher quality results than [rest of string was truncated]&quot;;.
+ /// </summary>
+ public static string FilterView_Sharpen {
+ get {
+ return ResourceManager.GetString("FilterView_Sharpen", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Sharpen filter preset. Sets the strength of the filter..
+ /// </summary>
+ public static string FilterView_SharpenPreset {
+ get {
+ return ResourceManager.GetString("FilterView_SharpenPreset", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Sharpen tune. Further adjusts the Sharpen preset to optimize settings for specific scenarios.
+ ///
+ ///None uses the default preset settings.
+ ///
+ ///Unsharp can be tuned for Fine, Medium-Fine, Medium, Medium-Coarse, or Coarse sharpening. Select one based on the output picture resolution and fineness of detail to enhance.
+ ///
+ ///Lapsharp&apos;s Film tune refines settings for use with most live action content. Film uses an isotropic Laplacian kernel to sharpen all edges similarly, and luminance (brightness) information is sharp [rest of string was truncated]&quot;;.
+ /// </summary>
+ public static string FilterView_SharpenTune {
+ get {
+ return ResourceManager.GetString("FilterView_SharpenTune", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Add a new preset..
/// </summary>
public static string MainView_AddPreset {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx
index fe02d4fa0..4792a539f 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx
@@ -418,4 +418,40 @@ Bob attempts to better preserve motion for a slight penalty to perceived resolut
<data name="PictureSettingsView_KeepAR" xml:space="preserve">
<value>Keep Aspect Ratio maintains the original display aspect of the source. Disabling this may result in a stretched or squeezed picture.</value>
</data>
+ <data name="FilterView_CustomSharpenParams" xml:space="preserve">
+ <value>Custom Sharpen parameters.
+
+Unsharp syntax: y-strength=y:y-size=y:cb-strength=c:cb-size=c:cr-strength=c:cr-size=c
+
+Unsharp default: y-strength=0.25:y-size=7:cb-strength=0.25:cb-size=7
+
+Lapsharp syntax: y-strength=y:y-kernel=y:cb-strength=c:cb-kernel=c:cr-strength=c:cr-kernel=c
+
+Lapsharp default: y-strength=0.2:y-kernel=isolap:cb-strength=0.2:cb-kernel=isolap</value>
+ </data>
+ <data name="FilterView_Sharpen" xml:space="preserve">
+ <value>Sharpening enhances the appearance of detail, especially edges. Overly strong Sharpen settings may damage picture quality and by creating ringing artifacts and enhancing noise, which can reduce compression efficiency.
+
+Unsharp is a general purpose unsharp masking filter. It sharpens by blurring, then calculating the difference between the blurred picture and the original.
+
+Lapsharp sharpens by using convolution kernels approximating Laplacian edge filters, sometimes producing higher quality results than unsharp masking.</value>
+ </data>
+ <data name="FilterView_SharpenPreset" xml:space="preserve">
+ <value>Sharpen filter preset. Sets the strength of the filter.</value>
+ </data>
+ <data name="FilterView_SharpenTune" xml:space="preserve">
+ <value>Sharpen tune. Further adjusts the Sharpen preset to optimize settings for specific scenarios.
+
+None uses the default preset settings.
+
+Unsharp can be tuned for Fine, Medium-Fine, Medium, Medium-Coarse, or Coarse sharpening. Select one based on the output picture resolution and fineness of detail to enhance.
+
+Lapsharp's Film tune refines settings for use with most live action content. Film uses an isotropic Laplacian kernel to sharpen all edges similarly, and luminance (brightness) information is sharpened more than chrominance (color) information.
+
+Lapsharp's Grain tune is similar to Film, but uses an isotropic Laplacian of Gaussian kernel to reduce the effect on noise and grain. Useful for preserving grain and as a general alternative to the Film tune.
+
+Lapsharp's Animation tune is useful for cel animation such as anime and cartoons. Animation is identical to Film, but overall strength is reduced to avoid creating artifacts.
+
+Lapsharp's Sprite tune is useful for 1-/4-/8-/16-bit 2-dimensional games. Sprite uses a 4-neighbor Laplacian kernel that enhances vertical and horizontal edges more than diagonal edges.</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
index f6a7898f0..594420109 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
@@ -502,6 +502,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Sharpen.
+ /// </summary>
+ public static string FiltersView_Sharpen {
+ get {
+ return ResourceManager.GetString("FiltersView_Sharpen", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Tune:.
/// </summary>
public static string FiltersView_Tune {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
index 6dce889d2..34edf84b0 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
@@ -908,4 +908,7 @@ This will not affect your current settings in the Subtitle tab.</value>
<data name="MainView_Searching" xml:space="preserve">
<value>Searching for start time</value>
</data>
+ <data name="FiltersView_Sharpen" xml:space="preserve">
+ <value>Sharpen</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
index 6647b7fdf..efa595c4b 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
@@ -488,6 +488,25 @@ namespace HandBrakeWPF.Services.Encode.Factories
}
}
+ // Sharpen
+ if (job.Sharpen != Sharpen.Off)
+ {
+ hb_filter_ids id = job.Sharpen == Sharpen.LapSharp
+ ? hb_filter_ids.HB_FILTER_LAPSHARP
+ : hb_filter_ids.HB_FILTER_UNSHARP;
+
+ IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)id, job.SharpenPreset.Key, job.SharpenTune.Key, job.SharpenCustom);
+ string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
+
+ if (!string.IsNullOrEmpty(unparsedJson))
+ {
+ JToken settings = JObject.Parse(unparsedJson);
+
+ Filter filterItem = new Filter { ID = (int)id, Settings = settings };
+ filter.FilterList.Add(filterItem);
+ }
+ }
+
// Deblock
if (job.Deblock >= 5)
{
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs
index 4d0da57fe..84d1eb7eb 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs
@@ -17,6 +17,7 @@ namespace HandBrakeWPF.Services.Encode.Model
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.Model.Filters;
using HandBrakeWPF.Services.Encode.Model.Models;
using AllowedPassthru = HandBrakeWPF.Services.Encode.Model.Models.AllowedPassthru;
@@ -33,9 +34,6 @@ namespace HandBrakeWPF.Services.Encode.Model
using VideoProfile = HandBrakeWPF.Services.Encode.Model.Models.Video.VideoProfile;
using VideoTune = HandBrakeWPF.Services.Encode.Model.Models.Video.VideoTune;
- /// <summary>
- /// An Encode Task
- /// </summary>
public class EncodeTask : PropertyChangedBase
{
#region Private Fields
@@ -108,6 +106,10 @@ namespace HandBrakeWPF.Services.Encode.Model
this.Detelecine = task.Detelecine;
this.FlipVideo = task.FlipVideo;
this.Rotation = task.Rotation;
+ this.Sharpen = task.Sharpen;
+ this.SharpenPreset = task.SharpenPreset;
+ this.SharpenTune = task.SharpenTune;
+ this.SharpenCustom = task.SharpenCustom;
this.DisplayWidth = task.DisplayWidth;
this.EndPoint = task.EndPoint;
@@ -368,6 +370,11 @@ namespace HandBrakeWPF.Services.Encode.Model
/// Flip the video.
/// </summary>
public bool FlipVideo { get; set; }
+
+ public Sharpen Sharpen { get; set; }
+ public FilterPreset SharpenPreset { get; set; }
+ public FilterTune SharpenTune { get; set; }
+ public string SharpenCustom { get; set; }
#endregion
#region Video
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index a1b2b30a5..55eb3f1b9 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -9,12 +9,14 @@
namespace HandBrakeWPF.Services.Presets.Factories
{
+ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.HbLib;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
@@ -22,6 +24,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Model.Filters;
using HandBrakeWPF.Model.Picture;
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Services.Encode.Model.Models;
@@ -100,6 +103,35 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.Task.Grayscale = importedPreset.VideoGrayScale;
preset.Task.Deblock = importedPreset.PictureDeblock;
+ if (importedPreset.PictureSharpenFilter != null)
+ {
+ preset.Task.Sharpen = EnumHelper<Sharpen>.GetValue(importedPreset.PictureSharpenFilter);
+ hb_filter_ids filterId = hb_filter_ids.HB_FILTER_INVALID;
+ switch (preset.Task.Sharpen)
+ {
+ case Sharpen.LapSharp:
+ filterId = hb_filter_ids.HB_FILTER_LAPSHARP;
+ break;
+ case Sharpen.UnSharp:
+ filterId = hb_filter_ids.HB_FILTER_UNSHARP;
+ break;
+ }
+
+ if (filterId != hb_filter_ids.HB_FILTER_INVALID)
+ {
+ preset.Task.SharpenPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)filterId).FirstOrDefault(s => s.ShortName == importedPreset.PictureSharpenPreset));
+ preset.Task.SharpenTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)filterId).FirstOrDefault(s => s.ShortName == importedPreset.PictureSharpenTune));
+ preset.Task.SharpenCustom = importedPreset.PictureSharpenCustom;
+ }
+ else
+ {
+ // Default Values.
+ preset.Task.SharpenPreset = new FilterPreset("Medium", "medium");
+ preset.Task.SharpenTune = new FilterTune("None", "none");
+ preset.Task.SharpenCustom = string.Empty;
+ }
+ }
+
switch (importedPreset.PictureDeinterlaceFilter)
{
case "decomb":
@@ -613,6 +645,11 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.PictureDetelecine = EnumHelper<Detelecine>.GetShortName(export.Task.Detelecine);
preset.PictureDetelecineCustom = export.Task.CustomDetelecine;
+ preset.PictureSharpenFilter = EnumHelper<Sharpen>.GetShortName(export.Task.Sharpen);
+ preset.PictureSharpenPreset = export.Task.SharpenPreset != null ? export.Task.SharpenPreset.Key : string.Empty;
+ preset.PictureSharpenTune = export.Task.SharpenTune != null ? export.Task.SharpenTune.Key : string.Empty;
+ preset.PictureSharpenCustom = export.Task.SharpenCustom;
+
// Video
preset.VideoEncoder = EnumHelper<VideoEncoder>.GetShortName(export.Task.VideoEncoder);
preset.VideoFramerate = export.Task.Framerate.ToString();
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
index 67476f57f..d3afd0e8b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
@@ -12,11 +12,15 @@ namespace HandBrakeWPF.ViewModels
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
+ using System.Linq;
using Caliburn.Micro;
+ using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.HbLib;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.Model.Filters;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
@@ -594,11 +598,131 @@ namespace HandBrakeWPF.ViewModels
}
}
+ #region Sharpen Filter
+
+ public IEnumerable<Sharpen> SharpenOptions
+ {
+ get
+ {
+ return EnumHelper<Sharpen>.GetEnumList();
+ }
+ }
+
+ public object SharpenPresets { get; set; }
+
+ public object SharpenTunes { get; set; }
+
+ public Sharpen SelectedSharpen
+ {
+ get
+ {
+ return this.CurrentTask.Sharpen;
+ }
+
+ set
+ {
+ if (value == this.CurrentTask.Sharpen) return;
+ this.CurrentTask.Sharpen = value;
+ this.NotifyOfPropertyChange(() => this.SelectedSharpen);
+ this.NotifyOfPropertyChange(() => this.ShowSharpenOptions);
+ this.NotifyOfPropertyChange(() => this.ShowSharpenTune);
+ this.NotifyOfPropertyChange(() => this.ShowSharpenCustom);
+
+ // Default preset and tune.
+ switch (value)
+ {
+ case Sharpen.LapSharp:
+ if (this.SelectedSharpenPreset == null)
+ this.SelectedSharpenPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_LAPSHARP).FirstOrDefault(s => s.ShortName == "medium"));
+ if (this.SelectedSharpenTune == null)
+ this.SelectedSharpenTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_LAPSHARP).FirstOrDefault(s => s.ShortName == "none"));
+ break;
+ case Sharpen.UnSharp:
+ if (this.SelectedSharpenPreset == null)
+ this.SelectedSharpenPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_UNSHARP).FirstOrDefault(s => s.ShortName == "medium"));
+ if (this.SelectedSharpenTune == null)
+ this.SelectedSharpenTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_UNSHARP).FirstOrDefault(s => s.ShortName == "none"));
+ break;
+ }
+
+ this.NotifyOfPropertyChange(() => this.SelectedSharpenTune);
+ this.NotifyOfPropertyChange(() => this.SelectedSharpenPreset);
+ }
+ }
+
+ public FilterPreset SelectedSharpenPreset
+ {
+ get
+ {
+ return this.CurrentTask.SharpenPreset;
+ }
+ set
+ {
+ if (Equals(value, this.CurrentTask.SharpenPreset)) return;
+ this.CurrentTask.SharpenPreset = value;
+ this.NotifyOfPropertyChange(() => this.SelectedSharpenPreset);
+ this.NotifyOfPropertyChange(() => this.ShowSharpenTune);
+ this.NotifyOfPropertyChange(() => this.ShowSharpenCustom);
+ }
+ }
+
+ public FilterTune SelectedSharpenTune
+ {
+ get
+ {
+ return this.CurrentTask.SharpenTune;
+ }
+ set
+ {
+ if (value == this.CurrentTask.SharpenTune) return;
+ this.CurrentTask.SharpenTune = value;
+ this.NotifyOfPropertyChange(() => this.SelectedSharpenTune);
+ }
+ }
+
+ public string CustomSharpen
+ {
+ get
+ {
+ return this.CurrentTask.SharpenCustom;
+ }
+ set
+ {
+ if (value == this.CurrentTask.SharpenCustom) return;
+ this.CurrentTask.SharpenCustom = value;
+ this.NotifyOfPropertyChange(() => this.CustomSharpen);
+ }
+ }
+
+ public bool ShowSharpenTune
+ {
+ get
+ {
+ return this.SelectedSharpenPreset != null && this.SelectedSharpenPreset.DisplayName != "Custom";
+ }
+ }
+
+ public bool ShowSharpenCustom
+ {
+ get
+ {
+ return this.SelectedSharpenPreset != null && this.SelectedSharpenPreset.DisplayName == "Custom";
+ }
+ }
+
+ public bool ShowSharpenOptions
+ {
+ get
+ {
+ return this.SelectedSharpen != Sharpen.Off;
+ }
+ }
+
#endregion
- #region Implemented Interfaces
+ #endregion
- #region ITabInterface
+ #region Implemented Interfaces
/// <summary>
/// Setup this tab for the specified preset.
@@ -641,6 +765,12 @@ namespace HandBrakeWPF.ViewModels
this.SelectedDenoisePreset = preset.Task.DenoisePreset;
this.SelectedDenoiseTune = preset.Task.DenoiseTune;
+ // Sharpen
+ this.SelectedSharpen = preset.Task.Sharpen;
+ this.SelectedSharpenPreset = preset.Task.SharpenPreset;
+ this.SelectedSharpenTune = preset.Task.SharpenTune;
+ this.CustomSharpen = preset.Task.SharpenCustom;
+
// Custom Values
this.CustomDecomb = preset.Task.CustomDecomb;
this.CustomDeinterlace = preset.Task.CustomDeinterlace;
@@ -716,7 +846,5 @@ namespace HandBrakeWPF.ViewModels
}
#endregion
-
- #endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml
index 14ce4b75d..3dbc38ea5 100644
--- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml
+++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml
@@ -11,6 +11,8 @@
<Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
<Converters:EnumComboConverter x:Key="boolComboConverter" />
<filters:DenoisePresetConverter x:Key="DenoisePresetConverter" />
+ <filters:SharpenPresetConverter x:Key="SharpenPresetConverter" />
+ <filters:SharpenTuneConverter x:Key="SharpenTuneConverter" />
</UserControl.Resources>
<Grid>
@@ -37,6 +39,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -143,22 +146,63 @@
</StackPanel>
</StackPanel>
+
+ <!-- Sharpen -->
+ <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Sharpen}" Grid.Row="4" Grid.Column="0" Margin="0,0,0,10"/>
+ <ComboBox Width="120" Grid.Row="4" ItemsSource="{Binding SharpenOptions, Converter={StaticResource boolComboConverter}}"
+ SelectedItem="{Binding SelectedSharpen, Converter={StaticResource boolComboConverter}}" Grid.Column="1"
+ HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,10" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Sharpen}" />
+
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Row="4" Grid.Column="2" Margin="0,0,0,10"
+ Visibility="{Binding ShowSharpenOptions, Converter={StaticResource boolToVisConverter}}">
+
+ <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Preset}" Margin="0,0,5,0" />
+ <ComboBox SelectedItem="{Binding SelectedSharpenPreset}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_SharpenPreset}"
+ MinWidth="100" HorizontalAlignment="Center" VerticalAlignment="Center" DisplayMemberPath="DisplayName" >
+ <ComboBox.ItemsSource>
+ <MultiBinding Converter="{StaticResource SharpenPresetConverter}">
+ <Binding Path="SharpenPresets" />
+ <Binding Path="SelectedSharpen" />
+ </MultiBinding>
+ </ComboBox.ItemsSource>
+ </ComboBox>
+
+ <StackPanel Orientation="Horizontal" Visibility="{Binding ShowSharpenTune, Converter={StaticResource boolToVisConverter}}">
+ <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Tune}" Margin="5,0,5,0" />
+ <ComboBox SelectedItem="{Binding SelectedSharpenTune}" MinWidth="100" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_SharpenTune}" VerticalAlignment="Center" DisplayMemberPath="DisplayName" >
+ <ComboBox.ItemsSource>
+ <MultiBinding Converter="{StaticResource SharpenTuneConverter}">
+ <Binding Path="SharpenTunes" />
+ <Binding Path="SelectedSharpen" />
+ </MultiBinding>
+ </ComboBox.ItemsSource>
+ </ComboBox>
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" Visibility="{Binding ShowSharpenCustom, Converter={StaticResource boolToVisConverter}}">
+ <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Custom}" Margin="5,0,5,0" />
+ <TextBox Width="120" Margin="0" Text="{Binding CustomSharpen, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22"
+ ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_CustomSharpenParams}" />
+ </StackPanel>
+
+ </StackPanel>
- <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Deblock}" Grid.Row="4" Grid.Column="0" Margin="0,0,0,10"/>
- <Slider Width="120" Value="{Binding DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="4" Grid.Column="1" Margin="0,0,0,10"
+ <!-- Deblock -->
+ <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Deblock}" Grid.Row="5" Grid.Column="0" Margin="0,0,0,10"/>
+ <Slider Width="120" Value="{Binding DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"
HorizontalAlignment="Left" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Deblock}" />
- <TextBlock Text="{Binding DeblockText}" Grid.Row="4" Grid.Column="2" Margin="0,0,0,10"/>
+ <TextBlock Text="{Binding DeblockText}" Grid.Row="5" Grid.Column="2" Margin="0,0,0,10"/>
- <CheckBox Content="{x:Static Properties:ResourcesUI.FiltersView_Grayscale}" IsChecked="{Binding Grayscale}" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"
+ <CheckBox Content="{x:Static Properties:ResourcesUI.FiltersView_Grayscale}" IsChecked="{Binding Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,0,0,10"
ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Grayscale}" />
<!-- Rotation -->
- <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Rotate}" Grid.Row="6" Grid.Column="0" Margin="0,0,0,0"/>
- <ComboBox Width="120" ItemsSource="{Binding RotationOptions}" Grid.Row="6" Grid.Column="1"
+ <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Rotate}" Grid.Row="7" Grid.Column="0" Margin="0,0,0,0"/>
+ <ComboBox Width="120" ItemsSource="{Binding RotationOptions}" Grid.Row="7" Grid.Column="1"
SelectedItem="{Binding SelectedRotation}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Rotate}"
HorizontalAlignment="Left" VerticalAlignment="Center" />
- <CheckBox Content="{x:Static Properties:ResourcesUI.FiltersView_FlipVideo}" Margin="5,0,0,0" VerticalAlignment="Center" Grid.Row="6" Grid.Column="2" IsChecked="{Binding FlipVideo, UpdateSourceTrigger=PropertyChanged}"
+ <CheckBox Content="{x:Static Properties:ResourcesUI.FiltersView_FlipVideo}" Margin="5,0,0,0" VerticalAlignment="Center" Grid.Row="7" Grid.Column="2" IsChecked="{Binding FlipVideo, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Flip}"/>
</Grid>