]> granicus.if.org Git - handbrake/commitdiff
WinGui: Add "None" as an option to the fallback encoder dropdown. Setting this option...
authorsr55 <sr55.hb@outlook.com>
Wed, 31 May 2017 19:56:25 +0000 (20:56 +0100)
committersr55 <sr55.hb@outlook.com>
Wed, 31 May 2017 19:56:25 +0000 (20:56 +0100)
win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs
win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs
win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs

index 7f70288ce8e8ea3b3be79045d5daadb8827f34de..4c3bd59b5810b66b3850b43749c0dfcb2f7ef4ee 100644 (file)
@@ -56,6 +56,8 @@ namespace HandBrakeWPF.Converters.Audio
                 List<AudioEncoder> encoders = EnumHelper<AudioEncoder>.GetEnumList().ToList();\r
                 EncodeTask task = values[1] as EncodeTask;\r
 \r
+                encoders.Remove(AudioEncoder.None); // Assume we never want to show this.\r
+\r
                 if (!HandBrakeEncoderHelpers.AudioEncoders.Any(a => a.ShortName.Contains("fdk")))\r
                 {\r
                     encoders.Remove(AudioEncoder.fdkaac);\r
@@ -71,6 +73,7 @@ namespace HandBrakeWPF.Converters.Audio
                     encoders.Remove(AudioEncoder.Opus);\r
                 }\r
 \r
+                // Hide the Passthru options and show the "None" option\r
                 if (parameter != null && parameter.ToString() == "True")\r
                 {\r
                     encoders.Remove(AudioEncoder.DtsHDPassthrough);\r
@@ -82,6 +85,8 @@ namespace HandBrakeWPF.Converters.Audio
                     encoders.Remove(AudioEncoder.Passthrough);\r
                     encoders.Remove(AudioEncoder.TrueHDPassthrough);\r
                     encoders.Remove(AudioEncoder.FlacPassthru);\r
+\r
+                    encoders.Add(AudioEncoder.None);\r
                 }\r
 \r
                 return EnumHelper<AudioEncoder>.GetEnumDisplayValuesSubset(encoders);\r
index 2d659bd398fa3c0a2df9f7e07d9488fbac2743c7..3f415e60e5a05a41986608d2211b5378d3d54cf0 100644 (file)
@@ -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,
index ff7a8376fea5fb060ea2f36bb0624f55ac838a2f..771267e26002ad3cb4d2ec7936ef7f09192265b6 100644 (file)
@@ -353,12 +353,18 @@ namespace HandBrakeWPF.ViewModels
                     {\r
                         case AudioTrackDefaultsMode.FirstTrack:\r
                             AudioBehaviourTrack template = this.AudioBehaviours.BehaviourTracks.FirstOrDefault();\r
-                            this.Task.AudioTracks.Add(template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+                            if (this.CanAddTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))\r
+                            {\r
+                                this.Task.AudioTracks.Add( template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+                            }\r
                             break;\r
                         case AudioTrackDefaultsMode.AllTracks:\r
                             foreach (AudioBehaviourTrack tmpl in this.AudioBehaviours.BehaviourTracks)\r
                             {\r
-                                this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+                                if (this.CanAddTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))\r
+                                {\r
+                                    this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+                                }\r
                             }\r
 \r
                             break;\r
@@ -367,6 +373,20 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        private bool CanAddTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback)\r
+        {\r
+            if (fallback == AudioEncoder.None)\r
+            {\r
+                HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(track.Encoder));\r
+                if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0)\r
+                {\r
+                    return false;\r
+                }\r
+            }\r
+\r
+            return true;\r
+        }\r
+\r
         /// <summary>\r
         /// Add all source tracks that don't currently exist on the list.\r
         /// </summary>\r
@@ -410,7 +430,11 @@ namespace HandBrakeWPF.ViewModels
             // Step 3, Setup the tracks from the preset\r
             foreach (AudioBehaviourTrack track in this.AudioBehaviours.BehaviourTracks)\r
             {\r
-                this.Task.AudioTracks.Add(new AudioTrack(track, this.GetPreferredAudioTrack(), this.Task.AllowedPassthruOptions.AudioEncoderFallback));\r
+                Audio sourceTrack = this.GetPreferredAudioTrack();\r
+                if (this.CanAddTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback))\r
+                {\r
+                    this.Task.AudioTracks.Add(new AudioTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback));\r
+                }\r
             }\r
            \r
             // Step 4, Handle the default selection behaviour.\r