diff options
author | sr55 <[email protected]> | 2015-01-22 16:32:22 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-22 16:32:22 +0000 |
commit | acf831a1c78044a01e470102385334d183d1d5b1 (patch) | |
tree | f508c79182ff84f33617dcf826110bd21312adeb /win/CS/HandBrake.ApplicationServices/Utilities | |
parent | 1ccc7a6a3caedda77d6e62972129727fb1598f35 (diff) |
WinGui: Initial re-factoring of the Video Tab. Replaces encoder specific preset/tune/profile/level options with generic versions. This will break all existing user presets so the version number for the presets has been bumped. This should trigger the old presets to be archived.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6789 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
4 files changed, 53 insertions, 354 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index d3fd4b6e5..3bb040052 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -14,8 +14,6 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Services.Encode.Model.Models;
using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.Model.Encoding.x264;
- using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// A class to convert various things to native C# objects
@@ -342,192 +340,6 @@ namespace HandBrake.ApplicationServices.Utilities #endregion
- #region x264
-
- /// <summary>
- /// Get the x264Preset from a cli parameter
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <returns>
- /// The x264Preset enum value
- /// </returns>
- public static x264Preset Getx264PresetFromCli(string preset)
- {
- switch (preset)
- {
- case "ultrafast":
- return x264Preset.Ultrafast;
- case "superfast":
- return x264Preset.Superfast;
- case "veryfast":
- return x264Preset.VeryFast;
- case "faster":
- return x264Preset.Faster;
- case "fast":
- return x264Preset.Fast;
- case "medium":
- return x264Preset.Medium;
- case "slow":
- return x264Preset.Slow;
- case "slower":
- return x264Preset.Slower;
- case "veryslow":
- return x264Preset.VerySlow;
- case "placebo":
- return x264Preset.Placebo;
- default:
- return x264Preset.Faster;
- }
- }
-
- /// <summary>
- /// Get the x264 Profile from the cli
- /// </summary>
- /// <param name="profile">
- /// The preset.
- /// </param>
- /// <returns>
- /// The x264Profile enum value
- /// </returns>
- public static x264Profile Getx264ProfileFromCli(string profile)
- {
- switch (profile)
- {
- case "baseline":
- return x264Profile.Baseline;
- case "main":
- return x264Profile.Main;
- case "high":
- return x264Profile.High;
- default:
- return x264Profile.Main;
- }
- }
-
- /// <summary>
- /// Get x264Tune enum from a cli string
- /// </summary>
- /// <param name="tune">
- /// The tune.
- /// </param>
- /// <returns>
- /// The x264Tune enum value
- /// </returns>
- public static x264Tune Getx264TuneFromCli(string tune)
- {
- switch (tune)
- {
- case "film":
- return x264Tune.Film;
- case "animation":
- return x264Tune.Animation;
- case "grain":
- return x264Tune.Grain;
- case "stillimage":
- return x264Tune.Stillimage;
- case "psnr":
- return x264Tune.Psnr;
- case "ssim":
- return x264Tune.Ssim;
- case "fastdecode":
- return x264Tune.Fastdecode;
- default:
- return x264Tune.Film;
- }
- }
-
- #endregion
-
- #region x265
-
- /// <summary>
- /// Get the x265Preset from a cli parameter
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <returns>
- /// The x265Preset enum value
- /// </returns>
- public static x265Preset Getx265PresetFromCli(string preset)
- {
- switch (preset)
- {
- case "ultrafast":
- return x265Preset.Ultrafast;
- case "superfast":
- return x265Preset.Superfast;
- case "veryfast":
- return x265Preset.VeryFast;
- case "faster":
- return x265Preset.Faster;
- case "fast":
- return x265Preset.Fast;
- case "medium":
- return x265Preset.Medium;
- case "slow":
- return x265Preset.Slow;
- case "slower":
- return x265Preset.Slower;
- case "veryslow":
- return x265Preset.VerySlow;
- case "placebo":
- return x265Preset.Placebo;
- default:
- return x265Preset.Faster;
- }
- }
-
- /// <summary>
- /// Get the x265 Profile from the cli
- /// </summary>
- /// <param name="profile">
- /// The preset.
- /// </param>
- /// <returns>
- /// The x265Profile enum value
- /// </returns>
- public static x265Profile Getx265ProfileFromCli(string profile)
- {
- switch (profile)
- {
- case "mainstillpicture":
- return x265Profile.Mainstillpicture;
- case "main":
- return x265Profile.Main;
- case "main10":
- return x265Profile.Main10;
- default:
- return x265Profile.Main;
- }
- }
-
- /// <summary>
- /// Get x265Tune enum from a cli string
- /// </summary>
- /// <param name="tune">
- /// The tune.
- /// </param>
- /// <returns>
- /// The x265Tune enum value
- /// </returns>
- public static x265Tune Getx265TuneFromCli(string tune)
- {
- switch (tune)
- {
- case "psnr":
- return x265Tune.psnr;
- case "ssim":
- return x265Tune.ssim;
- default:
- return x265Tune.psnr;
- }
- }
-
- #endregion
-
#region File Format
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index 0f2fa8688..8cd9588b8 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -18,8 +18,6 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Services.Encode.Model.Models;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.Model.Encoding.x264;
- using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// A Utility Class to Convert a
@@ -189,44 +187,20 @@ namespace HandBrake.ApplicationServices.Utilities job.TwoPass = work.TwoPass;
job.TurboFirstPass = work.TurboFirstPass;
- if (work.VideoEncoder == VideoEncoder.X264)
+ if (work.VideoEncoder == VideoEncoder.X264 || work.VideoEncoder == VideoEncoder.X265 || work.VideoEncoder == VideoEncoder.QuickSync)
{
- job.VideoPreset = work.X264Preset.ToString().ToLower().Replace(" ", string.Empty);
- job.VideoTunes = new List<string>();
+ job.VideoPreset = work.VideoPreset.ShortName;
+ job.VideoProfile = work.VideoProfile.ShortName;
+ job.VideoLevel = work.VideoLevel.ShortName;
- if (work.X264Tune != x264Tune.None)
+ if (work.VideoEncoder != VideoEncoder.QuickSync)
{
- job.VideoTunes.Add(work.X264Tune.ToString().ToLower().Replace(" ", string.Empty));
- }
-
- if (work.FastDecode)
- {
- job.VideoTunes.Add("fastdecode");
- }
-
- job.VideoProfile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty); // TODO change these away from strings.
- job.VideoLevel = work.H264Level;
- }
- else if (work.VideoEncoder == VideoEncoder.X265)
- {
- job.VideoPreset = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);
-
- if (work.H265Profile != x265Profile.None)
- {
- job.VideoProfile = work.H265Profile.ToString().ToLower().Replace(" ", string.Empty);
- }
-
- job.VideoTunes = new List<string>();
- if (work.X265Tune != x265Tune.None)
- {
- job.VideoTunes.Add(work.X265Tune.ToString().ToLower().Replace(" ", string.Empty));
- }
- }
- else if (work.VideoEncoder == VideoEncoder.QuickSync)
- {
- job.VideoPreset = work.QsvPreset.ToString().ToLower().Replace(" ", string.Empty);
- job.VideoProfile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty);
- job.VideoLevel = work.H264Level;
+ job.VideoTunes = new List<string>();
+ foreach (var item in work.VideoTunes)
+ {
+ job.VideoTunes.Add(item.ShortName);
+ }
+ }
}
// Chapter Markers
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 4c0eddac1..47c29db0a 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -14,13 +14,12 @@ namespace HandBrake.ApplicationServices.Utilities using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
+ using System.Linq;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Services.Encode.Model.Models;
using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.Model.Encoding.x264;
- using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// Generate a CLI Query for HandBrakeCLI
@@ -942,64 +941,21 @@ namespace HandBrake.ApplicationServices.Utilities {
string query = string.Empty;
- // X264 Only
- if (task.VideoEncoder == VideoEncoder.X264)
+ if (task.VideoEncoder == VideoEncoder.X264 || task.VideoEncoder == VideoEncoder.X265 || task.VideoEncoder == VideoEncoder.QuickSync)
{
if (!task.ShowAdvancedTab)
{
- if (task.X264Preset != x264Preset.Medium)
- {
- query += string.Format(
- " --encoder-preset={0} ", task.X264Preset.ToString().ToLower().Replace(" ", string.Empty));
- }
+ query += string.Format(" --encoder-preset={0} ", task.VideoPreset.ShortName);
- if (task.X264Tune != x264Tune.None)
+ string tuneQuery = task.VideoTunes.Aggregate(string.Empty, (current, tune) => string.IsNullOrEmpty(current) ? tune.ShortName : string.Format(",{0}", tune.ShortName));
+ if (!string.IsNullOrEmpty(tuneQuery))
{
- string tune = string.Empty;
-
- if (task.FastDecode)
- {
- tune = "fastdecode";
- }
-
- string tuneDropdown = task.X264Tune.ToString().ToLower().Replace(" ", string.Empty);
- if (task.X264Tune != x264Tune.None && !string.IsNullOrEmpty(tuneDropdown))
- {
- tune = string.IsNullOrEmpty(tune) ? tuneDropdown : string.Format(",{0}", tuneDropdown);
- }
-
- query += string.Format(" --encoder-tune=\"{0}\" ", tune);
+ query += string.Format(" --encoder-tune=\"{0}\" ", tuneQuery);
}
- if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
- {
- query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
- }
- }
- }
+ query += string.Format(" --encoder-profile={0} ", task.VideoProfile.ShortName);
- // X265 Only
- if (task.VideoEncoder == VideoEncoder.X265)
- {
- if (!task.ShowAdvancedTab)
- {
- if (task.X265Preset != x265Preset.Medium)
- {
- query += string.Format(
- " --encoder-preset={0} ", task.X265Preset.ToString().ToLower().Replace(" ", string.Empty));
- }
-
- if (task.X265Tune != x265Tune.None)
- {
- query += string.Format(
- " --encoder-tune=\"{0}\" ", task.X265Tune.ToString().ToLower().Replace(" ", string.Empty));
- }
-
- if (task.H265Profile != x265Profile.None)
- {
- query += string.Format(
- " --encoder-profile={0} ", task.H265Profile.ToString().ToLower().Replace(" ", string.Empty));
- }
+ query += string.Format(" --encoder-level=\"{0}\" ", task.VideoLevel.ShortName);
if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
{
@@ -1007,37 +963,18 @@ namespace HandBrake.ApplicationServices.Utilities }
}
}
-
- // QSV Only
- if (task.VideoEncoder == VideoEncoder.QuickSync)
+ else if (!task.ShowAdvancedTab && !string.IsNullOrEmpty(task.ExtraAdvancedArguments))
{
- query += string.Format(" --encoder-preset={0}", task.QsvPreset.ToString().ToLower());
+ query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
}
+
// options that apply to all encoders
- if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))
+ if (task.ShowAdvancedTab && !string.IsNullOrEmpty(task.AdvancedEncoderOptions))
{
query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
}
- // Options that apply to both x264 and QuickSync
- if (task.VideoEncoder == VideoEncoder.QuickSync || task.VideoEncoder == VideoEncoder.X264)
- {
- // when using x264 with the advanced panel, the H.264 profile/level widgets are disabled
- if (!(task.VideoEncoder == VideoEncoder.X264 && task.ShowAdvancedTab))
- {
- if (task.H264Level != "Auto")
- {
- query += string.Format(" --encoder-level=\"{0}\" ", task.H264Level);
- }
- if (task.H264Profile != x264Profile.Auto)
- {
- query += string.Format(
- " --encoder-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty));
- }
- }
- }
-
return query;
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index c8c79116f..4955cc3ef 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -18,6 +18,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Services.Encode.Model.Models;
+ using HandBrake.ApplicationServices.Services.Encode.Model.Models.Video;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
@@ -111,15 +112,11 @@ namespace HandBrake.ApplicationServices.Utilities // Advanced Tab
Match advanced = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
- Match x264Preset = Regex.Match(input, @"--x264-preset([=a-zA-Z0-9\s ]*)");
- Match x264Tune = Regex.Match(input, @"--x264-tune([=,a-zA-Z0-9\s ]*)");
- Match h264Profile = Regex.Match(input, @"--h264-profile([=a-zA-Z0-9\s ]*)");
- Match x264Profile = Regex.Match(input, @"--x264-profile([=a-zA-Z0-9\s ]*)");
- Match h264Level = Regex.Match(input, @"--h264-level([=a-zA-Z0-9.\s ]*)");
-
- Match x265Profile = Regex.Match(input, @"--x265-profile([=a-zA-Z0-9\s ]*)");
- Match x265Tune = Regex.Match(input, @"--x265-tune([=,a-zA-Z0-9\s ]*)");
- Match x265Preset = Regex.Match(input, @"--x265-preset([=a-zA-Z0-9\s ]*)");
+ Match videoLevel = Regex.Match(input, @"--encoder-level([=a-zA-Z0-9.\s ]*)");
+ Match videoProfile = Regex.Match(input, @"--encoder-profile([=a-zA-Z0-9\s ]*)");
+ Match videoTune = Regex.Match(input, @"--encoder-tune([=,a-zA-Z0-9\s ]*)");
+ Match videoPreset = Regex.Match(input, @"--encoder-preset([=a-zA-Z0-9\s ]*)");
+
#endregion
#region Set Varibles
@@ -492,60 +489,39 @@ namespace HandBrake.ApplicationServices.Utilities if (advanced.Success)
parsed.AdvancedEncoderOptions = advanced.ToString().Replace("-x ", string.Empty);
- if (x264Preset.Success)
- parsed.X264Preset =
- Converters.Getx264PresetFromCli(x264Preset.ToString().Replace("--x264-preset", string.Empty).Replace("=", string.Empty).Trim());
-
- if (h264Profile.Success)
- parsed.H264Profile =
- Converters.Getx264ProfileFromCli(h264Profile.ToString().Replace("--h264-profile", string.Empty).Replace("=", string.Empty).Trim());
-
- if (x264Profile.Success)
- parsed.H264Profile =
- Converters.Getx264ProfileFromCli(x264Profile.ToString().Replace("--x264-profile", string.Empty).Replace("=", string.Empty).Trim());
-
- if (h264Level.Success)
- parsed.H264Level =
- h264Level.ToString().Replace("--h264-level", string.Empty).Replace("=", string.Empty).Trim();
-
- if (x264Tune.Success)
+ if (videoPreset.Success)
{
- string tuneOptions =
- x264Tune.ToString().Replace("--x264-tune", string.Empty).Replace("=", string.Empty).Trim();
-
- parsed.FastDecode = tuneOptions.Contains("fastdecode");
-
- // Remove these options. They are not in the dropdown.
- tuneOptions = tuneOptions.Replace("fastdecode", string.Empty).Replace(
- ",", string.Empty);
-
- parsed.X264Tune = Converters.Getx264TuneFromCli(tuneOptions);
+ string preset = videoPreset.ToString().Replace("--encoder-preset", string.Empty).Replace("=", string.Empty).Trim();
+ parsed.VideoPreset = new VideoPreset(preset, preset);
}
- if (x265Preset.Success)
- parsed.X265Preset =
- Converters.Getx265PresetFromCli(x265Preset.ToString().Replace("--x265-preset", string.Empty).Replace("=", string.Empty).Trim());
-
- if (h264Profile.Success)
- parsed.H265Profile =
- Converters.Getx265ProfileFromCli(h264Profile.ToString().Replace("--h265-profile", string.Empty).Replace("=", string.Empty).Trim());
+ if (videoProfile.Success)
+ {
+ string profile = videoProfile.ToString().Replace("--encoder-profile", string.Empty).Replace("=", string.Empty).Trim();
+ parsed.VideoProfile = new VideoProfile(profile, profile);
+ }
- if (x265Profile.Success)
- parsed.H265Profile =
- Converters.Getx265ProfileFromCli(x265Profile.ToString().Replace("--x265-profile", string.Empty).Replace("=", string.Empty).Trim());
+ if (videoLevel.Success)
+ {
+ string level = videoLevel.ToString().Replace("--encoder-level", string.Empty).Replace("=", string.Empty).Trim();
+ parsed.VideoLevel = new VideoLevel(level, level);
+ }
- if (x265Tune.Success)
+ if (videoTune.Success)
{
- string tuneOptions =
- x265Tune.ToString().Replace("--x265-tune", string.Empty).Replace("=", string.Empty).Trim();
+ string tuneOptions = videoTune.ToString().Replace("--encoder-tune", string.Empty).Replace("=", string.Empty).Trim();
- parsed.FastDecode = tuneOptions.Contains("fastdecode");
+ if (tuneOptions.Contains("fastdecode"))
+ {
+ parsed.VideoTunes.Add(new VideoTune("fastdecode", "fastdecode"));
+ }
// Remove these options. They are not in the dropdown.
- tuneOptions = tuneOptions.Replace("fastdecode", string.Empty).Replace(
- ",", string.Empty);
-
- parsed.X265Tune = Converters.Getx265TuneFromCli(tuneOptions);
+ tuneOptions = tuneOptions.Replace("fastdecode", string.Empty).Replace(",", string.Empty);
+ if (!string.IsNullOrEmpty(tuneOptions.Trim()))
+ {
+ parsed.VideoTunes.Add(new VideoTune(tuneOptions, tuneOptions));
+ }
}
#endregion
|