summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Model
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-04-10 17:03:32 +0100
committersr55 <[email protected]>2017-04-10 17:03:32 +0100
commit0a8dde9d78fc57ef19e53f50405e9a3124802267 (patch)
tree5df830153170aba79732971a07d250c7193f29ac /win/CS/HandBrakeWPF/Model
parentd2f892878a87fa6b62996f76c1e4bd9f6c0212e7 (diff)
WinGui: Audio Defaults: Improve the Mixdown dropdown. Only show supported mixdowns and automatically select the highest available mixdown if the encoder is limited and doesn't support the current selection.
Diffstat (limited to 'win/CS/HandBrakeWPF/Model')
-rw-r--r--win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
index 78c20d52c..c59b15b8c 100644
--- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
+++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
@@ -10,6 +10,7 @@
namespace HandBrakeWPF.Model.Audio
{
using System.Collections.Generic;
+ using System.ComponentModel;
using System.Globalization;
using System.Linq;
using HandBrake.ApplicationServices.Interop;
@@ -35,6 +36,7 @@ namespace HandBrakeWPF.Model.Audio
private IEnumerable<double> encoderQualityValues;
private AudioEncoderRateType encoderRateType;
private double? quality;
+ private IEnumerable<HBMixdown> mixdowns;
/// <summary>
/// Initializes a new instance of the <see cref="AudioBehaviourTrack"/> class.
@@ -48,6 +50,7 @@ namespace HandBrakeWPF.Model.Audio
this.Bitrate = 160;
this.DRC = 0;
this.EncoderRateType = AudioEncoderRateType.Bitrate;
+
this.SetupLimits();
}
@@ -68,6 +71,7 @@ namespace HandBrakeWPF.Model.Audio
this.sampleRate = track.SampleRate;
this.Quality = track.Quality;
this.encoderRateType = track.EncoderRateType;
+
this.SetupLimits();
}
@@ -354,6 +358,15 @@ namespace HandBrakeWPF.Model.Audio
}
}
+ [JsonIgnore]
+ public IEnumerable<HBMixdown> Mixdowns
+ {
+ get
+ {
+ return this.mixdowns;
+ }
+ }
+
/// <summary>
/// Gets the quality compression values.
/// </summary>
@@ -466,6 +479,7 @@ namespace HandBrakeWPF.Model.Audio
{
this.SetupBitrateLimits();
this.SetupQualityCompressionLimits();
+ this.SetupMixdowns();
}
/// <summary>
@@ -566,6 +580,34 @@ namespace HandBrakeWPF.Model.Audio
}
/// <summary>
+ /// Restrict the available mixdowns to those that the enocder actually supports.
+ /// </summary>
+ private void SetupMixdowns()
+ {
+ this.mixdowns = new BindingList<HBMixdown>(HandBrakeEncoderHelpers.Mixdowns.ToList());
+
+ HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
+
+ BindingList<HBMixdown> mixdownList = new BindingList<HBMixdown>();
+ foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns)
+ {
+ if (HandBrakeEncoderHelpers.MixdownHasCodecSupport(mixdown, audioEncoder))
+ {
+ mixdownList.Add(mixdown);
+ }
+ }
+
+ this.mixdowns = new BindingList<HBMixdown>(mixdownList);
+ this.NotifyOfPropertyChange(() => this.Mixdowns);
+
+ // If the mixdown isn't supported, downgrade it to the best available.
+ if (!this.Mixdowns.Contains(this.MixDown))
+ {
+ this.MixDown = this.Mixdowns.LastOrDefault();
+ }
+ }
+
+ /// <summary>
/// Set the default mixdown when the mixdown is null or "none"
/// </summary>
private void GetDefaultMixdownIfNull()