diff options
author | sr55 <[email protected]> | 2012-12-29 14:25:17 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-12-29 14:25:17 +0000 |
commit | 3bb7333006c2ace5e3aaabfc80c5a00dcd92350e (patch) | |
tree | e135a842cb4a14b5acf5315c46105ca98fda7cb4 /win/CS/HandBrake.ApplicationServices | |
parent | a27835f8854129a45b8e9f3c28614966848ff9dd (diff) |
WinGui: Add the plist keys and fix numerous bugs in the x264 preset/tune/profile/level code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5115 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
5 files changed, 67 insertions, 3 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs index f07f0aa01..e47a76115 100644 --- a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs @@ -19,6 +19,7 @@ namespace HandBrake.ApplicationServices.Factories using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.Model.Encoding.x264;
/// <summary>
/// A Factory to translate a Plist object into a Preset.
@@ -172,13 +173,16 @@ namespace HandBrake.ApplicationServices.Factories // Video Tab
case "VideoAvgBitrate":
- preset.Task.VideoBitrate = int.Parse(kvp.Value);
+ if (!string.IsNullOrEmpty(kvp.Value))
+ {
+ preset.Task.VideoBitrate = int.Parse(kvp.Value);
+ }
break;
case "VideoEncoder":
preset.Task.VideoEncoder = EnumHelper<VideoEncoder>.GetValue(kvp.Value);
break;
case "VideoFramerate":
- preset.Task.Framerate = kvp.Value == "Same as source" ? null : double.Parse(kvp.Value, CultureInfo.InvariantCulture);
+ preset.Task.Framerate = kvp.Value == "Same as source" || string.IsNullOrEmpty(kvp.Value) ? null : double.Parse(kvp.Value, CultureInfo.InvariantCulture);
break;
case "VideoFramerateMode":
string parsedValue = kvp.Value;
@@ -210,6 +214,27 @@ namespace HandBrake.ApplicationServices.Factories case "VideoTwoPass":
preset.Task.TwoPass = kvp.Value == 1;
break;
+ case "x264OptionExtra":
+ preset.Task.AdvancedEncoderOptions = kvp.Value;
+ break;
+ case "x264Preset":
+ preset.Task.X264Preset = EnumHelper<x264Preset>.GetValue(kvp.Value, true);
+ break;
+ case "h264Profile":
+ preset.Task.H264Profile = EnumHelper<x264Profile>.GetValue(kvp.Value, true);
+ break;
+ case "x264Tune":
+ string value = kvp.Value;
+ if (value.Contains("fastdecode"))
+ {
+ preset.Task.FastDecode = true;
+ value = value.Replace("fastdecode", string.Empty).Replace(",", string.Empty);
+ }
+ preset.Task.X264Tune = EnumHelper<x264Tune>.GetValue(value, true);
+ break;
+ case "h264Level":
+ preset.Task.H264Level = kvp.Value;
+ 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 9f5c043a0..554f78c35 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -117,7 +117,9 @@ namespace HandBrake.ApplicationServices.Model this.X264Preset = task.X264Preset;
this.H264Profile = task.H264Profile;
this.X264Tune = task.X264Tune;
+ this.H264Level = task.H264Level;
this.FastDecode = task.FastDecode;
+ this.ExtraAdvancedArguments = task.ExtraAdvancedArguments;
this.PreviewStartAt = task.PreviewStartAt;
this.PreviewDuration = task.PreviewDuration;
@@ -421,6 +423,11 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public bool FastDecode { get; set; }
+ /// <summary>
+ /// Extra Advanced Arguments for the Video Tab.
+ /// </summary>
+ public string ExtraAdvancedArguments { get; set; }
+
#endregion
#region Preview
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs index d6c972b5e..c854e5a05 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs @@ -63,6 +63,17 @@ namespace HandBrake.ApplicationServices.Utilities /// <returns>The Enum Value</returns>
public static T GetValue(string description)
{
+ return GetValue(description, false);
+ }
+
+ /// <summary>
+ /// Get the Enumeration for a given Enum Description
+ /// </summary>
+ /// <param name="description">The String description</param>
+ /// <param name="insensitiveCase">Turn of sensitivity to cases.</param>
+ /// <returns>The Enum Value</returns>
+ public static T GetValue(string description, bool insensitiveCase)
+ {
foreach (T val in Enum.GetValues(typeof(T)))
{
string currDescription = GetDescription(val);
@@ -71,6 +82,12 @@ namespace HandBrake.ApplicationServices.Utilities {
return val;
}
+
+ if (insensitiveCase && currDescription.ToLower() == description.ToLower() ||
+ currDisplay.ToLower() == description.ToLower())
+ {
+ return val;
+ }
}
throw new ArgumentOutOfRangeException("The Description for the enum was not recognized.");
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index bea765e27..3df28820f 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -265,10 +265,20 @@ namespace HandBrake.ApplicationServices.Utilities // Video Settings
AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.VideoBitrate.ToString());
AddEncodeElement(xmlWriter, "VideoEncoder", "string", EnumHelper<VideoEncoder>.GetDisplay(parsed.VideoEncoder));
- AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.Framerate.ToString());
+ AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.Framerate == null ? "Same as source" : parsed.Framerate.ToString());
AddEncodeElement(xmlWriter, "VideFrameratePFR", "integer", parsed.FramerateMode == FramerateMode.PFR ? "1" : "0");
AddEncodeElement(xmlWriter, "VideoGrayScale", "integer", parsed.Grayscale ? "1" : "0");
AddEncodeElement(xmlWriter, "VideoQualitySlider", "real", parsed.Quality.ToString());
+ AddEncodeElement(xmlWriter, "h264Level", "string", parsed.H264Level);
+ AddEncodeElement(xmlWriter, "x264OptionExtra", "string", parsed.AdvancedEncoderOptions);
+ AddEncodeElement(xmlWriter, "x264Preset", "string", parsed.X264Preset.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "h264Profile", "string", parsed.H264Profile.ToString().ToLower());
+ string tune = parsed.X264Tune.ToString().ToLower();
+ if (parsed.FastDecode)
+ {
+ tune = tune == "none" ? "fastdecode" : tune + ",fastdecode";
+ }
+ AddEncodeElement(xmlWriter, "x264Tune", "string", tune);
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 b6fc06faf..1447c1b7e 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -941,6 +941,11 @@ namespace HandBrake.ApplicationServices.Utilities query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
}
+ if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
+ {
+ query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
+ }
+
return query;
}
|