]> granicus.if.org Git - handbrake/commitdiff
WinGui: Updated the Bitrate Converted to be a bit more intelligent about it's bitrate...
authorsr55 <sr55.hb@outlook.com>
Fri, 7 Sep 2012 21:40:41 +0000 (21:40 +0000)
committersr55 <sr55.hb@outlook.com>
Fri, 7 Sep 2012 21:40:41 +0000 (21:40 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4937 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs

index 6e5803c097e858c1706193270a664a109352ea2a..ac4b95e323cd3c38b5769f995ec6f1511e9bf4a7 100644 (file)
@@ -254,6 +254,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
             {\r
                 this.sampleRate = value;\r
                 this.NotifyOfPropertyChange("SampleRate");\r
+                this.NotifyOfPropertyChange("TrackReference");\r
             }\r
         }\r
 \r
index 28e31b07d2ab7c38d6af531728d4cabf8057fbeb..89016071ecbac1517c34beea1d3ee692ad37011a 100644 (file)
@@ -46,23 +46,56 @@ namespace HandBrakeWPF.Converters.Audio
             List<int> bitrates = new List<int> { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 640, 768 };\r
 \r
             int max = 160;\r
+\r
             AudioTrack track = value as AudioTrack;\r
             if (track != null)\r
             {\r
+                int channels = this.GetChannelCount(track.MixDown);\r
+\r
+                double samplerate = 48; // Default\r
+\r
+                if (!track.SampleRate.Equals(0.0d))\r
+                {\r
+                    samplerate = track.SampleRate;\r
+                }\r
+                else if (track.ScannedTrack != null && track.ScannedTrack.SampleRate != 0)\r
+                {\r
+                    samplerate = track.ScannedTrack.SampleRate / 1000d;\r
+                }\r
+             \r
                 switch (track.Encoder)\r
                 {\r
                     case AudioEncoder.Faac:\r
                     case AudioEncoder.ffaac:\r
-                        max = track.MixDown >= Mixdown.FivePoint1Channels ? 768 : 320;\r
+                        if (samplerate > 24)\r
+                        {\r
+                            max = 160 * channels;\r
+                            if (max > 768)\r
+                            {\r
+                                max = 768;\r
+                            }\r
+                        }\r
+                        else\r
+                        {\r
+                            max = 96 * channels;\r
+                            if (max > 480)\r
+                            {\r
+                                max = 480;\r
+                            }\r
+                        }\r
                         break;\r
                     case AudioEncoder.Lame:\r
-                        max = 320;\r
+                        max = samplerate > 24 ? 320 : 160;\r
                         break;\r
                     case AudioEncoder.Vorbis:\r
-                        max = 384;\r
+                        max = samplerate > 24\r
+                                  ? (channels > 2\r
+                                         ? 128 * channels\r
+                                         : (track.SampleRate > 32 ? 224 * channels : 160 * channels))\r
+                                  : 80 * this.GetChannelCount(track.MixDown);\r
                         break;\r
                     case AudioEncoder.Ac3:\r
-                        max = 640;\r
+                        max = samplerate > 24 ? 640 : 320;\r
                         break;\r
                     case AudioEncoder.Ac3Passthrough:\r
                     case AudioEncoder.DtsPassthrough:\r
@@ -88,6 +121,38 @@ namespace HandBrakeWPF.Converters.Audio
             return bitrates.Where(bitrate => bitrate <= max);\r
         }\r
 \r
+        /// <summary>\r
+        /// The get channel count.\r
+        /// </summary>\r
+        /// <param name="mixdown">\r
+        /// The mixdown.\r
+        /// </param>\r
+        /// <returns>\r
+        /// The System.Int32.\r
+        /// </returns>\r
+        private int GetChannelCount(Mixdown mixdown)\r
+        {\r
+            switch (mixdown)\r
+            {\r
+                case Mixdown.Five_2_LFE:\r
+                case Mixdown.SevenPoint1Channels:\r
+                    return 8;\r
+                case Mixdown.SixPoint1Channels:\r
+                    return 7;\r
+                case Mixdown.FivePoint1Channels:\r
+                    return 6;\r
+                case Mixdown.Mono:\r
+                case Mixdown.LeftOnly:\r
+                case Mixdown.RightOnly:\r
+                    return 1;\r
+                case Mixdown.None:\r
+                    return 0;\r
+                default:\r
+                    return 2;\r
+            }\r
+        }\r
+\r
+\r
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\r
         {\r
             throw new NotImplementedException();\r