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 /win/CS/HandBrake.ApplicationServices/Utilities | |
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
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
4 files changed, 99 insertions, 20 deletions
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 |