diff options
author | sr55 <[email protected]> | 2011-02-05 21:37:49 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-02-05 21:37:49 +0000 |
commit | c315f3cf228d84ab67c75c7f8fa7221379e88600 (patch) | |
tree | d52ef3b6b3aeb67a3628ef05fb6e318d90537641 /win | |
parent | 07bbd251a183b251d668ea44de1cc122221c7bd5 (diff) |
WinGui:
- Another round of refactoring. Query Parsing and Plist handling code moved to application services utilities namespace.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3781 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Functions/Converters.cs | 103 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj | 3 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs | 65 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Model/Encoding/Cropping.cs | 53 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Model/Encoding/Deinterlace.cs | 1 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Model/Encoding/FramerateMode.cs | 17 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeRateMode.cs (renamed from win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeMode.cs) | 4 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Services/LibScan.cs | 22 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs | 231 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs | 519 |
10 files changed, 488 insertions, 530 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs b/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs index e1a4069f3..1dd817e23 100644 --- a/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs +++ b/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs @@ -8,11 +8,19 @@ namespace HandBrake.ApplicationServices.Functions using System;
using System.Text.RegularExpressions;
+ using HandBrake.ApplicationServices.Model.Encoding;
+
/// <summary>
/// A class to convert various things to native C# objects
/// </summary>
public class Converters
{
+ /**
+ * TODO:
+ * - Many of these converters can be ditched at a later point. Should be able to model all this within the enums themsevles.
+ *
+ **/
+
/// <summary>
/// Convert HandBrakes time remaining into a TimeSpan
/// </summary>
@@ -64,7 +72,7 @@ namespace HandBrake.ApplicationServices.Functions /// </summary>
/// <param name="audioEnc">The Audio Encoder</param>
/// <returns>The GUI representation of that audio encoder</returns>
- public static string GetAudioEncoder(string audioEnc)
+ public static string GetGUIAudioEncoder(string audioEnc)
{
switch (audioEnc)
{
@@ -84,5 +92,98 @@ namespace HandBrake.ApplicationServices.Functions return "AAC (faac)";
}
}
+
+ /// <summary>
+ /// Get the Video Encoder for a given string
+ /// </summary>
+ /// <param name="encoder">
+ /// The encoder name
+ /// </param>
+ /// <returns>
+ /// VideoEncoder enum object
+ /// </returns>
+ public static VideoEncoder GetVideoEncoder(string encoder)
+ {
+ switch (encoder)
+ {
+ case "ffmpeg":
+ return VideoEncoder.FFMpeg;
+ case "x264":
+ return VideoEncoder.X264;
+ case "theora":
+ return VideoEncoder.Theora;
+ default:
+ return VideoEncoder.X264;
+ }
+ }
+
+ /// <summary>
+ /// Get a GUI name for a given video Encoder.
+ /// </summary>
+ /// <param name="encoder">
+ /// A VideoEncoder Enum object
+ /// </param>
+ /// <returns>
+ /// A GUI encoder name, default is x264
+ /// </returns>
+ public static string GetGUIVideoEncoder(VideoEncoder encoder)
+ {
+ switch (encoder)
+ {
+ case VideoEncoder.FFMpeg:
+ return "MPEG-4 (FFmpeg)";
+ case VideoEncoder.X264:
+ return "H.264 (x264)";
+ case VideoEncoder.Theora:
+ return "VP3 (Theora)";
+ default:
+ return "H.264 (x264)";
+ }
+ }
+
+
+ /// <summary>
+ /// Get the OutputFormat Enum for a given string
+ /// </summary>
+ /// <param name="format">
+ /// OutputFormat as a string
+ /// </param>
+ /// <returns>
+ /// An OutputFormat Enum
+ /// </returns>
+ public static OutputFormat GetFileFormat(string format)
+ {
+ switch (format.ToLower())
+ {
+ default:
+ return OutputFormat.Mp4;
+ case "m4v":
+ return OutputFormat.M4V;
+ case "mkv":
+ return OutputFormat.Mkv;
+ }
+ }
+
+ /// <summary>
+ /// Get the OutputFormat Enum for a given string
+ /// </summary>
+ /// <param name="format">
+ /// OutputFormat as a string
+ /// </param>
+ /// <returns>
+ /// An OutputFormat Enum
+ /// </returns>
+ public static string GetFileFormat(OutputFormat format)
+ {
+ switch (format)
+ {
+ default:
+ return "mp4";
+ case OutputFormat.M4V:
+ return "m4v";
+ case OutputFormat.Mkv:
+ return "mkv";
+ }
+ }
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index c338ed021..db3cd55ad 100644 --- a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -100,6 +100,7 @@ <Compile Include="Model\Encoding\AudioTrack.cs" />
<Compile Include="Model\Encoding\Anamorphic.cs" />
<Compile Include="Model\Encoding\AudioEncoder.cs" />
+ <Compile Include="Model\Encoding\FramerateMode.cs" />
<Compile Include="Model\Encoding\Mixdown.cs" />
<Compile Include="Model\Encoding\PointToPointMode.cs" />
<Compile Include="Model\Encoding\Cropping.cs" />
@@ -111,7 +112,7 @@ <Compile Include="Model\Encoding\OutputFormat.cs" />
<Compile Include="Model\Encoding\SubtitleTrack.cs" />
<Compile Include="Model\Encoding\VideoEncoder.cs" />
- <Compile Include="Model\Encoding\VideoEncodeMode.cs" />
+ <Compile Include="Model\Encoding\VideoEncodeRateMode.cs" />
<Compile Include="Model\Preset.cs" />
<Compile Include="Model\QueueTask.cs" />
<Compile Include="Model\Encoding\SubtitleType.cs" />
diff --git a/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs index a735902c1..8b561f496 100644 --- a/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -19,6 +19,7 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public EncodeTask()
{
+ this.Cropping = new Cropping();
}
#region Source
@@ -124,7 +125,7 @@ namespace HandBrake.ApplicationServices.Model /// <summary>
/// Gets or sets DisplayWidth.
/// </summary>
- public int DisplayWidth { get; set; }
+ public double DisplayWidth { get; set; }
/// <summary>
/// Gets or sets a value indicating whether KeepDisplayAspect.
@@ -205,22 +206,32 @@ namespace HandBrake.ApplicationServices.Model /// <summary>
/// Gets or sets VideoEncodeRateType.
/// </summary>
- public VideoEncodeMode VideoEncodeRateType { get; set; }
+ public VideoEncodeRateMode VideoEncodeRateType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VideoEncoder
+ /// </summary>
+ public VideoEncoder VideoEncoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Video Encode Mode
+ /// </summary>
+ public FramerateMode FramerateMode { get; set; }
/// <summary>
/// Gets or sets Quality.
/// </summary>
- public double Quality { get; set; }
+ public double? Quality { get; set; }
/// <summary>
/// Gets or sets TargetSize.
/// </summary>
- public int TargetSize { get; set; }
+ public int? TargetSize { get; set; }
/// <summary>
/// Gets or sets VideoBitrate.
/// </summary>
- public int VideoBitrate { get; set; }
+ public int? VideoBitrate { get; set; }
/// <summary>
/// Gets or sets a value indicating whether TwoPass.
@@ -238,11 +249,6 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public double? Framerate { get; set; }
- /// <summary>
- /// Gets or sets a value indicating whether PeakFramerate.
- /// </summary>
- public bool PeakFramerate { get; set; }
-
#endregion
#region Audio
@@ -281,6 +287,45 @@ namespace HandBrake.ApplicationServices.Model /// Gets or sets X264Options.
/// </summary>
public string X264Options { get; set; }
+
+ #endregion
+
+ #region Preset Information (TODO This should probably be dropped)
+
+ /// <summary>
+ /// Gets or sets PresetBuildNumber.
+ /// </summary>
+ public int PresetBuildNumber { get; set; }
+
+ /// <summary>
+ /// Gets or sets PresetDescription.
+ /// </summary>
+ public string PresetDescription { get; set; }
+
+ /// <summary>
+ /// Gets or sets PresetName.
+ /// </summary>
+ public string PresetName { get; set; }
+
+ /// <summary>
+ /// Gets or sets Type.
+ /// </summary>
+ public string Type { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether UsesMaxPictureSettings.
+ /// </summary>
+ public bool UsesMaxPictureSettings { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether UsesPictureFilters.
+ /// </summary>
+ public bool UsesPictureFilters { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether UsesPictureSettings.
+ /// </summary>
+ public bool UsesPictureSettings { get; set; }
#endregion
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Encoding/Cropping.cs b/win/C#/HandBrake.ApplicationServices/Model/Encoding/Cropping.cs index 81d665ed4..2ec98aaca 100644 --- a/win/C#/HandBrake.ApplicationServices/Model/Encoding/Cropping.cs +++ b/win/C#/HandBrake.ApplicationServices/Model/Encoding/Cropping.cs @@ -11,6 +11,36 @@ namespace HandBrake.ApplicationServices.Model.Encoding public class Cropping
{
/// <summary>
+ /// Initializes a new instance of the <see cref="Cropping"/> class.
+ /// </summary>
+ public Cropping()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Cropping"/> class.
+ /// </summary>
+ /// <param name="top">
+ /// The Top Value
+ /// </param>
+ /// <param name="bottom">
+ /// The Bottom Value
+ /// </param>
+ /// <param name="left">
+ /// The Left Value
+ /// </param>
+ /// <param name="right">
+ /// The Right Value
+ /// </param>
+ public Cropping(int top, int bottom, int left, int right)
+ {
+ this.Top = top;
+ this.Bottom = bottom;
+ this.Left = left;
+ this.Right = right;
+ }
+
+ /// <summary>
/// Gets or sets Top.
/// </summary>
public int Top { get; set; }
@@ -29,28 +59,5 @@ namespace HandBrake.ApplicationServices.Model.Encoding /// Gets or sets Right.
/// </summary>
public int Right { get; set; }
-
- /// <summary>
- /// Create a cropping object
- /// </summary>
- /// <param name="top">
- /// The top.
- /// </param>
- /// <param name="bottom">
- /// The bottom.
- /// </param>
- /// <param name="left">
- /// The left.
- /// </param>
- /// <param name="right">
- /// The right.
- /// </param>
- /// <returns>
- /// A Cropping object
- /// </returns>
- public static Cropping CreateCroppingObject(int top, int bottom, int left, int right)
- {
- return new Cropping { Top = top, Bottom = bottom, Left = left, Right = right };
- }
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Encoding/Deinterlace.cs b/win/C#/HandBrake.ApplicationServices/Model/Encoding/Deinterlace.cs index 154428987..38dadd04e 100644 --- a/win/C#/HandBrake.ApplicationServices/Model/Encoding/Deinterlace.cs +++ b/win/C#/HandBrake.ApplicationServices/Model/Encoding/Deinterlace.cs @@ -14,6 +14,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding Fast,
Slow,
Slower,
+ Slowest,
Custom
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Encoding/FramerateMode.cs b/win/C#/HandBrake.ApplicationServices/Model/Encoding/FramerateMode.cs new file mode 100644 index 000000000..508e63ced --- /dev/null +++ b/win/C#/HandBrake.ApplicationServices/Model/Encoding/FramerateMode.cs @@ -0,0 +1,17 @@ +/* VideoEncoderMode.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrake.ApplicationServices.Model.Encoding
+{
+ /// <summary>
+ /// The Mode of Video Encoding. CFR, VFR, PFR
+ /// </summary>
+ public enum FramerateMode
+ {
+ CFR = 0,
+ PFR,
+ VFR
+ }
+}
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeMode.cs b/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeRateMode.cs index cf42f3ca6..636d7829d 100644 --- a/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeMode.cs +++ b/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeRateMode.cs @@ -1,4 +1,4 @@ -/* VideoEncoderMode.cs $
+/* VideoEncoderRateMode.cs $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
@@ -8,7 +8,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding /// <summary>
/// The Mode of Video Encoding. Bitrate, Filesize or Quality
/// </summary>
- public enum VideoEncodeMode
+ public enum VideoEncodeRateMode
{
TargetSize = 0,
AverageBitrate,
diff --git a/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs b/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs index ea27ffdf0..6f200e447 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs @@ -261,18 +261,18 @@ namespace HandBrake.ApplicationServices.Services {
Title converted = new Title
{
- TitleNumber = title.TitleNumber,
- Duration = title.Duration,
- Resolution = new Size(title.Resolution.Width, title.Resolution.Height),
- AspectRatio = title.AspectRatio,
- AngleCount = title.AngleCount,
- ParVal = new Size(title.ParVal.Width, title.ParVal.Height),
+ TitleNumber = title.TitleNumber,
+ Duration = title.Duration,
+ Resolution = new Size(title.Resolution.Width, title.Resolution.Height),
+ AspectRatio = title.AspectRatio,
+ AngleCount = title.AngleCount,
+ ParVal = new Size(title.ParVal.Width, title.ParVal.Height),
AutoCropDimensions =
- Cropping.CreateCroppingObject(
- title.AutoCropDimensions.Top,
- title.AutoCropDimensions.Bottom,
- title.AutoCropDimensions.Left,
- title.AutoCropDimensions.Right),
+ new Cropping(
+ title.AutoCropDimensions.Top,
+ title.AutoCropDimensions.Bottom,
+ title.AutoCropDimensions.Left,
+ title.AutoCropDimensions.Right),
Fps = title.Framerate
};
diff --git a/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index c3dacb6d4..fc44b95d4 100644 --- a/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -6,12 +6,13 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System;
- using System.Collections;
+ using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
+ using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
@@ -24,23 +25,23 @@ namespace HandBrake.ApplicationServices.Utilities * TODO:
* - Update with the new vfr,pfr,cfr keys
* - Clean up this code, it's pretty nasty right now.
- **/
+ **/
#region Import
- public static QueryParserUtility Import(string filename)
+ public static EncodeTask Import(string filename)
{
XmlNode root = loadFile(filename);
if (root == null) return null;
// We'll query a query parser object and use it's public var structures to store all the data.
// This will allow the preset loader logic to be used instead of writing custom logic just for this file.
- QueryParserUtility queryParsed = new QueryParserUtility();
+ EncodeTask parsed = new EncodeTask();
string qualityMode = string.Empty;
#region Get a List of Audio Track Objects
XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[1];
- ArrayList audioTracks = new ArrayList();
+ List<AudioTrack> audioTracks = new List<AudioTrack>();
for (int i = 0; i < audioListDict.ChildNodes.Count; i++)
{
@@ -75,7 +76,7 @@ namespace HandBrake.ApplicationServices.Utilities }
}
audioTracks.Add(track);
- queryParsed.AudioInformation = audioTracks;
+ parsed.AudioTracks = audioTracks;
}
#endregion
@@ -93,16 +94,16 @@ namespace HandBrake.ApplicationServices.Utilities {
// Output Settings
case "FileFormat":
- queryParsed.Format = value;
+ parsed.OutputFormat = Converters.GetFileFormat(value);
break;
case "Mp4HttpOptimize":
- queryParsed.OptimizeMP4 = value == "1";
+ parsed.OptimizeMP4 = value == "1";
break;
case "Mp4LargeFile":
- queryParsed.LargeMP4 = value == "1";
+ parsed.IPod5GSupport = value == "1";
break;
case "Mp4iPodCompatible":
- queryParsed.IpodAtom = value == "1";
+ parsed.IPod5GSupport = value == "1";
break;
// Picture Settings
@@ -110,42 +111,58 @@ namespace HandBrake.ApplicationServices.Utilities // Not used
break;
case "PictureTopCrop":
- queryParsed.CropTop = value;
+ parsed.Cropping.Top = int.Parse(value);
break;
case "PictureBottomCrop":
- queryParsed.CropBottom = value;
+ parsed.Cropping.Bottom = int.Parse(value);
break;
case "PictureLeftCrop":
- queryParsed.CropLeft = value;
+ parsed.Cropping.Left = int.Parse(value);
break;
case "PictureRightCrop":
- queryParsed.CropRight = value;
+ parsed.Cropping.Right = int.Parse(value);
break;
case "PictureHeight":
- queryParsed.Height = int.Parse(value);
+ parsed.Height = int.Parse(value);
break;
case "PictureWidth":
- queryParsed.Width = int.Parse(value);
+ parsed.Width = int.Parse(value);
break;
case "PictureKeepRatio":
- queryParsed.KeepDisplayAsect = value == "1";
+ parsed.KeepDisplayAspect = value == "1";
break;
case "PicturePAR":
- queryParsed.AnamorphicMode = int.Parse(value);
+ switch (value)
+ {
+
+ case "0":
+ parsed.Anamorphic = Anamorphic.None;
+ break;
+ default:
+ parsed.Anamorphic = Anamorphic.Strict;
+ break;
+ case "2":
+ parsed.Anamorphic = Anamorphic.Loose;
+ break;
+ case "3":
+ parsed.Anamorphic = Anamorphic.Custom;
+ break;
+
+ }
break;
// Filters
case "PictureDeblock":
- queryParsed.DeBlock = int.Parse(value);
+ parsed.Deblock = int.Parse(value);
break;
case "PictureDecomb":
- queryParsed.Decomb = "Off";
+ parsed.Decomb = Decomb.Off;
// Don't place custom here as it's handled in the filter panel
- if (value == "2") queryParsed.Decomb = "Default";
+ if (value == "2") parsed.Decomb = Decomb.Default;
break;
case "PictureDecombCustom":
if (value != string.Empty)
- queryParsed.Decomb = value;
+ parsed.CustomDecomb = value;
break;
case "PictureDecombDeinterlace":
// Not Used
@@ -154,116 +171,116 @@ namespace HandBrake.ApplicationServices.Utilities switch (value)
{
case "0":
- queryParsed.DeInterlace = "Off";
+ parsed.Deinterlace = Deinterlace.Off;
break;
// Don't place custom here as it's handled in the filter panel
case "2":
- queryParsed.DeInterlace = "Fast";
+ parsed.Deinterlace = Deinterlace.Fast;
break;
case "3":
- queryParsed.DeInterlace = "Slow";
+ parsed.Deinterlace = Deinterlace.Slow;
break;
case "4":
- queryParsed.DeInterlace = "Slowest";
+ parsed.Deinterlace = Deinterlace.Slower;
break;
}
break;
case "PictureDeinterlaceCustom":
if (value != string.Empty)
- queryParsed.DeInterlace = value;
+ parsed.CustomDeinterlace = value;
break;
case "PictureDenoise":
switch (value)
{
case "0":
- queryParsed.DeNoise = "Off";
+ parsed.Denoise = Denoise.Off;
break;
// Don't place custom here as it's handled in the filter panel
case "2":
- queryParsed.DeNoise = "Weak";
+ parsed.Denoise = Denoise.Weak;
break;
case "3":
- queryParsed.DeNoise = "Medium";
+ parsed.Denoise = Denoise.Medium;
break;
case "4":
- queryParsed.DeNoise = "Strong";
+ parsed.Denoise = Denoise.Strong;
break;
}
break;
case "PictureDenoiseCustom":
if (value != string.Empty)
- queryParsed.DeNoise = value;
+ parsed.CustomDenoise = value;
break;
case "PictureDetelecine":
- queryParsed.DeTelecine = "Off";
- if (value == "1") queryParsed.DeTelecine = "Default";
+ parsed.Detelecine = Detelecine.Off;
+ if (value == "1") parsed.Detelecine = Detelecine.Default;
break;
case "PictureDetelecineCustom":
if (value != string.Empty)
- queryParsed.DeTelecine = value;
+ parsed.CustomDetelecine = value;
break;
// Video Tab
case "VideoAvgBitrate":
- queryParsed.AverageVideoBitrate = value;
+ parsed.VideoBitrate = int.Parse(value);
break;
case "VideoEncoder":
- queryParsed.VideoEncoder = value;
+ parsed.VideoEncoder = Converters.GetVideoEncoder(value);
break;
case "VideoFramerate":
- queryParsed.VideoFramerate = value;
+ parsed.Framerate = int.Parse(value);
break;
case "VideoGrayScale":
- queryParsed.Grayscale = value == "1";
+ parsed.Grayscale = value == "1";
break;
case "VideoQualitySlider":
- queryParsed.VideoQuality = float.Parse(value);
+ parsed.Quality = double.Parse(value);
break;
case "VideoQualityType": // The Type of Quality Mode used
qualityMode = value;
break;
case "VideoTargetSize":
- queryParsed.VideoTargetSize = value;
+ parsed.TargetSize = int.Parse(value);
break;
case "VideoTurboTwoPass":
- queryParsed.TurboFirstPass = value == "1";
+ parsed.TurboFirstPass = value == "1";
break;
case "VideoTwoPass":
- queryParsed.TwoPass = value == "1";
+ parsed.TwoPass = value == "1";
break;
// Chapter Markers Tab
case "ChapterMarkers":
- queryParsed.ChapterMarkers = value == "1";
+ parsed.IncludeChapterMarkers = value == "1";
break;
// Advanced x264 tab
case "x264Option":
- queryParsed.H264Query = value;
+ parsed.X264Options = value;
break;
// Preset Information
case "PresetBuildNumber":
- queryParsed.PresetBuildNumber = int.Parse(value);
+ parsed.PresetBuildNumber = int.Parse(value);
break;
case "PresetDescription":
- queryParsed.PresetDescription = value;
+ parsed.PresetDescription = value;
break;
case "PresetName":
- queryParsed.PresetName = value;
+ parsed.PresetName = value;
break;
case "Type":
- queryParsed.Type = value;
+ parsed.Type = value;
break;
case "UsesMaxPictureSettings":
- queryParsed.UsesMaxPictureSettings = value == "1";
+ parsed.UsesMaxPictureSettings = value == "1";
break;
case "UsesPictureFilters":
- queryParsed.UsesPictureFilters = value == "1";
+ parsed.UsesPictureFilters = value == "1";
break;
case "UsesPictureSettings":
- queryParsed.UsesPictureSettings = value == "1";
+ parsed.UsesPictureSettings = value == "1";
break;
}
}
@@ -272,21 +289,21 @@ namespace HandBrake.ApplicationServices.Utilities switch (qualityMode)
{
case "0": // FileSize
- queryParsed.VideoQuality = -1;
- queryParsed.AverageVideoBitrate = null;
+ parsed.Quality = null;
+ parsed.VideoBitrate = null;
break;
case "1": // Avg Bitrate
- queryParsed.VideoQuality = -1;
- queryParsed.VideoTargetSize = null;
+ parsed.Quality = null;
+ parsed.TargetSize = null;
break;
case "2": // CQ
- queryParsed.AverageVideoBitrate = null;
- queryParsed.VideoTargetSize = null;
+ parsed.VideoBitrate = null;
+ parsed.TargetSize = null;
break;
}
#endregion
- return queryParsed;
+ return parsed;
}
private static XmlNode loadFile(string filename)
@@ -343,7 +360,7 @@ namespace HandBrake.ApplicationServices.Utilities /// </param>
public static void Export(string path, Preset preset)
{
- QueryParserUtility parsed = QueryParserUtility.Parse(preset.Query);
+ EncodeTask parsed = QueryParserUtility.Parse(preset.Query);
XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented };
// Header
@@ -379,7 +396,7 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="preset">
/// The preset.
/// </param>
- private static void WritePreset(XmlTextWriter xmlWriter, QueryParserUtility parsed, Preset preset)
+ private static void WritePreset(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset)
{
xmlWriter.WriteStartElement("dict");
AudioListArrayDict(xmlWriter, parsed);
@@ -400,93 +417,93 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="preset">
/// The preset.
/// </param>
- private static void AddEncodeSettings(XmlTextWriter xmlWriter, QueryParserUtility parsed, Preset preset)
+ private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset)
{
- AddEncodeElement(xmlWriter, "ChapterMarkers", "integer", parsed.ChapterMarkers ? "1" : "0");
+ AddEncodeElement(xmlWriter, "ChapterMarkers", "integer", parsed.IncludeChapterMarkers ? "1" : "0");
AddEncodeElement(xmlWriter, "Default", "integer", "0");
- AddEncodeElement(xmlWriter, "FileFormat", "string", parsed.Format.ToUpper() + " file");
+ AddEncodeElement(xmlWriter, "FileFormat", "string", Converters.GetFileFormat(parsed.OutputFormat) + " file");
AddBooleanElement(xmlWriter, "Folder", false);
AddEncodeElement(xmlWriter, "Mp4HttpOptimize", "integer", parsed.OptimizeMP4 ? "1" : "0");
- AddEncodeElement(xmlWriter, "Mp4LargeFile", "integer", parsed.LargeMP4 ? "1" : "0");
- AddEncodeElement(xmlWriter, "Mp4iPodCompatible", "integer", parsed.IpodAtom ? "1" : "0");
+ AddEncodeElement(xmlWriter, "Mp4LargeFile", "integer", parsed.LargeFile ? "1" : "0");
+ AddEncodeElement(xmlWriter, "Mp4iPodCompatible", "integer", parsed.IPod5GSupport ? "1" : "0");
AddEncodeElement(xmlWriter, "PictureAutoCrop", "integer", "1");
- AddEncodeElement(xmlWriter, "PictureBottomCrop", "integer", parsed.CropBottom);
+ AddEncodeElement(xmlWriter, "PictureBottomCrop", "integer", parsed.Cropping.Bottom.ToString());
// Filters
- AddEncodeElement(xmlWriter, "PictureDeblock", "integer", parsed.DeBlock.ToString());
+ AddEncodeElement(xmlWriter, "PictureDeblock", "integer", parsed.Deblock.ToString());
switch (parsed.Decomb)
{
- case "Off":
+ case Decomb.Off:
AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "0");
AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty);
break;
- case "Default":
+ case Decomb.Default:
AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "1");
AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty);
break;
default:
AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "2");
- AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", parsed.Decomb);
+ AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", parsed.CustomDecomb);
break;
}
- AddEncodeElement(xmlWriter, "PictureDecombDeinterlace", "integer", parsed.Decomb != "Off" ? "0" : "1");
+ AddEncodeElement(xmlWriter, "PictureDecombDeinterlace", "integer", parsed.Decomb != Decomb.Off ? "0" : "1");
- switch (parsed.DeInterlace)
+ switch (parsed.Deinterlace)
{
- case "Off":
+ case Deinterlace.Off:
AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "0");
AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty);
break;
- case "Fast":
+ case Deinterlace.Fast:
AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "1");
AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty);
break;
- case "Slow":
+ case Deinterlace.Slow:
AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "2");
AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty);
break;
- case "Slower":
+ case Deinterlace.Slower:
AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "3");
AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty);
break;
default:
AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "4");
- AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", parsed.DeInterlace);
+ AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", parsed.CustomDeinterlace);
break;
}
- switch (parsed.DeNoise)
+ switch (parsed.Denoise)
{
- case "Off":
+ case Denoise.Off:
AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "0");
AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty);
break;
- case "Weak":
+ case Denoise.Weak:
AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "1");
AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty);
break;
- case "Medium":
+ case Denoise.Medium:
AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "2");
AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty);
break;
- case "Strong":
+ case Denoise.Strong:
AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "3");
AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty);
break;
default:
AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "4");
- AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.DeNoise);
+ AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.CustomDenoise);
break;
}
int detelecine;
- switch (parsed.DeTelecine)
+ switch (parsed.Detelecine)
{
- case "Off":
+ case Detelecine.Off:
detelecine = 0;
break;
- case "Default":
+ case Detelecine.Default:
detelecine = 2;
break;
default:
@@ -495,16 +512,16 @@ namespace HandBrake.ApplicationServices.Utilities }
AddEncodeElement(xmlWriter, "PictureDetelecine", "integer", detelecine.ToString());
- AddEncodeElement(xmlWriter, "PictureDetelecineCustom", "string", detelecine == 1 ? parsed.DeTelecine : string.Empty);
+ AddEncodeElement(xmlWriter, "PictureDetelecineCustom", "string", detelecine == 1 ? parsed.CustomDecomb : string.Empty);
// Picture Settings
AddEncodeElement(xmlWriter, "PictureHeight", "integer", parsed.Height.ToString());
- AddEncodeElement(xmlWriter, "PictureKeepRatio", "integer", parsed.KeepDisplayAsect ? "1" : "0");
- AddEncodeElement(xmlWriter, "PictureLeftCrop", "integer", parsed.CropLeft);
- AddEncodeElement(xmlWriter, "PictureModulus", "integer", parsed.AnamorphicModulus.ToString());
- AddEncodeElement(xmlWriter, "PicturePAR", "integer", parsed.AnamorphicMode.ToString());
- AddEncodeElement(xmlWriter, "PictureRightCrop", "integer", parsed.CropRight);
- AddEncodeElement(xmlWriter, "PictureTopCrop", "integer", parsed.CropTop);
+ AddEncodeElement(xmlWriter, "PictureKeepRatio", "integer", parsed.KeepDisplayAspect ? "1" : "0");
+ AddEncodeElement(xmlWriter, "PictureLeftCrop", "integer", parsed.Cropping.Left.ToString());
+ AddEncodeElement(xmlWriter, "PictureModulus", "integer", parsed.Modulus.ToString());
+ AddEncodeElement(xmlWriter, "PicturePAR", "integer", ((int)parsed.Anamorphic).ToString());
+ AddEncodeElement(xmlWriter, "PictureRightCrop", "integer", parsed.Cropping.Right.ToString());
+ AddEncodeElement(xmlWriter, "PictureTopCrop", "integer", parsed.Cropping.Top.ToString());
AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString());
// Preset Information
@@ -519,25 +536,25 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "UsesPictureSettings", "integer", "2");
// Video Settings
- AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.AverageVideoBitrate);
- AddEncodeElement(xmlWriter, "VideoEncoder", "string", parsed.VideoEncoder);
- AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.VideoFramerate);
- AddEncodeElement(xmlWriter, "VideFrameratePFR", "integer", parsed.Pfr ? "1" : "0");
+ AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.VideoBitrate.ToString());
+ AddEncodeElement(xmlWriter, "VideoEncoder", "string", Converters.GetGUIVideoEncoder(parsed.VideoEncoder));
+ AddEncodeElement(xmlWriter, "VideoFramerate", "string", 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.VideoQuality.ToString());
+ AddEncodeElement(xmlWriter, "VideoQualitySlider", "real", parsed.Quality.ToString());
int videoQualityType = 0;
- if (!string.IsNullOrEmpty(parsed.VideoTargetSize)) videoQualityType = 0;
- else if (!string.IsNullOrEmpty(parsed.AverageVideoBitrate)) videoQualityType = 1;
- else if (parsed.VideoQuality != 0) videoQualityType = 2;
+ if (parsed.TargetSize != null) videoQualityType = 0;
+ else if (parsed.VideoBitrate != null) videoQualityType = 1;
+ else if (parsed.Quality != null) videoQualityType = 2;
AddEncodeElement(xmlWriter, "VideoQualityType", "integer", videoQualityType.ToString());
- AddEncodeElement(xmlWriter, "VideoTargetSize", "string", parsed.VideoTargetSize);
+ AddEncodeElement(xmlWriter, "VideoTargetSize", "string", parsed.TargetSize.ToString());
AddEncodeElement(xmlWriter, "VideoTurboTwoPass", "integer", parsed.TurboFirstPass ? "1" : "0");
AddEncodeElement(xmlWriter, "VideoTwoPass", "integer", parsed.TwoPass ? "1" : "0");
// x264 string
- AddEncodeElement(xmlWriter, "x264Option", "string", parsed.H264Query);
+ AddEncodeElement(xmlWriter, "x264Option", "string", parsed.X264Options);
}
/// <summary>
@@ -598,14 +615,14 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="parsed">
/// The parsed.
/// </param>
- private static void AudioListArrayDict(XmlTextWriter xmlWriter, QueryParserUtility parsed)
+ private static void AudioListArrayDict(XmlTextWriter xmlWriter, EncodeTask parsed)
{
xmlWriter.WriteStartElement("key");
xmlWriter.WriteString("AudioList");
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("array");
- foreach (AudioTrack track in parsed.AudioInformation)
+ foreach (AudioTrack track in parsed.AudioTracks)
{
AddAudioItem(xmlWriter, track);
}
@@ -635,7 +652,7 @@ namespace HandBrake.ApplicationServices.Utilities xmlWriter.WriteElementString("string", audioTrack.MixDown);
xmlWriter.WriteElementString("key", "AudioSamplerate");
- xmlWriter.WriteElementString("string", audioTrack.SampleRate);
+ xmlWriter.WriteElementString("string", audioTrack.SampleRate);
xmlWriter.WriteElementString("key", "AudioTrack");
xmlWriter.WriteElementString("integer", audioTrack.Track);
diff --git a/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index 9f5f93d24..3fb6a0e18 100644 --- a/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -7,10 +7,12 @@ namespace HandBrake.ApplicationServices.Utilities {
using System;
using System.Collections;
+ using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using HandBrake.ApplicationServices.Functions;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
/// <summary>
@@ -18,280 +20,16 @@ namespace HandBrake.ApplicationServices.Utilities /// </summary>
public class QueryParserUtility
{
- /// <summary>
- /// The Culture
- /// </summary>
- private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
-
- #region Varibles
-
- #region Source Title / Chapters
- /// <summary>
- /// Gets or sets Title.
- /// </summary>
- public int Title { get; set; }
-
- /// <summary>
- /// Gets or sets ChapterStart.
- /// </summary>
- public int ChapterStart { get; set; }
-
- /// <summary>
- /// Gets or sets ChapterFinish.
- /// </summary>
- public int ChapterFinish { get; set; }
- #endregion
-
- #region Output Settings
- /// <summary>
- /// Gets or sets the file Format. e.g mkv or mp4
- /// </summary>
- public string Format { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether LargeMP4 support is enabled.
- /// This is the 64bit MP4 file that allows >4GB files
- /// </summary>
- public bool LargeMP4 { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether IpodAtom is inserted
- /// </summary>
- public bool IpodAtom { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether OptimizeMP4 is enabed for web streaming
- /// </summary>
- public bool OptimizeMP4 { get; set; }
- #endregion
-
- #region Picture Settings
-
- /// <summary>
- /// Gets or sets Width.
- /// </summary>
- public int Width { get; set; }
-
- /// <summary>
- /// Gets or sets Height.
- /// </summary>
- public int Height { get; set; }
-
- /// <summary>
- /// Gets or sets MaxWidth.
- /// </summary>
- public int MaxWidth { get; set; }
-
- /// <summary>
- /// Gets or sets MaxHeight.
- /// </summary>
- public int MaxHeight { get; set; }
-
- /// <summary>
- /// Gets or sets CropValues.
- /// </summary>
- public string CropValues { get; set; }
-
- /// <summary>
- /// Gets or sets CropTop.
- /// </summary>
- public string CropTop { get; set; }
-
- /// <summary>
- /// Gets or sets CropBottom.
- /// </summary>
- public string CropBottom { get; set; }
-
- /// <summary>
- /// Gets or sets CropLeft.
- /// </summary>
- public string CropLeft { get; set; }
-
- /// <summary>
- /// Gets or sets CropRight.
- /// </summary>
- public string CropRight { get; set; }
-
- /// <summary>
- /// Gets or sets AnamorphicMode.
- /// </summary>
- public int AnamorphicMode { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether KeepDisplayAsect.
- /// </summary>
- public bool KeepDisplayAsect { get; set; }
-
- /// <summary>
- /// Gets or sets DisplayWidthValue.
- /// </summary>
- public double DisplayWidthValue { get; set; }
-
- /// <summary>
- /// Gets or sets PixelAspectWidth.
- /// </summary>
- public int PixelAspectWidth { get; set; }
-
- /// <summary>
- /// Gets or sets PixelAspectHeight.
- /// </summary>
- public int PixelAspectHeight { get; set; }
-
- /// <summary>
- /// Gets or sets AnamorphicModulus.
- /// </summary>
- public int AnamorphicModulus { get; set; }
- #endregion
-
- #region Video Filters
-
- /// <summary>
- /// Gets or sets DeTelecine.
- /// </summary>
- public string DeTelecine { get; set; }
-
- /// <summary>
- /// Gets or sets DeBlock.
- /// </summary>
- public int DeBlock { get; set; }
-
- /// <summary>
- /// Gets or sets DeInterlace.
- /// </summary>
- public string DeInterlace { get; set; }
-
- /// <summary>
- /// Gets or sets DeNoise.
- /// </summary>
- public string DeNoise { get; set; }
-
- /// <summary>
- /// Gets or sets Decomb.
- /// </summary>
- public string Decomb { get; set; }
- #endregion
-
- #region Video Settings
- /// <summary>
- /// Gets or sets VideoEncoder.
- /// </summary>
- public string VideoEncoder { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether Grayscale.
- /// </summary>
- public bool Grayscale { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether TwoPass.
- /// </summary>
- public bool TwoPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether TurboFirstPass.
- /// </summary>
- public bool TurboFirstPass { get; set; }
-
- /// <summary>
- /// Gets or sets VideoFramerate.
- /// </summary>
- public string VideoFramerate { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether Pfr.
- /// </summary>
- public bool Pfr { get; set; }
-
- /// <summary>
- /// Gets or sets AverageVideoBitrate.
- /// </summary>
- public string AverageVideoBitrate { get; set; }
-
- /// <summary>
- /// Gets or sets VideoTargetSize.
- /// </summary>
- public string VideoTargetSize { get; set; }
-
- /// <summary>
- /// Gets or sets VideoQuality.
- /// </summary>
- public float VideoQuality { get; set; }
- #endregion
-
- #region Audio Settings
-
- /// <summary>
- /// Gets or sets AudioInformation.
- /// </summary>
- public ArrayList AudioInformation { get; set; }
- /// <summary>
- /// Gets or sets Subtitles.
- /// </summary>
- public string Subtitles { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether ForcedSubtitles.
- /// </summary>
- public bool ForcedSubtitles { get; set; }
- #endregion
-
- #region Other
- /// <summary>
- /// Gets or sets a value indicating whether ChapterMarkers.
- /// </summary>
- public bool ChapterMarkers { get; set; }
-
- /// <summary>
- /// Gets or sets H264Query.
- /// </summary>
- public string H264Query { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether Verbose.
- /// </summary>
- public bool Verbose { get; set; }
- #endregion
-
- #region Preset Information
-
- /// <summary>
- /// Gets or sets PresetBuildNumber.
- /// </summary>
- public int PresetBuildNumber { get; set; }
-
- /// <summary>
- /// Gets or sets PresetDescription.
- /// </summary>
- public string PresetDescription { get; set; }
-
- /// <summary>
- /// Gets or sets PresetName.
- /// </summary>
- public string PresetName { get; set; }
+ /**
+ * TODO
+ * - Add support for PointToPointMode = Seconds or Frames
+ **/
/// <summary>
- /// Gets or sets Type.
- /// </summary>
- public string Type { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether UsesMaxPictureSettings.
- /// </summary>
- public bool UsesMaxPictureSettings { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether UsesPictureFilters.
- /// </summary>
- public bool UsesPictureFilters { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether UsesPictureSettings.
+ /// The Culture
/// </summary>
- public bool UsesPictureSettings { get; set; }
- #endregion
-
- #endregion
+ private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
/// <summary>
/// Takes in a query which can be in any order and parses it.
@@ -299,9 +37,9 @@ namespace HandBrake.ApplicationServices.Utilities /// </summary>
/// <param name="input">A ClI Query</param>
/// <returns>A Parsed Query</returns>
- public static QueryParserUtility Parse(string input)
+ public static EncodeTask Parse(string input)
{
- var thisQuery = new QueryParserUtility();
+ var parsed = new EncodeTask();
#region Regular Expressions
@@ -310,7 +48,7 @@ namespace HandBrake.ApplicationServices.Utilities Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
// Output Settings
- Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
+ Match format = Regex.Match(input, @"-f ([a-zA-Z0-9]*)");
Match grayscale = Regex.Match(input, @" -g");
Match largerMp4 = Regex.Match(input, @" -4");
Match ipodAtom = Regex.Match(input, @" -I");
@@ -350,6 +88,8 @@ namespace HandBrake.ApplicationServices.Utilities Match turboFirstPass = Regex.Match(input, @" -T");
Match optimizeMP4 = Regex.Match(input, @" -O");
Match pfr = Regex.Match(input, @" --pfr");
+ Match vfr = Regex.Match(input, @" --vfr");
+ Match cfr = Regex.Match(input, @" --cfr");
// Audio Settings Tab
Match noAudio = Regex.Match(input, @"-a none");
@@ -360,10 +100,6 @@ namespace HandBrake.ApplicationServices.Utilities Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z
Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");
- Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
- Match subScan = Regex.Match(input, @" -U");
- Match forcedSubtitles = Regex.Match(input, @" -F");
-
// Chapters Tab
Match chapterMarkers = Regex.Match(input, @" -m");
Match chapterMarkersFileMode = Regex.Match(input, @"--markers");
@@ -371,9 +107,6 @@ namespace HandBrake.ApplicationServices.Utilities // H264 Tab
Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
- // Program Options
- Match verbose = Regex.Match(input, @" -v");
-
#endregion
#region Set Varibles
@@ -383,170 +116,215 @@ namespace HandBrake.ApplicationServices.Utilities #region Source Tab
if (title.Success)
- thisQuery.Title = int.Parse(title.ToString().Replace("-t ", string.Empty));
+ {
+ parsed.Title = int.Parse(title.ToString().Replace("-t ", string.Empty));
+ }
if (chapters.Success)
{
+ parsed.PointToPointMode = PointToPointMode.Chapters;
string[] actTitles = chapters.ToString().Replace("-c ", string.Empty).Split('-');
- thisQuery.ChapterStart = int.Parse(actTitles[0]);
+ parsed.StartPoint = int.Parse(actTitles[0]);
if (actTitles.Length > 1)
{
- thisQuery.ChapterFinish = int.Parse(actTitles[1]);
+ parsed.EndPoint = int.Parse(actTitles[1]);
}
- if ((thisQuery.ChapterStart == 1) && (thisQuery.ChapterFinish == 0))
- thisQuery.ChapterFinish = thisQuery.ChapterStart;
+ if ((parsed.StartPoint == 1) && (parsed.EndPoint == 0))
+ {
+ parsed.EndPoint = parsed.StartPoint;
+ }
}
-
+
#endregion
#region Output Settings
if (format.Success)
- thisQuery.Format = format.ToString().Replace("-f ", string.Empty);
- thisQuery.LargeMP4 = largerMp4.Success;
- thisQuery.IpodAtom = ipodAtom.Success;
- thisQuery.OptimizeMP4 = optimizeMP4.Success;
+ {
+ parsed.OutputFormat = Converters.GetFileFormat(format.Groups[1].ToString());
+ }
+ parsed.LargeFile = largerMp4.Success;
+ parsed.IPod5GSupport = ipodAtom.Success;
+ parsed.OptimizeMP4 = optimizeMP4.Success;
#endregion
#region Picture Tab
if (width.Success)
- thisQuery.Width = int.Parse(width.Groups[0].Value.Replace("-w ", string.Empty));
+ parsed.Width = int.Parse(width.Groups[0].Value.Replace("-w ", string.Empty));
if (height.Success)
- thisQuery.Height = int.Parse(height.Groups[0].Value.Replace("-l ", string.Empty));
+ parsed.Height = int.Parse(height.Groups[0].Value.Replace("-l ", string.Empty));
if (maxWidth.Success)
- thisQuery.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", string.Empty));
+ parsed.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", string.Empty));
if (maxHeight.Success)
- thisQuery.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", string.Empty));
+ parsed.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", string.Empty));
if (crop.Success)
{
- thisQuery.CropValues = crop.ToString().Replace("--crop ", string.Empty);
- string[] actCropValues = thisQuery.CropValues.Split(':');
- thisQuery.CropTop = actCropValues[0];
- thisQuery.CropBottom = actCropValues[1];
- thisQuery.CropLeft = actCropValues[2];
- thisQuery.CropRight = actCropValues[3];
+ try
+ {
+ string values = crop.ToString().Replace("--crop ", string.Empty);
+ string[] actCropValues = values.Split(':');
+ parsed.Cropping = new Cropping(
+ int.Parse(actCropValues[0]),
+ int.Parse(actCropValues[1]),
+ int.Parse(actCropValues[2]),
+ int.Parse(actCropValues[3]));
+ }
+ catch (Exception)
+ {
+ // No need to do anything.
+ }
}
if (strictAnamorphic.Success)
- thisQuery.AnamorphicMode = 1;
+ parsed.Anamorphic = Anamorphic.Strict;
else if (looseAnamorphic.Success)
- thisQuery.AnamorphicMode = 2;
+ parsed.Anamorphic = Anamorphic.Loose;
else if (customAnamorphic.Success)
- thisQuery.AnamorphicMode = 3;
+ parsed.Anamorphic = Anamorphic.Custom;
else
- thisQuery.AnamorphicMode = 0;
+ parsed.Anamorphic = Anamorphic.None;
- thisQuery.KeepDisplayAsect = keepDisplayAsect.Success;
+ parsed.KeepDisplayAspect = keepDisplayAsect.Success;
if (displayWidth.Success)
- thisQuery.DisplayWidthValue =
+ parsed.DisplayWidth =
double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", string.Empty));
if (pixelAspect.Success)
- thisQuery.PixelAspectWidth = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", string.Empty));
+ parsed.PixelAspectX = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", string.Empty));
if (pixelAspect.Success && pixelAspect.Groups.Count >= 3)
- thisQuery.PixelAspectHeight = int.Parse(pixelAspect.Groups[2].Value.Replace("--pixel-aspect ", string.Empty));
+ parsed.PixelAspectY = int.Parse(pixelAspect.Groups[2].Value.Replace("--pixel-aspect ", string.Empty));
if (modulus.Success)
- thisQuery.AnamorphicModulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", string.Empty));
+ parsed.Modulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", string.Empty));
#endregion
#region Filters
- thisQuery.Decomb = "Off";
+ parsed.Decomb = Decomb.Off;
if (decomb.Success)
{
- thisQuery.Decomb = "Default";
+ parsed.Decomb = Decomb.Default;
if (decombValue.Success)
- thisQuery.Decomb = decombValue.ToString().Replace("--decomb=", string.Empty).Replace("\"", string.Empty);
+ {
+ parsed.CustomDecomb = decombValue.ToString().Replace("--decomb=", string.Empty).Replace("\"", string.Empty);
+ }
}
- thisQuery.DeInterlace = "Off";
+ parsed.Deinterlace = Deinterlace.Off;
if (deinterlace.Success)
{
- thisQuery.DeInterlace = deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty);
- thisQuery.DeInterlace =
- thisQuery.DeInterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");
- thisQuery.DeInterlace = thisQuery.DeInterlace.Replace("slowest", "Slowest");
+ switch (deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty).ToLower())
+ {
+ case "fast":
+ parsed.Deinterlace = Deinterlace.Fast;
+ break;
+ case "slow":
+ parsed.Deinterlace = Deinterlace.Slow;
+ break;
+ case "slower":
+ parsed.Deinterlace = Deinterlace.Slower;
+ break;
+ case "slowest":
+ parsed.Deinterlace = Deinterlace.Slowest;
+ break;
+ default:
+ parsed.Deinterlace = Deinterlace.Custom;
+ parsed.CustomDeinterlace = deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty).ToLower();
+ break;
+ }
}
- thisQuery.DeNoise = "Off";
+ parsed.Denoise = Denoise.Off;
if (denoise.Success)
{
- thisQuery.DeNoise = denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty);
- thisQuery.DeNoise =
- thisQuery.DeNoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");
+ switch (denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty))
+ {
+ case "weak":
+ parsed.Denoise = Denoise.Weak;
+ break;
+ case "medium":
+ parsed.Denoise = Denoise.Medium;
+ break;
+ case "strong":
+ parsed.Denoise = Denoise.Strong;
+ break;
+ default:
+ parsed.Denoise = Denoise.Custom;
+ parsed.CustomDenoise = denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty);
+ break;
+ }
}
- string deblockValue = string.Empty;
- thisQuery.DeBlock = 0;
+ parsed.Deblock = 0;
if (deblock.Success)
- deblockValue = deblock.ToString().Replace("--deblock=", string.Empty);
-
- int dval = 0;
- if (deblockValue != string.Empty)
- int.TryParse(deblockValue, out dval);
- thisQuery.DeBlock = dval;
+ {
+ int dval;
+ int.TryParse(deblock.ToString().Replace("--deblock=", string.Empty), out dval);
+ parsed.Deblock = dval;
+ }
- thisQuery.DeTelecine = "Off";
+ parsed.Detelecine = Detelecine.Off;
if (detelecine.Success)
{
- thisQuery.DeTelecine = "Default";
+ parsed.Detelecine = Detelecine.Default;
if (detelecineValue.Success)
- thisQuery.DeTelecine = detelecineValue.ToString().Replace("--detelecine=", string.Empty).Replace("\"", string.Empty);
+ {
+ parsed.CustomDetelecine = detelecineValue.ToString().Replace("--detelecine=", string.Empty).Replace("\"", string.Empty);
+ parsed.Detelecine = Detelecine.Custom;
+ }
}
#endregion
#region Video Settings Tab
- string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", string.Empty);
- switch (videoEncoderConvertion)
+ parsed.VideoEncoder = Converters.GetVideoEncoder(videoEncoder.ToString().Replace("-e ", string.Empty));
+
+ if (videoFramerate.Success)
{
- case "ffmpeg":
- videoEncoderConvertion = "MPEG-4 (FFmpeg)";
- break;
- case "x264":
- videoEncoderConvertion = "H.264 (x264)";
- break;
- case "theora":
- videoEncoderConvertion = "VP3 (Theora)";
- break;
- default:
- videoEncoderConvertion = "MPEG-4 (FFmpeg)";
- break;
+ double fps;
+ double.TryParse(videoFramerate.Groups[1].ToString(), out fps);
+ parsed.Framerate = fps;
}
- thisQuery.VideoEncoder = videoEncoderConvertion;
- thisQuery.VideoFramerate = videoFramerate.Success
- ? videoFramerate.ToString().Replace("-r ", string.Empty)
- : "Same as source";
- thisQuery.Pfr = pfr.Success;
- thisQuery.Grayscale = grayscale.Success;
- thisQuery.TwoPass = twoPass.Success;
- thisQuery.TurboFirstPass = turboFirstPass.Success;
+ if (pfr.Success)
+ parsed.FramerateMode = FramerateMode.PFR;
+ else if (vfr.Success)
+ parsed.FramerateMode = FramerateMode.VFR;
+ else if (cfr.Success)
+ parsed.FramerateMode = FramerateMode.CFR;
+
+ parsed.Grayscale = grayscale.Success;
+ parsed.TwoPass = twoPass.Success;
+ parsed.TurboFirstPass = turboFirstPass.Success;
if (videoBitrate.Success)
- thisQuery.AverageVideoBitrate = videoBitrate.ToString().Replace("-b ", string.Empty);
+ {
+ parsed.VideoEncodeRateType = VideoEncodeRateMode.AverageBitrate;
+ parsed.VideoBitrate = int.Parse(videoBitrate.ToString().Replace("-b ", string.Empty));
+ }
+
if (videoFilesize.Success)
- thisQuery.VideoTargetSize = videoFilesize.ToString().Replace("-S ", string.Empty);
+ {
+ parsed.VideoEncodeRateType = VideoEncodeRateMode.TargetSize;
+ parsed.TargetSize = int.Parse(videoBitrate.ToString().Replace("-S ", string.Empty));
+ }
if (videoQuality.Success)
{
- float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", string.Empty), Culture);
- thisQuery.VideoQuality = qConvert;
+ float quality = float.Parse(videoQuality.ToString().Replace("-q ", string.Empty), Culture);
+ parsed.Quality = quality;
}
- else
- thisQuery.VideoQuality = -1;
#endregion
@@ -582,7 +360,7 @@ namespace HandBrake.ApplicationServices.Utilities trackDRCvalues = drcValues.ToString().Replace("-D ", string.Empty).Split(',');
// Create new Audio Track Classes and store them in the ArrayList
- ArrayList allAudioTrackInfo = new ArrayList();
+ List<AudioTrack> allAudioTrackInfo = new List<AudioTrack>();
for (int x = 0; x < encoderCount; x++)
{
AudioTrack track = new AudioTrack();
@@ -596,7 +374,7 @@ namespace HandBrake.ApplicationServices.Utilities if (trackEncoders != null)
if (trackEncoders.Length >= (x + 1)) // Audio Mix
- track.Encoder = Converters.GetAudioEncoder(trackEncoders[x].Trim());
+ track.Encoder = Converters.GetGUIAudioEncoder(trackEncoders[x].Trim());
if (trackBitrates != null)
if (trackBitrates.Length >= (x + 1)) // Audio Encoder
@@ -612,31 +390,22 @@ namespace HandBrake.ApplicationServices.Utilities allAudioTrackInfo.Add(track);
}
- thisQuery.AudioInformation = allAudioTrackInfo;
- // Subtitle Stuff
- if (subtitles.Success)
- thisQuery.Subtitles = subtitles.ToString().Replace("-s ", string.Empty);
- else
- thisQuery.Subtitles = subScan.Success ? "Autoselect" : "None";
-
- thisQuery.ForcedSubtitles = forcedSubtitles.Success;
+ parsed.AudioTracks = allAudioTrackInfo;
#endregion
#region Chapters Tab
if (chapterMarkersFileMode.Success || chapterMarkers.Success)
- thisQuery.ChapterMarkers = true;
+ parsed.IncludeChapterMarkers = true;
#endregion
#region H.264 and other
if (x264.Success)
- thisQuery.H264Query = x264.ToString().Replace("-x ", string.Empty);
-
- thisQuery.Verbose = verbose.Success;
+ parsed.X264Options = x264.ToString().Replace("-x ", string.Empty);
#endregion
}
@@ -647,7 +416,7 @@ namespace HandBrake.ApplicationServices.Utilities #endregion
- return thisQuery;
+ return parsed;
}
}
}
\ No newline at end of file |