]> granicus.if.org Git - handbrake/commitdiff
WinGui: Removing some redundant code from the interop library.
authorsr55 <sr55.hb@outlook.com>
Sun, 18 Jan 2015 18:10:12 +0000 (18:10 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 18 Jan 2015 18:10:12 +0000 (18:10 +0000)
Fixed the libdvdnav option for the libhb based encoding.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6768 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/CroppingType.cs [deleted file]
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs

index 0fbc7dbfef2a4c432b128a6f35a715554f3816e7..215b05e021671a247f1d16584f1db55d32ddafcd 100644 (file)
@@ -134,6 +134,8 @@ namespace HandBrake.ApplicationServices.Services.Encode
                     this.ScanCompleted(job, this.instance);\r
                 };\r
 \r
+                HandBrakeUtils.SetDvdNav(!job.Configuration.IsDvdNavDisabled);\r
+\r
                 this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);\r
             }\r
             catch (Exception exc)\r
index 2ffc766b5fbc70999d7498a8ce8778759eba45cf..50388fc0d95335c8f8e4e9ab53b335d5d409c39d 100644 (file)
@@ -68,7 +68,6 @@ namespace HandBrake.ApplicationServices.Utilities
 \r
             // Audio Settings\r
             job.AudioEncodings = new List<AudioEncoding>();\r
-            job.ChosenAudioTracks = new List<int>();\r
             foreach (AudioTrack track in work.AudioTracks)\r
             {\r
                 AudioEncoding newTrack = new AudioEncoding\r
@@ -86,10 +85,6 @@ namespace HandBrake.ApplicationServices.Utilities
                                              };\r
 \r
                 job.AudioEncodings.Add(newTrack);\r
-                if (track.Track != null)\r
-                {\r
-                    job.ChosenAudioTracks.Add(track.Track.Value);\r
-                }\r
             }\r
 \r
             // Title Settings\r
@@ -155,7 +150,6 @@ namespace HandBrake.ApplicationServices.Utilities
             // Picture Settings\r
             job.Anamorphic = work.Anamorphic;\r
             job.Cropping = new Cropping { Top = work.Cropping.Top, Bottom = work.Cropping.Bottom, Left = work.Cropping.Left, Right = work.Cropping.Right };\r
-            job.CroppingType = CroppingType.Custom; // TODO deal with this better\r
             job.DisplayWidth = work.DisplayWidth.HasValue ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString()) : 0;\r
             job.PixelAspectX = work.PixelAspectX;\r
             job.PixelAspectY = work.PixelAspectY;\r
index 52939e219a7dcca7e1bfcd7477cc93d1de6a5330..7d5c59f0dcfaf900077a118a1d2a650d15153c83 100644 (file)
     <Compile Include="HandBrakeEncoderHelpers.cs" />\r
     <Compile Include="Model\Encoding\Anamorphic.cs" />\r
     <Compile Include="Model\Encoding\AudioEncodeRateType.cs" />\r
-    <Compile Include="Model\Encoding\CroppingType.cs" />\r
     <Compile Include="Model\Encoding\HBAudioEncoder.cs" />\r
     <Compile Include="Model\Encoding\AudioEncoder.cs" />\r
     <Compile Include="Model\Encoding\AudioEncoding.cs" />\r
index 1d7042ab3dac0a7d837ce0988b602ccb2e51c64e..1726ea635cb1ac4813b93bdf7524a721df19538e 100644 (file)
@@ -294,249 +294,6 @@ namespace HandBrake.Interop
             return x264Settings;\r
         }\r
 \r
-        /// <summary>\r
-        /// Gets the total number of seconds on the given encode job.\r
-        /// </summary>\r
-        /// <param name="job">\r
-        /// The encode job to query.\r
-        /// </param>\r
-        /// <param name="title">\r
-        /// The title being encoded.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The total number of seconds of video to encode.\r
-        /// </returns>\r
-        internal static double GetJobLengthSeconds(EncodeJob job, Title title)\r
-        {\r
-            switch (job.RangeType)\r
-            {\r
-                // case VideoRangeType.All:\r
-                //    return title.Duration.TotalSeconds;\r
-                case VideoRangeType.Chapters:\r
-                    TimeSpan duration = TimeSpan.Zero;\r
-                    for (int i = job.ChapterStart; i <= job.ChapterEnd; i++)\r
-                    {\r
-                        duration += title.Chapters[i - 1].Duration;\r
-                    }\r
-\r
-                    return duration.TotalSeconds;\r
-                case VideoRangeType.Seconds:\r
-                    return job.SecondsEnd - job.SecondsStart;\r
-                case VideoRangeType.Frames:\r
-                    return (job.FramesEnd - job.FramesStart) / title.Framerate;\r
-            }\r
-\r
-            return 0;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Gets the number of audio samples used per frame for the given audio encoder.\r
-        /// </summary>\r
-        /// <param name="encoderName">\r
-        /// The encoder to query.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The number of audio samples used per frame for the given\r
-        /// audio encoder.\r
-        /// </returns>\r
-        internal static int GetAudioSamplesPerFrame(string encoderName)\r
-        {\r
-            switch (encoderName)\r
-            {\r
-                case "faac":\r
-                case "ffaac":\r
-                case "copy:aac":\r
-                case "vorbis":\r
-                    return 1024;\r
-                case "lame":\r
-                case "copy:mp3":\r
-                    return 1152;\r
-                case "ffac3":\r
-                case "copy":\r
-                case "copy:ac3":\r
-                case "copy:dts":\r
-                case "copy:dtshd":\r
-                    return 1536;\r
-            }\r
-\r
-            // Unknown encoder; make a guess.\r
-            return 1536;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Gets the size in bytes for the audio with the given parameters.\r
-        /// </summary>\r
-        /// <param name="job">\r
-        /// The encode job.\r
-        /// </param>\r
-        /// <param name="lengthSeconds">\r
-        /// The length of the encode in seconds.\r
-        /// </param>\r
-        /// <param name="title">\r
-        /// The title to encode.\r
-        /// </param>\r
-        /// <param name="outputTrackList">\r
-        /// The list of tracks to encode.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The size in bytes for the audio with the given parameters.\r
-        /// </returns>\r
-        internal static long GetAudioSize(EncodeJob job, double lengthSeconds, Title title, List<Tuple<AudioEncoding, int>> outputTrackList)\r
-        {\r
-            long audioBytes = 0;\r
-\r
-            foreach (Tuple<AudioEncoding, int> outputTrack in outputTrackList)\r
-            {\r
-                AudioEncoding encoding = outputTrack.Item1;\r
-                AudioTrack track = title.AudioTracks[outputTrack.Item2 - 1];\r
-\r
-                int samplesPerFrame = GetAudioSamplesPerFrame(encoding.Encoder);\r
-                int audioBitrate;\r
-\r
-                HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(encoding.Encoder);\r
-\r
-                if (audioEncoder.IsPassthrough)\r
-                {\r
-                    // Input bitrate is in bits/second.\r
-                    audioBitrate = track.Bitrate / 8;\r
-                }\r
-                else if (encoding.EncodeRateType == AudioEncodeRateType.Quality)\r
-                {\r
-                    // Can't predict size of quality targeted audio encoding.\r
-                    audioBitrate = 0;\r
-                }\r
-                else\r
-                {\r
-                    int outputBitrate;\r
-                    if (encoding.Bitrate > 0)\r
-                    {\r
-                        outputBitrate = encoding.Bitrate;\r
-                    }\r
-                    else\r
-                    {\r
-                        outputBitrate = HandBrakeEncoderHelpers.GetDefaultBitrate(\r
-                            audioEncoder, \r
-                            encoding.SampleRateRaw == 0 ? track.SampleRate : encoding.SampleRateRaw,\r
-                            HandBrakeEncoderHelpers.SanitizeMixdown(HandBrakeEncoderHelpers.GetMixdown(encoding.Mixdown), audioEncoder, track.ChannelLayout));\r
-                    }\r
-\r
-                    // Output bitrate is in kbps.\r
-                    audioBitrate = outputBitrate * 1000 / 8;\r
-                }\r
-\r
-                audioBytes += (long)(lengthSeconds * audioBitrate);\r
-\r
-                // Audio overhead\r
-                audioBytes += encoding.SampleRateRaw * ContainerOverheadPerFrame / samplesPerFrame;\r
-            }\r
-\r
-            return audioBytes;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Calculates the video bitrate for the given job and target size.\r
-        /// </summary>\r
-        /// <param name="job">\r
-        /// The encode job.\r
-        /// </param>\r
-        /// <param name="title">\r
-        /// The title.\r
-        /// </param>\r
-        /// <param name="sizeMB">\r
-        /// The target size in MB.\r
-        /// </param>\r
-        /// <param name="overallSelectedLengthSeconds">\r
-        /// The currently selected encode length. Used in preview\r
-        /// for calculating bitrate when the target size would be wrong.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The video bitrate in kbps.\r
-        /// </returns>\r
-        public static int CalculateBitrate(EncodeJob job, Title title, int sizeMB, double overallSelectedLengthSeconds = 0)\r
-        {\r
-            long availableBytes = ((long)sizeMB) * 1024 * 1024;\r
-\r
-            EncodeJob profile = job;\r
-\r
-            double lengthSeconds = overallSelectedLengthSeconds > 0 ? overallSelectedLengthSeconds : GetJobLengthSeconds(job, title);\r
-            lengthSeconds += 1.5;\r
-\r
-            double outputFramerate;\r
-            if (profile.Framerate == 0)\r
-            {\r
-                outputFramerate = title.Framerate;\r
-            }\r
-            else\r
-            {\r
-                // Not sure what to do for VFR here hb_calc_bitrate never handled it...\r
-                //   just use the peak for now.\r
-                outputFramerate = profile.Framerate;\r
-            }\r
-\r
-            long frames = (long)(lengthSeconds * outputFramerate);\r
-\r
-            availableBytes -= frames * ContainerOverheadPerFrame;\r
-\r
-            List<Tuple<AudioEncoding, int>> outputTrackList = GetOutputTracks(job, title);\r
-            availableBytes -= GetAudioSize(job, lengthSeconds, title, outputTrackList);\r
-\r
-            if (availableBytes < 0)\r
-            {\r
-                return 0;\r
-            }\r
-\r
-            // Video bitrate is in kilobits per second, or where 1 kbps is 1000 bits per second.\r
-            // So 1 kbps is 125 bytes per second.\r
-            return (int)(availableBytes / (125 * lengthSeconds));\r
-        }\r
-\r
-        /// <summary>\r
-        /// Gives estimated file size (in MB) of the given job and video bitrate.\r
-        /// </summary>\r
-        /// <param name="job">\r
-        /// The encode job.\r
-        /// </param>\r
-        /// <param name="title">\r
-        /// The title.\r
-        /// </param>\r
-        /// <param name="videoBitrate">\r
-        /// The video bitrate to be used (kbps).\r
-        /// </param>\r
-        /// <returns>\r
-        /// The estimated file size (in MB) of the given job and video bitrate.\r
-        /// </returns>\r
-        public static double CalculateFileSize(EncodeJob job, Title title, int videoBitrate)\r
-        {\r
-            long totalBytes = 0;\r
-\r
-            EncodeJob profile = job;\r
-\r
-            double lengthSeconds = GetJobLengthSeconds(job, title);\r
-            lengthSeconds += 1.5;\r
-\r
-            double outputFramerate;\r
-            if (profile.Framerate == 0)\r
-            {\r
-                outputFramerate = title.Framerate;\r
-            }\r
-            else\r
-            {\r
-                // Not sure what to do for VFR here hb_calc_bitrate never handled it...\r
-                //   just use the peak for now.\r
-                outputFramerate = profile.Framerate;\r
-            }\r
-\r
-            long frames = (long)(lengthSeconds * outputFramerate);\r
-\r
-            totalBytes += (long)(lengthSeconds * videoBitrate * 125);\r
-            totalBytes += frames * ContainerOverheadPerFrame;\r
-\r
-            List<Tuple<AudioEncoding, int>> outputTrackList = GetOutputTracks(job, title);\r
-            totalBytes += GetAudioSize(job, lengthSeconds, title, outputTrackList);\r
-\r
-            return (double)totalBytes / 1024 / 1024;\r
-        }\r
-\r
         /// <summary>\r
         /// Sends the message logged event to any registered listeners.\r
         /// </summary>\r
@@ -568,47 +325,5 @@ namespace HandBrake.Interop
 \r
             Debug.WriteLine("ERROR: " + message);\r
         }\r
-\r
-        /// <summary>\r
-        /// Gets a list of encodings and target track indices (1-based).\r
-        /// </summary>\r
-        /// <param name="job">The encode job</param>\r
-        /// <param name="title">The title the job is meant to encode.</param>\r
-        /// <returns>A list of encodings and target track indices (1-based).</returns>\r
-        private static List<Tuple<AudioEncoding, int>> GetOutputTracks(EncodeJob job, Title title)\r
-        {\r
-            var list = new List<Tuple<AudioEncoding, int>>();\r
-\r
-            foreach (AudioEncoding encoding in job.AudioEncodings)\r
-            {\r
-                if (encoding.InputNumber == 0)\r
-                {\r
-                    // Add this encoding for all chosen tracks\r
-                    foreach (int chosenTrack in job.ChosenAudioTracks)\r
-                    {\r
-                        // In normal cases we'll never have a chosen audio track that doesn't exist but when batch encoding\r
-                        // we just choose the first audio track without checking if it exists.\r
-                        if (chosenTrack <= title.AudioTracks.Count)\r
-                        {\r
-                            list.Add(new Tuple<AudioEncoding, int>(encoding, chosenTrack));\r
-                        }\r
-                    }\r
-                }\r
-                else if (encoding.InputNumber <= job.ChosenAudioTracks.Count)\r
-                {\r
-                    // Add this encoding for the specified track, if it exists\r
-                    int trackNumber = job.ChosenAudioTracks[encoding.InputNumber - 1];\r
-\r
-                    // In normal cases we'll never have a chosen audio track that doesn't exist but when batch encoding\r
-                    // we just choose the first audio track without checking if it exists.\r
-                    if (trackNumber <= title.AudioTracks.Count)\r
-                    {\r
-                        list.Add(new Tuple<AudioEncoding, int>(encoding, trackNumber));\r
-                    }\r
-                }\r
-            }\r
-\r
-            return list;\r
-        }\r
     }\r
 }\r
index ce7209948098d1ae26f66868d85e7875dd36818d..f231073f4ab52748ab20a54c0ba129fee9da312e 100644 (file)
@@ -156,11 +156,6 @@ namespace HandBrake.Interop.Model
         /// </summary>\r
         public ScaleMethod ScaleMethod { get; set; }\r
 \r
-        /// <summary>\r
-        /// Gets or sets the cropping type.\r
-        /// </summary>\r
-        public CroppingType CroppingType { get; set; }\r
-\r
         /// <summary>\r
         /// Gets or sets the cropping.\r
         /// </summary>\r
@@ -376,11 +371,6 @@ namespace HandBrake.Interop.Model
         /// </summary>\r
         public List<AudioEncoding> AudioEncodings { get; set; }\r
 \r
-        /// <summary>\r
-        ///     Gets or sets the list of chosen audio tracks (1-based)\r
-        /// </summary>\r
-        public List<int> ChosenAudioTracks { get; set; }\r
-\r
         /// <summary>\r
         /// Gets or sets the audio encoder fallback.\r
         /// </summary>\r
@@ -439,7 +429,6 @@ namespace HandBrake.Interop.Model
                                                                SecondsEnd = this.SecondsEnd, \r
                                                                FramesStart = this.FramesStart, \r
                                                                FramesEnd = this.FramesEnd, \r
-                                                               ChosenAudioTracks = new List<int>(this.ChosenAudioTracks), \r
                                                                Subtitles = this.Subtitles, \r
                                                                UseDefaultChapterNames = this.UseDefaultChapterNames, \r
                                                                DxvaDecoding = this.DxvaDecoding, \r
@@ -456,7 +445,6 @@ namespace HandBrake.Interop.Model
                                 MaxWidth = this.MaxWidth, \r
                                 MaxHeight = this.MaxHeight, \r
                                 ScaleMethod = this.ScaleMethod, \r
-                                CroppingType = this.CroppingType, \r
                                 Cropping = this.Cropping.Clone(), \r
                                 Anamorphic = this.Anamorphic, \r
                                 UseDisplayWidth = this.UseDisplayWidth, \r
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/CroppingType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/CroppingType.cs
deleted file mode 100644 (file)
index e7c8da4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="CroppingType.cs" company="HandBrake Project (http://handbrake.fr)">\r
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-//   The type of cropping to apply.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.Interop.Model.Encoding\r
-{\r
-       /// <summary>\r
-       /// The type of cropping to apply.\r
-       /// </summary>\r
-       public enum CroppingType\r
-       {\r
-               Automatic,\r
-               None,\r
-               Custom\r
-       }\r
-}\r
index 0476b167349bb8847326f294f17a0cc538562ccb..716d6540261aabf57a2a59855bc5ccddc4a8b08e 100644 (file)
@@ -1,7 +1,10 @@
 // --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="Rotation.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// <copyright file="PictureRotation.cs" company="HandBrake Project (http://handbrake.fr)">\r
 //   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
 // </copyright>\r
+// <summary>\r
+//   Possible picture rotations.\r
+// </summary>\r
 // --------------------------------------------------------------------------------------------------------------------\r
 \r
 namespace HandBrake.Interop.Model.Encoding\r