diff options
author | sr55 <[email protected]> | 2021-01-30 17:20:03 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2021-01-30 17:20:03 +0000 |
commit | 64e15a878106652f723bd0d72c3a32a3e7e184c8 (patch) | |
tree | 77f888ce0bd1510723e5612298bc1193aeb48084 /win/CS | |
parent | 15cad9f2092ece526ea245b9600fd57de0d0561c (diff) |
WinGui: Add support for the colourspace filter.
Diffstat (limited to 'win/CS')
13 files changed, 258 insertions, 6 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/hb_filter_ids.cs b/win/CS/HandBrake.Interop/Interop/HbLib/hb_filter_ids.cs index 0bd958f15..1b410e488 100644 --- a/win/CS/HandBrake.Interop/Interop/HbLib/hb_filter_ids.cs +++ b/win/CS/HandBrake.Interop/Interop/HbLib/hb_filter_ids.cs @@ -33,6 +33,7 @@ namespace HandBrake.Interop.Interop.HbLib HB_FILTER_ROTATE, HB_FILTER_GRAYSCALE, HB_FILTER_PAD, + HB_FILTER_COLORSPACE, // Finally filters that don't care what order they are in, // except that they must be after the above filters @@ -42,6 +43,9 @@ namespace HandBrake.Interop.Interop.HbLib HB_FILTER_QSV_POST, // default MSDK VPP filter HB_FILTER_QSV, - HB_FILTER_LAST = HB_FILTER_QSV + HB_FILTER_LAST = HB_FILTER_QSV, + + // wrapper filter for frame based multi-threading of simple filters + HB_FILTER_MT_FRAME, } } diff --git a/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs index 578bcfc50..4e42409b8 100644 --- a/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs +++ b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs @@ -187,6 +187,10 @@ namespace HandBrake.Interop.Interop.Json.Presets /// </summary> public string PictureDetelecineCustom { get; set; } + public string PictureColorspacePreset { get; set; } + + public string PictureColorspaceCustom { get; set; } + /// <summary> /// Gets or sets a value indicating whether picture itu par. /// </summary> diff --git a/win/CS/HandBrakeWPF/Converters/Queue/FilterSettingsDescConverter.cs b/win/CS/HandBrakeWPF/Converters/Queue/FilterSettingsDescConverter.cs index d9ef55f22..0707457f2 100644 --- a/win/CS/HandBrakeWPF/Converters/Queue/FilterSettingsDescConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Queue/FilterSettingsDescConverter.cs @@ -61,11 +61,16 @@ namespace HandBrakeWPF.Converters.Queue filters.Add(Resources.SummaryView_Rotation); } + if (task.Colourspace != null && task.Colourspace.Key != ColourSpaceFilter.Off) + { + filters.Add(Resources.SummaryView_Colourspace); + } + if (filters.Count == 0) { return Resources.SummaryView_NoFilters; } - + return string.Join(", ", filters).TrimEnd(',').Trim(); } diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 601dabd99..115f5befe 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -971,6 +971,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to Colourspace:. + /// </summary> + public static string FiltersView_ColourSpace { + get { + return ResourceManager.GetString("FiltersView_ColourSpace", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Custom:. /// </summary> public static string FiltersView_Custom { @@ -6142,6 +6151,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to Colourspace. + /// </summary> + public static string SummaryView_Colourspace { + get { + return ResourceManager.GetString("SummaryView_Colourspace", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Deblock. /// </summary> public static string SummaryView_Deblock { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 34943b9e6..76cd45b47 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -2417,4 +2417,10 @@ Fields are limited to: <data name="OptionsView_RequiresRestart" xml:space="preserve">
<value>(Requires Restart)</value>
</data>
+ <data name="FiltersView_ColourSpace" xml:space="preserve">
+ <value>Colourspace:</value>
+ </data>
+ <data name="SummaryView_Colourspace" xml:space="preserve">
+ <value>Colourspace</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs index 4e2e746bd..2e053e9f7 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs @@ -61,6 +61,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Colourspace Filter..
+ /// </summary>
+ public static string FiltersView_ColourSpace {
+ get {
+ return ResourceManager.GetString("FiltersView_ColourSpace", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Custom Denoise parameters.
///
///NLMeans syntax: y-strength=y:y-origin-tune=y:y-patch-size=y:y-range=y:y-frame-count=y:y-prefilter=y:cb-strength=c:cb-origin-tune=c:cb-patch-size=c:cb-range=c:cb-frame-count=c:cb-prefilter=c:cr-strength=c:cr-origin-tune=c:cr-patch-size=c:cr-range=c:cr-frame-count=c:cr-prefilter=c:threads=t
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx index b65e11e36..8690319ae 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx @@ -112,10 +112,10 @@ <value>2.0</value>
</resheader>
<resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="FilterView_Deblock" xml:space="preserve">
<value>Deblock reduces blocky artifacts caused by low quality video compression.</value>
@@ -465,4 +465,7 @@ Lapsharp's Sprite tune is useful for 1-/4-/8-/16-bit 2-dimensional games. Sprite <value>When enabled the auto name system will always use the default path.
When disabled, it will use the path in the destination box on the main window if populated, otherwise it will use the default path.</value>
</data>
+ <data name="FiltersView_ColourSpace" xml:space="preserve">
+ <value>Colourspace Filter.</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs index da1fcf678..faba29387 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -486,6 +486,20 @@ namespace HandBrakeWPF.Services.Encode.Factories } } + // Colourspace + if (job.Colourspace != null && job.Colourspace.Key != "off") + { + string unparsedJson = HandBrakeFilterHelpers.GenerateFilterSettingJson((int)hb_filter_ids.HB_FILTER_COLORSPACE, job.Colourspace.Key, null, job.CustomColourspace); + if (!string.IsNullOrEmpty(unparsedJson)) + { + JsonDocument settings = JsonDocument.Parse(unparsedJson); + + Filter filterItem = new Filter { ID = (int)hb_filter_ids.HB_FILTER_COLORSPACE, 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 710127d0c..bd50f19cf 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -91,6 +91,8 @@ namespace HandBrakeWPF.Services.Encode.Model this.SharpenTune = task.SharpenTune; this.SharpenCustom = task.SharpenCustom; this.Padding = task.Padding; + this.Colourspace = task.Colourspace; + this.CustomColourspace = task.CustomColourspace; this.DisplayWidth = task.DisplayWidth; this.EndPoint = task.EndPoint; @@ -237,6 +239,10 @@ namespace HandBrakeWPF.Services.Encode.Model public string CustomDeblock { get; set; } public PaddingFilter Padding { get; set; } + + public FilterPreset Colourspace { get; set; } + + public string CustomColourspace { get; set; } /* Video */ diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs index 4559f61f5..bf116c183 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs @@ -88,6 +88,16 @@ namespace HandBrakeWPF.Services.Presets.Factories /* Filter Settings */
preset.Task.Grayscale = importedPreset.VideoGrayScale;
+ if (!string.IsNullOrEmpty(importedPreset.PictureColorspacePreset))
+ {
+ preset.Task.Colourspace = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_COLORSPACE).FirstOrDefault(s => s.ShortName == importedPreset.PictureColorspacePreset));
+ preset.Task.CustomColourspace = importedPreset.PictureColorspaceCustom;
+ }
+ else
+ {
+ preset.Task.Colourspace = new FilterPreset("Off", "off");
+ }
+
if (!string.IsNullOrEmpty(importedPreset.PictureDeblockPreset))
{
preset.Task.DeblockPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockPreset));
@@ -635,6 +645,9 @@ namespace HandBrakeWPF.Services.Presets.Factories preset.PictureSharpenTune = export.Task.SharpenTune != null ? export.Task.SharpenTune.Key : string.Empty;
preset.PictureSharpenCustom = export.Task.SharpenCustom;
+ preset.PictureColorspacePreset = export.Task.Colourspace?.Key;
+ preset.PictureColorspaceCustom = export.Task.CustomColourspace;
+
// Video
preset.VideoEncoder = EnumHelper<VideoEncoder>.GetShortName(export.Task.VideoEncoder);
preset.VideoFramerate = export.Task.Framerate.HasValue ? export.Task.Framerate.ToString() : null;
diff --git a/win/CS/HandBrakeWPF/ViewModelItems/Filters/ColourspaceFilter.cs b/win/CS/HandBrakeWPF/ViewModelItems/Filters/ColourspaceFilter.cs new file mode 100644 index 000000000..5d251bc99 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModelItems/Filters/ColourspaceFilter.cs @@ -0,0 +1,141 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="ColourSpaceFilter.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 ColourSpaceFilter type. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModelItems.Filters +{ + using System.ComponentModel; + using System.Linq; + + using Caliburn.Micro; + + using HandBrake.Interop.Interop; + using HandBrake.Interop.Interop.HbLib; + using HandBrake.Interop.Interop.Model.Encoding; + + using HandBrakeWPF.Model.Filters; + using HandBrakeWPF.Services.Encode.Model; + using HandBrakeWPF.Services.Presets.Model; + using HandBrakeWPF.Services.Scan.Model; + + using Action = System.Action; + + public class ColourSpaceFilter : PropertyChangedBase + { + public static readonly string Off = "off"; + public static readonly string Custom = "custom"; + + private readonly Action triggerTabChanged; + + public ColourSpaceFilter(EncodeTask currentTask, Action triggerTabChanged) + { + this.triggerTabChanged = triggerTabChanged; + this.CurrentTask = currentTask; + + this.SetPresets(); + } + + public EncodeTask CurrentTask { get; private set; } + + public object Presets { get; set; } + + public bool ShowColourspaceCustom => this.SelectedPreset != null && this.SelectedPreset.Key == Custom; + + public FilterPreset SelectedPreset + { + get => this.CurrentTask.Colourspace; + + set + { + if (Equals(value, this.CurrentTask.Colourspace)) + { + return; + } + + this.CurrentTask.Colourspace = value; + + this.NotifyOfPropertyChange(() => this.SelectedPreset); + this.NotifyOfPropertyChange(() => this.ShowColourspaceCustom); + this.NotifyOfPropertyChange(() => this.ShowColourspaceCustom); + this.triggerTabChanged(); + } + } + + public string CustomColourspace + { + get => this.CurrentTask.CustomColourspace; + + set + { + if (value == this.CurrentTask.CustomColourspace) + { + return; + } + + this.CurrentTask.CustomColourspace = value; + this.NotifyOfPropertyChange(() => this.CustomColourspace); + } + } + + public void SetPreset(Preset preset, EncodeTask task) + { + this.CurrentTask = task; + + if (preset == null) + { + this.SelectedPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_COLORSPACE).FirstOrDefault(s => s.ShortName == "off")); + this.CustomColourspace = string.Empty; + return; + } + + this.SelectedPreset = preset.Task.Colourspace; + this.CustomColourspace = preset.Task.CustomColourspace; + } + + public void UpdateTask(EncodeTask task) + { + this.CurrentTask = task; + this.NotifyOfPropertyChange(() => this.SelectedPreset); + this.NotifyOfPropertyChange(() => this.CustomColourspace); + + this.NotifyOfPropertyChange(() => this.ShowColourspaceCustom); + } + + public bool MatchesPreset(Preset preset) + { + if (this.SelectedPreset?.Key != preset.Task?.Colourspace?.Key) + { + return false; + } + + if (this.CustomColourspace != preset?.Task?.CustomColourspace) + { + return false; + } + + return true; + } + + public void SetSource(Source source, Title title, Preset preset, EncodeTask task) + { + this.CurrentTask = task; + } + + private void SetPresets() + { + BindingList<FilterPreset> presets = new BindingList<FilterPreset>(); + foreach (HBPresetTune tune in HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_COLORSPACE)) + { + presets.Add(new FilterPreset(tune)); + } + + this.Presets = presets; + this.NotifyOfPropertyChange(() => this.Presets); + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index f43bb6af5..d1e58f589 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -18,7 +18,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.ViewModelItems.Filters;
using HandBrakeWPF.ViewModels.Interfaces;
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
+ using EncodeTask = Services.Encode.Model.EncodeTask;
public class FiltersViewModel : ViewModelBase, IFiltersViewModel
{
@@ -32,6 +32,7 @@ namespace HandBrakeWPF.ViewModels this.DeinterlaceFilter = new DeinterlaceFilterItem(this.CurrentTask, () => this.OnTabStatusChanged(null));
this.DeblockFilter = new DeblockFilter(this.CurrentTask, () => this.OnTabStatusChanged(null));
this.GrayscaleFilter = new GrayscaleFilter(this.CurrentTask, () => this.OnTabStatusChanged(null));
+ this.ColourSpaceFilter = new ColourSpaceFilter(this.CurrentTask, () => this.OnTabStatusChanged(null));
}
public event EventHandler<TabStatusEventArgs> TabStatusChanged;
@@ -48,6 +49,8 @@ namespace HandBrakeWPF.ViewModels public DeblockFilter DeblockFilter { get; set; }
+ public ColourSpaceFilter ColourSpaceFilter { get; set; }
+
public GrayscaleFilter GrayscaleFilter { get; set; }
public void SetPreset(Preset preset, EncodeTask task)
@@ -59,6 +62,7 @@ namespace HandBrakeWPF.ViewModels this.DetelecineFilter.SetPreset(preset, task);
this.DeinterlaceFilter.SetPreset(preset, task);
this.DeblockFilter.SetPreset(preset, task);
+ this.ColourSpaceFilter.SetPreset(preset, task);
}
public void UpdateTask(EncodeTask task)
@@ -71,6 +75,7 @@ namespace HandBrakeWPF.ViewModels this.DeinterlaceFilter.UpdateTask(task);
this.DeblockFilter.UpdateTask(task);
this.GrayscaleFilter.UpdateTask(task);
+ this.ColourSpaceFilter.UpdateTask(task);
}
public bool MatchesPreset(Preset preset)
@@ -105,6 +110,11 @@ namespace HandBrakeWPF.ViewModels return false;
}
+ if (!this.ColourSpaceFilter.MatchesPreset(preset))
+ {
+ return false;
+ }
+
return true;
}
@@ -117,6 +127,7 @@ namespace HandBrakeWPF.ViewModels this.DeinterlaceFilter.SetSource(source, title, preset, task);
this.DeblockFilter.SetSource(source, title, preset, task);
this.GrayscaleFilter.SetSource(source, title, preset, task);
+ this.ColourSpaceFilter.SetSource(source, title, preset, task);
}
protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml index 5a14d9f8f..a164c9ac9 100644 --- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml +++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml @@ -41,6 +41,7 @@ <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -191,8 +192,25 @@ <TextBox Width="240" Margin="0" Text="{Binding DeblockFilter.CustomDeblock, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22" />
</StackPanel>
+
+
+ <!-- Colourspace -->
+ <TextBlock Text="{x:Static Properties:Resources.FiltersView_ColourSpace}" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" Margin="0,10,0,10" />
+ <ComboBox Width="120" Grid.Row="6" Grid.Column="1" Margin="0,10,0,10"
+ ItemsSource="{Binding ColourSpaceFilter.Presets}" DisplayMemberPath="DisplayName"
+ SelectedItem="{Binding ColourSpaceFilter.SelectedPreset}"
+ AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_ColourSpace}"
+ HorizontalAlignment="Left" VerticalAlignment="Center"
+ ToolTip="{x:Static Properties:ResourcesTooltips.FiltersView_ColourSpace}" />
+
+
+ <StackPanel Orientation="Horizontal" Visibility="{Binding ColourSpaceFilter.ShowColourspaceCustom, Converter={StaticResource boolToVisConverter}}" Grid.Row="6" Grid.Column="2" Margin="0,10,0,10" >
+ <TextBlock Text="{x:Static Properties:Resources.FiltersView_Custom}" Margin="5,0,5,0" VerticalAlignment="Center" />
+ <TextBox Width="240" Margin="0" Text="{Binding ColourSpaceFilter.CustomColourspace, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22" />
+ </StackPanel>
+
<!-- Grayscale -->
- <CheckBox Content="{x:Static Properties:Resources.FiltersView_Grayscale}" IsChecked="{Binding GrayscaleFilter.Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,10,0,10"
+ <CheckBox Content="{x:Static Properties:Resources.FiltersView_Grayscale}" IsChecked="{Binding GrayscaleFilter.Grayscale}" Grid.Row="7" Grid.Column="1" Margin="0,10,0,10"
ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Grayscale}" HorizontalAlignment="Left" />
</Grid>
|