diff options
author | sr55 <[email protected]> | 2013-08-23 13:20:38 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-08-23 13:20:38 +0000 |
commit | c7dc884bbee9c87fb4e7eb974d5ee029f4c234e4 (patch) | |
tree | 9775daec15adcc3c39b957e9dd37e858b5a2cbf1 | |
parent | 1270ebc49fc8dc11ea509815094faacfa8338834 (diff) |
WinGui: Manually merged the QuickSync UI changes from the qsv branch to trunk
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5741 b64f7644-9d1e-0410-96f1-a4d463321fa5
15 files changed, 482 insertions, 58 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs index e3daf4154..488f1b9b6 100644 --- a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs @@ -238,6 +238,9 @@ namespace HandBrake.ApplicationServices.Factories case "h264Level":
preset.Task.H264Level = kvp.Value;
break;
+ case "QsvPreset":
+ preset.Task.QsvPreset = EnumHelper<QsvPreset>.GetValue(kvp.Value, true);
+ break;
// Chapter Markers Tab
case "ChapterMarkers":
diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index 9e57ef03a..87ddadd43 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -46,6 +46,7 @@ namespace HandBrake.ApplicationServices.Model this.ChapterNames = new ObservableCollection<ChapterMarker>();
this.AllowedPassthruOptions = new AllowedPassthru();
this.X264Preset = x264Preset.Medium;
+ this.QsvPreset = QsvPreset.Quality;
this.H264Profile = x264Profile.None;
this.X264Tune = x264Tune.None;
this.Modulus = 16;
@@ -126,6 +127,7 @@ namespace HandBrake.ApplicationServices.Model this.VideoEncodeRateType = task.VideoEncodeRateType;
this.Width = task.Width;
this.X264Preset = task.X264Preset;
+ this.QsvPreset = task.QsvPreset;
this.H264Profile = task.H264Profile;
this.X264Tune = task.X264Tune;
this.H264Level = task.H264Level;
@@ -418,6 +420,11 @@ namespace HandBrake.ApplicationServices.Model public x264Preset X264Preset { get; set; }
/// <summary>
+ /// Gets or sets the qsv preset.
+ /// </summary>
+ public QsvPreset QsvPreset { get; set; }
+
+ /// <summary>
/// Gets or sets x264Profile.
/// </summary>
public x264Profile H264Profile { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 66a936d1f..4e48c4f0f 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -292,6 +292,8 @@ namespace HandBrake.ApplicationServices.Utilities return VideoEncoder.FFMpeg2;
case "x264":
return VideoEncoder.X264;
+ case "qsv_h264":
+ return VideoEncoder.QuickSync;
case "theora":
return VideoEncoder.Theora;
default:
@@ -318,6 +320,8 @@ namespace HandBrake.ApplicationServices.Utilities return "mpeg2";
case VideoEncoder.X264:
return "x264";
+ case VideoEncoder.QuickSync:
+ return "qsv_h264";
case VideoEncoder.Theora:
return "theora";
default:
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index a6a91cce7..420717dfa 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -280,7 +280,7 @@ namespace HandBrake.ApplicationServices.Utilities }
AddEncodeElement(xmlWriter, "x264Tune", "string", tune);
AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0");
-
+ AddEncodeElement(xmlWriter, "QsvPreset", "string", parsed.QsvPreset.ToString());
int videoQualityType = 0;
if (parsed.VideoBitrate != null) videoQualityType = 1;
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 040600207..3c78664c7 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -427,6 +427,9 @@ namespace HandBrake.ApplicationServices.Utilities case VideoEncoder.X264:
query += " -e x264";
break;
+ case VideoEncoder.QuickSync:
+ query += " -e qsv_h264";
+ break;
case VideoEncoder.Theora:
query += " -e theora";
break;
@@ -575,7 +578,7 @@ namespace HandBrake.ApplicationServices.Utilities firstLoop = false;
}
else
- audioItems += "," + Converters.GetCliAudioEncoder(item);
+ audioItems += "," + Converters.GetCliAudioEncoder(item);
}
if (audioItems.Trim() != String.Empty)
query += " -E " + audioItems;
@@ -724,10 +727,10 @@ namespace HandBrake.ApplicationServices.Utilities {
query += string.Format(" --audio-copy-mask {0}", fallbackEncoders);
}
- }
+ }
else
{
- query += string.Format(" --audio-copy-mask none");
+ query += string.Format(" --audio-copy-mask none");
}
query += string.Format(" --audio-fallback {0}", Converters.GetCliAudioEncoder(task.AllowedPassthruOptions.AudioEncoderFallback));
@@ -897,10 +900,11 @@ namespace HandBrake.ApplicationServices.Utilities /// </returns>
private static string AdvancedQuery(EncodeTask task)
{
+ string query = string.Empty;
+
+ // X264 Only
if (task.VideoEncoder == VideoEncoder.X264)
{
- string query = string.Empty;
-
if (!task.ShowAdvancedTab)
{
if (task.X264Preset != x264Preset.Medium)
@@ -909,12 +913,6 @@ namespace HandBrake.ApplicationServices.Utilities " --x264-preset={0} ", task.X264Preset.ToString().ToLower().Replace(" ", string.Empty));
}
- if (task.H264Profile != x264Profile.None)
- {
- query += string.Format(
- " --x264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));
- }
-
if (task.X264Tune != x264Tune.None)
{
string tune = string.Empty;
@@ -933,23 +931,69 @@ namespace HandBrake.ApplicationServices.Utilities query += string.Format(" --x264-tune=\"{0}\" ", tune);
}
- if (task.H264Level != "Auto")
- {
- query += string.Format(" --h264-level=\"{0}\" ", task.H264Level);
- }
-
if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
{
query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
}
+ }
+ }
+ // Options that apply to both x264 and QuickSync
+ if (task.VideoEncoder == VideoEncoder.QuickSync || task.VideoEncoder == VideoEncoder.X264)
+ {
+ if (task.H264Level != "Auto")
+ {
+ query += string.Format(" --h264-level=\"{0}\" ", task.H264Level);
}
- else
+
+ if (task.H264Profile != x264Profile.None)
+ {
+ query += string.Format(
+ " --h264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (task.VideoEncoder == VideoEncoder.QuickSync)
{
- if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))
+ string qsvPreset;
+
+ if (SystemInfo.IsHswOrNewer)
{
- query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
+ switch (task.QsvPreset)
+ {
+ case QsvPreset.Speed:
+ qsvPreset = "6";
+ break;
+ case QsvPreset.Balanced:
+ qsvPreset = "4";
+ break;
+ default:
+ qsvPreset = "2";
+ break;
+ }
}
+ else
+ {
+ switch (task.QsvPreset)
+ {
+ case QsvPreset.Speed:
+ qsvPreset = "4";
+ break;
+ case QsvPreset.Balanced:
+ qsvPreset = "2";
+ break;
+ default:
+ qsvPreset = "2";
+ break;
+ }
+ }
+
+ query += string.IsNullOrEmpty(task.AdvancedEncoderOptions)
+ ? string.Format(" -x target-usage={0}", qsvPreset)
+ : string.Format(" -x target-usage={0}:{1}", qsvPreset, task.AdvancedEncoderOptions);
+ }
+ else if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions)) // Not a H.264 encode
+ {
+ query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
}
return query;
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs b/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs index 32328ab47..99ab990ca 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs @@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Utilities
{
+ using System.Text.RegularExpressions;
using System.Windows.Forms;
using Microsoft.Win32;
@@ -56,5 +57,35 @@ namespace HandBrake.ApplicationServices.Utilities {
get { return Screen.PrimaryScreen; }
}
+
+ /// <summary>
+ /// Gets a value indicating whether is hsw or newer.
+ /// </summary>
+ public static bool IsHswOrNewer
+ {
+ get
+ {
+ // TODO replace with a call to libhb
+ string cpu = GetCpuCount.ToString();
+ if (cpu.Contains("Intel"))
+ {
+ Match match = Regex.Match(cpu, "([0-9]{4})");
+ if (match.Success)
+ {
+ string cpuId = match.Groups[0].ToString();
+ int cpuNumber;
+ if (int.TryParse(cpuId, out cpuNumber))
+ {
+ if (cpuNumber > 4000)
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+ }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index d213ca39a..047a172e6 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -166,6 +166,7 @@ <Compile Include="Model\Encoding\Mixdown.cs" />
<Compile Include="Model\Encoding\OutputExtension.cs" />
<Compile Include="Model\Encoding\Container.cs" />
+ <Compile Include="Model\Encoding\QsvPreset.cs" />
<Compile Include="Model\Encoding\VideoEncoder.cs" />
<Compile Include="Model\Encoding\VideoEncodeRateType.cs" />
<Compile Include="Model\Encoding\x264\x264Preset.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/QsvPreset.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/QsvPreset.cs new file mode 100644 index 000000000..08147a5d3 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/QsvPreset.cs @@ -0,0 +1,28 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="QsvPreset.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>
+// The qsv preset.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Model.Encoding
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The qsv preset.
+ /// </summary>
+ public enum QsvPreset
+ {
+ [Display(Name = "Best Speed")]
+ Speed,
+
+ [Display(Name = "Balanced")]
+ Balanced,
+
+ [Display(Name = "Best Quality")]
+ Quality,
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs index e05f74419..b355d5038 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs @@ -22,6 +22,9 @@ namespace HandBrake.Interop.Model.Encoding [ShortName("x264")]
X264 = 0,
+ [Display(Name = "H.264 (Intel QSV)")]
+ QuickSync,
+
[Display(Name = "MPEG-4 (FFmpeg)")]
[ShortName("mpeg4")]
FFMpeg,
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs index 6f89bb52f..d65b7f9f1 100644 --- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -65,6 +65,10 @@ namespace HandBrakeWPF.Converters {
return EnumHelper<Mixdown>.GetEnumDisplayValues(typeof(Mixdown));
}
+ if (targetType == typeof(QsvPreset) || value.GetType() == typeof(QsvPreset))
+ {
+ return EnumHelper<QsvPreset>.GetDisplay((QsvPreset)value);
+ }
if (value is IEnumerable<PresetPictureSettingsMode>)
{
@@ -182,6 +186,10 @@ namespace HandBrakeWPF.Converters {
return EnumHelper<Mixdown>.GetValue(value.ToString());
}
+ if (targetType == typeof(QsvPreset) || value.GetType() == typeof(QsvPreset))
+ {
+ return EnumHelper<QsvPreset>.GetValue(value.ToString());
+ }
if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode))
{
diff --git a/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs b/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs index f44e18a3e..8cd29431f 100644 --- a/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs @@ -19,10 +19,6 @@ namespace HandBrakeWPF.Converters [ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
- #region Implemented Interfaces
-
- #region IValueConverter
-
/// <summary>
/// The convert.
/// </summary>
@@ -73,9 +69,5 @@ namespace HandBrakeWPF.Converters {
throw new NotSupportedException();
}
-
- #endregion
-
- #endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs index f1da43828..d7ae4e498 100644 --- a/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs @@ -33,6 +33,7 @@ namespace HandBrakeWPF.ViewModels public EncoderOptionsViewModel()
{
this.Task = new EncodeTask();
+ cachedOptions.Add(VideoEncoder.QuickSync, "async-depth=4");
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index f37f9c7ea..bc07f57f5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -63,6 +63,16 @@ namespace HandBrakeWPF.ViewModels private bool displayX264Options;
/// <summary>
+ /// The display qsv options.
+ /// </summary>
+ private bool displayQSVOptions;
+
+ /// <summary>
+ /// Backing field used to display / hide the h264 options
+ /// </summary>
+ private bool displayEncoderOptions;
+
+ /// <summary>
/// The quality max.
/// </summary>
private int qualityMax;
@@ -88,6 +98,11 @@ namespace HandBrakeWPF.ViewModels private int x264PresetValue;
/// <summary>
+ /// The qsv preset value.
+ /// </summary>
+ private int qsvPresetValue;
+
+ /// <summary>
/// The extra arguments.
/// </summary>
private string extraArguments;
@@ -102,6 +117,11 @@ namespace HandBrakeWPF.ViewModels /// </summary>
private bool useAdvancedTab;
+ /// <summary>
+ /// The display framerate controls.
+ /// </summary>
+ private bool displayNonQSVControls;
+
#endregion
#region Constructors and Destructors
@@ -126,6 +146,7 @@ namespace HandBrakeWPF.ViewModels this.VideoEncoders = EnumHelper<VideoEncoder>.GetEnumList();
X264Presets = new BindingList<x264Preset>(EnumHelper<x264Preset>.GetEnumList().ToList());
+ QsvPresets = new BindingList<QsvPreset>(EnumHelper<QsvPreset>.GetEnumList().ToList());
H264Profiles = EnumHelper<x264Profile>.GetEnumList();
X264Tunes = EnumHelper<x264Tune>.GetEnumList().Where(t => t != x264Tune.Fastdecode);
this.H264Levels = Levels;
@@ -149,13 +170,17 @@ namespace HandBrakeWPF.ViewModels {
get
{
- bool showAdvTabSetting =
- this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedTab);
+ bool showAdvTabSetting = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedTab);
if (!showAdvTabSetting)
{
this.UseAdvancedTab = false;
}
+ if (this.SelectedVideoEncoder == VideoEncoder.QuickSync)
+ {
+ return false;
+ }
+
return showAdvTabSetting;
}
}
@@ -303,7 +328,7 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return 0.0.Equals(this.DisplayRF);
+ return 0.0.Equals(this.DisplayRF) && this.SelectedVideoEncoder == VideoEncoder.X264;
}
}
@@ -366,6 +391,7 @@ namespace HandBrakeWPF.ViewModels case VideoEncoder.FFMpeg2:
this.Task.Quality = (32 - value);
break;
+ case VideoEncoder.QuickSync:
case VideoEncoder.X264:
double rfValue = 51.0 - value * cqStep;
rfValue = Math.Round(rfValue, 2);
@@ -394,6 +420,40 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets a value indicating whether two pass.
+ /// </summary>
+ public bool TwoPass
+ {
+ get
+ {
+ return this.Task.TwoPass;
+ }
+
+ set
+ {
+ this.Task.TwoPass = value;
+ this.NotifyOfPropertyChange(() => this.TwoPass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether turbo first pass.
+ /// </summary>
+ public bool TurboFirstPass
+ {
+ get
+ {
+ return this.Task.TurboFirstPass;
+ }
+
+ set
+ {
+ this.Task.TurboFirstPass = value;
+ this.NotifyOfPropertyChange(() => this.TurboFirstPass);
+ }
+ }
+
+ /// <summary>
/// Gets the rfqp.
/// </summary>
public string Rfqp
@@ -480,9 +540,23 @@ namespace HandBrakeWPF.ViewModels // Hide the x264 controls when not needed.
this.DisplayX264Options = value == VideoEncoder.X264;
+ this.DisplayQSVOptions = value == VideoEncoder.QuickSync;
+ this.DisplayH264Options = value == VideoEncoder.X264 || value == VideoEncoder.QuickSync;
+ this.UseAdvancedTab = value != VideoEncoder.QuickSync && this.UseAdvancedTab;
+ this.DisplayNonQSVControls = value != VideoEncoder.QuickSync;
this.NotifyOfPropertyChange(() => this.Rfqp);
+ this.NotifyOfPropertyChange(() => this.ShowAdvancedTab);
+
this.NotifyOfPropertyChange(() => this.HighQualityLabel);
+ if (value == VideoEncoder.QuickSync)
+ {
+ this.IsConstantFramerate = true;
+ this.TwoPass = false;
+ this.TurboFirstPass = false;
+ this.Task.Framerate = null;
+ this.NotifyOfPropertyChange(() => SelectedFramerate);
+ }
}
}
@@ -526,6 +600,23 @@ namespace HandBrakeWPF.ViewModels }
}
}
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to display H264
+ /// </summary>
+ public bool DisplayH264Options
+ {
+ get
+ {
+ return this.displayEncoderOptions;
+ }
+ set
+ {
+ this.displayEncoderOptions = value;
+ this.NotifyOfPropertyChange(() => this.DisplayH264Options);
+ }
+ }
+
/// <summary>
/// Gets or sets a value indicating whether display x 264 options.
@@ -544,6 +635,40 @@ namespace HandBrakeWPF.ViewModels }
}
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to display qsv options.
+ /// </summary>
+ public bool DisplayQSVOptions
+ {
+ get
+ {
+ return this.displayQSVOptions;
+ }
+ set
+ {
+ this.displayQSVOptions = value;
+ this.NotifyOfPropertyChange(() => this.DisplayQSVOptions);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether display framerate controls.
+ /// </summary>
+ public bool DisplayNonQSVControls
+ {
+ get
+ {
+ return this.displayNonQSVControls;
+ }
+
+ set
+ {
+ this.displayNonQSVControls = value;
+ this.NotifyOfPropertyChange(() => this.DisplayNonQSVControls);
+ }
+ }
+
/// <summary>
/// Gets or sets the x 264 preset value.
/// </summary>
@@ -585,6 +710,45 @@ namespace HandBrakeWPF.ViewModels }
}
}
+
+ /// <summary>
+ /// Gets or sets X264Preset.
+ /// </summary>
+ public QsvPreset QsvPreset
+ {
+ get
+ {
+ return this.Task.QsvPreset;
+ }
+ set
+ {
+ if (!object.Equals(this.QsvPreset, value))
+ {
+ this.Task.QsvPreset = value;
+ this.NotifyOfPropertyChange(() => this.QsvPreset);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the x 264 preset value.
+ /// </summary>
+ public int QsvPresetValue
+ {
+ get
+ {
+ return this.qsvPresetValue;
+ }
+ set
+ {
+ if (!object.Equals(this.QsvPresetValue, value))
+ {
+ this.qsvPresetValue = value;
+ this.QsvPreset = this.QsvPresets[value];
+ this.NotifyOfPropertyChange(() => this.QsvPresetValue);
+ }
+ }
+ }
/// <summary>
/// Gets or sets H264Profile.
@@ -677,6 +841,12 @@ namespace HandBrakeWPF.ViewModels public BindingList<x264Preset> X264Presets { get; set; }
/// <summary>
+ /// Gets or sets QsvPreset.
+ /// </summary>
+ public BindingList<QsvPreset> QsvPresets { get; set; }
+
+
+ /// <summary>
/// Gets or sets X264Profiles.
/// </summary>
public IEnumerable<x264Profile> H264Profiles { get; set; }
@@ -702,6 +872,17 @@ namespace HandBrakeWPF.ViewModels }
}
+ /// <summary>
+ /// Gets the qsv slider max.
+ /// </summary>
+ public int QsvSliderMax
+ {
+ get
+ {
+ return SystemInfo.IsHswOrNewer ? 2 : 1;
+ }
+ }
+
#endregion
#region Public Methods
@@ -774,6 +955,7 @@ namespace HandBrakeWPF.ViewModels this.RF = 32 - cq;
}
break;
+ case VideoEncoder.QuickSync:
case VideoEncoder.X264:
double multiplier = 1.0 / cqStep;
@@ -812,6 +994,10 @@ namespace HandBrakeWPF.ViewModels this.FastDecode = preset.Task.VideoEncoder == VideoEncoder.X264 && preset.Task.FastDecode;
this.ExtraArguments = preset.Task.ExtraAdvancedArguments;
+ this.QsvPresetValue = preset.Task.VideoEncoder == VideoEncoder.QuickSync
+ ? (int)preset.Task.QsvPreset
+ : SystemInfo.IsHswOrNewer ? (int)QsvPreset.Quality : (int)QsvPreset.Balanced;
+
this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab;
}
}
@@ -843,6 +1029,7 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.H264Profile);
this.NotifyOfPropertyChange(() => this.FastDecode);
this.NotifyOfPropertyChange(() => this.ExtraArguments);
+ this.NotifyOfPropertyChange(() => this.QsvPreset);
}
/// <summary>
@@ -853,7 +1040,14 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetEncoder(VideoEncoder encoder)
{
+ this.DisplayH264Options = encoder == VideoEncoder.X264 || encoder == VideoEncoder.QuickSync;
this.DisplayX264Options = encoder == VideoEncoder.X264;
+ this.DisplayQSVOptions = encoder == VideoEncoder.QuickSync;
+
+ if (encoder == VideoEncoder.QuickSync)
+ {
+ this.UseAdvancedTab = false;
+ }
}
/// <summary>
@@ -909,6 +1103,7 @@ namespace HandBrakeWPF.ViewModels this.QualityMax = 31;
break;
case VideoEncoder.X264:
+ case VideoEncoder.QuickSync:
this.QualityMin = 0;
this.QualityMax = (int)(51 / userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step));
break;
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml index c4bd565c7..fffbfd0b2 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml @@ -6,7 +6,8 @@ xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
xmlns:Video="clr-namespace:HandBrakeWPF.Converters.Video"
xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
- xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" mc:Ignorable="d" >
+ xmlns:cal="http://www.caliburnproject.org"
+ mc:Ignorable="d" >
<UserControl.Resources>
<Converters:BooleanConverter x:Key="boolConverter" />
@@ -74,12 +75,18 @@ <StackPanel Orientation="Horizontal">
<TextBlock Text="Framerate (FPS):" VerticalAlignment="Top" Margin="0,5,0,0" Width="100"/>
<StackPanel Orientation="Vertical">
- <ComboBox Width="120" ItemsSource="{Binding Framerates}" SelectedItem="{Binding SelectedFramerate}" />
- <RadioButton Content="Constant Framerate" IsChecked="{Binding IsConstantFramerate}" Margin="0,10,0,0" />
- <RadioButton Content="Variable Framerate" IsChecked="{Binding IsVariableFramerate}" Margin="0,5,0,0"
+ <ComboBox Width="120" ItemsSource="{Binding Framerates}" SelectedItem="{Binding SelectedFramerate}"
+ Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
+ <TextBlock Text="Same as source" VerticalAlignment="Center" Margin="0,5,0,0"
+ Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/>
+
+ <StackPanel Orientation="Vertical" Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}}">
+ <RadioButton Content="Constant Framerate" IsChecked="{Binding IsConstantFramerate}" Margin="0,10,0,0" />
+ <RadioButton Content="Variable Framerate" IsChecked="{Binding IsVariableFramerate}" Margin="0,5,0,0"
Visibility="{Binding ShowPeakFramerate, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
- <RadioButton Content="Peak Framerate" IsChecked="{Binding IsPeakFramerate}" Margin="0,5,0,0"
+ <RadioButton Content="Peak Framerate" IsChecked="{Binding IsPeakFramerate}" Margin="0,5,0,0"
Visibility="{Binding ShowPeakFramerate, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
+ </StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
@@ -89,7 +96,7 @@ <TextBlock Text="Quality" FontWeight="Bold" Margin="0,0,0,10"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10" >
- <RadioButton Content="Constant Quality:" IsChecked="{Binding IsConstantQuantity}" Margin="0,0,10,0"/>
+ <RadioButton Content="Constant Quality:" IsChecked="{Binding IsConstantQuantity}" Margin="0,0,10,0" Checked="qsv_preset_radiobutton"/>
<TextBlock Text="{Binding DisplayRF}" MinWidth="30" />
<TextBlock Text="{Binding Rfqp}" FontWeight="Bold" Margin="5,0,0,0" />
@@ -112,22 +119,21 @@ </Grid>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
- <RadioButton Content="Avg Bitrate (kbps):" IsChecked="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,10,0"/>
- <TextBox Width="75" Text="{Binding Task.VideoBitrate, UpdateSourceTrigger=PropertyChanged}"
- IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" />
+ <RadioButton Content="Avg Bitrate (kbps):" IsChecked="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,10,0" Checked="qsv_preset_radiobutton"/>
+ <TextBox Width="75" Text="{Binding Task.VideoBitrate, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" />
</StackPanel>
- <StackPanel Orientation="Horizontal" Margin="30,0,0,0">
+ <StackPanel Orientation="Horizontal" Margin="30,0,0,0" Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}}">
<CheckBox Content="2-Pass Encoding" IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}"
- IsChecked="{Binding Task.TwoPass}" Margin="0,0,10,0" />
+ IsChecked="{Binding TwoPass}" Margin="0,0,10,0" />
<CheckBox Content="Turbo first pass" IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}"
- IsChecked="{Binding Task.TurboFirstPass}" />
+ IsChecked="{Binding TurboFirstPass}" />
</StackPanel>
</StackPanel>
<!-- H264 settings -->
- <Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="0,20,0,0" Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}">
+ <Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="0,20,0,0" Visibility="{Binding DisplayH264Options, Converter={StaticResource boolToVisConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -139,8 +145,7 @@ <CheckBox Content="Use Advanced Tab instead" Grid.Row="1" IsChecked="{Binding UseAdvancedTab}"
Visibility="{Binding ShowAdvancedTab, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
- <Grid Grid.Row="2" Margin="0,5,0,0" IsEnabled="{Binding UseAdvancedTab, Converter={StaticResource inverseConverter}}"
- Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}">
+ <Grid Grid.Row="2" Margin="0,5,0,0" IsEnabled="{Binding UseAdvancedTab, Converter={StaticResource inverseConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -160,22 +165,36 @@ <!-- Row 1 -->
- <TextBlock Text="x264 Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" />
- <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal">
+ <TextBlock Text="x264 Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" />
+ <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" >
<Slider Minimum="0" Maximum="9" Width="150" Value="{Binding X264PresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}"
IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" ToolTip="{x:Static Properties:Resources.Video_x264Preset}"
Style="{StaticResource LongToolTipHolder}" />
<TextBlock Text="{Binding X264Preset, Converter={StaticResource enumComboConverter}}" Margin="5,0,0,0" />
</StackPanel>
- <TextBlock Text="x264 Tune:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="0,10,0,0" />
+ <TextBlock Text="x264 Tune:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="0,10,0,0"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" />
<ComboBox Width="100" Grid.Row="2" Grid.Column="1" Margin="5,10,5,0" Height="22"
- ItemsSource="{Binding X264Tunes, Converter={StaticResource enumComboConverter}}"
- SelectedItem="{Binding X264Tune, Converter={StaticResource enumComboConverter}}"
- ToolTip="{x:Static Properties:Resources.Video_x264Tune}"
- Style="{StaticResource LongToolTipHolder}" />
+ 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}"
+ Style="{StaticResource LongToolTipHolder}" />
<CheckBox IsChecked="{Binding FastDecode}" Content="Fast Decode" Grid.Row="2" Grid.Column="2" Margin="10,10,10,0" VerticalAlignment="Center"
- ToolTip="{x:Static Properties:Resources.Video_x264FastDecode}"/>
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}"
+ ToolTip="{x:Static Properties:Resources.Video_x264FastDecode}"/>
+
+ <TextBlock Text="QSV Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
+ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" />
+ <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal"
+ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" >
+ <Slider Minimum="0" Maximum="{Binding QsvSliderMax}" Width="150" Value="{Binding QsvPresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}"
+ IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" ValueChanged="qsv_preset_ValueChanged"/>
+ <TextBlock Text="{Binding QsvPreset, Converter={StaticResource enumComboConverter}}" Margin="5,0,0,0" />
+ </StackPanel>
<!-- Row 2-->
@@ -194,13 +213,15 @@ ToolTip="{x:Static Properties:Resources.Video_x264Level}"/>
<!-- Row 3 -->
- <TextBlock Text="Extra Options:" Grid.Row="4" Grid.Column="0" Margin="0,10,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" />
+ <TextBlock Text="Extra Options:" Grid.Row="4" Grid.Column="0" Margin="0,10,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" />
<TextBox Text="{Binding ExtraArguments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- Height="30" MaxLines="2" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,10,0,0" VerticalAlignment="Center"
- ToolTip="{Binding FullOptionsTooltip}" Style="{StaticResource LongToolTipHolder}">
+ Height="30" MaxLines="2" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,10,0,0" VerticalAlignment="Center"
+ ToolTip="{Binding FullOptionsTooltip}" Style="{StaticResource LongToolTipHolder}"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" >
<TextBox.ContextMenu>
<ContextMenu>
- <MenuItem Header="Copy Full Query" Micro:Message.Attach="[Event Click] = [Action CopyQuery]" />
+ <MenuItem Header="Copy Full Query" cal:Message.Attach="[Event Click] = [Action CopyQuery]" />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs b/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs index 8a0842a96..a285e490b 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs @@ -9,8 +9,19 @@ namespace HandBrakeWPF.Views
{
+ using System.Collections.Generic;
+ using System.Windows;
using System.Windows.Controls;
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Utilities;
+ using HandBrake.Interop.Model.Encoding;
+
+ using HandBrakeWPF.ViewModels;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
/// <summary>
/// Interaction logic for VideoView.xaml
/// </summary>
@@ -23,5 +34,80 @@ namespace HandBrakeWPF.Views {
InitializeComponent();
}
+
+
+ private void qsv_preset_radiobutton(object sender, System.Windows.RoutedEventArgs e)
+ {
+ qsv_preset_ValueChanged(sender, null);
+ }
+
+ private void qsv_preset_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+ {
+ VideoViewModel mvm = ((VideoViewModel)this.DataContext);
+ EncodeTask task = mvm.Task;
+
+ string addon = "";
+
+ if (SystemInfo.IsHswOrNewer)
+ {
+ if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
+ {
+ if (task.QsvPreset == QsvPreset.Balanced ||
+ task.QsvPreset == QsvPreset.Speed)
+ addon = "num-ref-frame=1";
+ }
+ if (task.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate)
+ {
+ if (task.QsvPreset == QsvPreset.Quality)
+ addon = "lookahead=1:gop-ref-dist=3";
+ else
+ if (task.QsvPreset == QsvPreset.Balanced)
+ {
+ addon = "num-ref-frame=1:gop-ref-dist=1";
+ }
+ else
+ if (task.QsvPreset == QsvPreset.Speed)
+ addon = "gop-ref-dist=1";
+ }
+ }
+
+
+ string full_string = addon + ":";
+
+ IDictionary<string, string> newOptions = new Dictionary<string, string>();
+ string[] existingSegments = full_string.Split(':');
+ foreach (string existingSegment in existingSegments)
+ {
+ string optionName = existingSegment;
+ string optionValue = string.Empty;
+ int equalsIndex = existingSegment.IndexOf('=');
+ if (equalsIndex >= 0)
+ {
+ optionName = existingSegment.Substring(
+ 0, existingSegment.IndexOf("=", System.StringComparison.Ordinal));
+ optionValue = existingSegment.Substring(equalsIndex);
+ }
+
+ if (optionName != string.Empty)
+ {
+ if (newOptions.ContainsKey(optionName))
+ newOptions.Remove(optionName);
+ newOptions.Add(optionName, optionValue);
+ }
+ }
+
+ full_string = "";
+ foreach (KeyValuePair<string, string> entry in newOptions)
+ {
+ full_string += entry.Key;
+ if (entry.Value != string.Empty)
+ full_string += entry.Value;
+ full_string += ":";
+ }
+ full_string = full_string.TrimEnd(':');
+
+ task.AdvancedEncoderOptions = full_string;
+ task.NotifyOfPropertyChange(() => task.AdvancedEncoderOptions);
+ }
}
}
|