From 047b684310107ec84d16bb767a9345c7c7fe1afe Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 30 Jan 2021 18:33:56 +0000 Subject: WinGui: Add support for Chroma Smooth filter. --- .../Services/Encode/Factories/EncodeTaskFactory.cs | 12 ++++++++++++ win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs | 11 ++++++++++- .../Services/Presets/Factories/JsonPresetFactory.cs | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'win/CS/HandBrakeWPF/Services') diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs index faba29387..cac804d38 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -499,6 +499,18 @@ namespace HandBrakeWPF.Services.Encode.Factories } } + if (job.ChromaSmooth != null && job.ChromaSmooth.Key != "off") + { + string unparsedJson = HandBrakeFilterHelpers.GenerateFilterSettingJson((int)hb_filter_ids.HB_FILTER_CHROMA_SMOOTH, job.ChromaSmooth.Key, job.ChromaSmoothTune?.Key, job.CustomChromaSmooth); + if (!string.IsNullOrEmpty(unparsedJson)) + { + JsonDocument settings = JsonDocument.Parse(unparsedJson); + + Filter filterItem = new Filter { ID = (int)hb_filter_ids.HB_FILTER_CHROMA_SMOOTH, Settings = settings }; + filter.FilterList.Add(filterItem); + } + } + // Grayscale if (job.Grayscale) diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index bd50f19cf..3f1835888 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -93,6 +93,9 @@ namespace HandBrakeWPF.Services.Encode.Model this.Padding = task.Padding; this.Colourspace = task.Colourspace; this.CustomColourspace = task.CustomColourspace; + this.ChromaSmooth = task.ChromaSmooth; + this.ChromaSmoothTune = task.ChromaSmoothTune; + this.CustomChromaSmooth = task.CustomChromaSmooth; this.DisplayWidth = task.DisplayWidth; this.EndPoint = task.EndPoint; @@ -243,7 +246,13 @@ namespace HandBrakeWPF.Services.Encode.Model public FilterPreset Colourspace { get; set; } public string CustomColourspace { get; set; } - + + public FilterPreset ChromaSmooth { get; set; } + + public FilterTune ChromaSmoothTune { get; set; } + + public string CustomChromaSmooth { get; set; } + /* Video */ public VideoEncodeRateType VideoEncodeRateType { get; set; } diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs index bf116c183..d54330c81 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs @@ -97,6 +97,17 @@ namespace HandBrakeWPF.Services.Presets.Factories { preset.Task.Colourspace = new FilterPreset("Off", "off"); } + + if (!string.IsNullOrEmpty(importedPreset.PictureChromaSmoothPreset)) + { + preset.Task.ChromaSmooth = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_CHROMA_SMOOTH).FirstOrDefault(s => s.ShortName == importedPreset.PictureChromaSmoothPreset)); + preset.Task.ChromaSmoothTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_CHROMA_SMOOTH).FirstOrDefault(s => s.ShortName == importedPreset.PictureChromaSmoothTune)); + preset.Task.CustomChromaSmooth = importedPreset.PictureChromaSmoothCustom; + } + else + { + preset.Task.ChromaSmooth = new FilterPreset("Off", "off"); + } if (!string.IsNullOrEmpty(importedPreset.PictureDeblockPreset)) { @@ -648,6 +659,10 @@ namespace HandBrakeWPF.Services.Presets.Factories preset.PictureColorspacePreset = export.Task.Colourspace?.Key; preset.PictureColorspaceCustom = export.Task.CustomColourspace; + preset.PictureChromaSmoothPreset = export.Task.ChromaSmooth?.Key; + preset.PictureChromaSmoothTune = export.Task.ChromaSmoothTune?.Key; + preset.PictureChromaSmoothCustom = export.Task.CustomChromaSmooth; + // Video preset.VideoEncoder = EnumHelper.GetShortName(export.Task.VideoEncoder); preset.VideoFramerate = export.Task.Framerate.HasValue ? export.Task.Framerate.ToString() : null; -- cgit v1.2.3