diff options
author | sr55 <[email protected]> | 2014-02-23 15:43:16 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-02-23 15:43:16 +0000 |
commit | 71c53a04fc0d43fee4ee024f854ebc6783234fd2 (patch) | |
tree | 38f3ed0d47fb7dc388999dfdb554334827d45337 /win/CS/HandBrake.ApplicationServices | |
parent | b29ad15acd51f7fc869f7bac9d77d7540e143740 (diff) |
WinGui: x265 UI patch by Zhang Zhigiang.
This enables support for the x265 encoder from the GUI when paired with a build of HandBrake that has x265 enabled.
Thanks
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6062 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
8 files changed, 219 insertions, 3 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs index fd10e22bd..e6b59c31d 100644 --- a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs @@ -20,6 +20,7 @@ namespace HandBrake.ApplicationServices.Factories using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
+ using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// A Factory to translate a Plist object into a Preset.
@@ -237,6 +238,15 @@ namespace HandBrake.ApplicationServices.Factories case "QsvPreset":
preset.Task.QsvPreset = EnumHelper<QsvPreset>.GetValue(kvp.Value, true);
break;
+ case "h265Profile":
+ preset.Task.H265Profile = EnumHelper<x265Profile>.GetValue(kvp.Value, true);
+ break;
+ case "x265Tune":
+ preset.Task.X265Tune = EnumHelper<x265Profile>.GetValue(kvp.Value, true);
+ break;
+ case "x265Preset":
+ preset.Task.X265Preset = EnumHelper<x265Preset>.GetValue(kvp.Value, true);
+ break;
// Chapter Markers Tab
case "ChapterMarkers":
diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index b521d3b9d..6a519a382 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -18,6 +18,7 @@ namespace HandBrake.ApplicationServices.Model using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
+ using HandBrake.Interop.Model.Encoding.x265;
using OutputFormat = HandBrake.ApplicationServices.Model.Encoding.OutputFormat;
@@ -55,6 +56,10 @@ namespace HandBrake.ApplicationServices.Model this.H264Profile = x264Profile.None;
this.X264Tune = x264Tune.None;
this.Modulus = 16;
+
+ this.H265Profile = x265Profile.None;
+ this.X265Preset = x265Preset.VeryFast;
+ this.X265Tune = x265Tune.None;
}
/// <summary>
@@ -137,11 +142,15 @@ namespace HandBrake.ApplicationServices.Model this.H264Level = task.H264Level;
this.FastDecode = task.FastDecode;
this.ExtraAdvancedArguments = task.ExtraAdvancedArguments;
-
+
this.PreviewStartAt = task.PreviewStartAt;
this.PreviewDuration = task.PreviewDuration;
this.ShowAdvancedTab = task.ShowAdvancedTab;
+
+ this.X265Preset = task.X265Preset;
+ this.X265Tune = task.X265Tune;
+ this.H265Profile = task.H265Profile;
}
#region Source
@@ -457,6 +466,21 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public string ExtraAdvancedArguments { get; set; }
+ /// <summary>
+ /// Gets or sets x265Preset.
+ /// </summary>
+ public x265Preset X265Preset { get; set; }
+
+ /// <summary>
+ /// Gets or sets x265Profile.
+ /// </summary>
+ public x265Profile H265Profile { get; set; }
+
+ /// <summary>
+ /// Gets or sets X265Tune.
+ /// </summary>
+ public x265Tune X265Tune { get; set; }
+
#endregion
#region Preview
@@ -484,7 +508,7 @@ namespace HandBrake.ApplicationServices.Model {
if (this.OutputFormat == OutputFormat.M4V || this.OutputFormat == OutputFormat.Mp4)
{
- bool audio = this.AudioTracks.Any(item => item.Encoder == AudioEncoder.Ac3Passthrough ||
+ bool audio = this.AudioTracks.Any(item => item.Encoder == AudioEncoder.Ac3Passthrough ||
item.Encoder == AudioEncoder.Ac3 || item.Encoder == AudioEncoder.DtsPassthrough || item.Encoder == AudioEncoder.Passthrough);
bool subtitles = this.SubtitleTracks.Any(track => track.SubtitleType != SubtitleType.VobSub);
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/OutputFormat.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/OutputFormat.cs index 9323cc862..d9070de2f 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/OutputFormat.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/OutputFormat.cs @@ -24,5 +24,8 @@ namespace HandBrake.ApplicationServices.Model.Encoding [Description("MKV")]
Mkv,
+
+ [Description("X265")]
+ X265,
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 9651c6e71..aa9842124 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -15,6 +15,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Model.Encoding;
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
@@ -296,6 +297,8 @@ namespace HandBrake.ApplicationServices.Utilities return VideoEncoder.QuickSync;
case "theora":
return VideoEncoder.Theora;
+ case "hevc":
+ return VideoEncoder.X265;
default:
return VideoEncoder.X264;
}
@@ -324,6 +327,8 @@ namespace HandBrake.ApplicationServices.Utilities return "qsv_h264";
case VideoEncoder.Theora:
return "theora";
+ case VideoEncoder.X265:
+ return "hevc";
default:
return "x264";
}
@@ -429,6 +434,94 @@ namespace HandBrake.ApplicationServices.Utilities #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>
@@ -450,6 +543,8 @@ namespace HandBrake.ApplicationServices.Utilities return OutputFormat.Mp4;
case "mkv":
return OutputFormat.Mkv;
+ case "x265":
+ return OutputFormat.X265;
}
}
@@ -472,6 +567,8 @@ namespace HandBrake.ApplicationServices.Utilities return "m4v";
case OutputFormat.Mkv:
return "mkv";
+ case OutputFormat.X265:
+ return "x265";
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index 67f243432..a4aacac7f 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -135,6 +135,9 @@ namespace HandBrake.ApplicationServices.Utilities case OutputFormat.Mkv:
profile.ContainerName = "av_mkv"; // TODO make part of enum.
break;
+ case OutputFormat.X265:
+ profile.ContainerName = "x265"; // TODO make part of enum.
+ break;
}
// Picture Settings
@@ -196,6 +199,10 @@ namespace HandBrake.ApplicationServices.Utilities profile.X264Tunes.Add("fastdecode");
}
+ profile.X265Preset = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);
+ profile.X265Profile = work.H265Profile.ToString().ToLower().Replace(" ", string.Empty);
+ profile.X265Tunes = new List<string>();
+
// Chapter Markers
profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
job.CustomChapterNames = work.ChapterNames.Select(item => item.ChapterName).ToList();
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 25c3a1426..7448f4bc5 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -281,6 +281,10 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0");
AddEncodeElement(xmlWriter, "qsvPreset", "string", parsed.QsvPreset.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "h265Profile", "string", parsed.H265Profile.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "x265Preset", "string", parsed.X265Preset.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "x265Tune", "string", parsed.X265Tune.ToString().ToLower());
+
int videoQualityType = 0;
if (parsed.VideoBitrate != null) videoQualityType = 1;
else if (parsed.Quality != null) videoQualityType = 2;
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index b1db2fcaa..8b246b58c 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -22,6 +22,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
+ using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// Generate a CLI Query for HandBrakeCLI
@@ -435,6 +436,9 @@ namespace HandBrake.ApplicationServices.Utilities default:
query += " -e x264";
break;
+ case VideoEncoder.X265:
+ query += " -e x265";
+ break;
}
switch (task.VideoEncodeRateType)
@@ -457,6 +461,9 @@ namespace HandBrake.ApplicationServices.Utilities case VideoEncoder.Theora:
query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
break;
+ case VideoEncoder.X265:
+ query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
+ break;
}
break;
}
@@ -937,6 +944,36 @@ namespace HandBrake.ApplicationServices.Utilities }
}
+ // X265 Only
+ if (task.VideoEncoder == VideoEncoder.X265)
+ {
+ if (!task.ShowAdvancedTab)
+ {
+ if (task.X265Preset != x265Preset.VeryFast)
+ {
+ query += string.Format(
+ " --x265-preset={0} ", task.X265Preset.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (task.X265Tune != x265Tune.None)
+ {
+ query += string.Format(
+ " --x265-tune=\"{0}\" ", task.X265Tune.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (task.H265Profile != x265Profile.None)
+ {
+ query += string.Format(
+ " --h265-profile={0} ", task.H265Profile.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
+ {
+ query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
+ }
+ }
+ }
+
// QSV Only
if (task.VideoEncoder == VideoEncoder.QuickSync)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index 4872d6e7d..a3cfae6fe 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -115,6 +115,9 @@ namespace HandBrake.ApplicationServices.Utilities 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 ]*)");
#endregion
#region Set Varibles
@@ -476,7 +479,38 @@ namespace HandBrake.ApplicationServices.Utilities parsed.X264Tune = Converters.Getx264TuneFromCli(tuneOptions);
}
-
+
+
+
+
+
+
+ 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 (x265Profile.Success)
+ parsed.H265Profile =
+ Converters.Getx265ProfileFromCli(x265Profile.ToString().Replace("--x265-profile", string.Empty).Replace("=", string.Empty).Trim());
+
+ if (x265Tune.Success)
+ {
+ string tuneOptions =
+ x265Tune.ToString().Replace("--x265-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.X265Tune = Converters.Getx265TuneFromCli(tuneOptions);
+ }
+
#endregion
}
catch (Exception exc)
|