diff options
author | sr55 <[email protected]> | 2017-06-02 22:03:16 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-06-02 22:03:16 +0100 |
commit | 27f366140509b18897f0dc54194a1a0d55cf0bb6 (patch) | |
tree | 62fc39ba1edd10fc4d5914177760df318eb4a25c /win/CS/HandBrakeWPF/Services | |
parent | 844a0bf724abc56edcad0390d82bf92eae219144 (diff) |
WinGui: Support for the new sharpen filter.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
3 files changed, 66 insertions, 3 deletions
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();
|