From 2dc567b1f18fd8ed09f21df0a8c3e3a3bd1499ea Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 9 Jan 2015 21:24:39 +0000 Subject: WinGui: Move the Encoders class to the root level of the Interop Library and Rename to HandBrakeEncoderHelpers. All the HandBrake API calls we make now have wrappers at the top level of this project. Remove some region from small classes where they don't offer any benifit. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6706 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeInterop/Converters/Converters.cs | 8 +- .../HandBrakeInterop/HandBrakeEncoderHelpers.cs | 529 +++++++++++++++++++++ .../HandBrakeInterop/HandBrakeInterop.csproj | 2 +- .../HandBrakeInterop/HandBrakeUtils.cs | 8 +- .../Json/Factories/EncodeFactory.cs | 8 +- .../HandBrakeInterop/Model/Encoders.cs | 529 --------------------- .../Model/Encoding/AudioEncodeRateType.cs | 18 +- .../HandBrakeInterop/Model/Encoding/Container.cs | 32 +- .../Model/Encoding/HBAudioEncoder.cs | 4 - .../HandBrakeInterop/Model/Encoding/HBContainer.cs | 4 - .../Model/Encoding/x264/x264Profile.cs | 11 +- .../HandBrakeInterop/Model/RangeLimits.cs | 4 - .../HandBrakeInterop/Model/Size.cs | 8 - .../HandBrakeInterop/Model/SourceSubtitle.cs | 8 - .../HandBrakeInterop/Model/SrtSubtitle.cs | 2 +- .../HandBrakeInterop/Model/Subtitles.cs | 4 - 16 files changed, 569 insertions(+), 610 deletions(-) create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeEncoderHelpers.cs delete mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs (limited to 'win/CS') diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters/Converters.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters/Converters.cs index 100ea1554..8f7003c29 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters/Converters.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters/Converters.cs @@ -36,7 +36,7 @@ namespace HandBrake.Interop.Converters HandBrakeUtils.EnsureGlobalInit(); VideoRates = new Dictionary(); - foreach (var framerate in Encoders.VideoFramerates) + foreach (var framerate in HandBrakeEncoderHelpers.VideoFramerates) { VideoRates.Add(double.Parse(framerate.Name, CultureInfo.InvariantCulture), framerate.Rate); } @@ -100,10 +100,10 @@ namespace HandBrake.Interop.Converters Id = encoder.codec, ShortName = encoder.short_name, DisplayName = encoder.name, - CompatibleContainers = encoder.muxers, - QualityLimits = Encoders.GetAudioQualityLimits(encoder.codec), + CompatibleContainers = encoder.muxers, + QualityLimits = HandBrakeEncoderHelpers.GetAudioQualityLimits(encoder.codec), DefaultQuality = HBFunctions.hb_audio_quality_get_default((uint)encoder.codec), - CompressionLimits = Encoders.GetAudioCompressionLimits(encoder.codec), + CompressionLimits = HandBrakeEncoderHelpers.GetAudioCompressionLimits(encoder.codec), DefaultCompression = HBFunctions.hb_audio_compression_get_default((uint)encoder.codec) }; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeEncoderHelpers.cs new file mode 100644 index 000000000..80b1fc3ad --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeEncoderHelpers.cs @@ -0,0 +1,529 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The encoders. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop +{ + using System.Collections.Generic; + using System.Linq; + + using HandBrake.Interop.HbLib; + using HandBrake.Interop.Helpers; + using HandBrake.Interop.Model; + using HandBrake.Interop.Model.Encoding; + using HandBrake.Interop.Model.Scan; + + /// + /// The encoders. + /// + public static class HandBrakeEncoderHelpers + { + /// + /// The audio encoders. + /// + private static List audioEncoders; + + /// + /// The video encoders. + /// + private static List videoEncoders; + + /// + /// Video framerates in pts. + /// + private static List videoFramerates; + + /// + /// List of HandBrake mixdowns. + /// + private static List mixdowns; + + /// + /// List of HandBrake containers. + /// + private static List containers; + + /// + /// The audio bitrates. + /// + private static List audioBitrates; + + /// + /// Audio sample rates in Hz. + /// + private static List audioSampleRates; + + /// + /// Initializes static members of the EncoderHelpers class. + /// + static HandBrakeEncoderHelpers() + { + HandBrakeUtils.EnsureGlobalInit(); + } + + /// + /// Gets a list of supported audio encoders. + /// + public static List AudioEncoders + { + get + { + if (audioEncoders == null) + { + audioEncoders = InteropUtilities.ToListFromIterator(HBFunctions.hb_audio_encoder_get_next, Converters.Converters.NativeToAudioEncoder); + } + + return audioEncoders; + } + } + + /// + /// Gets a list of supported video encoders. + /// + public static List VideoEncoders + { + get + { + if (videoEncoders == null) + { + videoEncoders = InteropUtilities.ToListFromIterator(HBFunctions.hb_video_encoder_get_next, Converters.Converters.NativeToVideoEncoder); + } + + return videoEncoders; + } + } + + /// + /// Gets a list of supported video framerates (in pts). + /// + public static List VideoFramerates + { + get + { + if (videoFramerates == null) + { + videoFramerates = InteropUtilities.ToListFromIterator(HBFunctions.hb_video_framerate_get_next, Converters.Converters.NativeToRate); + } + + return videoFramerates; + } + } + + /// + /// Gets a list of supported mixdowns. + /// + public static List Mixdowns + { + get + { + if (mixdowns == null) + { + mixdowns = InteropUtilities.ToListFromIterator(HBFunctions.hb_mixdown_get_next, Converters.Converters.NativeToMixdown); + } + + return mixdowns; + } + } + + /// + /// Gets a list of supported audio bitrates. + /// + public static List AudioBitrates + { + get + { + if (audioBitrates == null) + { + audioBitrates = InteropUtilities.ToListFromIterator(HBFunctions.hb_audio_bitrate_get_next, b => b.rate); + } + + return audioBitrates; + } + } + + /// + /// Gets a list of supported audio sample rates (in Hz). + /// + public static List AudioSampleRates + { + get + { + if (audioSampleRates == null) + { + audioSampleRates = InteropUtilities.ToListFromIterator(HBFunctions.hb_audio_samplerate_get_next, Converters.Converters.NativeToRate); + } + + return audioSampleRates; + } + } + + /// + /// Gets a list of supported containers. + /// + public static List Containers + { + get + { + if (containers == null) + { + containers = InteropUtilities.ToListFromIterator(HBFunctions.hb_container_get_next, Converters.Converters.NativeToContainer); + } + + return containers; + } + } + + /// + /// Gets a value indicating whether SRT subtitles can be burnt in. + /// + public static bool CanBurnSrt + { + get + { + return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.SRTSUB) > 0; + } + } + + /// + /// Gets the audio encoder with the specified short name. + /// + /// + /// The name of the audio encoder. + /// + /// + /// The requested audio encoder. + /// + public static HBAudioEncoder GetAudioEncoder(string shortName) + { + return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName); + } + + /// + /// Gets the audio encoder with the specified codec ID. + /// + /// + /// The ID of the audio encoder. + /// + /// + /// The requested audio encoder. + /// + public static HBAudioEncoder GetAudioEncoder(int codecId) + { + return AudioEncoders.SingleOrDefault(e => e.Id == codecId); + } + + /// + /// Gets the video encoder with the specified short name. + /// + /// + /// The name of the video encoder. + /// + /// + /// The requested video encoder. + /// + public static HBVideoEncoder GetVideoEncoder(string shortName) + { + return VideoEncoders.SingleOrDefault(e => e.ShortName == shortName); + } + + /// + /// Gets the mixdown with the specified short name. + /// + /// + /// The name of the mixdown. + /// + /// + /// The requested mixdown. + /// + public static HBMixdown GetMixdown(string shortName) + { + return Mixdowns.SingleOrDefault(m => m.ShortName == shortName); + } + + /// + /// Gets the container with the specified short name. + /// + /// + /// The name of the container. + /// + /// + /// The requested container. + /// + public static HBContainer GetContainer(string shortName) + { + return Containers.SingleOrDefault(c => c.ShortName == shortName); + } + + /// + /// Determines if the given encoder is compatible with the given track. + /// + /// + /// The audio track to examine. + /// + /// + /// The encoder to examine. + /// + /// + /// True if the given encoder is comatible with the given audio track. + /// + /// + /// Only works with passthrough encoders. + /// + public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder) + { + return (track.CodecId & encoder.Id) > 0; + } + + /// + /// Determines if the given mixdown supports the given channel layout. + /// + /// + /// The mixdown to evaluate. + /// + /// + /// The channel layout to evaluate. + /// + /// + /// True if the mixdown supports the given channel layout. + /// + public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout) + { + return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0; + } + + /// + /// Determines if the given encoder supports the given mixdown. + /// + /// + /// The mixdown to evaluate. + /// + /// + /// The encoder to evaluate. + /// + /// + /// True if the encoder supports the mixdown. + /// + public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder) + { + return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0; + } + + /// + /// Determines if DRC can be applied to the given track with the given encoder. + /// + /// + /// The track to apply DRC to. + /// + /// + /// The encoder to use for DRC. + /// + /// + /// True if DRC can be applied to the track with the given encoder. + /// + public static bool CanApplyDrc(AudioTrack track, HBAudioEncoder encoder) + { + return HBFunctions.hb_audio_can_apply_drc(track.CodecId, track.CodecParam, encoder.Id) > 0; + } + + /// + /// Determines if the given input audio codec can be passed through. + /// + /// + /// The input codec to consider. + /// + /// + /// True if the codec can be passed through. + /// + public static bool CanPassthroughAudio(int codecId) + { + return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0; + } + + /// + /// Sanitizes a mixdown given the output codec and input channel layout. + /// + /// + /// The desired mixdown. + /// + /// + /// The output encoder to be used. + /// + /// + /// The input channel layout. + /// + /// + /// A sanitized mixdown value. + /// + public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout) + { + int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id); + return Mixdowns.Single(m => m.Id == sanitizedMixdown); + } + + /// + /// Gets the default mixdown for the given audio encoder and channel layout. + /// + /// + /// The output codec to be used. + /// + /// + /// The input channel layout. + /// + /// + /// The default mixdown for the given codec and channel layout. + /// + public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout) + { + int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout); + return Mixdowns.Single(m => m.Id == defaultMixdown); + } + + /// + /// Gets the bitrate limits for the given audio codec, sample rate and mixdown. + /// + /// + /// The audio encoder used. + /// + /// + /// The sample rate used (Hz). + /// + /// + /// The mixdown used. + /// + /// + /// Limits on the audio bitrate for the given settings. + /// + public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) + { + int low = 0; + int high = 0; + + HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high); + + return new BitrateLimits { Low = low, High = high }; + } + + /// + /// Gets the video quality limits for the given video codec. + /// + /// + /// The video encoder to check. + /// + /// + /// Limits on the video quality for the encoder. + /// + public static VideoQualityLimits GetVideoQualityLimits(HBVideoEncoder encoder) + { + float low = 0; + float high = 0; + float granularity = 0; + int direction = 0; + + HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction); + + return new VideoQualityLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } + + /// + /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown. + /// + /// + /// The desired audio bitrate. + /// + /// + /// The output encoder to be used. + /// + /// + /// The output sample rate to be used. + /// + /// + /// The mixdown to be used. + /// + /// + /// A sanitized audio bitrate. + /// + public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) + { + return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id); + } + + /// + /// Gets the default audio bitrate for the given parameters. + /// + /// + /// The encoder to use. + /// + /// + /// The sample rate to use. + /// + /// + /// The mixdown to use. + /// + /// + /// The default bitrate for these parameters. + /// + public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) + { + return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id); + } + + /// + /// Gets limits on audio quality for a given encoder. + /// + /// + /// The audio encoder ID. + /// + /// + /// Limits on the audio quality for the given encoder. + /// + internal static RangeLimits GetAudioQualityLimits(int encoderId) + { + float low = 0, high = 0, granularity = 0; + int direction = 0; + HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); + + return new RangeLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } + + /// + /// Gets limits on audio compression for a given encoder. + /// + /// + /// The audio encoder ID. + /// + /// + /// Limits on the audio compression for the given encoder. + /// + internal static RangeLimits GetAudioCompressionLimits(int encoderId) + { + float low = 0, high = 0, granularity = 0; + int direction = 0; + HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); + + return new RangeLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index 936cff5bb..da3060766 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -229,7 +229,7 @@ - + diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index c1f5a5cad..4cb51886d 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -393,7 +393,7 @@ namespace HandBrake.Interop int samplesPerFrame = GetAudioSamplesPerFrame(encoding.Encoder); int audioBitrate; - HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(encoding.Encoder); + HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(encoding.Encoder); if (audioEncoder.IsPassthrough) { @@ -414,10 +414,10 @@ namespace HandBrake.Interop } else { - outputBitrate = Encoders.GetDefaultBitrate( + outputBitrate = HandBrakeEncoderHelpers.GetDefaultBitrate( audioEncoder, - encoding.SampleRateRaw == 0 ? track.SampleRate : encoding.SampleRateRaw, - Encoders.SanitizeMixdown(Encoders.GetMixdown(encoding.Mixdown), audioEncoder, track.ChannelLayout)); + encoding.SampleRateRaw == 0 ? track.SampleRate : encoding.SampleRateRaw, + HandBrakeEncoderHelpers.SanitizeMixdown(HandBrakeEncoderHelpers.GetMixdown(encoding.Mixdown), audioEncoder, track.ChannelLayout)); } // Output bitrate is in kbps. diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs index f9e3ef074..88bae4116 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs @@ -216,7 +216,7 @@ namespace HandBrake.Interop.Json.Factories { Video video = new Video(); - HBVideoEncoder videoEncoder = Encoders.VideoEncoders.FirstOrDefault(e => e.ShortName == job.EncodingProfile.VideoEncoder); + HBVideoEncoder videoEncoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(e => e.ShortName == job.EncodingProfile.VideoEncoder); Validate.NotNull(videoEncoder, "Video encoder " + job.EncodingProfile.VideoEncoder + " not recognized."); if (videoEncoder != null) { @@ -251,7 +251,7 @@ namespace HandBrake.Interop.Json.Factories if (!string.IsNullOrEmpty(job.EncodingProfile.AudioEncoderFallback)) { - HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(job.EncodingProfile.AudioEncoderFallback); + HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(job.EncodingProfile.AudioEncoderFallback); Validate.NotNull(audioEncoder, "Unrecognized fallback audio encoder: " + job.EncodingProfile.AudioEncoderFallback); audio.FallbackEncoder = audioEncoder.Id; } @@ -262,10 +262,10 @@ namespace HandBrake.Interop.Json.Factories int numTracks = 0; foreach (AudioEncoding item in job.EncodingProfile.AudioEncodings) { - HBAudioEncoder encoder = Encoders.GetAudioEncoder(item.Encoder); + HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(item.Encoder); Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); - HBMixdown mixdown = Encoders.GetMixdown(item.Mixdown); + HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(item.Mixdown); Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.Mixdown); AudioList audioTrack = new AudioList diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs deleted file mode 100644 index 8a4c737f0..000000000 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs +++ /dev/null @@ -1,529 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The encoders. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.Interop.Model -{ - using System.Collections.Generic; - using System.Linq; - - using HandBrake.Interop.Converters; - using HandBrake.Interop.HbLib; - using HandBrake.Interop.Helpers; - using HandBrake.Interop.Model.Encoding; - using HandBrake.Interop.Model.Scan; - - /// - /// The encoders. - /// - public static class Encoders - { - /// - /// The audio encoders. - /// - private static List audioEncoders; - - /// - /// The video encoders. - /// - private static List videoEncoders; - - /// - /// Video framerates in pts. - /// - private static List videoFramerates; - - /// - /// List of HandBrake mixdowns. - /// - private static List mixdowns; - - /// - /// List of HandBrake containers. - /// - private static List containers; - - /// - /// The audio bitrates. - /// - private static List audioBitrates; - - /// - /// Audio sample rates in Hz. - /// - private static List audioSampleRates; - - /// - /// Initializes static members of the Encoders class. - /// - static Encoders() - { - HandBrakeUtils.EnsureGlobalInit(); - } - - /// - /// Gets a list of supported audio encoders. - /// - public static List AudioEncoders - { - get - { - if (audioEncoders == null) - { - audioEncoders = InteropUtilities.ToListFromIterator(HBFunctions.hb_audio_encoder_get_next, Converters.NativeToAudioEncoder); - } - - return audioEncoders; - } - } - - /// - /// Gets a list of supported video encoders. - /// - public static List VideoEncoders - { - get - { - if (videoEncoders == null) - { - videoEncoders = InteropUtilities.ToListFromIterator(HBFunctions.hb_video_encoder_get_next, Converters.NativeToVideoEncoder); - } - - return videoEncoders; - } - } - - /// - /// Gets a list of supported video framerates (in pts). - /// - public static List VideoFramerates - { - get - { - if (videoFramerates == null) - { - videoFramerates = InteropUtilities.ToListFromIterator(HBFunctions.hb_video_framerate_get_next, Converters.NativeToRate); - } - - return videoFramerates; - } - } - - /// - /// Gets a list of supported mixdowns. - /// - public static List Mixdowns - { - get - { - if (mixdowns == null) - { - mixdowns = InteropUtilities.ToListFromIterator(HBFunctions.hb_mixdown_get_next, Converters.NativeToMixdown); - } - - return mixdowns; - } - } - - /// - /// Gets a list of supported audio bitrates. - /// - public static List AudioBitrates - { - get - { - if (audioBitrates == null) - { - audioBitrates = InteropUtilities.ToListFromIterator(HBFunctions.hb_audio_bitrate_get_next, b => b.rate); - } - - return audioBitrates; - } - } - - /// - /// Gets a list of supported audio sample rates (in Hz). - /// - public static List AudioSampleRates - { - get - { - if (audioSampleRates == null) - { - audioSampleRates = InteropUtilities.ToListFromIterator(HBFunctions.hb_audio_samplerate_get_next, Converters.NativeToRate); - } - - return audioSampleRates; - } - } - - /// - /// Gets a list of supported containers. - /// - public static List Containers - { - get - { - if (containers == null) - { - containers = InteropUtilities.ToListFromIterator(HBFunctions.hb_container_get_next, Converters.NativeToContainer); - } - - return containers; - } - } - - /// - /// Gets a value indicating whether SRT subtitles can be burnt in. - /// - public static bool CanBurnSrt - { - get - { - return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.SRTSUB) > 0; - } - } - - /// - /// Gets the audio encoder with the specified short name. - /// - /// - /// The name of the audio encoder. - /// - /// - /// The requested audio encoder. - /// - public static HBAudioEncoder GetAudioEncoder(string shortName) - { - return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName); - } - - /// - /// Gets the audio encoder with the specified codec ID. - /// - /// - /// The ID of the audio encoder. - /// - /// - /// The requested audio encoder. - /// - public static HBAudioEncoder GetAudioEncoder(int codecId) - { - return AudioEncoders.SingleOrDefault(e => e.Id == codecId); - } - - /// - /// Gets the video encoder with the specified short name. - /// - /// - /// The name of the video encoder. - /// - /// - /// The requested video encoder. - /// - public static HBVideoEncoder GetVideoEncoder(string shortName) - { - return VideoEncoders.SingleOrDefault(e => e.ShortName == shortName); - } - - /// - /// Gets the mixdown with the specified short name. - /// - /// - /// The name of the mixdown. - /// - /// - /// The requested mixdown. - /// - public static HBMixdown GetMixdown(string shortName) - { - return Mixdowns.SingleOrDefault(m => m.ShortName == shortName); - } - - /// - /// Gets the container with the specified short name. - /// - /// - /// The name of the container. - /// - /// - /// The requested container. - /// - public static HBContainer GetContainer(string shortName) - { - return Containers.SingleOrDefault(c => c.ShortName == shortName); - } - - /// - /// Determines if the given encoder is compatible with the given track. - /// - /// - /// The audio track to examine. - /// - /// - /// The encoder to examine. - /// - /// - /// True if the given encoder is comatible with the given audio track. - /// - /// - /// Only works with passthrough encoders. - /// - public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder) - { - return (track.CodecId & encoder.Id) > 0; - } - - /// - /// Determines if the given mixdown supports the given channel layout. - /// - /// - /// The mixdown to evaluate. - /// - /// - /// The channel layout to evaluate. - /// - /// - /// True if the mixdown supports the given channel layout. - /// - public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout) - { - return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0; - } - - /// - /// Determines if the given encoder supports the given mixdown. - /// - /// - /// The mixdown to evaluate. - /// - /// - /// The encoder to evaluate. - /// - /// - /// True if the encoder supports the mixdown. - /// - public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder) - { - return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0; - } - - /// - /// Determines if DRC can be applied to the given track with the given encoder. - /// - /// - /// The track to apply DRC to. - /// - /// - /// The encoder to use for DRC. - /// - /// - /// True if DRC can be applied to the track with the given encoder. - /// - public static bool CanApplyDrc(AudioTrack track, HBAudioEncoder encoder) - { - return HBFunctions.hb_audio_can_apply_drc(track.CodecId, track.CodecParam, encoder.Id) > 0; - } - - /// - /// Determines if the given input audio codec can be passed through. - /// - /// - /// The input codec to consider. - /// - /// - /// True if the codec can be passed through. - /// - public static bool CanPassthroughAudio(int codecId) - { - return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0; - } - - /// - /// Sanitizes a mixdown given the output codec and input channel layout. - /// - /// - /// The desired mixdown. - /// - /// - /// The output encoder to be used. - /// - /// - /// The input channel layout. - /// - /// - /// A sanitized mixdown value. - /// - public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout) - { - int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id); - return Mixdowns.Single(m => m.Id == sanitizedMixdown); - } - - /// - /// Gets the default mixdown for the given audio encoder and channel layout. - /// - /// - /// The output codec to be used. - /// - /// - /// The input channel layout. - /// - /// - /// The default mixdown for the given codec and channel layout. - /// - public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout) - { - int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout); - return Mixdowns.Single(m => m.Id == defaultMixdown); - } - - /// - /// Gets the bitrate limits for the given audio codec, sample rate and mixdown. - /// - /// - /// The audio encoder used. - /// - /// - /// The sample rate used (Hz). - /// - /// - /// The mixdown used. - /// - /// - /// Limits on the audio bitrate for the given settings. - /// - public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) - { - int low = 0; - int high = 0; - - HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high); - - return new BitrateLimits { Low = low, High = high }; - } - - /// - /// Gets the video quality limits for the given video codec. - /// - /// - /// The video encoder to check. - /// - /// - /// Limits on the video quality for the encoder. - /// - public static VideoQualityLimits GetVideoQualityLimits(HBVideoEncoder encoder) - { - float low = 0; - float high = 0; - float granularity = 0; - int direction = 0; - - HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction); - - return new VideoQualityLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; - } - - /// - /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown. - /// - /// - /// The desired audio bitrate. - /// - /// - /// The output encoder to be used. - /// - /// - /// The output sample rate to be used. - /// - /// - /// The mixdown to be used. - /// - /// - /// A sanitized audio bitrate. - /// - public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) - { - return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id); - } - - /// - /// Gets the default audio bitrate for the given parameters. - /// - /// - /// The encoder to use. - /// - /// - /// The sample rate to use. - /// - /// - /// The mixdown to use. - /// - /// - /// The default bitrate for these parameters. - /// - public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) - { - return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id); - } - - /// - /// Gets limits on audio quality for a given encoder. - /// - /// - /// The audio encoder ID. - /// - /// - /// Limits on the audio quality for the given encoder. - /// - internal static RangeLimits GetAudioQualityLimits(int encoderId) - { - float low = 0, high = 0, granularity = 0; - int direction = 0; - HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); - - return new RangeLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; - } - - /// - /// Gets limits on audio compression for a given encoder. - /// - /// - /// The audio encoder ID. - /// - /// - /// Limits on the audio compression for the given encoder. - /// - internal static RangeLimits GetAudioCompressionLimits(int encoderId) - { - float low = 0, high = 0, granularity = 0; - int direction = 0; - HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); - - return new RangeLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; - } - } -} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncodeRateType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncodeRateType.cs index 6017b872c..dbd625604 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncodeRateType.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncodeRateType.cs @@ -5,16 +5,16 @@ // // The audio encode rate type. // -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.Interop.Model.Encoding +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Model.Encoding { /// /// The audio encode rate type. /// - public enum AudioEncodeRateType - { - Bitrate, - Quality - } -} + public enum AudioEncodeRateType + { + Bitrate, + Quality + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Container.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Container.cs index 50261cfdc..59b4277c1 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Container.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Container.cs @@ -5,24 +5,24 @@ // // Defines the Container type. // -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.Interop.Model.Encoding -{ - using System; +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Model.Encoding +{ + using System; using System.ComponentModel.DataAnnotations; /// /// The container. /// - [Flags] - public enum Container - { - None = 0x0, - - [Display(Name = "MP4")] - MP4, - [Display(Name = "MKV")] - MKV - } -} + [Flags] + public enum Container + { + None = 0x0, + + [Display(Name = "MP4")] + MP4, + [Display(Name = "MKV")] + MKV + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBAudioEncoder.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBAudioEncoder.cs index 6bcd8e0d7..088f448c5 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBAudioEncoder.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBAudioEncoder.cs @@ -16,8 +16,6 @@ namespace HandBrake.Interop.Model.Encoding /// public class HBAudioEncoder { - #region Public Properties - /// /// Gets or sets the compatible containers. /// @@ -90,7 +88,5 @@ namespace HandBrake.Interop.Model.Encoding return this.QualityLimits.High >= 0; } } - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBContainer.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBContainer.cs index 3b6feea48..18fc3911e 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBContainer.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBContainer.cs @@ -14,8 +14,6 @@ namespace HandBrake.Interop.Model.Encoding /// public class HBContainer { - #region Public Properties - /// /// Gets or sets the default extension. /// @@ -35,7 +33,5 @@ namespace HandBrake.Interop.Model.Encoding /// Gets or sets the short name. /// public string ShortName { get; set; } - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/x264/x264Profile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/x264/x264Profile.cs index ad2bc9063..bc0983ff1 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/x264/x264Profile.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/x264/x264Profile.cs @@ -26,15 +26,6 @@ namespace HandBrake.Interop.Model.Encoding.x264 Main, [Display(Name = "High")] - High, - - //[Display(Name = "High 10")] - //High10, HandBrake does not yet support 10bit. - - //[Display(Name = "High 422")] - //High422, Not supported - - //[Display(Name = "High 444")] - // High444, Use Auto Instead. + High } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/RangeLimits.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/RangeLimits.cs index 2c30b2b44..420126cca 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/RangeLimits.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/RangeLimits.cs @@ -14,8 +14,6 @@ namespace HandBrake.Interop.Model /// public class RangeLimits { - #region Properties - /// /// Gets or sets a value indicating whether ascending. /// @@ -35,7 +33,5 @@ namespace HandBrake.Interop.Model /// Gets or sets the low. /// public float Low { get; set; } - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Size.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Size.cs index dcc58e0e3..0cf7eb5b0 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Size.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Size.cs @@ -14,8 +14,6 @@ namespace HandBrake.Interop.Model /// public class Size { - #region Constructors and Destructors - /// /// Initializes a new instance of the class. /// @@ -31,10 +29,6 @@ namespace HandBrake.Interop.Model this.Height = height; } - #endregion - - #region Properties - /// /// Gets or sets the height. /// @@ -44,7 +38,5 @@ namespace HandBrake.Interop.Model /// Gets or sets the width. /// public int Width { get; set; } - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SourceSubtitle.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SourceSubtitle.cs index e4bb3c39e..ab5f8c610 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SourceSubtitle.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SourceSubtitle.cs @@ -14,8 +14,6 @@ namespace HandBrake.Interop.Model /// public class SourceSubtitle { - #region Properties - /// /// Gets or sets a value indicating whether the subtitle track should be burned in. /// @@ -36,10 +34,6 @@ namespace HandBrake.Interop.Model /// public int TrackNumber { get; set; } - #endregion - - #region Public Methods - /// /// The clone. /// @@ -56,7 +50,5 @@ namespace HandBrake.Interop.Model BurnedIn = this.BurnedIn }; } - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SrtSubtitle.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SrtSubtitle.cs index 9a60c8ab3..336f7ccac 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SrtSubtitle.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/SrtSubtitle.cs @@ -25,7 +25,7 @@ namespace HandBrake.Interop.Model public bool Default { get; set; } /// - /// Gets or sets a value indicating the subtitle track should be burned in. + /// Gets or sets a value indicating whether the subtitle track should be burned in. /// public bool BurnedIn { get; set; } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Subtitles.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Subtitles.cs index 843d0d442..0d16c4c41 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Subtitles.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Subtitles.cs @@ -16,8 +16,6 @@ namespace HandBrake.Interop.Model /// public class Subtitles { - #region Properties - /// /// Gets or sets the source subtitles. /// @@ -27,7 +25,5 @@ namespace HandBrake.Interop.Model /// Gets or sets the srt subtitles. /// public List SrtSubtitles { get; set; } - - #endregion } } \ No newline at end of file -- cgit v1.2.3