summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2016-04-09 14:46:54 +0100
committersr55 <[email protected]>2016-04-09 14:46:54 +0100
commitfc3324c8fa6c0aaa37c89d8d0bf098092d705932 (patch)
tree6789acc002fdd809e8327eb2d42bed9f440cf89e /win/CS/HandBrakeWPF/Services
parentca2fc63cfd6a47920492bc96c3efd7e207af817d (diff)
WinGui: Use Mixdowns from LibHBand sanitise the choices. The GUI no longer shows invalid mixdowns.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs48
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs5
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/LibScan.cs3
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs11
5 files changed, 43 insertions, 26 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
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index 7bcbc6a08..c8331076b 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -14,6 +14,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
using System.Globalization;
using System.Linq;
+ using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
@@ -399,7 +400,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
// track.CompressionLevel = audioTrack.AudioCompressionLevel;
// track.AudioDitherMethod = audioTrack.AudioDitherMethod;
track.Encoder = EnumHelper<AudioEncoder>.GetValue(audioTrack.AudioEncoder);
- track.MixDown = EnumHelper<Mixdown>.GetValue(audioTrack.AudioMixdown);
+ track.MixDown = audioTrack.AudioMixdown;
// track.AudioNormalizeMixLevel = audioTrack.AudioNormalizeMixLevel;
track.SampleRate = audioTrack.AudioSamplerate == "auto" ? 0 : double.Parse(audioTrack.AudioSamplerate);
@@ -540,7 +541,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
AudioCompressionLevel = 0, // TODO
AudioDitherMethod = null, // TODO
AudioEncoder = EnumHelper<AudioEncoder>.GetShortName(item.Encoder),
- AudioMixdown = EnumHelper<Mixdown>.GetShortName(item.MixDown),
+ AudioMixdown = item.MixDown,
AudioNormalizeMixLevel = false, // TODO
AudioSamplerate = item.SampleRate == 0 ? "auto" : item.SampleRate.ToString(), // TODO check formatting.
AudioTrackDRCSlider = item.DRC,
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
index d72593cff..23d38af4e 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
@@ -384,7 +384,8 @@ namespace HandBrakeWPF.Services.Scan
int currentAudioTrack = 1;
foreach (SourceAudioTrack track in title.AudioList)
{
- converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate));
+
+ converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate, track.ChannelLayout));
currentAudioTrack++;
}
diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs
index 1f0a2af98..ca2841bee 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs
@@ -48,8 +48,12 @@ namespace HandBrakeWPF.Services.Scan.Model
/// <param name="bitrate">
/// The bitrate.
/// </param>
- public Audio(int trackNumber, string language, string languageCode, string description, string format, int sampleRate, int bitrate)
+ /// <param name="channelLayout">
+ /// The channel Layout.
+ /// </param>
+ public Audio(int trackNumber, string language, string languageCode, string description, string format, int sampleRate, int bitrate, int channelLayout)
{
+ this.ChannelLayout = channelLayout;
this.TrackNumber = trackNumber;
this.Language = language;
this.LanguageCode = languageCode;
@@ -95,6 +99,11 @@ namespace HandBrakeWPF.Services.Scan.Model
public int Bitrate { get; set; }
/// <summary>
+ /// Gets or sets the channel layout of the source track (mixdown)
+ /// </summary>
+ public int ChannelLayout { get; set; }
+
+ /// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// </summary>
/// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>