summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-03-24 21:31:49 +0000
committersr55 <[email protected]>2012-03-24 21:31:49 +0000
commit654057c737c7b51f236bdc6f5100f24f3fc4f8be (patch)
treec3c42ba0c649bab1a3a393b7fcbb460b3352e5e6 /win/CS/HandBrakeWPF/ViewModels
parent71be55c4db11cd6e2f8ba2f2df25e030fa089644 (diff)
WinGui: (WPF) Port the Advanced Panel for x264 from VidCoder.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4536 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs1034
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs1
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs1
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs129
4 files changed, 1104 insertions, 61 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
index cd1904cb3..0d65ff5be 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
@@ -9,18 +9,21 @@
namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
+ using System.Globalization;
+ using System.Linq;
using Caliburn.Micro;
- using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.Model.Encoding.x264;
+ using HandBrakeWPF.Helpers;
+ using HandBrakeWPF.Model;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
@@ -32,9 +35,129 @@ namespace HandBrakeWPF.ViewModels
#region Constants and Fields
/// <summary>
- /// Backing field used to display / hide the x264 options
+ /// Backing field for displaying x264 options
/// </summary>
- private bool displayX264Options;
+ private bool? displayX264Options;
+
+ /// <summary>
+ /// The adaptive b frames.
+ /// </summary>
+ private AdvancedChoice adaptiveBFrames;
+
+ /// <summary>
+ /// The adaptive quantization strength.
+ /// </summary>
+ private double adaptiveQuantizationStrength;
+
+ /// <summary>
+ /// The analysis.
+ /// </summary>
+ private AdvancedChoice analysis;
+
+ /// <summary>
+ /// The b frames.
+ /// </summary>
+ private AdvancedChoice bFrames;
+
+ /// <summary>
+ /// The cabac entropy coding.
+ /// </summary>
+ private bool cabacEntropyCoding;
+
+ /// <summary>
+ /// The deblocking strength.
+ /// </summary>
+ private AdvancedChoice deblockingStrength;
+
+ /// <summary>
+ /// The deblocking threshold.
+ /// </summary>
+ private AdvancedChoice deblockingThreshold;
+
+ /// <summary>
+ /// The direct prediction.
+ /// </summary>
+ private AdvancedChoice directPrediction;
+
+ /// <summary>
+ /// The eight by eight dct.
+ /// </summary>
+ private bool eightByEightDct;
+
+ /// <summary>
+ /// The motion estimation method.
+ /// </summary>
+ private AdvancedChoice motionEstimationMethod;
+
+ /// <summary>
+ /// The motion estimation range.
+ /// </summary>
+ private AdvancedChoice motionEstimationRange;
+
+ /// <summary>
+ /// The no dct decimate.
+ /// </summary>
+ private bool noDctDecimate;
+
+ /// <summary>
+ /// The psychovisual rate distortion.
+ /// </summary>
+ private double psychovisualRateDistortion;
+
+ /// <summary>
+ /// The psychovisual trellis.
+ /// </summary>
+ private double psychovisualTrellis;
+
+ /// <summary>
+ /// The pyramidal b frames.
+ /// </summary>
+ private AdvancedChoice pyramidalBFrames;
+
+ /// <summary>
+ /// The reference frames.
+ /// </summary>
+ private AdvancedChoice referenceFrames;
+
+ /// <summary>
+ /// The subpixel motion estimation.
+ /// </summary>
+ private AdvancedChoice subpixelMotionEstimation;
+
+ /// <summary>
+ /// The trellis.
+ /// </summary>
+ private AdvancedChoice trellis;
+
+ /// <summary>
+ /// X264 options that have UI elements that correspond to them.
+ /// </summary>
+ private HashSet<string> uiOptions = new HashSet<string>
+ {
+ "ref",
+ "bframes",
+ "b-adapt",
+ "direct",
+ "weightp",
+ "b-pyramid",
+ "me",
+ "subme",
+ "subq",
+ "merange",
+ "analyse",
+ "8x8dct",
+ "cabac",
+ "trellis",
+ "aq-strength",
+ "psy-rd",
+ "no-dct-decimate",
+ "deblock"
+ };
+
+ /// <summary>
+ /// The weighted p frames.
+ /// </summary>
+ private bool weightedPFrames;
#endregion
@@ -52,112 +175,458 @@ namespace HandBrakeWPF.ViewModels
public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
this.Task = new EncodeTask();
- X264Presets = EnumHelper<x264Preset>.GetEnumList();
- X264Profiles = EnumHelper<x264Profile>.GetEnumList();
- X264Tunes = EnumHelper<x264Tune>.GetEnumList();
+ this.UpdateUIFromAdvancedOptions();
}
#endregion
- #region Public Properties
+ #region Properties
/// <summary>
- /// Gets or sets Task.
+ /// Gets or sets a value indicating whether DisplayX264Options.
/// </summary>
- public EncodeTask Task { get; set; }
+ public bool? DisplayX264Options
+ {
+ get
+ {
+ return this.displayX264Options;
+ }
+ set
+ {
+ this.displayX264Options = value;
+ this.NotifyOfPropertyChange(() => this.DisplayX264Options);
+ }
+ }
/// <summary>
- /// Gets or sets State.
+ /// Gets or sets AdaptiveBFrames.
/// </summary>
- public string Query
+ public AdvancedChoice AdaptiveBFrames
+ {
+ get
+ {
+ return this.adaptiveBFrames;
+ }
+
+ set
+ {
+ this.adaptiveBFrames = value;
+ this.NotifyOfPropertyChange(() => this.AdaptiveBFrames);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets AdaptiveQuantizationStrength.
+ /// </summary>
+ public double AdaptiveQuantizationStrength
+ {
+ get
+ {
+ return this.adaptiveQuantizationStrength;
+ }
+
+ set
+ {
+ this.adaptiveQuantizationStrength = value;
+ this.NotifyOfPropertyChange(() => this.AdaptiveQuantizationStrength);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets AdvancedOptionsString.
+ /// </summary>
+ public string AdvancedOptionsString
{
get
{
return this.Task.AdvancedEncoderOptions;
}
+
set
{
this.Task.AdvancedEncoderOptions = value;
- this.NotifyOfPropertyChange(() => this.Query);
+ this.UpdateUIFromAdvancedOptions();
+ this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets Analysis.
+ /// </summary>
+ public AdvancedChoice Analysis
+ {
+ get
+ {
+ return this.analysis;
+ }
+
+ set
+ {
+ this.analysis = value;
+ this.NotifyOfPropertyChange(() => this.Analysis);
+ this.NotifyOfPropertyChange(() => this.EightByEightDctVisible);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether AutomaticChange.
+ /// </summary>
+ public bool AutomaticChange { get; set; }
+
+ /// <summary>
+ /// Gets or sets BFrames.
+ /// </summary>
+ public AdvancedChoice BFrames
+ {
+ get
+ {
+ return this.bFrames;
+ }
+
+ set
+ {
+ this.bFrames = value;
+ this.NotifyOfPropertyChange(() => this.BFrames);
+ this.NotifyOfPropertyChange(() => this.BFramesOptionsVisible);
+ this.NotifyOfPropertyChange(() => this.PyramidalBFramesVisible);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether BFramesOptionsVisible.
+ /// </summary>
+ public bool BFramesOptionsVisible
+ {
+ get
+ {
+ return this.BFrames.Value != "0";
}
}
/// <summary>
- /// Gets or sets X264Preset.
+ /// Gets or sets a value indicating whether CabacEntropyCoding.
/// </summary>
- public x264Preset X264Preset
+ public bool CabacEntropyCoding
{
get
{
- return this.Task.x264Preset;
+ return this.cabacEntropyCoding;
}
+
set
{
- this.Task.x264Preset = value;
- this.NotifyOfPropertyChange(() => this.X264Preset);
+ this.cabacEntropyCoding = value;
+ this.NotifyOfPropertyChange(() => this.CabacEntropyCoding);
+ this.NotifyOfPropertyChange(() => this.PsychovisualTrellisVisible);
+ this.UpdateOptionsString();
}
}
/// <summary>
- /// Gets or sets X264Profile.
+ /// Gets or sets DeblockingStrength.
/// </summary>
- public x264Profile X264Profile
+ public AdvancedChoice DeblockingStrength
{
get
{
- return this.Task.x264Profile;
+ return this.deblockingStrength;
}
+
set
{
- this.Task.x264Profile = value;
- this.NotifyOfPropertyChange(() => this.X264Profile);
+ this.deblockingStrength = value;
+ this.NotifyOfPropertyChange(() => this.DeblockingStrength);
+ this.UpdateOptionsString();
}
}
/// <summary>
- /// Gets or sets X264Tune.
+ /// Gets or sets DeblockingThreshold.
/// </summary>
- public x264Tune X264Tune
+ public AdvancedChoice DeblockingThreshold
{
get
{
- return this.Task.X264Tune;
+ return this.deblockingThreshold;
}
+
set
{
- this.Task.X264Tune = value;
- this.NotifyOfPropertyChange(() => this.X264Tune);
+ this.deblockingThreshold = value;
+ this.NotifyOfPropertyChange(() => this.DeblockingThreshold);
+ this.UpdateOptionsString();
}
}
/// <summary>
- /// Gets or sets X264Presets.
+ /// Gets or sets DirectPrediction.
/// </summary>
- public IEnumerable<x264Preset> X264Presets { get; set; }
+ public AdvancedChoice DirectPrediction
+ {
+ get
+ {
+ return this.directPrediction;
+ }
+
+ set
+ {
+ this.directPrediction = value;
+ this.NotifyOfPropertyChange(() => this.DirectPrediction);
+ this.UpdateOptionsString();
+ }
+ }
/// <summary>
- /// Gets or sets X264Profiles.
+ /// Gets or sets a value indicating whether EightByEightDct.
/// </summary>
- public IEnumerable<x264Profile> X264Profiles { get; set; }
+ public bool EightByEightDct
+ {
+ get
+ {
+ return this.eightByEightDct;
+ }
+
+ set
+ {
+ this.eightByEightDct = value;
+ this.NotifyOfPropertyChange(() => this.EightByEightDct);
+ this.UpdateOptionsString();
+ }
+ }
/// <summary>
- /// Gets or sets X264Tunes.
+ /// Gets a value indicating whether EightByEightDctVisible.
/// </summary>
- public IEnumerable<x264Tune> X264Tunes { get; set; }
+ public bool EightByEightDctVisible
+ {
+ get
+ {
+ return this.Analysis.Value != "none";
+ }
+ }
/// <summary>
- /// Gets or sets a value indicating whether DisplayX264Options.
+ /// Gets or sets MotionEstimationMethod.
/// </summary>
- public bool DisplayX264Options
+ public AdvancedChoice MotionEstimationMethod
{
get
{
- return this.displayX264Options;
+ return this.motionEstimationMethod;
}
+
set
{
- this.displayX264Options = value;
- this.NotifyOfPropertyChange(() => this.DisplayX264Options);
+ this.motionEstimationMethod = value;
+ this.NotifyOfPropertyChange(() => this.MotionEstimationMethod);
+ this.NotifyOfPropertyChange(() => this.MotionEstimationRangeVisible);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets MotionEstimationRange.
+ /// </summary>
+ public AdvancedChoice MotionEstimationRange
+ {
+ get
+ {
+ return this.motionEstimationRange;
+ }
+
+ set
+ {
+ this.motionEstimationRange = value;
+ this.NotifyOfPropertyChange(() => this.MotionEstimationRange);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether MotionEstimationRangeVisible.
+ /// </summary>
+ public bool MotionEstimationRangeVisible
+ {
+ get
+ {
+ string motionMethod = this.MotionEstimationMethod.Value;
+ return motionMethod == "umh" || motionMethod == "esa" || motionMethod == "tesa";
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether NoDctDecimate.
+ /// </summary>
+ public bool NoDctDecimate
+ {
+ get
+ {
+ return this.noDctDecimate;
+ }
+
+ set
+ {
+ this.noDctDecimate = value;
+ this.NotifyOfPropertyChange(() => this.NoDctDecimate);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets PsychovisualRateDistortion.
+ /// </summary>
+ public double PsychovisualRateDistortion
+ {
+ get
+ {
+ return this.psychovisualRateDistortion;
+ }
+
+ set
+ {
+ this.psychovisualRateDistortion = value;
+ this.NotifyOfPropertyChange(() => this.PsychovisualRateDistortion);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets PsychovisualTrellis.
+ /// </summary>
+ public double PsychovisualTrellis
+ {
+ get
+ {
+ return this.psychovisualTrellis;
+ }
+
+ set
+ {
+ this.psychovisualTrellis = value;
+ this.NotifyOfPropertyChange(() => this.PsychovisualTrellis);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether PsychovisualTrellisVisible.
+ /// </summary>
+ public bool PsychovisualTrellisVisible
+ {
+ get
+ {
+ return this.CabacEntropyCoding && this.Trellis.Value != "0";
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets PyramidalBFrames.
+ /// </summary>
+ public AdvancedChoice PyramidalBFrames
+ {
+ get
+ {
+ return this.pyramidalBFrames;
+ }
+
+ set
+ {
+ this.pyramidalBFrames = value;
+ this.NotifyOfPropertyChange(() => this.PyramidalBFrames);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether PyramidalBFramesVisible.
+ /// </summary>
+ public bool PyramidalBFramesVisible
+ {
+ get
+ {
+ return int.Parse(this.BFrames.Value) > 1;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets ReferenceFrames.
+ /// </summary>
+ public AdvancedChoice ReferenceFrames
+ {
+ get
+ {
+ return this.referenceFrames;
+ }
+
+ set
+ {
+ this.referenceFrames = value;
+ this.NotifyOfPropertyChange(() => this.ReferenceFrames);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets SubpixelMotionEstimation.
+ /// </summary>
+ public AdvancedChoice SubpixelMotionEstimation
+ {
+ get
+ {
+ return this.subpixelMotionEstimation;
+ }
+
+ set
+ {
+ this.subpixelMotionEstimation = value;
+ this.NotifyOfPropertyChange(() => this.SubpixelMotionEstimation);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets Task.
+ /// </summary>
+ public EncodeTask Task { get; set; }
+
+ /// <summary>
+ /// Gets or sets Trellis.
+ /// </summary>
+ public AdvancedChoice Trellis
+ {
+ get
+ {
+ return this.trellis;
+ }
+
+ set
+ {
+ this.trellis = value;
+ this.NotifyOfPropertyChange(() => this.Trellis);
+ this.NotifyOfPropertyChange(() => this.PsychovisualTrellisVisible);
+ this.UpdateOptionsString();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether WeightedPFrames.
+ /// </summary>
+ public bool WeightedPFrames
+ {
+ get
+ {
+ return this.weightedPFrames;
+ }
+
+ set
+ {
+ this.weightedPFrames = value;
+ this.NotifyOfPropertyChange(() => this.WeightedPFrames);
+ this.UpdateOptionsString();
}
}
@@ -166,56 +635,499 @@ namespace HandBrakeWPF.ViewModels
#region Public Methods
/// <summary>
- /// Setup this window for a new source
+ /// The notify all changed.
/// </summary>
- /// <param name="title">
- /// The title.
+ public void NotifyAllChanged()
+ {
+ this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
+ }
+
+ /// <summary>
+ /// The update ui from advanced options.
+ /// </summary>
+ public void UpdateUIFromAdvancedOptions()
+ {
+ this.AutomaticChange = true;
+
+ // Reset UI to defaults, and re-apply options.
+ this.SetAdvancedToDefaults();
+
+ if (this.Task.AdvancedEncoderOptions == null)
+ {
+ this.AutomaticChange = false;
+ return;
+ }
+
+ // Check the updated options string. Update UI for any recognized options.
+ string[] newOptionsSegments = this.Task.AdvancedEncoderOptions.Split(':');
+ foreach (string newOptionsSegment in newOptionsSegments)
+ {
+ int equalsIndex = newOptionsSegment.IndexOf('=');
+ if (equalsIndex >= 0)
+ {
+ string optionName = newOptionsSegment.Substring(0, equalsIndex);
+ string optionValue = newOptionsSegment.Substring(equalsIndex + 1);
+
+ if (optionName != string.Empty && optionValue != string.Empty)
+ {
+ AdvancedChoice newChoice;
+ int parseInt;
+ double parseDouble;
+ string[] subParts;
+
+ switch (optionName)
+ {
+ case "ref":
+ if (int.TryParse(optionValue, out parseInt))
+ {
+ newChoice =
+ AdvancedChoicesHelper.ReferenceFrames.SingleOrDefault(
+ choice => choice.Value == parseInt.ToString(CultureInfo.InvariantCulture));
+ if (newChoice != null)
+ {
+ this.ReferenceFrames = newChoice;
+ }
+ }
+
+ break;
+ case "bframes":
+ if (int.TryParse(optionValue, out parseInt))
+ {
+ newChoice =
+ AdvancedChoicesHelper.BFrames.SingleOrDefault(
+ choice => choice.Value == parseInt.ToString(CultureInfo.InvariantCulture));
+ if (newChoice != null)
+ {
+ this.BFrames = newChoice;
+ }
+ }
+
+ break;
+ case "b-adapt":
+ newChoice =
+ AdvancedChoicesHelper.AdaptiveBFrames.SingleOrDefault(
+ choice => choice.Value == optionValue);
+ if (newChoice != null)
+ {
+ this.AdaptiveBFrames = newChoice;
+ }
+
+ break;
+ case "direct":
+ newChoice =
+ AdvancedChoicesHelper.DirectPrediction.SingleOrDefault(
+ choice => choice.Value == optionValue);
+ if (newChoice != null)
+ {
+ this.DirectPrediction = newChoice;
+ }
+
+ break;
+ case "weightp":
+ if (optionValue == "0")
+ {
+ this.WeightedPFrames = false;
+ }
+ else if (optionValue == "1")
+ {
+ this.WeightedPFrames = true;
+ }
+
+ break;
+ case "b-pyramid":
+ newChoice =
+ AdvancedChoicesHelper.PyramidalBFrames.SingleOrDefault(
+ choice => choice.Value == optionValue);
+ if (newChoice != null)
+ {
+ this.PyramidalBFrames = newChoice;
+ }
+
+ break;
+ case "me":
+ newChoice =
+ AdvancedChoicesHelper.MotionEstimationMethod.SingleOrDefault(
+ choice => choice.Value == optionValue);
+ if (newChoice != null)
+ {
+ this.MotionEstimationMethod = newChoice;
+ }
+
+ break;
+ case "subme":
+ case "subq":
+ if (int.TryParse(optionValue, out parseInt))
+ {
+ newChoice =
+ AdvancedChoicesHelper.SubpixelMotionEstimation.SingleOrDefault(
+ choice => choice.Value == parseInt.ToString(CultureInfo.InvariantCulture));
+ if (newChoice != null)
+ {
+ this.SubpixelMotionEstimation = newChoice;
+ }
+ }
+
+ break;
+ case "merange":
+ if (int.TryParse(optionValue, out parseInt))
+ {
+ newChoice =
+ AdvancedChoicesHelper.MotionEstimationRange.SingleOrDefault(
+ choice => choice.Value == parseInt.ToString(CultureInfo.InvariantCulture));
+ if (newChoice != null)
+ {
+ this.MotionEstimationRange = newChoice;
+ }
+ }
+
+ break;
+ case "analyse":
+ newChoice =
+ AdvancedChoicesHelper.Analysis.SingleOrDefault(
+ choice => choice.Value == optionValue);
+ if (newChoice != null)
+ {
+ this.Analysis = newChoice;
+ }
+
+ break;
+ case "8x8dct":
+ if (optionValue == "0")
+ {
+ this.EightByEightDct = false;
+ }
+ else if (optionValue == "1")
+ {
+ this.EightByEightDct = true;
+ }
+
+ break;
+ case "cabac":
+ if (optionValue == "0")
+ {
+ this.CabacEntropyCoding = false;
+ }
+ else if (optionValue == "1")
+ {
+ this.CabacEntropyCoding = true;
+ }
+
+ break;
+ case "trellis":
+ if (int.TryParse(optionValue, out parseInt))
+ {
+ newChoice =
+ AdvancedChoicesHelper.Trellis.SingleOrDefault(
+ choice => choice.Value == parseInt.ToString(CultureInfo.InvariantCulture));
+ if (newChoice != null)
+ {
+ this.Trellis = newChoice;
+ }
+ }
+
+ break;
+ case "aq-strength":
+ if (double.TryParse(optionValue, out parseDouble) && parseDouble >= 0.0 &&
+ parseDouble <= 2.0)
+ {
+ this.AdaptiveQuantizationStrength = Math.Round(parseDouble, 1);
+ }
+
+ break;
+ case "psy-rd":
+ subParts = optionValue.Split(',');
+ if (subParts.Length == 2)
+ {
+ double psyRD, psyTrellis;
+ if (double.TryParse(subParts[0], out psyRD) &&
+ double.TryParse(subParts[1], out psyTrellis))
+ {
+ if (psyRD >= 0.0 && psyRD <= 2.0 && psyTrellis >= 0.0 && psyTrellis <= 1.0)
+ {
+ this.PsychovisualRateDistortion = Math.Round(psyRD, 1);
+ this.PsychovisualTrellis = Math.Round(psyTrellis, 2);
+ }
+ }
+ }
+
+ break;
+ case "no-dct-decimate":
+ if (optionValue == "0")
+ {
+ this.NoDctDecimate = false;
+ }
+ else if (optionValue == "1")
+ {
+ this.NoDctDecimate = true;
+ }
+
+ break;
+ case "deblock":
+ subParts = optionValue.Split(',');
+ if (subParts.Length == 2)
+ {
+ int dbStrength, dbThreshold;
+ if (int.TryParse(subParts[0], out dbStrength) &&
+ int.TryParse(subParts[1], out dbThreshold))
+ {
+ newChoice =
+ AdvancedChoicesHelper.DeblockingStrength.SingleOrDefault(
+ choice => choice.Value == subParts[0]);
+ if (newChoice != null)
+ {
+ this.DeblockingStrength = newChoice;
+ }
+
+ newChoice =
+ AdvancedChoicesHelper.DeblockingThreshold.SingleOrDefault(
+ choice => choice.Value == subParts[1]);
+ if (newChoice != null)
+ {
+ this.DeblockingThreshold = newChoice;
+ }
+ }
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ this.AutomaticChange = false;
+ }
+
+ #endregion
+
+ #region Implemented Interfaces
+
+ #region IAdvancedViewModel
+
+ /// <summary>
+ /// The set encoder.
+ /// </summary>
+ /// <param name="encoder">
+ /// The encoder.
/// </param>
+ public void SetEncoder(VideoEncoder encoder)
+ {
+ this.DisplayX264Options = encoder == VideoEncoder.X264;
+ if (encoder == VideoEncoder.Theora)
+ {
+ this.DisplayX264Options = null;
+ }
+ }
+
+ #endregion
+
+ #region ITabInterface
+
+ /// <summary>
+ /// Setup this tab for the specified preset.
+ /// </summary>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
- public void SetSource(Title title, Preset preset, EncodeTask task)
+ public void SetPreset(Preset preset, EncodeTask task)
{
this.Task = task;
- this.NotifyOfPropertyChange(() => this.Task);
+ this.AdvancedOptionsString = preset.Task.AdvancedEncoderOptions;
}
/// <summary>
- /// Setup this tab for the specified preset.
+ /// Setup this window for a new source
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
- public void SetPreset(Preset preset, EncodeTask task)
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
this.Task = task;
- this.NotifyOfPropertyChange(() => this.Task);
- if (preset != null && preset.Task != null)
- {
- this.Query = preset.Task.AdvancedEncoderOptions;
- this.SetEncoder(preset.Task.VideoEncoder);
+ this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
+ }
- this.X264Preset = preset.Task.x264Preset;
- this.X264Profile = preset.Task.x264Profile;
- this.X264Tune = preset.Task.X264Tune;
- }
+ #endregion
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// The set advanced to defaults.
+ /// </summary>
+ private void SetAdvancedToDefaults()
+ {
+ this.ReferenceFrames = AdvancedChoicesHelper.ReferenceFrames.SingleOrDefault(choice => choice.IsDefault);
+ this.BFrames = AdvancedChoicesHelper.BFrames.SingleOrDefault(choice => choice.IsDefault);
+ this.AdaptiveBFrames = AdvancedChoicesHelper.AdaptiveBFrames.SingleOrDefault(choice => choice.IsDefault);
+ this.DirectPrediction = AdvancedChoicesHelper.DirectPrediction.SingleOrDefault(choice => choice.IsDefault);
+ this.WeightedPFrames = true;
+ this.PyramidalBFrames = AdvancedChoicesHelper.PyramidalBFrames.SingleOrDefault(choice => choice.IsDefault);
+ this.MotionEstimationMethod =
+ AdvancedChoicesHelper.MotionEstimationMethod.SingleOrDefault(choice => choice.IsDefault);
+ this.SubpixelMotionEstimation =
+ AdvancedChoicesHelper.SubpixelMotionEstimation.SingleOrDefault(choice => choice.IsDefault);
+ this.MotionEstimationRange =
+ AdvancedChoicesHelper.MotionEstimationRange.SingleOrDefault(choice => choice.IsDefault);
+ this.Analysis = AdvancedChoicesHelper.Analysis.SingleOrDefault(choice => choice.IsDefault);
+ this.EightByEightDct = true;
+ this.CabacEntropyCoding = true;
+ this.Trellis = AdvancedChoicesHelper.Trellis.SingleOrDefault(choice => choice.IsDefault);
+ this.AdaptiveQuantizationStrength = 1.0;
+ this.PsychovisualRateDistortion = 1.0;
+ this.PsychovisualTrellis = 0.0;
+ this.DeblockingStrength =
+ AdvancedChoicesHelper.DeblockingStrength.SingleOrDefault(choice => choice.IsDefault);
+ this.DeblockingThreshold =
+ AdvancedChoicesHelper.DeblockingThreshold.SingleOrDefault(choice => choice.IsDefault);
+ this.NoDctDecimate = false;
}
/// <summary>
- /// Set the currently selected encoder.
+ /// Update the x264 options string from a UI change.
/// </summary>
- /// <param name="encoder">
- /// The Video Encoder.
- /// </param>
- public void SetEncoder(VideoEncoder encoder)
+ private void UpdateOptionsString()
{
- this.DisplayX264Options = encoder == VideoEncoder.X264;
+ if (this.AutomaticChange)
+ {
+ return;
+ }
+
+ List<string> newOptions = new List<string>();
+
+ // First add any parts of the options string that don't correspond to the UI
+ if (this.AdvancedOptionsString != null)
+ {
+ string[] existingSegments = this.AdvancedOptionsString.Split(':');
+ foreach (string existingSegment in existingSegments)
+ {
+ string optionName = existingSegment;
+ int equalsIndex = existingSegment.IndexOf('=');
+ if (equalsIndex >= 0)
+ {
+ optionName = existingSegment.Substring(0, existingSegment.IndexOf("="));
+ }
+
+ if (!this.uiOptions.Contains(optionName) && optionName != string.Empty)
+ {
+ newOptions.Add(existingSegment);
+ }
+ }
+ }
+
+ // Now add everything from the UI
+ if (!this.ReferenceFrames.IsDefault)
+ {
+ newOptions.Add("ref=" + this.ReferenceFrames.Value);
+ }
+
+ if (!this.BFrames.IsDefault)
+ {
+ newOptions.Add("bframes=" + this.BFrames.Value);
+ }
+
+ if (this.BFrames.Value != "0")
+ {
+ if (!this.AdaptiveBFrames.IsDefault)
+ {
+ newOptions.Add("b-adapt=" + this.AdaptiveBFrames.Value);
+ }
+
+ if (!this.DirectPrediction.IsDefault)
+ {
+ newOptions.Add("direct=" + this.DirectPrediction.Value);
+ }
+
+ if (this.BFrames.Value != "1" && !this.PyramidalBFrames.IsDefault)
+ {
+ newOptions.Add("b-pyramid=" + this.PyramidalBFrames.Value);
+ }
+ }
+
+ if (!this.WeightedPFrames)
+ {
+ newOptions.Add("weightp=0");
+ }
+
+ if (!this.MotionEstimationMethod.IsDefault)
+ {
+ newOptions.Add("me=" + this.MotionEstimationMethod.Value);
+ }
+
+ if (!this.SubpixelMotionEstimation.IsDefault)
+ {
+ newOptions.Add("subme=" + this.SubpixelMotionEstimation.Value);
+ }
+
+ string motionEstimation = this.MotionEstimationMethod.Value;
+ if ((motionEstimation == "umh" || motionEstimation == "esa" || motionEstimation == "tesa") &&
+ !this.MotionEstimationRange.IsDefault)
+ {
+ newOptions.Add("merange=" + this.MotionEstimationRange.Value);
+ }
+
+ if (!this.Analysis.IsDefault)
+ {
+ newOptions.Add("analyse=" + this.Analysis.Value);
+ }
+
+ if (this.Analysis.Value != "none" && !this.EightByEightDct)
+ {
+ newOptions.Add("8x8dct=0");
+ }
+
+ if (!this.CabacEntropyCoding)
+ {
+ newOptions.Add("cabac=0");
+ }
+
+ if (!this.Trellis.IsDefault)
+ {
+ newOptions.Add("trellis=" + this.Trellis.Value);
+ }
+
+ double psTrellis = 0.0;
+ if (this.CabacEntropyCoding && this.Trellis.Value != "0")
+ {
+ psTrellis = this.PsychovisualTrellis;
+ }
+
+ if (this.AdaptiveQuantizationStrength != 1.0)
+ {
+ newOptions.Add(
+ "aq-strength=" + this.AdaptiveQuantizationStrength.ToString("F1", CultureInfo.InvariantCulture));
+ }
+
+ if (this.PsychovisualRateDistortion != 1.0 || psTrellis > 0.0)
+ {
+ newOptions.Add(
+ "psy-rd=" + this.PsychovisualRateDistortion.ToString("F1", CultureInfo.InvariantCulture) + "," +
+ psTrellis.ToString("F2", CultureInfo.InvariantCulture));
+ }
+
+ if (this.NoDctDecimate)
+ {
+ newOptions.Add("no-dct-decimate=1");
+ }
+
+ if (!this.DeblockingStrength.IsDefault || !this.DeblockingThreshold.IsDefault)
+ {
+ newOptions.Add("deblock=" + this.DeblockingStrength.Value + "," + this.DeblockingThreshold.Value);
+ }
+
+ this.Task.AdvancedEncoderOptions = string.Join(":", newOptions);
+ this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
#endregion
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
index 6a2e64ac8..634068142 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
@@ -224,6 +224,7 @@ namespace HandBrakeWPF.ViewModels
public void SetPreset(Preset preset, EncodeTask task)
{
this.Task = task;
+ this.Task.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
this.NotifyOfPropertyChange(() => this.Task);
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index 3be51ec05..a67bc293e 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -227,6 +227,7 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public void SetPreset(Preset preset, EncodeTask task)
{
+ // Note, We don't support Subtitles in presets yet.
this.Task = task;
this.NotifyOfPropertyChange(() => this.Task);
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index 358ebcbf5..7f7520dc4 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -22,6 +22,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.Model.Encoding.x264;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -38,6 +39,11 @@ namespace HandBrakeWPF.ViewModels
private IUserSettingService userSettingService;
/// <summary>
+ /// Backing field used to display / hide the x264 options
+ /// </summary>
+ private bool displayX264Options;
+
+ /// <summary>
/// The quality max.
/// </summary>
private int qualityMax;
@@ -78,6 +84,10 @@ namespace HandBrakeWPF.ViewModels
this.QualityMax = 51;
this.IsConstantQuantity = true;
this.VideoEncoders = EnumHelper<VideoEncoder>.GetEnumList();
+
+ //X264Presets = EnumHelper<x264Preset>.GetEnumList();
+ //X264Profiles = EnumHelper<x264Profile>.GetEnumList();
+ //X264Tunes = EnumHelper<x264Tune>.GetEnumList();
}
#endregion
@@ -432,8 +442,127 @@ namespace HandBrakeWPF.ViewModels
this.Task.VideoBitrate = preset.Task.VideoBitrate;
this.NotifyOfPropertyChange(() => this.Task);
+
+ //if (preset != null && preset.Task != null)
+ //{
+ // this.Query = preset.Task.AdvancedEncoderOptions;
+ // this.SetEncoder(preset.Task.VideoEncoder);
+
+ // this.X264Preset = preset.Task.x264Preset;
+ // this.X264Profile = preset.Task.x264Profile;
+ // this.X264Tune = preset.Task.X264Tune;
+ //}
+
}
+ /// <summary>
+ /// Set the currently selected encoder.
+ /// </summary>
+ /// <param name="encoder">
+ /// The Video Encoder.
+ /// </param>
+ public void SetEncoder(VideoEncoder encoder)
+ {
+ //this.DisplayX264Options = encoder == VideoEncoder.X264;
+ }
+
+ #endregion
+
+ #region Advanced
+ ///// <summary>
+ ///// Gets or sets State.
+ ///// </summary>
+ //public string Query
+ //{
+ // get
+ // {
+ // return this.Task.AdvancedEncoderOptions;
+ // }
+ // set
+ // {
+ // this.Task.AdvancedEncoderOptions = value;
+ // this.NotifyOfPropertyChange(() => this.Query);
+ // }
+ //}
+
+ ///// <summary>
+ ///// Gets or sets X264Preset.
+ ///// </summary>
+ //public x264Preset X264Preset
+ //{
+ // get
+ // {
+ // return this.Task.x264Preset;
+ // }
+ // set
+ // {
+ // this.Task.x264Preset = value;
+ // this.NotifyOfPropertyChange(() => this.X264Preset);
+ // }
+ //}
+
+ ///// <summary>
+ ///// Gets or sets X264Profile.
+ ///// </summary>
+ //public x264Profile X264Profile
+ //{
+ // get
+ // {
+ // return this.Task.x264Profile;
+ // }
+ // set
+ // {
+ // this.Task.x264Profile = value;
+ // this.NotifyOfPropertyChange(() => this.X264Profile);
+ // }
+ //}
+
+ ///// <summary>
+ ///// Gets or sets X264Tune.
+ ///// </summary>
+ //public x264Tune X264Tune
+ //{
+ // get
+ // {
+ // return this.Task.X264Tune;
+ // }
+ // set
+ // {
+ // this.Task.X264Tune = value;
+ // this.NotifyOfPropertyChange(() => this.X264Tune);
+ // }
+ //}
+
+ ///// <summary>
+ ///// Gets or sets X264Presets.
+ ///// </summary>
+ //public IEnumerable<x264Preset> X264Presets { get; set; }
+
+ ///// <summary>
+ ///// Gets or sets X264Profiles.
+ ///// </summary>
+ //public IEnumerable<x264Profile> X264Profiles { get; set; }
+
+ ///// <summary>
+ ///// Gets or sets X264Tunes.
+ ///// </summary>
+ //public IEnumerable<x264Tune> X264Tunes { get; set; }
+
+ ///// <summary>
+ ///// Gets or sets a value indicating whether DisplayX264Options.
+ ///// </summary>
+ //public bool DisplayX264Options
+ //{
+ // get
+ // {
+ // return this.displayX264Options;
+ // }
+ // set
+ // {
+ // this.displayX264Options = value;
+ // this.NotifyOfPropertyChange(() => this.DisplayX264Options);
+ // }
+ //}
#endregion
}
} \ No newline at end of file