From cb636fdc6858c09affb9ced024ef2859e9f13035 Mon Sep 17 00:00:00 2001 From: randomengy Date: Sat, 31 Mar 2012 18:37:15 +0000 Subject: Interop: Expose option to enable or disable LibDVDNav on scans. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4571 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeInterop/HandBrakeUtils.cs | 167 +++++++++++---------- 1 file changed, 87 insertions(+), 80 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 908afe250..e0f04c3d9 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -4,14 +4,12 @@ // // // Defines the HandBrakeUtils type. -// -// -------------------------------------------------------------------------------------------------------------------- - -using System.Runtime.InteropServices; - -namespace HandBrake.Interop -{ - using System; +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop +{ + using System; using System.Collections.Generic; using HandBrake.Interop.HbLib; @@ -49,6 +47,15 @@ namespace HandBrake.Interop /// public static event EventHandler ErrorLogged; + /// + /// Enables or disables LibDVDNav. If disabled libdvdread will be used instead. + /// + /// True to enable LibDVDNav. + public static void SetDvdNav(bool enableDvdNav) + { + HBFunctions.hb_dvd_set_dvdnav(enableDvdNav ? 1 : 0); + } + /// /// Register the logger. /// @@ -113,12 +120,12 @@ namespace HandBrake.Interop System.Diagnostics.Debug.WriteLine("ERROR: " + message); } - } - - /// - /// Gets the total number of seconds on the given encode job. - /// - /// The encode job to query. + } + + /// + /// Gets the total number of seconds on the given encode job. + /// + /// The encode job to query. /// The title being encoded. /// The total number of seconds of video to encode. internal static double GetJobLengthSeconds(EncodeJob job, Title title) @@ -142,37 +149,37 @@ namespace HandBrake.Interop return 0; } - /// - /// Gets the number of audio samples used per frame for the given audio encoder. - /// - /// The encoder to query. - /// The number of audio samples used per frame for the given - /// audio encoder. - internal static int GetAudioSamplesPerFrame(string encoderName) - { - switch (encoderName) - { - case "faac": - case "ffaac": - case "copy:aac": - case "vorbis": - return 1024; - case "lame": - case "copy:mp3": - return 1152; - case "ffac3": - case "copy": - case "copy:ac3": - case "copy:dts": - case "copy:dtshd": - return 1536; - } - - // Unknown encoder; make a guess. - return 1536; - } - - /// + /// + /// Gets the number of audio samples used per frame for the given audio encoder. + /// + /// The encoder to query. + /// The number of audio samples used per frame for the given + /// audio encoder. + internal static int GetAudioSamplesPerFrame(string encoderName) + { + switch (encoderName) + { + case "faac": + case "ffaac": + case "copy:aac": + case "vorbis": + return 1024; + case "lame": + case "copy:mp3": + return 1152; + case "ffac3": + case "copy": + case "copy:ac3": + case "copy:dts": + case "copy:dtshd": + return 1536; + } + + // Unknown encoder; make a guess. + return 1536; + } + + /// /// Gets the size in bytes for the audio with the given parameters. /// /// The encode job. @@ -189,41 +196,41 @@ namespace HandBrake.Interop AudioEncoding encoding = outputTrack.Item1; AudioTrack track = title.AudioTracks[outputTrack.Item2 - 1]; - int samplesPerFrame = HandBrakeUtils.GetAudioSamplesPerFrame(encoding.Encoder); - int audioBitrate; - - HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(encoding.Encoder); - - if (audioEncoder.IsPassthrough) - { - // Input bitrate is in bits/second. - audioBitrate = track.Bitrate / 8; - } - else if (encoding.EncodeRateType == AudioEncodeRateType.Quality) - { - // Can't predict size of quality targeted audio encoding. - audioBitrate = 0; - } - else - { - int outputBitrate; - if (encoding.Bitrate > 0) - { - outputBitrate = encoding.Bitrate; - } - else - { - outputBitrate = Encoders.GetDefaultBitrate( - audioEncoder, - encoding.SampleRateRaw == 0 ? track.SampleRate : encoding.SampleRateRaw, - Encoders.SanitizeMixdown(Encoders.GetMixdown(encoding.Mixdown), audioEncoder, track.ChannelLayout)); - } - - // Output bitrate is in kbps. - audioBitrate = outputBitrate * 1000 / 8; - } - - audioBytes += (long)(lengthSeconds * audioBitrate); + int samplesPerFrame = HandBrakeUtils.GetAudioSamplesPerFrame(encoding.Encoder); + int audioBitrate; + + HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(encoding.Encoder); + + if (audioEncoder.IsPassthrough) + { + // Input bitrate is in bits/second. + audioBitrate = track.Bitrate / 8; + } + else if (encoding.EncodeRateType == AudioEncodeRateType.Quality) + { + // Can't predict size of quality targeted audio encoding. + audioBitrate = 0; + } + else + { + int outputBitrate; + if (encoding.Bitrate > 0) + { + outputBitrate = encoding.Bitrate; + } + else + { + outputBitrate = Encoders.GetDefaultBitrate( + audioEncoder, + encoding.SampleRateRaw == 0 ? track.SampleRate : encoding.SampleRateRaw, + Encoders.SanitizeMixdown(Encoders.GetMixdown(encoding.Mixdown), audioEncoder, track.ChannelLayout)); + } + + // Output bitrate is in kbps. + audioBitrate = outputBitrate * 1000 / 8; + } + + audioBytes += (long)(lengthSeconds * audioBitrate); // Audio overhead audioBytes += encoding.SampleRateRaw * ContainerOverheadPerFrame / samplesPerFrame; -- cgit v1.2.3