]> granicus.if.org Git - handbrake/commitdiff
WinGui: Support for the new sharpen filter.
authorsr55 <sr55.hb@outlook.com>
Fri, 2 Jun 2017 21:03:16 +0000 (22:03 +0100)
committersr55 <sr55.hb@outlook.com>
Fri, 2 Jun 2017 21:03:16 +0000 (22:03 +0100)
19 files changed:
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Interop/HbLib/hb_filter_ids.cs
win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs
win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/Sharpen.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Converters/Filters/SharpenTuneConverter.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs
win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx
win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs
win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
win/CS/HandBrakeWPF/Views/FiltersView.xaml

index c5f5555e97d1270aaefad63129fb5f995ef38766..a141598903b42ff0e5987f96c81cdfd15a994331 100644 (file)
     <Compile Include="Interop\Model\Encoding\CombDetect.cs" />\r
     <Compile Include="Interop\Model\Encoding\DeinterlaceFilter.cs" />\r
     <Compile Include="Interop\Model\Encoding\HBPresetTune.cs" />\r
+    <Compile Include="Interop\Model\Encoding\Sharpen.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
     <Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" />\r
     <Compile Include="Interop\Json\Scan\SourceChapter.cs" />\r
index 76059fe8b7265c444714aa35021b6c803764b967..63e279410c8b3dfe289dedfd1b2f9ad001f59f41 100644 (file)
@@ -27,6 +27,8 @@ namespace HandBrake.ApplicationServices.Interop.HbLib
         HB_FILTER_NLMEANS,\r
         HB_FILTER_RENDER_SUB,\r
         HB_FILTER_CROP_SCALE,\r
+        HB_FILTER_LAPSHARP,\r
+        HB_FILTER_UNSHARP,\r
         HB_FILTER_ROTATE,\r
         HB_FILTER_GRAYSCALE,\r
         HB_FILTER_PAD,\r
index 7e1e94697d8b3bec976ddb6366b6fb21afcfb3fb..6ddb9c0c29e6a54e5ee930137312d19564f93f9d 100644 (file)
@@ -166,6 +166,11 @@ namespace HandBrake.ApplicationServices.Interop.Json.Presets
         /// </summary>\r
         public string PictureDenoiseTune { get; set; }\r
 \r
+        public string PictureSharpenCustom { get; set; }\r
+        public string PictureSharpenFilter { get; set; }\r
+        public string PictureSharpenPreset { get; set; }\r
+        public string PictureSharpenTune { get; set; }\r
+\r
         /// <summary>\r
         /// Gets or sets the picture detelecine.\r
         /// </summary>\r
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 (file)
index 0000000..7f5b9e7
--- /dev/null
@@ -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
+    }
+}
index 91c30311a87bc78855779286e80d977fb2d9cbc6..c9afb8c14dac678f2c8ab59c959aca1cfb186919 100644 (file)
@@ -91,6 +91,10 @@ namespace HandBrakeWPF.Converters
             {\r
                 return EnumHelper<CombDetect>.GetEnumDisplayValues(typeof(CombDetect));\r
             }\r
+            if (value is IEnumerable<Sharpen>)\r
+            {\r
+                return EnumHelper<Sharpen>.GetEnumDisplayValues(typeof(Sharpen));\r
+            }\r
 \r
             // Single Items\r
             if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))\r
@@ -140,6 +144,10 @@ namespace HandBrakeWPF.Converters
             {\r
                 return EnumHelper<CombDetect>.GetDisplay((CombDetect)value);\r
             }\r
+            if (targetType == typeof(Sharpen) || value.GetType() == typeof(Sharpen))\r
+            {\r
+                return EnumHelper<Sharpen>.GetDisplay((Sharpen)value);\r
+            }\r
 \r
             return null;\r
         }\r
@@ -210,6 +218,11 @@ namespace HandBrakeWPF.Converters
             {\r
                 return EnumHelper<CombDetect>.GetValue(value.ToString());\r
             }\r
+\r
+            if (targetType == typeof(Sharpen) || value.GetType() == typeof(Sharpen))\r
+            {\r
+                return EnumHelper<Sharpen>.GetValue(value.ToString());\r
+            }\r
             return null;\r
         }\r
     }\r
diff --git a/win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs b/win/CS/HandBrakeWPF/Converters/Filters/SharpenPresetConverter.cs
new file mode 100644 (file)
index 0000000..417b0d1
--- /dev/null
@@ -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 (file)
index 0000000..72d40e3
--- /dev/null
@@ -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;
+        }
+    }
+}
index 44c58bc0fee7d6e92b7e8e9cee9082a3f1f795ed..393bba2a483b2af88412a0d573541a1746225ac6 100644 (file)
     <Compile Include="Converters\Audio\AudioTrackDefaultBehaviourConverter.cs" />\r
     <Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />\r
     <Compile Include="Converters\Filters\DenoisePresetConverter.cs" />\r
+    <Compile Include="Converters\Filters\SharpenTuneConverter.cs" />\r
+    <Compile Include="Converters\Filters\SharpenPresetConverter.cs" />\r
     <Compile Include="Converters\Options\FileSizeConverter.cs" />\r
     <Compile Include="Converters\Options\LogLevelConverter.cs" />\r
     <Compile Include="Converters\PresetsMenuConverter.cs" />\r
     <Compile Include="Model\Audio\AudioBehaviourModes.cs" />\r
     <Compile Include="Model\Audio\AudioBehaviours.cs" />\r
     <Compile Include="Model\DriveInformation.cs" />\r
+    <Compile Include="Model\Filters\FilterTune.cs" />\r
+    <Compile Include="Model\Filters\FilterPreset.cs" />\r
     <Compile Include="Model\Picture\PresetPictureSettingsMode.cs" />\r
     <Compile Include="Model\Subtitles\SubtitleBurnInBehaviourModes.cs" />\r
     <Compile Include="Model\Subtitles\SubtitleBehaviourModes.cs" />\r
diff --git a/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs b/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs
new file mode 100644 (file)
index 0000000..8745e68
--- /dev/null
@@ -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 (file)
index 0000000..6f804a5
--- /dev/null
@@ -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;
+        }
+    }
+}
index ca1faa57d91a1bc90b8f4f7e0b822f63a70bb2a0..5f16110fe813ad606d88384877dccec3b87582c6 100644 (file)
@@ -75,6 +75,23 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Custom Sharpen parameters.\r
+        ///\r
+        ///Unsharp syntax: y-strength=y:y-size=y:cb-strength=c:cb-size=c:cr-strength=c:cr-size=c\r
+        ///\r
+        ///Unsharp default: y-strength=0.25:y-size=7:cb-strength=0.25:cb-size=7\r
+        ///\r
+        ///Lapsharp syntax: y-strength=y:y-kernel=y:cb-strength=c:cb-kernel=c:cr-strength=c:cr-kernel=c\r
+        ///\r
+        ///Lapsharp default: y-strength=0.2:y-kernel=isolap:cb-strength=0.2:cb-kernel=isolap.\r
+        /// </summary>\r
+        public static string FilterView_CustomSharpenParams {\r
+            get {\r
+                return ResourceManager.GetString("FilterView_CustomSharpenParams", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Deblock reduces blocky artifacts caused by low quality video compression..\r
         /// </summary>\r
@@ -248,6 +265,43 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   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.\r
+        ///\r
+        ///Unsharp is a general purpose unsharp masking filter. It sharpens by blurring, then calculating the difference between the blurred picture and the original.\r
+        ///\r
+        ///Lapsharp sharpens by using convolution kernels approximating Laplacian edge filters, sometimes producing higher quality results than [rest of string was truncated]&quot;;.\r
+        /// </summary>\r
+        public static string FilterView_Sharpen {\r
+            get {\r
+                return ResourceManager.GetString("FilterView_Sharpen", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Sharpen filter preset. Sets the strength of the filter..\r
+        /// </summary>\r
+        public static string FilterView_SharpenPreset {\r
+            get {\r
+                return ResourceManager.GetString("FilterView_SharpenPreset", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Sharpen tune. Further adjusts the Sharpen preset to optimize settings for specific scenarios.\r
+        ///\r
+        ///None uses the default preset settings.\r
+        ///\r
+        ///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.\r
+        ///\r
+        ///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;;.\r
+        /// </summary>\r
+        public static string FilterView_SharpenTune {\r
+            get {\r
+                return ResourceManager.GetString("FilterView_SharpenTune", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Add a new preset..\r
         /// </summary>\r
index fe02d4fa0efe46cf8498cd8669d54e226961aa49..4792a539f71f75722b7e18398a19c93657d4db10 100644 (file)
@@ -418,4 +418,40 @@ Bob attempts to better preserve motion for a slight penalty to perceived resolut
   <data name="PictureSettingsView_KeepAR" xml:space="preserve">\r
     <value>Keep Aspect Ratio maintains the original display aspect of the source. Disabling this may result in a stretched or squeezed picture.</value>\r
   </data>\r
+  <data name="FilterView_CustomSharpenParams" xml:space="preserve">\r
+    <value>Custom Sharpen parameters.\r
+\r
+Unsharp syntax: y-strength=y:y-size=y:cb-strength=c:cb-size=c:cr-strength=c:cr-size=c\r
+\r
+Unsharp default: y-strength=0.25:y-size=7:cb-strength=0.25:cb-size=7\r
+\r
+Lapsharp syntax: y-strength=y:y-kernel=y:cb-strength=c:cb-kernel=c:cr-strength=c:cr-kernel=c\r
+\r
+Lapsharp default: y-strength=0.2:y-kernel=isolap:cb-strength=0.2:cb-kernel=isolap</value>\r
+  </data>\r
+  <data name="FilterView_Sharpen" xml:space="preserve">\r
+    <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.\r
+\r
+Unsharp is a general purpose unsharp masking filter. It sharpens by blurring, then calculating the difference between the blurred picture and the original.\r
+\r
+Lapsharp sharpens by using convolution kernels approximating Laplacian edge filters, sometimes producing higher quality results than unsharp masking.</value>\r
+  </data>\r
+  <data name="FilterView_SharpenPreset" xml:space="preserve">\r
+    <value>Sharpen filter preset. Sets the strength of the filter.</value>\r
+  </data>\r
+  <data name="FilterView_SharpenTune" xml:space="preserve">\r
+    <value>Sharpen tune. Further adjusts the Sharpen preset to optimize settings for specific scenarios.\r
+\r
+None uses the default preset settings.\r
+\r
+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.\r
+\r
+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.\r
+\r
+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.\r
+\r
+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.\r
+\r
+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>\r
+  </data>\r
 </root>
\ No newline at end of file
index f6a7898f0df536372941d3126e78f811ce517d5d..5944201090d66d9c9ba17547c0c76cee079562ed 100644 (file)
@@ -501,6 +501,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Sharpen.\r
+        /// </summary>\r
+        public static string FiltersView_Sharpen {\r
+            get {\r
+                return ResourceManager.GetString("FiltersView_Sharpen", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Tune:.\r
         /// </summary>\r
index 6dce889d239ac3b94ac9a763a1e1ff210b397a4a..34edf84b045b3d244548bbe3a931bce6c54e0218 100644 (file)
@@ -908,4 +908,7 @@ This will not affect your current settings in the Subtitle tab.</value>
   <data name="MainView_Searching" xml:space="preserve">\r
     <value>Searching for start time</value>\r
   </data>\r
+  <data name="FiltersView_Sharpen" xml:space="preserve">\r
+    <value>Sharpen</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index 6647b7fdfcb5f16101678574e124903fd50c2c1b..efa595c4b7b981bd7ec1955f0f0247645b9c69ae 100644 (file)
@@ -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)
             {
index 4d0da57fe1f5942755f983743d142fc057557226..84d1eb7ebc018f8bafd177eec623ef3266cf6a1d 100644 (file)
@@ -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
index a1b2b30a5174892d8614894505dce69615b83bc2..55eb3f1b98b69bd05f4ea66c8bea3d83b1342c0f 100644 (file)
@@ -9,12 +9,14 @@
 \r
 namespace HandBrakeWPF.Services.Presets.Factories\r
 {\r
+    using System;\r
     using System.Collections.Generic;\r
     using System.Collections.ObjectModel;\r
     using System.Globalization;\r
     using System.Linq;\r
 \r
     using HandBrake.ApplicationServices.Interop;\r
+    using HandBrake.ApplicationServices.Interop.HbLib;\r
     using HandBrake.ApplicationServices.Interop.Json.Presets;\r
     using HandBrake.ApplicationServices.Interop.Model;\r
     using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
@@ -22,6 +24,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
     using HandBrake.ApplicationServices.Utilities;\r
 \r
     using HandBrakeWPF.Model.Audio;\r
+    using HandBrakeWPF.Model.Filters;\r
     using HandBrakeWPF.Model.Picture;\r
     using HandBrakeWPF.Model.Subtitles;\r
     using HandBrakeWPF.Services.Encode.Model.Models;\r
@@ -100,6 +103,35 @@ namespace HandBrakeWPF.Services.Presets.Factories
             preset.Task.Grayscale = importedPreset.VideoGrayScale;\r
             preset.Task.Deblock = importedPreset.PictureDeblock;\r
 \r
+            if (importedPreset.PictureSharpenFilter != null)\r
+            {\r
+                preset.Task.Sharpen = EnumHelper<Sharpen>.GetValue(importedPreset.PictureSharpenFilter);\r
+                hb_filter_ids filterId = hb_filter_ids.HB_FILTER_INVALID;\r
+                switch (preset.Task.Sharpen)\r
+                {\r
+                    case Sharpen.LapSharp:\r
+                        filterId = hb_filter_ids.HB_FILTER_LAPSHARP;\r
+                        break;\r
+                    case Sharpen.UnSharp:\r
+                        filterId = hb_filter_ids.HB_FILTER_UNSHARP;\r
+                        break;\r
+                }\r
+\r
+                if (filterId != hb_filter_ids.HB_FILTER_INVALID)\r
+                {\r
+                    preset.Task.SharpenPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)filterId).FirstOrDefault(s => s.ShortName == importedPreset.PictureSharpenPreset));\r
+                    preset.Task.SharpenTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)filterId).FirstOrDefault(s => s.ShortName == importedPreset.PictureSharpenTune));\r
+                    preset.Task.SharpenCustom = importedPreset.PictureSharpenCustom;\r
+                }\r
+                else\r
+                {\r
+                    // Default Values.\r
+                    preset.Task.SharpenPreset = new FilterPreset("Medium", "medium");\r
+                    preset.Task.SharpenTune = new FilterTune("None", "none");\r
+                    preset.Task.SharpenCustom = string.Empty;\r
+                }\r
+            }\r
+\r
             switch (importedPreset.PictureDeinterlaceFilter)\r
             {\r
                 case "decomb":\r
@@ -613,6 +645,11 @@ namespace HandBrakeWPF.Services.Presets.Factories
             preset.PictureDetelecine = EnumHelper<Detelecine>.GetShortName(export.Task.Detelecine);\r
             preset.PictureDetelecineCustom = export.Task.CustomDetelecine;\r
 \r
+            preset.PictureSharpenFilter = EnumHelper<Sharpen>.GetShortName(export.Task.Sharpen);\r
+            preset.PictureSharpenPreset = export.Task.SharpenPreset != null ? export.Task.SharpenPreset.Key : string.Empty; \r
+            preset.PictureSharpenTune = export.Task.SharpenTune != null ? export.Task.SharpenTune.Key : string.Empty;\r
+            preset.PictureSharpenCustom = export.Task.SharpenCustom;\r
+\r
             // Video\r
             preset.VideoEncoder = EnumHelper<VideoEncoder>.GetShortName(export.Task.VideoEncoder);\r
             preset.VideoFramerate = export.Task.Framerate.ToString();\r
index 67476f57f63594518430815af2b6d46638623725..d3afd0e8bc71967cb37ef7b3f68ca8e8b9609981 100644 (file)
@@ -12,11 +12,15 @@ namespace HandBrakeWPF.ViewModels
     using System.Collections.Generic;\r
     using System.ComponentModel;\r
     using System.Globalization;\r
+    using System.Linq;\r
 \r
     using Caliburn.Micro;\r
 \r
+    using HandBrake.ApplicationServices.Interop;\r
+    using HandBrake.ApplicationServices.Interop.HbLib;\r
     using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
 \r
+    using HandBrakeWPF.Model.Filters;\r
     using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.Services.Presets.Model;\r
     using HandBrakeWPF.Services.Scan.Model;\r
@@ -594,11 +598,131 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        #region Sharpen Filter\r
+\r
+        public IEnumerable<Sharpen> SharpenOptions\r
+        {\r
+            get\r
+            {\r
+                return EnumHelper<Sharpen>.GetEnumList();\r
+            }\r
+        }\r
+\r
+        public object SharpenPresets { get; set; }\r
+\r
+        public object SharpenTunes { get; set; }\r
+\r
+        public Sharpen SelectedSharpen\r
+        {\r
+            get\r
+            {\r
+                return this.CurrentTask.Sharpen;\r
+            }\r
+\r
+            set\r
+            {\r
+                if (value == this.CurrentTask.Sharpen) return;\r
+                this.CurrentTask.Sharpen = value;\r
+                this.NotifyOfPropertyChange(() => this.SelectedSharpen);\r
+                this.NotifyOfPropertyChange(() => this.ShowSharpenOptions);\r
+                this.NotifyOfPropertyChange(() => this.ShowSharpenTune);\r
+                this.NotifyOfPropertyChange(() => this.ShowSharpenCustom);\r
+\r
+                // Default preset and tune.\r
+                switch (value)\r
+                {\r
+                    case Sharpen.LapSharp:\r
+                        if (this.SelectedSharpenPreset == null)\r
+                            this.SelectedSharpenPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_LAPSHARP).FirstOrDefault(s => s.ShortName == "medium"));\r
+                        if (this.SelectedSharpenTune == null)\r
+                            this.SelectedSharpenTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_LAPSHARP).FirstOrDefault(s => s.ShortName == "none"));\r
+                        break;\r
+                    case Sharpen.UnSharp:\r
+                        if (this.SelectedSharpenPreset == null)\r
+                            this.SelectedSharpenPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_UNSHARP).FirstOrDefault(s => s.ShortName == "medium"));\r
+                        if (this.SelectedSharpenTune == null)\r
+                            this.SelectedSharpenTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_UNSHARP).FirstOrDefault(s => s.ShortName == "none"));\r
+                        break;\r
+                }\r
+\r
+                this.NotifyOfPropertyChange(() => this.SelectedSharpenTune);\r
+                this.NotifyOfPropertyChange(() => this.SelectedSharpenPreset);\r
+            }\r
+        }\r
+\r
+        public FilterPreset SelectedSharpenPreset\r
+        {\r
+            get\r
+            {\r
+                return this.CurrentTask.SharpenPreset;\r
+            }\r
+            set\r
+            {\r
+                if (Equals(value, this.CurrentTask.SharpenPreset)) return;\r
+                this.CurrentTask.SharpenPreset = value;\r
+                this.NotifyOfPropertyChange(() => this.SelectedSharpenPreset);\r
+                this.NotifyOfPropertyChange(() => this.ShowSharpenTune);\r
+                this.NotifyOfPropertyChange(() => this.ShowSharpenCustom);\r
+            }\r
+        }\r
+\r
+        public FilterTune SelectedSharpenTune\r
+        {\r
+            get\r
+            {\r
+                return this.CurrentTask.SharpenTune;\r
+            }\r
+            set\r
+            {\r
+                if (value == this.CurrentTask.SharpenTune) return;\r
+                this.CurrentTask.SharpenTune = value;\r
+                this.NotifyOfPropertyChange(() => this.SelectedSharpenTune);\r
+            }\r
+        }\r
+\r
+        public string CustomSharpen\r
+        {\r
+            get\r
+            {\r
+                return this.CurrentTask.SharpenCustom;\r
+            }\r
+            set\r
+            {\r
+                if (value == this.CurrentTask.SharpenCustom) return;\r
+                this.CurrentTask.SharpenCustom = value;\r
+                this.NotifyOfPropertyChange(() => this.CustomSharpen);\r
+            }\r
+        }\r
+\r
+        public bool ShowSharpenTune\r
+        {\r
+            get\r
+            {\r
+                return this.SelectedSharpenPreset != null && this.SelectedSharpenPreset.DisplayName != "Custom";\r
+            }\r
+        }\r
+\r
+        public bool ShowSharpenCustom\r
+        {\r
+            get\r
+            {\r
+                return this.SelectedSharpenPreset != null && this.SelectedSharpenPreset.DisplayName == "Custom";\r
+            }\r
+        }\r
+\r
+        public bool ShowSharpenOptions\r
+        {\r
+            get\r
+            {\r
+                return this.SelectedSharpen != Sharpen.Off;\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
-        #region Implemented Interfaces\r
+        #endregion\r
 \r
-        #region ITabInterface\r
+        #region Implemented Interfaces\r
 \r
         /// <summary>\r
         /// Setup this tab for the specified preset.\r
@@ -641,6 +765,12 @@ namespace HandBrakeWPF.ViewModels
                 this.SelectedDenoisePreset = preset.Task.DenoisePreset;\r
                 this.SelectedDenoiseTune = preset.Task.DenoiseTune;\r
 \r
+                // Sharpen\r
+                this.SelectedSharpen = preset.Task.Sharpen;\r
+                this.SelectedSharpenPreset = preset.Task.SharpenPreset;\r
+                this.SelectedSharpenTune = preset.Task.SharpenTune;\r
+                this.CustomSharpen = preset.Task.SharpenCustom;\r
+\r
                 // Custom Values\r
                 this.CustomDecomb = preset.Task.CustomDecomb;\r
                 this.CustomDeinterlace = preset.Task.CustomDeinterlace;\r
@@ -716,7 +846,5 @@ namespace HandBrakeWPF.ViewModels
         }\r
 \r
         #endregion\r
-\r
-        #endregion\r
     }\r
 }
\ No newline at end of file
index 14ce4b75d449ff08cff59faa5d82a5e4a554b46a..3dbc38ea566f90195a7b8661a0290bff02e3cbeb 100644 (file)
@@ -11,6 +11,8 @@
         <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />\r
         <Converters:EnumComboConverter x:Key="boolComboConverter" />\r
         <filters:DenoisePresetConverter x:Key="DenoisePresetConverter" />\r
+        <filters:SharpenPresetConverter x:Key="SharpenPresetConverter" />\r
+        <filters:SharpenTuneConverter x:Key="SharpenTuneConverter" />\r
     </UserControl.Resources>\r
 \r
     <Grid>\r
@@ -37,6 +39,7 @@
                     <RowDefinition Height="Auto" />\r
                     <RowDefinition Height="Auto" />\r
                     <RowDefinition Height="Auto" />\r
+                    <RowDefinition Height="Auto" />\r
                 </Grid.RowDefinitions>\r
 \r
                 <Grid.ColumnDefinitions>\r
                     </StackPanel>\r
 \r
                 </StackPanel>\r
+                \r
+                <!-- Sharpen -->\r
+                <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Sharpen}" Grid.Row="4" Grid.Column="0" Margin="0,0,0,10"/>\r
+                <ComboBox Width="120" Grid.Row="4" ItemsSource="{Binding SharpenOptions, Converter={StaticResource boolComboConverter}}" \r
+                          SelectedItem="{Binding SelectedSharpen, Converter={StaticResource boolComboConverter}}" Grid.Column="1"\r
+                          HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,10" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Sharpen}" />\r
+                \r
+                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Row="4" Grid.Column="2" Margin="0,0,0,10" \r
+                            Visibility="{Binding ShowSharpenOptions, Converter={StaticResource boolToVisConverter}}">\r
+                    \r
+                    <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Preset}" Margin="0,0,5,0" />\r
+                    <ComboBox SelectedItem="{Binding SelectedSharpenPreset}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_SharpenPreset}"\r
+                              MinWidth="100"  HorizontalAlignment="Center" VerticalAlignment="Center" DisplayMemberPath="DisplayName" >\r
+                        <ComboBox.ItemsSource>\r
+                            <MultiBinding Converter="{StaticResource SharpenPresetConverter}">\r
+                                <Binding Path="SharpenPresets" />\r
+                                <Binding Path="SelectedSharpen" />\r
+                            </MultiBinding>\r
+                        </ComboBox.ItemsSource>\r
+                    </ComboBox>\r
+\r
+                    <StackPanel Orientation="Horizontal" Visibility="{Binding ShowSharpenTune, Converter={StaticResource boolToVisConverter}}">\r
+                        <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Tune}" Margin="5,0,5,0" />\r
+                        <ComboBox SelectedItem="{Binding SelectedSharpenTune}" MinWidth="100" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_SharpenTune}" VerticalAlignment="Center" DisplayMemberPath="DisplayName" >\r
+                            <ComboBox.ItemsSource>\r
+                                <MultiBinding Converter="{StaticResource SharpenTuneConverter}">\r
+                                    <Binding Path="SharpenTunes" />\r
+                                    <Binding Path="SelectedSharpen" />\r
+                                </MultiBinding>\r
+                            </ComboBox.ItemsSource>\r
+                        </ComboBox>\r
+                    </StackPanel>\r
+\r
+                    <StackPanel Orientation="Horizontal" Visibility="{Binding ShowSharpenCustom, Converter={StaticResource boolToVisConverter}}">\r
+                        <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Custom}" Margin="5,0,5,0" />\r
+                        <TextBox Width="120" Margin="0" Text="{Binding CustomSharpen, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22"\r
+                                 ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_CustomSharpenParams}" />\r
+                    </StackPanel>\r
+\r
+                </StackPanel>\r
 \r
-                <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Deblock}" Grid.Row="4" Grid.Column="0" Margin="0,0,0,10"/>\r
-                <Slider Width="120" Value="{Binding DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="4" Grid.Column="1" Margin="0,0,0,10"\r
+                <!-- Deblock -->\r
+                <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Deblock}" Grid.Row="5" Grid.Column="0" Margin="0,0,0,10"/>\r
+                <Slider Width="120" Value="{Binding DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"\r
                         HorizontalAlignment="Left" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Deblock}" />\r
-                <TextBlock Text="{Binding DeblockText}" Grid.Row="4" Grid.Column="2" Margin="0,0,0,10"/>\r
+                <TextBlock Text="{Binding DeblockText}" Grid.Row="5" Grid.Column="2" Margin="0,0,0,10"/>\r
 \r
-                <CheckBox Content="{x:Static Properties:ResourcesUI.FiltersView_Grayscale}" IsChecked="{Binding Grayscale}" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"\r
+                <CheckBox Content="{x:Static Properties:ResourcesUI.FiltersView_Grayscale}" IsChecked="{Binding Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,0,0,10"\r
                           ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Grayscale}" />\r
 \r
                 <!-- Rotation -->\r
-                <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Rotate}" Grid.Row="6" Grid.Column="0" Margin="0,0,0,0"/>\r
-                <ComboBox Width="120" ItemsSource="{Binding RotationOptions}" Grid.Row="6" Grid.Column="1"\r
+                <TextBlock Text="{x:Static Properties:ResourcesUI.FiltersView_Rotate}" Grid.Row="7" Grid.Column="0" Margin="0,0,0,0"/>\r
+                <ComboBox Width="120" ItemsSource="{Binding RotationOptions}" Grid.Row="7" Grid.Column="1"\r
                               SelectedItem="{Binding SelectedRotation}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Rotate}"\r
                               HorizontalAlignment="Left" VerticalAlignment="Center" />\r
 \r
-                <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}"\r
+                <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}"\r
                           ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Flip}"/>\r
             </Grid>\r
 \r