this.ChapterNames = new ObservableCollection<ChapterMarker>();\r
this.AllowedPassthruOptions = new AllowedPassthru();\r
this.X264Preset = x264Preset.Medium;\r
+ this.QsvPreset = QsvPreset.Quality;\r
this.H264Profile = x264Profile.None;\r
this.X264Tune = x264Tune.None;\r
this.Modulus = 16;\r
this.VideoEncodeRateType = task.VideoEncodeRateType;\r
this.Width = task.Width;\r
this.X264Preset = task.X264Preset;\r
+ this.QsvPreset = task.QsvPreset;\r
this.H264Profile = task.H264Profile;\r
this.X264Tune = task.X264Tune;\r
this.H264Level = task.H264Level;\r
/// </summary>\r
public x264Preset X264Preset { get; set; }\r
\r
+ /// <summary>\r
+ /// Gets or sets the qsv preset.\r
+ /// </summary>\r
+ public QsvPreset QsvPreset { get; set; }\r
+\r
/// <summary>\r
/// Gets or sets x264Profile.\r
/// </summary>\r
using System;\r
using System.Collections.Generic;\r
using System.Diagnostics;\r
- using System.Globalization;\r
using System.IO;\r
using System.Linq;\r
using System.Text;\r
- using System.Text.RegularExpressions;\r
using System.Windows.Forms;\r
\r
using HandBrake.ApplicationServices.Model;\r
\r
if (task.H264Profile != x264Profile.None)\r
{\r
- query += string.Format(" --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));\r
+ query += string.Format(\r
+ " --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));\r
}\r
\r
- if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))\r
+ if (task.VideoEncoder == VideoEncoder.QuickSync)\r
+ {\r
+ string qsvPreset;\r
+ switch (task.QsvPreset)\r
+ {\r
+ case QsvPreset.Quality:\r
+ qsvPreset = "1";\r
+ break;\r
+ case QsvPreset.Balanced:\r
+ qsvPreset = "4";\r
+ break;\r
+ default:\r
+ qsvPreset = "7";\r
+ break;\r
+ }\r
+\r
+ query += string.IsNullOrEmpty(task.AdvancedEncoderOptions)\r
+ ? string.Format(" -x qsv-target-usage={0}", qsvPreset)\r
+ : string.Format(" -x qsv-target-usage={0}:{1}", qsvPreset, task.AdvancedEncoderOptions);\r
+ }\r
+ else if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))\r
{\r
query += string.Format(" -x {0}", task.AdvancedEncoderOptions);\r
}\r
return query;\r
}\r
\r
-\r
return string.IsNullOrEmpty(task.AdvancedEncoderOptions) ? string.Empty : string.Format(" -x {0}", task.AdvancedEncoderOptions);\r
}\r
\r
<Compile Include="Model\Encoding\Mixdown.cs" />\r
<Compile Include="Model\Encoding\OutputExtension.cs" />\r
<Compile Include="Model\Encoding\Container.cs" />\r
+ <Compile Include="Model\Encoding\QsvPreset.cs" />\r
<Compile Include="Model\Encoding\VideoEncoder.cs" />\r
<Compile Include="Model\Encoding\VideoEncodeRateType.cs" />\r
<Compile Include="Model\Encoding\x264\x264Preset.cs" />\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="QsvPreset.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The qsv preset.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.Interop.Model.Encoding\r
+{\r
+ using System.ComponentModel.DataAnnotations;\r
+\r
+ /// <summary>\r
+ /// The qsv preset.\r
+ /// </summary>\r
+ public enum QsvPreset\r
+ {\r
+ [Display(Name = "Best Speed")]\r
+ Speed,\r
+\r
+ [Display(Name = "Balanced")]\r
+ Balanced,\r
+\r
+ [Display(Name = "Best Quality")]\r
+ Quality,\r
+ }\r
+}\r
{\r
return EnumHelper<Mixdown>.GetDisplay((Mixdown)value);\r
}\r
+ if (targetType == typeof(QsvPreset) || value.GetType() == typeof(QsvPreset))\r
+ {\r
+ return EnumHelper<QsvPreset>.GetDisplay((QsvPreset)value);\r
+ }\r
\r
if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode))\r
{\r
{\r
return EnumHelper<Mixdown>.GetValue(value.ToString());\r
}\r
+ if (targetType == typeof(QsvPreset) || value.GetType() == typeof(QsvPreset))\r
+ {\r
+ return EnumHelper<QsvPreset>.GetValue(value.ToString());\r
+ }\r
\r
if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode))\r
{\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using System.Collections.Generic;\r
+\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Parsing;\r
using HandBrake.Interop.Model.Encoding;\r
/// <summary>\r
/// The Simple Encoder options screen\r
/// </summary>\r
- public class EncoderOptionsViewModel : ViewModelBase, IEncoderOptionsViewModel, ITabInterface\r
+ public class EncoderOptionsViewModel : ViewModelBase, IEncoderOptionsViewModel\r
{\r
+ /// <summary>\r
+ /// The cached options.\r
+ /// </summary>\r
+ private readonly Dictionary<VideoEncoder, string> cachedOptions = new Dictionary<VideoEncoder, string>();\r
+\r
/// <summary>\r
/// Initializes a new instance of the <see cref="EncoderOptionsViewModel"/> class.\r
/// </summary>\r
public EncoderOptionsViewModel()\r
{\r
this.Task = new EncodeTask();\r
+ cachedOptions.Add(VideoEncoder.QuickSync, "qsv-num-ref-frame=3:qsv-gop-ref-dist=5:qsv-gop-pic-size=5:qsv-async-depth=4");\r
}\r
\r
/// <summary>\r
/// </summary>\r
public EncodeTask Task { get; set; }\r
\r
+ /// <summary>\r
+ /// Gets or sets the preset.\r
+ /// </summary>\r
+ public Preset Preset { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the current video encoder.\r
+ /// </summary>\r
+ public VideoEncoder CurrentVideoEncoder { get; set; }\r
+\r
/// <summary>\r
/// Gets or sets the options string.\r
/// </summary>\r
public void SetSource(Title selectedTitle, Preset currentPreset, EncodeTask task)\r
{\r
this.Task = task;\r
+ this.Preset = currentPreset;\r
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);\r
}\r
\r
public void SetPreset(Preset preset, EncodeTask task)\r
{\r
this.Task = task;\r
+ this.Preset = preset;\r
this.AdvancedOptionsString = preset.Task.AdvancedEncoderOptions;\r
}\r
\r
/// </param>\r
public void SetEncoder(VideoEncoder encoder)\r
{\r
+ // Cache the existing string so it can be reused if the user changes the encoder back.\r
+ if (!string.IsNullOrEmpty(this.AdvancedOptionsString))\r
+ {\r
+ this.cachedOptions[CurrentVideoEncoder] = this.AdvancedOptionsString;\r
+ }\r
+\r
+ // Set the option from the cached version if we have one.\r
+ string advacnedOptionsString;\r
+ if (cachedOptions.TryGetValue(encoder, out advacnedOptionsString)\r
+ && !string.IsNullOrEmpty(advacnedOptionsString))\r
+ {\r
+ this.AdvancedOptionsString = advacnedOptionsString;\r
+ }\r
+ else\r
+ {\r
+ this.AdvancedOptionsString = this.Preset != null && this.Preset.Task != null\r
+ && !string.IsNullOrEmpty(this.Preset.Task.AdvancedEncoderOptions)\r
+ ? this.Preset.Task.AdvancedEncoderOptions\r
+ : string.Empty;\r
+ }\r
}\r
\r
/// <summary>\r
/// </summary>\r
private bool displayX264Options;\r
\r
+ /// <summary>\r
+ /// The display qsv options.\r
+ /// </summary>\r
+ private bool displayQSVOptions;\r
+\r
/// <summary>\r
/// Backing field used to display / hide the h264 options\r
/// </summary>\r
/// </summary>\r
private int x264PresetValue;\r
\r
+ /// <summary>\r
+ /// The qsv preset value.\r
+ /// </summary>\r
+ private int qsvPresetValue;\r
+\r
/// <summary>\r
/// The extra arguments.\r
/// </summary>\r
this.VideoEncoders = EnumHelper<VideoEncoder>.GetEnumList();\r
\r
X264Presets = new BindingList<x264Preset>(EnumHelper<x264Preset>.GetEnumList().ToList());\r
+ QsvPresets = new BindingList<QsvPreset>(EnumHelper<QsvPreset>.GetEnumList().ToList());\r
H264Profiles = EnumHelper<x264Profile>.GetEnumList();\r
X264Tunes = EnumHelper<x264Tune>.GetEnumList().Where(t => t != x264Tune.Fastdecode);\r
this.H264Levels = Levels;\r
\r
// Hide the x264 controls when not needed.\r
this.DisplayX264Options = value == VideoEncoder.X264;\r
+ this.DisplayQSVOptions = value == VideoEncoder.QuickSync;\r
+ this.DisplayH264Options = value == VideoEncoder.X264 || value == VideoEncoder.QuickSync;\r
+ this.UseAdvancedTab = value != VideoEncoder.QuickSync && this.UseAdvancedTab;\r
\r
this.NotifyOfPropertyChange(() => this.Rfqp);\r
this.NotifyOfPropertyChange(() => this.ShowAdvancedTab);\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether to display qsv options.\r
+ /// </summary>\r
+ public bool DisplayQSVOptions\r
+ {\r
+ get\r
+ {\r
+ return this.displayQSVOptions;\r
+ }\r
+ set\r
+ {\r
+ this.displayQSVOptions = value;\r
+ this.NotifyOfPropertyChange(() => this.DisplayQSVOptions);\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Gets or sets the x 264 preset value.\r
/// </summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Gets or sets X264Preset.\r
+ /// </summary>\r
+ public QsvPreset QsvPreset\r
+ {\r
+ get\r
+ {\r
+ return this.Task.QsvPreset;\r
+ }\r
+ set\r
+ {\r
+ if (!object.Equals(this.QsvPreset, value))\r
+ {\r
+ this.Task.QsvPreset = value;\r
+ this.NotifyOfPropertyChange(() => this.QsvPreset);\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the x 264 preset value.\r
+ /// </summary>\r
+ public int QsvPresetValue\r
+ {\r
+ get\r
+ {\r
+ return this.qsvPresetValue;\r
+ }\r
+ set\r
+ {\r
+ if (!object.Equals(this.QsvPresetValue, value))\r
+ {\r
+ this.qsvPresetValue = value;\r
+ this.QsvPreset = this.QsvPresets[value];\r
+ this.NotifyOfPropertyChange(() => this.QsvPresetValue);\r
+ }\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Gets or sets H264Profile.\r
/// </summary>\r
/// </summary>\r
public BindingList<x264Preset> X264Presets { get; set; }\r
\r
+ /// <summary>\r
+ /// Gets or sets QsvPreset.\r
+ /// </summary>\r
+ public BindingList<QsvPreset> QsvPresets { get; set; }\r
+\r
/// <summary>\r
/// Gets or sets X264Profiles.\r
/// </summary>\r
this.FastDecode = preset.Task.VideoEncoder == VideoEncoder.X264 && preset.Task.FastDecode;\r
this.ExtraArguments = preset.Task.ExtraAdvancedArguments;\r
\r
+ this.QsvPresetValue = preset.Task.VideoEncoder == VideoEncoder.QuickSync\r
+ ? (int)preset.Task.QsvPreset\r
+ : (int)QsvPreset.Quality;\r
+\r
this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab;\r
}\r
}\r
{\r
this.DisplayH264Options = encoder == VideoEncoder.X264 || encoder == VideoEncoder.QuickSync;\r
this.DisplayX264Options = encoder == VideoEncoder.X264;\r
+ this.DisplayQSVOptions = encoder == VideoEncoder.QuickSync;\r
+\r
+ if (encoder == VideoEncoder.QuickSync)\r
+ {\r
+ this.UseAdvancedTab = false;\r
+ }\r
}\r
\r
/// <summary>\r
{\r
this.canClear = false;\r
this.X264PresetValue = 5;\r
+ this.qsvPresetValue = 2;\r
this.X264Tune = x264Tune.None;\r
this.H264Profile = x264Profile.None;\r
this.FastDecode = false;\r
<RowDefinition Height="Auto" />\r
</Grid.RowDefinitions>\r
\r
- <ContentControl x:Name="X264ViewModel"\r
+ <ContentControl x:Name="X264ViewModel" Grid.Row="0"\r
Visibility="{Binding ShowX264Panel, Converter={StaticResource BooleanVisibilityConverter}}" />\r
\r
- <ContentControl x:Name="EncoderOptionsViewModel" \r
+ <ContentControl x:Name="EncoderOptionsViewModel" Grid.Row="0"\r
Visibility="{Binding ShowSimplePanel, Converter={StaticResource BooleanVisibilityConverter}}" />\r
\r
\r
Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}"\r
ToolTip="{x:Static Properties:Resources.Video_x264FastDecode}"/>\r
\r
+ <TextBlock Text="QSV Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"\r
+ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" />\r
+ <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal"\r
+ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" >\r
+ <Slider Minimum="0" Maximum="2" Width="150" Value="{Binding QsvPresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}" \r
+ IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" />\r
+ <TextBlock Text="{Binding QsvPreset, Converter={StaticResource enumComboConverter}}" Margin="5,0,0,0" />\r
+ </StackPanel>\r
+\r
\r
<!-- Row 2-->\r
<TextBlock Text="H.264 Profile:" Grid.Row="3" Grid.Column="0" Margin="0,10,0,0" VerticalAlignment="Center" />\r