summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-12-29 14:25:17 +0000
committersr55 <[email protected]>2012-12-29 14:25:17 +0000
commit3bb7333006c2ace5e3aaabfc80c5a00dcd92350e (patch)
treee135a842cb4a14b5acf5315c46105ca98fda7cb4 /win
parenta27835f8854129a45b8e9f3c28614966848ff9dd (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')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs29
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs7
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs17
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs12
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs20
-rw-r--r--win/CS/HandBrakeWPF/Views/VideoView.xaml3
7 files changed, 85 insertions, 8 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;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index c4acd7fa8..b0b46b760 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -388,6 +388,9 @@ namespace HandBrakeWPF.ViewModels
// Update the Quality Slider. Make sure the bounds are up to date with the users settings.
this.SetQualitySliderBounds();
+
+ // Hide the x264 controls when not needed.
+ this.DisplayX264Options = value == VideoEncoder.X264;
}
}
@@ -419,13 +422,13 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.extraArguments;
+ return this.Task.ExtraAdvancedArguments;
}
set
{
- if (!object.Equals(this.extraArguments, value))
+ if (!object.Equals(this.Task.AdvancedEncoderOptions, value))
{
- this.extraArguments = value;
+ this.Task.ExtraAdvancedArguments = value;
this.NotifyOfPropertyChange(() => this.ExtraArguments);
}
}
@@ -705,7 +708,9 @@ namespace HandBrakeWPF.ViewModels
: (int)x264Preset.Medium;
this.H264Profile = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Profile : x264Profile.None;
this.X264Tune = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.X264Tune : x264Tune.None;
- this.H264Level = preset.Task.H264Level;
+ this.H264Level = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Level : "Auto";
+ this.FastDecode = preset.Task.VideoEncoder == VideoEncoder.X264 && preset.Task.FastDecode;
+ this.ExtraArguments = preset.Task.ExtraAdvancedArguments;
}
}
@@ -729,6 +734,13 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange(() => this.Task.VideoBitrate);
this.NotifyOfPropertyChange(() => this.Task.TwoPass);
this.NotifyOfPropertyChange(() => this.Task.TurboFirstPass);
+
+ this.NotifyOfPropertyChange(() => this.X264Tune);
+ this.NotifyOfPropertyChange(() => this.X264Preset);
+ this.NotifyOfPropertyChange(() => this.H264Level);
+ this.NotifyOfPropertyChange(() => this.H264Profile);
+ this.NotifyOfPropertyChange(() => this.FastDecode);
+ this.NotifyOfPropertyChange(() => this.ExtraArguments);
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml
index ffc027786..78186238d 100644
--- a/win/CS/HandBrakeWPF/Views/VideoView.xaml
+++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml
@@ -157,7 +157,8 @@
<!-- Row 3 -->
<TextBlock Text="Extra Options:" Grid.Row="4" Grid.Column="0" Margin="0,10,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" />
- <TextBox Text="{Binding ExtraArguments}" Height="30" MaxLines="2" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,10,0,0" VerticalAlignment="Center"
+ <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}"/>