From 71c53a04fc0d43fee4ee024f854ebc6783234fd2 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 23 Feb 2014 15:43:16 +0000 Subject: WinGui: x265 UI patch by Zhang Zhigiang. This enables support for the x265 encoder from the GUI when paired with a build of HandBrake that has x265 enabled. Thanks git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6062 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Converters/Video/VideoEncoderConverter.cs | 5 + .../HandBrakeWPF/Properties/Resources.Designer.cs | 108 ++++++------ win/CS/HandBrakeWPF/Properties/Resources.resx | 12 +- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 3 + win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 181 ++++++++++++++++++++- win/CS/HandBrakeWPF/Views/VideoView.xaml | 86 +++++++++- 6 files changed, 327 insertions(+), 68 deletions(-) (limited to 'win/CS/HandBrakeWPF') diff --git a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs index 8e2f1d379..6854656d4 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs @@ -60,6 +60,11 @@ namespace HandBrakeWPF.Converters.Video encoders.Remove(VideoEncoder.QuickSync); } + if (task != null && task.OutputFormat != OutputFormat.X265) + { + encoders.Remove(VideoEncoder.X265); + } + return EnumHelper.GetEnumDisplayValuesSubset(encoders); } diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 45a63951a..2eca4f527 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -792,6 +792,60 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to The full list of encoder parameters: + ///{0}. + /// + public static string Video_EncoderExtraArgs { + get { + return ResourceManager.GetString("Video_EncoderExtraArgs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets and ensures compliance with the specified H.264 Levels. This will override all other settings.. + /// + public static string Video_EncoderLevel { + get { + return ResourceManager.GetString("Video_EncoderLevel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Adjusts x264 settings to trade off compression efficiency against encoding speed. + /// + ///This establishes your default x264 settings. Tunes, profiles, levels and advanced options string will be applied to this. + /// + ///You should generally set this option to the slowest you can bear since slower settings will result in better quality or smaller files.. + /// + public static string Video_EncoderPreset { + get { + return ResourceManager.GetString("Video_EncoderPreset", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Limit the H.264 profile of the output stream. This will override all other settings.. + /// + public static string Video_EncoderProfile { + get { + return ResourceManager.GetString("Video_EncoderProfile", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tune settings to optimise for common scenarios + /// + ///This can improve efficiency for particular source characteristics or set of characteristics of the output file. + /// + ///Changes will be applied after the preset but before all other parameters.. + /// + public static string Video_EncoderTune { + get { + return ResourceManager.GetString("Video_EncoderTune", resourceCulture); + } + } + /// /// Looks up a localized string similar to Higher Quality |. /// @@ -884,16 +938,6 @@ namespace HandBrakeWPF.Properties { } } - /// - /// Looks up a localized string similar to The full x264 list of parameters: - ///{0}. - /// - public static string Video_x264ExtraArgs { - get { - return ResourceManager.GetString("Video_x264ExtraArgs", resourceCulture); - } - } - /// /// Looks up a localized string similar to Reduce decoder CPU usage. /// @@ -905,50 +949,6 @@ namespace HandBrakeWPF.Properties { } } - /// - /// Looks up a localized string similar to Sets and ensures compliance with the specified H.264 Levels. This will override all other settings.. - /// - public static string Video_x264Level { - get { - return ResourceManager.GetString("Video_x264Level", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Adjusts x264 settings to trade off compression efficiency against encoding speed. - /// - ///This establishes your default x264 settings. Tunes, profiles, levels and advanced options string will be applied to this. - /// - ///You should generally set this option to the slowest you can bear since slower settings will result in better quality or smaller files.. - /// - public static string Video_x264Preset { - get { - return ResourceManager.GetString("Video_x264Preset", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Limit the H.264 profile of the output stream. This will override all other settings.. - /// - public static string Video_x264Profile { - get { - return ResourceManager.GetString("Video_x264Profile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tune settings to optimise for common scenarios - /// - ///This can improve efficiency for particular source characteristics or set of characteristics of the output file. - /// - ///Changes will be applied after the preset but before all other parameters.. - /// - public static string Video_x264Tune { - get { - return ResourceManager.GetString("Video_x264Tune", resourceCulture); - } - } - /// /// Looks up a localized string similar to Warning. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index d86c6cc5b..2f323b50e 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -233,8 +233,8 @@ Baseline profile, as required for iPods and similar devices, requires weighted P Note that some devices and players, even those that support Main Profile, may have problems with Weighted P-frame prediction: the Apple TV is completely incompatible with it, for example. - - The full x264 list of parameters: + + The full list of encoder parameters: {0} @@ -242,20 +242,20 @@ may have problems with Weighted P-frame prediction: the Apple TV is completely i Set this if your device is struggling to play the output. (i.e. dropped frames) - + Sets and ensures compliance with the specified H.264 Levels. This will override all other settings. - + Adjusts x264 settings to trade off compression efficiency against encoding speed. This establishes your default x264 settings. Tunes, profiles, levels and advanced options string will be applied to this. You should generally set this option to the slowest you can bear since slower settings will result in better quality or smaller files. - + Limit the H.264 profile of the output stream. This will override all other settings. - + Tune settings to optimise for common scenarios This can improve efficiency for particular source characteristics or set of characteristics of the output file. diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index d9c2640f8..4306fc7f7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1440,6 +1440,9 @@ namespace HandBrakeWPF.ViewModels case ".m4v": this.SelectedOutputFormat = OutputFormat.M4V; break; + case ".x265": + this.SelectedOutputFormat = OutputFormat.X265; + break; } this.NotifyOfPropertyChange(() => this.CurrentTask); diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 5dd4b07aa..0d3dc5ce0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -25,6 +25,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.Interop; using HandBrake.Interop.Model.Encoding; using HandBrake.Interop.Model.Encoding.x264; + using HandBrake.Interop.Model.Encoding.x265; using HandBrakeWPF.Commands.Interfaces; using HandBrakeWPF.Properties; @@ -45,7 +46,7 @@ namespace HandBrakeWPF.ViewModels /// /// The possible h264 levels. /// - private static readonly List Levels = new List { "Auto", "1.0", "1b", "1.1", "1.2", "1.3", "2.0", "2.1", "2.2", "3.0", "3.1", "3.2", "4.0", "4.1", "4.2", "5.0", "5.1", "5.2"}; + private static readonly List Levels = new List { "Auto", "1.0", "1b", "1.1", "1.2", "1.3", "2.0", "2.1", "2.2", "3.0", "3.1", "3.2", "4.0", "4.1", "4.2", "5.0", "5.1", "5.2" }; /// /// Backing field for the user setting service. @@ -62,6 +63,11 @@ namespace HandBrakeWPF.ViewModels /// private bool displayX264Options; + /// + /// Backing field used to display / hide the x265 options + /// + private bool displayX265Options; + /// /// The display qsv options. /// @@ -122,6 +128,11 @@ namespace HandBrakeWPF.ViewModels /// private bool displayNonQSVControls; + /// + /// The x265 preset value. + /// + private int x265PresetValue; + #endregion #region Constructors and Destructors @@ -151,6 +162,10 @@ namespace HandBrakeWPF.ViewModels X264Tunes = EnumHelper.GetEnumList().Where(t => t != x264Tune.Fastdecode); this.H264Levels = Levels; + X265Presets = new BindingList(EnumHelper.GetEnumList().ToList()); + H265Profiles = EnumHelper.GetEnumList(); + X265Tunes = EnumHelper.GetEnumList(); + this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged; } @@ -400,6 +415,9 @@ namespace HandBrakeWPF.ViewModels case VideoEncoder.Theora: Task.Quality = value; break; + case VideoEncoder.X265: + Task.Quality = value; + break; } this.NotifyOfPropertyChange(() => this.RF); @@ -539,6 +557,10 @@ namespace HandBrakeWPF.ViewModels // Hide the x264 controls when not needed. this.DisplayX264Options = value == VideoEncoder.X264; + + // Hide the x265 controls when not needed. + this.DisplayX265Options = value == VideoEncoder.X265; + this.DisplayQSVOptions = value == VideoEncoder.QuickSync; this.DisplayH264Options = value == VideoEncoder.X264 || value == VideoEncoder.QuickSync; this.UseAdvancedTab = value != VideoEncoder.QuickSync && this.UseAdvancedTab; @@ -599,7 +621,7 @@ namespace HandBrakeWPF.ViewModels } } } - + /// /// Gets or sets a value indicating whether to display H264 /// @@ -633,6 +655,23 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets or sets a value indicating whether display x 264 options. + /// + public bool DisplayX265Options + { + get + { + return this.displayX265Options; + } + set + { + this.displayX265Options = value; + this.NotifyOfPropertyChange(() => this.DisplayX265Options); + this.NotifyOfPropertyChange(() => FullOptionsTooltip); + } + } + /// /// Gets or sets a value indicating whether to display qsv options. /// @@ -707,7 +746,7 @@ namespace HandBrakeWPF.ViewModels } } } - + /// /// Gets or sets X264Preset. /// @@ -864,7 +903,7 @@ namespace HandBrakeWPF.ViewModels { get { - return string.Format(Resources.Video_x264ExtraArgs, this.GetActualx264Query()); // "You can provide additional arguments using the standard x264 format"; + return string.Format(Resources.Video_EncoderExtraArgs, this.GetActualx264Query()); // "You can provide additional arguments using the standard x264 format"; } } @@ -879,6 +918,106 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets or sets the x 265 preset value. + /// + public int X265PresetValue + { + get + { + return this.x265PresetValue; + } + set + { + if (!object.Equals(this.X265PresetValue, value)) + { + this.x265PresetValue = value; + this.X265Preset = this.X265Presets[value]; + this.NotifyOfPropertyChange(() => this.x265PresetValue); + this.NotifyOfPropertyChange(() => FullOptionsTooltip); + } + } + } + + /// + /// Gets or sets X265Preset. + /// + public x265Preset X265Preset + { + get + { + return this.Task.X265Preset; + } + set + { + if (!object.Equals(this.X265Preset, value)) + { + this.Task.X265Preset = value; + this.NotifyOfPropertyChange(() => this.X265Preset); + ResetAdvancedTab(); + this.NotifyOfPropertyChange(() => FullOptionsTooltip); + } + } + } + + + /// + /// Gets or sets H265Profile. + /// + public x265Profile H265Profile + { + get + { + return this.Task.H265Profile; + } + + set + { + if (!object.Equals(this.H265Profile, value)) + { + this.Task.H265Profile = value; + this.NotifyOfPropertyChange(() => this.H265Profile); + ResetAdvancedTab(); + this.NotifyOfPropertyChange(() => FullOptionsTooltip); + } + } + } + + /// + /// Gets or sets X265Tune. + /// + public x265Tune X265Tune + { + get + { + return this.Task.X265Tune; + } + set + { + if (!object.Equals(this.X265Tune, value)) + { + this.Task.X265Tune = value; + this.NotifyOfPropertyChange(() => this.X265Tune); + ResetAdvancedTab(); + this.NotifyOfPropertyChange(() => FullOptionsTooltip); + } + } + } + + /// + /// Gets or sets X265Presets. + /// + public BindingList X265Presets { get; set; } + + /// + /// Gets or sets X265Profiles. + /// + public IEnumerable H265Profiles { get; set; } + + /// + /// Gets or sets X265Tunes. + /// + public IEnumerable X265Tunes { get; set; } #endregion #region Public Methods @@ -970,6 +1109,13 @@ namespace HandBrakeWPF.ViewModels this.RF = (int)preset.Task.Quality.Value; } break; + + case VideoEncoder.X265: + if (preset.Task.Quality.HasValue) + { + this.RF = (int)preset.Task.Quality.Value; + } + break; } this.Task.TwoPass = preset.Task.TwoPass; @@ -1009,6 +1155,20 @@ namespace HandBrakeWPF.ViewModels this.FastDecode = false; } + // x265 Only + if (preset.Task.VideoEncoder == VideoEncoder.X265) + { + this.X265PresetValue = (int)preset.Task.X264Preset; + this.X265Tune = preset.Task.X265Tune; + this.H265Profile = preset.Task.H265Profile; + } + else + { + this.X265PresetValue = (int)x265Preset.VeryFast; + this.X265Tune = x265Tune.None; + this.H265Profile = x265Profile.None; + } + // QSV Only if (preset.Task.VideoEncoder == VideoEncoder.QuickSync) { @@ -1054,6 +1214,10 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.FastDecode); this.NotifyOfPropertyChange(() => this.ExtraArguments); this.NotifyOfPropertyChange(() => this.QsvPreset); + + this.NotifyOfPropertyChange(() => this.H265Profile); + this.NotifyOfPropertyChange(() => this.X265Preset); + this.NotifyOfPropertyChange(() => this.X265Tune); } /// @@ -1067,6 +1231,7 @@ namespace HandBrakeWPF.ViewModels this.DisplayH264Options = encoder == VideoEncoder.X264 || encoder == VideoEncoder.QuickSync; this.DisplayX264Options = encoder == VideoEncoder.X264; this.DisplayQSVOptions = encoder == VideoEncoder.QuickSync; + this.DisplayX265Options = encoder == VideoEncoder.X265; if (encoder == VideoEncoder.QuickSync) { @@ -1100,6 +1265,10 @@ namespace HandBrakeWPF.ViewModels this.H264Level = "Auto"; this.ExtraArguments = string.Empty; this.canClear = true; + + this.H265Profile = x265Profile.None; + this.x265PresetValue = 1; + this.X265Tune = x265Tune.None; } /// @@ -1135,6 +1304,10 @@ namespace HandBrakeWPF.ViewModels this.QualityMin = 0; this.QualityMax = 63; break; + case VideoEncoder.X265: + this.QualityMin = 0; + this.QualityMax = 50; + break; } } diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml index 1f0b31764..a7b87a3a7 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml @@ -170,7 +170,7 @@ @@ -181,7 +181,7 @@ ItemsSource="{Binding X264Tunes, Converter={StaticResource enumComboConverter}}" SelectedItem="{Binding X264Tune, Converter={StaticResource enumComboConverter}}" Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" - ToolTip="{x:Static Properties:Resources.Video_x264Tune}" + ToolTip="{x:Static Properties:Resources.Video_EncoderTune}" Style="{StaticResource LongToolTipHolder}" /> + ToolTip="{x:Static Properties:Resources.Video_EncoderProfile}" /> + ToolTip="{x:Static Properties:Resources.Video_EncoderLevel}"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3