diff options
author | sr55 <[email protected]> | 2017-05-31 20:56:25 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-05-31 20:56:25 +0100 |
commit | 5e787c33895fbfa0e91b4b802c0ee85b6fd2c36f (patch) | |
tree | b245930a68924e3d4259d71fefed3e3f71362750 /win/CS | |
parent | 37642a848bfaa1ba85ba12067a9b1c4e9c28e953 (diff) |
WinGui: Add "None" as an option to the fallback encoder dropdown. Setting this option to none will not add a passthru track when the passthru codec does not match the source track. #623
Diffstat (limited to 'win/CS')
3 files changed, 36 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs index 7f70288ce..4c3bd59b5 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs @@ -56,6 +56,8 @@ namespace HandBrakeWPF.Converters.Audio List<AudioEncoder> encoders = EnumHelper<AudioEncoder>.GetEnumList().ToList();
EncodeTask task = values[1] as EncodeTask;
+ encoders.Remove(AudioEncoder.None); // Assume we never want to show this.
+
if (!HandBrakeEncoderHelpers.AudioEncoders.Any(a => a.ShortName.Contains("fdk")))
{
encoders.Remove(AudioEncoder.fdkaac);
@@ -71,6 +73,7 @@ namespace HandBrakeWPF.Converters.Audio encoders.Remove(AudioEncoder.Opus);
}
+ // Hide the Passthru options and show the "None" option
if (parameter != null && parameter.ToString() == "True")
{
encoders.Remove(AudioEncoder.DtsHDPassthrough);
@@ -82,6 +85,8 @@ namespace HandBrakeWPF.Converters.Audio encoders.Remove(AudioEncoder.Passthrough);
encoders.Remove(AudioEncoder.TrueHDPassthrough);
encoders.Remove(AudioEncoder.FlacPassthru);
+
+ encoders.Add(AudioEncoder.None);
}
return EnumHelper<AudioEncoder>.GetEnumDisplayValuesSubset(encoders);
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs index 2d659bd39..3f415e60e 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs @@ -16,6 +16,10 @@ namespace HandBrakeWPF.Services.Encode.Model.Models /// </summary> public enum AudioEncoder { + [DisplayName("None")] + [ShortName("none")] + None, + [DisplayName("AAC (avcodec)")] [ShortName("av_aac")] ffaac, diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index ff7a8376f..771267e26 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -353,12 +353,18 @@ namespace HandBrakeWPF.ViewModels {
case AudioTrackDefaultsMode.FirstTrack:
AudioBehaviourTrack template = this.AudioBehaviours.BehaviourTracks.FirstOrDefault();
- this.Task.AudioTracks.Add(template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ if (this.CanAddTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))
+ {
+ this.Task.AudioTracks.Add( template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ }
break;
case AudioTrackDefaultsMode.AllTracks:
foreach (AudioBehaviourTrack tmpl in this.AudioBehaviours.BehaviourTracks)
{
- this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ if (this.CanAddTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))
+ {
+ this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ }
}
break;
@@ -367,6 +373,20 @@ namespace HandBrakeWPF.ViewModels }
}
+ private bool CanAddTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback)
+ {
+ if (fallback == AudioEncoder.None)
+ {
+ HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(track.Encoder));
+ if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/// <summary>
/// Add all source tracks that don't currently exist on the list.
/// </summary>
@@ -410,7 +430,11 @@ namespace HandBrakeWPF.ViewModels // Step 3, Setup the tracks from the preset
foreach (AudioBehaviourTrack track in this.AudioBehaviours.BehaviourTracks)
{
- this.Task.AudioTracks.Add(new AudioTrack(track, this.GetPreferredAudioTrack(), this.Task.AllowedPassthruOptions.AudioEncoderFallback));
+ Audio sourceTrack = this.GetPreferredAudioTrack();
+ if (this.CanAddTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback))
+ {
+ this.Task.AudioTracks.Add(new AudioTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback));
+ }
}
// Step 4, Handle the default selection behaviour.
|