From 93235d2c7d15e031015ebbbfeefa14778fe9a56e Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 28 Dec 2012 11:21:14 +0000 Subject: WinGui: Initial work to implement x264 Preset/Tune/Profile/Level options in-gui. Still some stuff to tidy up but should be usable for now. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5113 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Model/EncodeTask.cs | 24 +++++++---- .../Services/Encode.cs | 3 +- .../Utilities/Converters.cs | 2 - .../Utilities/QueryGeneratorUtility.cs | 33 +++++++++++++--- .../Utilities/QueryParserUtility.cs | 46 +++++++++++++--------- 5 files changed, 74 insertions(+), 34 deletions(-) (limited to 'win/CS/HandBrake.ApplicationServices') diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index e7869459b..9f5c043a0 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -34,8 +34,8 @@ namespace HandBrake.ApplicationServices.Model this.SubtitleTracks = new ObservableCollection(); this.ChapterNames = new ObservableCollection(); this.AllowedPassthruOptions = new AllowedPassthru(); - this.x264Preset = x264Preset.None; - this.x264Profile = x264Profile.None; + this.X264Preset = x264Preset.Medium; + this.H264Profile = x264Profile.None; this.X264Tune = x264Tune.None; this.Modulus = 16; } @@ -60,7 +60,6 @@ namespace HandBrake.ApplicationServices.Model this.AudioTracks.Add(new AudioTrack(track)); } - this.ChapterNames = new ObservableCollection(); foreach (ChapterMarker track in task.ChapterNames) { @@ -115,9 +114,10 @@ namespace HandBrake.ApplicationServices.Model this.VideoEncoder = task.VideoEncoder; this.VideoEncodeRateType = task.VideoEncodeRateType; this.Width = task.Width; - this.x264Preset = task.x264Preset; - this.x264Profile = task.x264Profile; + this.X264Preset = task.X264Preset; + this.H264Profile = task.H264Profile; this.X264Tune = task.X264Tune; + this.FastDecode = task.FastDecode; this.PreviewStartAt = task.PreviewStartAt; this.PreviewDuration = task.PreviewDuration; @@ -399,18 +399,28 @@ namespace HandBrake.ApplicationServices.Model /// /// Gets or sets x264Preset. /// - public x264Preset x264Preset { get; set; } + public x264Preset X264Preset { get; set; } /// /// Gets or sets x264Profile. /// - public x264Profile x264Profile { get; set; } + public x264Profile H264Profile { get; set; } + + /// + /// Gets or sets the x 264 level. + /// + public string H264Level { get; set; } /// /// Gets or sets X264Tune. /// public x264Tune X264Tune { get; set; } + /// + /// Gets or sets a value indicating whether fast decode. + /// + public bool FastDecode { get; set; } + #endregion #region Preview diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 0c35c8f41..ce75267c5 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -67,8 +67,7 @@ namespace HandBrake.ApplicationServices.Services : base(userSettingService) { this.userSettingService = userSettingService; - this.EncodeStarted += this.EncodeEncodeStarted; - + this.EncodeStarted += this.EncodeEncodeStarted; } #region Properties diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 0638a8e28..46e696ca1 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -470,8 +470,6 @@ namespace HandBrake.ApplicationServices.Utilities return x264Tune.Ssim; case "fastdecode": return x264Tune.Fastdecode; - case "zerolatency": - return x264Tune.Zerolatency; default: return x264Tune.Film; } diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index a6dc97758..b6fc06faf 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -45,6 +45,11 @@ namespace HandBrake.ApplicationServices.Utilities /// public static string GenerateQuery(EncodeTask task, int previewScanCount, int verbosity, bool disableLibDvdNav) { + if (string.IsNullOrEmpty(task.Source)) + { + return "No source selected"; + } + string query = string.Empty; query += SourceQuery(task, null, null, previewScanCount); query += DestinationQuery(task); @@ -898,19 +903,37 @@ namespace HandBrake.ApplicationServices.Utilities { string query = string.Empty; - if (task.x264Preset != x264Preset.None) + if (task.X264Preset != x264Preset.Medium) { - query += string.Format("--x264-preset={0} ", task.x264Preset.ToString().ToLower().Replace(" ", string.Empty)); + query += string.Format(" --x264-preset={0} ", task.X264Preset.ToString().ToLower().Replace(" ", string.Empty)); } - if (task.x264Profile != x264Profile.None) + if (task.H264Profile != x264Profile.None) { - query += string.Format("--x264-profile={0} ", task.x264Profile.ToString().ToLower().Replace(" ", string.Empty)); + query += string.Format(" --x264-profile={0} ", task.H264Profile.ToString().ToLower().Replace(" ", string.Empty)); } if (task.X264Tune != x264Tune.None) { - query += string.Format("--x264-tune={0} ", task.X264Tune.ToString().ToLower().Replace(" ", string.Empty)); + 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(" --x264-tune=\"{0}\" ", tune); + } + + if (task.H264Level != "Auto") + { + query += string.Format(" --h264-level=\"{0}\" ", task.H264Level); } if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions)) diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index f0b5d65e3..eae37e2b5 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -91,12 +91,9 @@ 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"); - Match audioTracks = Regex.Match(input, @"-a ([0-9,]+)"); Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]+)"); Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,:\*]+)"); Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]+)"); // Auto = a-z @@ -112,9 +109,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 x264Profile = Regex.Match(input, @"--x264-profile([=a-zA-Z0-9\s]*)"); + 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 ]*)"); #endregion @@ -243,7 +242,6 @@ namespace HandBrake.ApplicationServices.Utilities parsed.CustomDecomb = value; parsed.Decomb = parsed.CustomDecomb == "7:2:6:9:1:80" ? Decomb.Fast : Decomb.Custom; } - } } @@ -364,7 +362,6 @@ namespace HandBrake.ApplicationServices.Utilities } // Get the data from the regular expression results - string[] trackData = null; string[] trackMixes = null; string[] trackEncoders = null; string[] trackBitrates = null; @@ -372,8 +369,6 @@ namespace HandBrake.ApplicationServices.Utilities string[] trackDRCvalues = null; string[] trackGainValues = null; - if (audioTracks.Success) - trackData = audioTracks.ToString().Replace("-a ", string.Empty).Split(','); if (audioTrackMixes.Success) trackMixes = audioTrackMixes.ToString().Replace("-6 ", string.Empty).Split(','); if (audioEncoders.Success) @@ -392,9 +387,6 @@ namespace HandBrake.ApplicationServices.Utilities for (int x = 0; x < encoderCount; x++) { AudioTrack track = new AudioTrack(); - //if (trackData != null) - // if (trackData.Length >= (x + 1)) // Audio Track - // track.ScannedTrack = trackData[x].Trim(); if (trackMixes != null) if (trackMixes.Length >= (x + 1)) // Audio Mix @@ -457,17 +449,35 @@ namespace HandBrake.ApplicationServices.Utilities parsed.AdvancedEncoderOptions = advanced.ToString().Replace("-x ", string.Empty); if (x264Preset.Success) - parsed.x264Preset = + 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.x264Profile = - Converters.Getx264ProfileFromCli(x264Profile.ToString().Replace("--x264-profile", string.Empty).Replace("=", string.Empty).Trim()); + 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) - parsed.X264Tune = - Converters.Getx264TuneFromCli(x264Tune.ToString().Replace("--x264-tune", string.Empty).Replace("=", string.Empty).Trim()); + { + 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); + } + #endregion } catch (Exception exc) -- cgit v1.2.3