diff options
author | sr55 <[email protected]> | 2016-04-09 14:46:54 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2016-04-09 14:46:54 +0100 |
commit | fc3324c8fa6c0aaa37c89d8d0bf098092d705932 (patch) | |
tree | 6789acc002fdd809e8327eb2d42bed9f440cf89e /win/CS/HandBrakeWPF/Services/Encode | |
parent | ca2fc63cfd6a47920492bc96c3efd7e207af817d (diff) |
WinGui: Use Mixdowns from LibHBand sanitise the choices. The GUI no longer shows invalid mixdowns.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Encode')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs | 48 |
2 files changed, 28 insertions, 22 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs index cd4fbb44f..ea90a50f3 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs @@ -339,7 +339,7 @@ namespace HandBrakeWPF.Services.Encode.Factories HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(item.Encoder)); Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); - HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(item.MixDown)); + HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(item.MixDown); Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.MixDown); HBRate sampleRate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(s => s.Name == item.SampleRate.ToString(CultureInfo.InvariantCulture)); diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs index 87e6caaaa..b875df16c 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs @@ -34,7 +34,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models private double drc; private HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder encoder; private int gain; - private Mixdown mixDown; + private string mixDown; private double sampleRate; [NonSerialized] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -52,7 +52,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models { // Default Values this.Encoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder.ffaac; - this.MixDown = Mixdown.DolbyProLogicII; + this.MixDown = HandBrakeEncoderHelpers.Mixdowns.FirstOrDefault(m => m.ShortName == "dpl2")?.ShortName; this.SampleRate = 48; this.Bitrate = 160; this.DRC = 0; @@ -137,13 +137,13 @@ namespace HandBrakeWPF.Services.Encode.Model.Models } /// <summary> - /// Gets or sets Audio Mixdown + /// Gets or sets Audio Mixdown (ShortName) /// </summary> - public Mixdown MixDown + public string MixDown { get { - return this.IsPassthru ? Mixdown.Auto : this.mixDown; + return this.IsPassthru ? null : this.mixDown; } set @@ -151,7 +151,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models this.mixDown = value; this.NotifyOfPropertyChange(() => this.MixDown); this.SetupLimits(); - this.NotifyOfPropertyChange(() => this.TrackReference); } } @@ -173,8 +172,9 @@ namespace HandBrakeWPF.Services.Encode.Model.Models this.NotifyOfPropertyChange(() => this.IsBitrateVisible); this.NotifyOfPropertyChange(() => this.IsQualityVisible); this.NotifyOfPropertyChange(() => this.IsRateTypeVisible); - this.SetupLimits(); this.NotifyOfPropertyChange(() => this.TrackReference); + this.GetDefaultMixdownIfNull(); + this.SetupLimits(); // Refresh the available encoder rate types. this.NotifyOfPropertyChange(() => this.AudioEncoderRateTypes); @@ -200,7 +200,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models this.sampleRate = value; this.NotifyOfPropertyChange(() => this.SampleRate); this.SetupLimits(); - this.NotifyOfPropertyChange(() => this.TrackReference); } } @@ -283,18 +282,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models } /// <summary> - /// Gets AudioMixdownDisplayValue. - /// </summary> - [JsonIgnore] - public string AudioMixdownDisplayValue - { - get - { - return EnumHelper<Mixdown>.GetDisplay(this.MixDown); - } - } - - /// <summary> /// Gets the The UI display value for bit rate /// </summary> [JsonIgnore] @@ -369,6 +356,9 @@ namespace HandBrakeWPF.Services.Encode.Model.Models { this.scannedTrack = value; this.NotifyOfPropertyChange(() => this.ScannedTrack); + this.NotifyOfPropertyChange(() => this.TrackReference); + + this.GetDefaultMixdownIfNull(); } } @@ -550,7 +540,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models // Based on the users settings, find the high and low bitrates. HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder>.GetShortName(this.Encoder)); HBRate rate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(t => t.Name == this.SampleRate.ToString(CultureInfo.InvariantCulture)); - HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(this.MixDown)); + HBMixdown mixdown = this.mixDown != null ? HandBrakeEncoderHelpers.GetMixdown(this.mixDown) : HandBrakeEncoderHelpers.GetMixdown("dpl2"); BitrateLimits limits = HandBrakeEncoderHelpers.GetBitrateLimits(hbaenc, rate != null ? rate.Rate : 48000, mixdown); if (limits != null) @@ -632,6 +622,22 @@ namespace HandBrakeWPF.Services.Encode.Model.Models this.NotifyOfPropertyChange(() => this.EncoderQualityValues); } + /// <summary> + /// Set the default mixdown when the mixdown is null or "none" + /// </summary> + private void GetDefaultMixdownIfNull() + { + if ((this.mixDown == null || this.mixDown == "none" ) && this.ScannedTrack != null) + { + HBAudioEncoder aencoder = + HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.encoder)); + + HBMixdown mixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(aencoder, (uint)this.ScannedTrack.ChannelLayout); + + this.MixDown = mixdown.ShortName; + } + } + #endregion } }
\ No newline at end of file |