diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
11 files changed, 163 insertions, 35 deletions
diff --git a/win/CS/HandBrakeWPF/Constants.cs b/win/CS/HandBrakeWPF/Constants.cs index 5bb064fb7..f4a65d7d2 100644 --- a/win/CS/HandBrakeWPF/Constants.cs +++ b/win/CS/HandBrakeWPF/Constants.cs @@ -38,7 +38,7 @@ namespace HandBrakeWPF public const string SourceFolderName = "{source_folder_name}";
/* Preset Versions */
- public const string PresetVersionMajor = "34";
+ public const string PresetVersionMajor = "35";
public const string PresetVersionMinor = "0";
public const string PresetVersionMicro = "0";
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 733a31c72..4dcab0179 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1034,6 +1034,24 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to FiltersView_DeblockPreset. + /// </summary> + public static string FiltersViewAuto_DeblockPreset { + get { + return ResourceManager.GetString("FiltersViewAuto_DeblockPreset", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Deblock Tune. + /// </summary> + public static string FiltersViewAuto_DeblockTune { + get { + return ResourceManager.GetString("FiltersViewAuto_DeblockTune", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Add. /// </summary> public static string Generic_Add { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index d389ea639..aa473b6a8 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -1978,4 +1978,10 @@ Non-Live Options: {date} {time} {creation-date} {creation-time} {quality} {bitra <data name="CollisionBehaviour_AppendNumber" xml:space="preserve">
<value>Append Number</value>
</data>
+ <data name="FiltersViewAuto_DeblockPreset" xml:space="preserve">
+ <value>FiltersView_DeblockPreset</value>
+ </data>
+ <data name="FiltersViewAuto_DeblockTune" xml:space="preserve">
+ <value>Deblock Tune</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 3c6e4d35c..72948a332 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -503,9 +503,9 @@ namespace HandBrakeWPF.Services.Encode.Factories } // Deblock - if (job.Deblock >= 5) + if (job.DeblockPreset != null && job.DeblockPreset.Key != "off") { - IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEBLOCK, null, null, string.Format("qp={0}", job.Deblock)); + IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEBLOCK, job.DeblockPreset.Key, job.DeblockTune.Key, job.CustomDeblock); string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr); if (!string.IsNullOrEmpty(unparsedJson)) { diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskImportFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskImportFactory.cs index 3daf6b353..8cc635017 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskImportFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskImportFactory.cs @@ -271,7 +271,6 @@ namespace HandBrakeWPF.Services.Encode.Factories } task.SubtitleTracks.Add(null); - } } @@ -318,7 +317,7 @@ namespace HandBrakeWPF.Services.Encode.Factories if (deblockFilter != null) { var filterSettings = deblockFilter.Settings; - task.Deblock = filterSettings.Value<string>("qp").ToInt(); + task.DeblockPreset = null; // TODO Support Preset / Tune } // Sharpen diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index aec7219c2..5272810cd 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -81,7 +81,9 @@ namespace HandBrakeWPF.Services.Encode.Model this.CustomDetelecine = task.CustomDetelecine; this.CustomCombDetect = task.CustomCombDetect; this.CombDetect = task.CombDetect; - this.Deblock = task.Deblock; + this.DeblockPreset = task.DeblockPreset; + this.DeblockTune = task.DeblockTune; + this.CustomDeblock = task.CustomDeblock; this.DeinterlacePreset = task.DeinterlacePreset; this.DeinterlaceFilter = task.DeinterlaceFilter; this.Denoise = task.Denoise; @@ -327,11 +329,6 @@ namespace HandBrakeWPF.Services.Encode.Model public string CustomDenoise { get; set; } /// <summary> - /// Gets or sets Deblock. - /// </summary> - public int Deblock { get; set; } - - /// <summary> /// Gets or sets a value indicating whether Grayscale. /// </summary> public bool Grayscale { get; set; } @@ -350,6 +347,10 @@ namespace HandBrakeWPF.Services.Encode.Model public FilterPreset SharpenPreset { get; set; } public FilterTune SharpenTune { get; set; } public string SharpenCustom { get; set; } + + public FilterPreset DeblockPreset { get; set; } + public FilterTune DeblockTune { get; set; } + public string CustomDeblock { 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 360cf7cab..c6dd9595e 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs @@ -102,7 +102,10 @@ namespace HandBrakeWPF.Services.Presets.Factories /* Filter Settings */
preset.Task.Grayscale = importedPreset.VideoGrayScale;
- preset.Task.Deblock = importedPreset.PictureDeblock;
+
+ preset.Task.DeblockPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockPreset));
+ preset.Task.DeblockTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockTune));
+ preset.Task.CustomDeblock = importedPreset.PictureDeblockCustom;
if (importedPreset.PictureSharpenFilter != null)
{
@@ -603,7 +606,9 @@ namespace HandBrakeWPF.Services.Presets.Factories preset.PictureBottomCrop = export.Task.Cropping.Bottom;
// Filters
- preset.PictureDeblock = export.Task.Deblock;
+ preset.PictureDeblockPreset = export.Task.DeblockPreset?.Key;
+ preset.PictureDeblockTune = export.Task.DeblockTune?.Key;
+ preset.PictureDeblockCustom = export.Task.CustomDeblock;
preset.PictureDeinterlaceFilter = export.Task.DeinterlaceFilter == DeinterlaceFilter.Decomb
? "decomb"
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index c54780042..52f1d5d7f 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -806,7 +806,6 @@ namespace HandBrakeWPF.Services.Presets this.Add(preset, true);
}
}
-
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs b/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs index 09b785e3b..221a41e15 100644 --- a/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs +++ b/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs @@ -9,10 +9,17 @@ namespace HandBrakeWPF.ViewModelItems.Filters { + using System.ComponentModel; using System.Globalization; + 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; @@ -21,60 +28,113 @@ namespace HandBrakeWPF.ViewModelItems.Filters public class DeblockFilter : PropertyChangedBase { + public static readonly string Off = "off"; + public static readonly string Custom = "custom"; + private readonly Action triggerTabChanged; public DeblockFilter(EncodeTask currentTask, Action triggerTabChanged) { this.triggerTabChanged = triggerTabChanged; this.CurrentTask = currentTask; - this.DeblockValue = 4; // OFF + + this.SetPresets(); + this.SetTunes(); } public EncodeTask CurrentTask { get; private set; } - public string DeblockText => - this.DeblockValue == 4 ? "Off" : this.DeblockValue.ToString(CultureInfo.InvariantCulture); + public object Presets { get; set; } + + public object Tunes { get; set; } + + public bool ShowDeblockTune => this.SelectedPreset != null && this.SelectedPreset.Key != Off && this.SelectedPreset.Key != Custom; + + public bool ShowDeblockCustom => this.SelectedPreset != null && this.SelectedPreset.Key == Custom; - public int DeblockValue + public FilterPreset SelectedPreset { - get + get => this.CurrentTask.DeblockPreset; + + set { - return this.CurrentTask.Deblock; + if (Equals(value, this.CurrentTask.DeblockPreset)) return; + this.CurrentTask.DeblockPreset = value; + + this.NotifyOfPropertyChange(() => this.SelectedPreset); + this.NotifyOfPropertyChange(() => this.ShowDeblockTune); + this.NotifyOfPropertyChange(() => this.ShowDeblockCustom); + this.triggerTabChanged(); } + } + + public FilterTune SelectedTune + { + get => this.CurrentTask.DeblockTune; set { - this.CurrentTask.Deblock = value; - this.NotifyOfPropertyChange(() => this.DeblockValue); - this.NotifyOfPropertyChange(() => this.DeblockText); + if (Equals(value, this.CurrentTask.DeblockTune)) return; + this.CurrentTask.DeblockTune = value; + + this.NotifyOfPropertyChange(() => this.SelectedTune); this.triggerTabChanged(); } } + public string CustomDeblock + { + get => this.CurrentTask.CustomDeblock; + + set + { + if (value == this.CurrentTask.CustomDeblock) return; + this.CurrentTask.CustomDeblock = value; + this.NotifyOfPropertyChange(() => this.CustomDeblock); + } + } + public void SetPreset(Preset preset, EncodeTask task) { this.CurrentTask = task; if (preset == null) { - this.DeblockValue = 4; // OFF + this.SelectedPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == "off")); + this.CustomDeblock = string.Empty; + this.SelectedTune = null; return; } - this.DeblockValue = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock; + this.SelectedPreset = preset.Task.DeblockPreset; + this.SelectedTune = preset.Task.DeblockTune; + this.CustomDeblock = preset.Task.CustomDeblock; } public void UpdateTask(EncodeTask task) { this.CurrentTask = task; - this.NotifyOfPropertyChange(() => this.DeblockValue); + this.NotifyOfPropertyChange(() => this.SelectedPreset); + this.NotifyOfPropertyChange(() => this.SelectedTune); + this.NotifyOfPropertyChange(() => this.CustomDeblock); + + this.NotifyOfPropertyChange(() => this.ShowDeblockTune); + this.NotifyOfPropertyChange(() => this.ShowDeblockCustom); } public bool MatchesPreset(Preset preset) { - int presetDeblock = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock; + if (this.SelectedPreset?.Key != preset.Task?.DeblockPreset?.Key) + { + return false; + } + + if (this.SelectedTune.Key != preset?.Task?.DeblockTune.Key) + { + return false; + } - if (presetDeblock != this.DeblockValue) + if (this.CustomDeblock != preset?.Task?.CustomDeblock) { return false; } @@ -86,5 +146,29 @@ namespace HandBrakeWPF.ViewModelItems.Filters { this.CurrentTask = task; } + + private void SetPresets() + { + BindingList<FilterPreset> presets = new BindingList<FilterPreset>(); + foreach (HBPresetTune tune in HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEBLOCK)) + { + presets.Add(new FilterPreset(tune)); + } + + this.Presets = presets; + this.NotifyOfPropertyChange(() => this.Presets); + } + + private void SetTunes() + { + BindingList<FilterTune> tunes = new BindingList<FilterTune>(); + foreach (HBPresetTune tune in HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_DEBLOCK)) + { + tunes.Add(new FilterTune(tune)); + } + + this.Tunes = tunes; + this.NotifyOfPropertyChange(() => this.Tunes); + } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs index b5f711e5a..add04d299 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs @@ -31,6 +31,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Services.Scan.Interfaces; using HandBrakeWPF.Services.Scan.Model; using HandBrakeWPF.Utilities; + using HandBrakeWPF.ViewModelItems.Filters; using HandBrakeWPF.ViewModels.Interfaces; public class SummaryViewModel : ViewModelBase, ISummaryViewModel @@ -541,7 +542,7 @@ namespace HandBrakeWPF.ViewModels filters.Add(this.Task.Sharpen.ToString()); } - if (this.Task.Deblock > 4) + if (this.Task.DeblockPreset != null && this.Task.DeblockPreset.Key != DeblockFilter.Off) { filters.Add(Resources.SummaryView_Deblock); } diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml index d1b567ae2..87aa45e50 100644 --- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml +++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml @@ -171,13 +171,28 @@ </StackPanel>
<!-- Deblock -->
- <TextBlock Text="{x:Static Properties:Resources.FiltersView_Deblock}" Grid.Row="5" Grid.Column="0" Margin="0,0,0,10"/>
- <Slider Width="120" Value="{Binding DeblockFilter.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}"
- AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Deblock}" />
- <TextBlock Text="{Binding DeblockFilter.DeblockText}" Grid.Row="5" Grid.Column="2" Margin="0,0,0,10"/>
+ <TextBlock Text="{x:Static Properties:Resources.FiltersView_Deblock}" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" />
+ <ComboBox Width="120" Grid.Row="5" Grid.Column="1"
+ ItemsSource="{Binding DeblockFilter.Presets}" DisplayMemberPath="DisplayName"
+ SelectedItem="{Binding DeblockFilter.SelectedPreset}"
+ AutomationProperties.Name="{x:Static Properties:Resources.FiltersViewAuto_DeblockPreset}"
+ HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,0"
+ ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Deblock}" />
+
+ <StackPanel Orientation="Horizontal" Visibility="{Binding DeblockFilter.ShowDeblockTune, Converter={StaticResource boolToVisConverter}}" Grid.Row="5" Grid.Column="2" >
+ <TextBlock Text="{x:Static Properties:Resources.FiltersView_Tune}" Margin="5,0,5,0" />
+ <ComboBox ItemsSource="{Binding DeblockFilter.Tunes}" DisplayMemberPath="DisplayName" SelectedItem="{Binding DeblockFilter.SelectedTune}"
+ MinWidth="100" VerticalAlignment="Center"
+ AutomationProperties.Name="{x:Static Properties:Resources.FiltersViewAuto_DeblockTune}" />
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" Visibility="{Binding DeblockFilter.ShowDeblockCustom, Converter={StaticResource boolToVisConverter}}" Grid.Row="5" Grid.Column="2" >
+ <TextBlock Text="{x:Static Properties:Resources.FiltersView_Custom}" Margin="5,0,5,0" VerticalAlignment="Center" />
+ <TextBox Width="240" Margin="0" Text="{Binding DeblockFilter.CustomDeblock, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22" />
+ </StackPanel>
- <CheckBox Content="{x:Static Properties:Resources.FiltersView_Grayscale}" IsChecked="{Binding GrayscaleFilter.Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,0,0,10"
+ <!-- Grayscale -->
+ <CheckBox Content="{x:Static Properties:Resources.FiltersView_Grayscale}" IsChecked="{Binding GrayscaleFilter.Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,10,0,10"
ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Grayscale}" />
<!-- Rotation -->
|