From 9c4ba8930b22f92f0d8b985eb77a96fca4a62d28 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 16 Jun 2013 16:00:15 +0000 Subject: WiWinGui: Remap the audio and video encoders. Hopefully this should also be backwards compatible with user presets, but it is recommended to re-create any user presets to that the new keys get picked up incase we drop the fallbacks in the future. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5591 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrake.ApplicationServices.csproj | 1 + .../LibHb/AudioVideoHelpers.cs | 18 ++++ .../Model/Encoding/AudioTrack.cs | 6 +- .../Services/Interfaces/IPresetService.cs | 5 + .../Services/PresetService.cs | 46 ++++----- .../Utilities/Converters.cs | 111 ++++++--------------- .../Utilities/EnumHelper.cs | 19 ++++ .../Utilities/GeneralUtilities.cs | 2 - .../HandBrakeInterop/Attributes/ShortName.cs | 35 +++++++ .../HandBrakeInterop/Converters.cs | 9 +- .../HandBrakeInterop/HandBrakeInterop.csproj | 1 + .../HandBrakeInterop/HbLib/NativeConstants.cs | 57 ++++++----- .../Model/Encoding/AudioEncoder.cs | 37 +++++-- .../Model/Encoding/VideoEncoder.cs | 14 ++- .../HandBrakeInterop/SourceData/AudioCodec.cs | 2 +- .../Converters/Audio/AudioBitrateConverter.cs | 21 ++-- .../Converters/Audio/AudioEncoderConverter.cs | 2 + win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 7 +- 18 files changed, 230 insertions(+), 163 deletions(-) create mode 100644 win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 445b09c36..4888c9e9b 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -95,6 +95,7 @@ + diff --git a/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs b/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs new file mode 100644 index 000000000..022d78180 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the AudioVideoHelpers type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.LibHb +{ + /// + /// The audio video helpers. + /// + class AudioVideoHelpers + { + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs index c8238927f..fcbaddf6f 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs @@ -75,7 +75,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding public AudioTrack() { // Default Values - this.Encoder = AudioEncoder.Faac; + this.Encoder = AudioEncoder.ffaac; this.MixDown = Mixdown.DolbyProLogicII; this.SampleRate = 48; this.Bitrate = 160; @@ -341,7 +341,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding { get { - return this.IsPassthru || this.Encoder == AudioEncoder.ffflac; + return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24; } } @@ -352,7 +352,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding { get { - return this.IsPassthru || this.Encoder == AudioEncoder.ffflac; + return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24; } } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs index 63fe25158..83e1206b2 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs @@ -28,6 +28,11 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// Preset DefaultPreset { get; } + /// + /// The load. + /// + void Load(); + /// /// Add a new preset to the system /// diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index 8f375258c..b0cfc9a74 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -37,11 +37,6 @@ namespace HandBrake.ApplicationServices.Services /// private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List)); - /// - /// The User Setting Service - /// - private readonly IUserSettingService userSettingService; - /// /// User Preset Default Catgory Name /// @@ -60,30 +55,10 @@ namespace HandBrake.ApplicationServices.Services /// /// A Collection of presets /// - private ObservableCollection presets = new ObservableCollection(); + private readonly ObservableCollection presets = new ObservableCollection(); #endregion - - /// - /// Initializes a new instance of the class. - /// - /// - /// The user Setting Service. - /// - public PresetService(IUserSettingService userSettingService) - { - this.userSettingService = userSettingService; - - // If the preset file doesn't exist. Create it. - if (!File.Exists(this.builtInPresetFile)) - { - this.UpdateBuiltInPresets(); - } - - this.LoadPresets(); - } - /// /// Gets a Collection of presets. /// @@ -113,6 +88,20 @@ namespace HandBrake.ApplicationServices.Services #region Public Methods + /// + /// The load. + /// + public void Load() + { + // If the preset file doesn't exist. Create it. + if (!File.Exists(this.builtInPresetFile)) + { + this.UpdateBuiltInPresets(); + } + + this.LoadPresets(); + } + /// /// Add a new preset to the system. /// Performs an Update if it already exists @@ -412,7 +401,7 @@ namespace HandBrake.ApplicationServices.Services // Recover from Error. if (File.Exists(file)) { - string disabledFile = file + ".old"; + string disabledFile = string.Format("{0}.{1}", file, GeneralUtilities.ProcessId); File.Move(file, disabledFile); if (File.Exists(file)) { @@ -455,7 +444,6 @@ namespace HandBrake.ApplicationServices.Services { RecoverFromCorruptedPresetFile(this.builtInPresetFile); this.UpdateBuiltInPresets(); - throw new GeneralApplicationException("HandBrake has detected corruption in the presets file and has attempted to rebuild this file.", "Please restart HandBrake before continuing.", exc); } // Load in the users Presets from UserPresets.xml @@ -476,7 +464,7 @@ namespace HandBrake.ApplicationServices.Services catch (Exception exc) { RecoverFromCorruptedPresetFile(this.userPresetFile); - throw new GeneralApplicationException("HandBrake has detected corruption in the presets file and has attempted to rebuild this file.", "Please restart HandBrake before continuing.", exc); + throw new GeneralApplicationException("HandBrake has detected a problem with your presets.", "Your old presets file has been renamed so that it doesn't get loaded on next launch.", exc); } } diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 8ac89c0ee..641380e9c 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -25,7 +25,7 @@ namespace HandBrake.ApplicationServices.Utilities * TODO: * - Many of these converters can be ditched at a later point. Should be able to model all this within the enums themsevles. * - **/ + **/ /// /// Convert HandBrakes time remaining into a TimeSpan @@ -155,46 +155,6 @@ namespace HandBrake.ApplicationServices.Utilities } } - /// - /// Get the GUI equiv to a CLI audio encoder - /// - /// The Audio Encoder - /// The GUI representation of that audio encoder - public static string GetGUIAudioEncoder(string audioEnc) - { - switch (audioEnc) - { - case "faac": - return "AAC (faac)"; - case "lame": - return "MP3 (lame)"; - case "vorbis": - return "Vorbis (vorbis)"; - case "ffac3": - return "AC3 (ffmpeg)"; - case "copy:ac3": - return "AC3 Passthru"; - case "copy:dts": - return "DTS Passthru"; - case "copy:dtshd": - return "MP3 Passthru"; - case "copy:mp3": - return "AAC Passthru"; - case "copy:aac": - return "DTS-HD Passthru"; - case "ffaac": - return "AAC (ffmpeg)"; - case "ffflac": - return "FLAC (ffmpeg)"; - case "ffflac24": - return "FLAC (24-bit)"; - case "copy": - return "Auto Passthru"; - default: - return "AAC (faac)"; - } - } - /// /// Get the GUI equiv to a CLI audio encoder /// @@ -205,17 +165,24 @@ namespace HandBrake.ApplicationServices.Utilities switch (audioEnc) { case "faac": - return AudioEncoder.Faac; case "ffaac": return AudioEncoder.ffaac; + case "fdk_aac": + return AudioEncoder.fdkaac; + case "fdk_haac": + return AudioEncoder.fdkheaac; + case "mp3": case "lame": return AudioEncoder.Lame; case "vorbis": return AudioEncoder.Vorbis; + case "ac3": case "ffac3": return AudioEncoder.Ac3; + case "flac16": case "ffflac": return AudioEncoder.ffflac; + case "flac24": case "ffflac24": return AudioEncoder.ffflac24; case "copy:ac3": @@ -231,7 +198,7 @@ namespace HandBrake.ApplicationServices.Utilities case "copy": return AudioEncoder.Passthrough; default: - return AudioEncoder.Faac; + return AudioEncoder.ffaac; } } @@ -245,16 +212,22 @@ namespace HandBrake.ApplicationServices.Utilities switch (audioEnc) { case "AAC (faac)": - return AudioEncoder.Faac; + case "AAC (CoreAudio)": case "AAC (ffmpeg)": + case "AAC (avcodec)": return AudioEncoder.ffaac; - case "AAC (CoreAudio)": - return AudioEncoder.Faac; + case "AAC (FDK)": + return AudioEncoder.fdkaac; + case "HE-AAC (FDK)": + return AudioEncoder.fdkheaac; case "MP3 (lame)": + case "MP3": return AudioEncoder.Lame; case "Vorbis (vorbis)": + case "Vorbis": return AudioEncoder.Vorbis; case "AC3 (ffmpeg)": + case "AC3": return AudioEncoder.Ac3; case "AC3 Passthru": return AudioEncoder.Ac3Passthrough; @@ -267,13 +240,15 @@ namespace HandBrake.ApplicationServices.Utilities case "MP3 Passthru": return AudioEncoder.Mp3Passthru; case "FLAC (ffmpeg)": + case "FLAC 16-bit": return AudioEncoder.ffflac; case "FLAC (24-bit)": + case "FLAC 24-bit": return AudioEncoder.ffflac24; case "Auto Passthru": return AudioEncoder.Passthrough; default: - return AudioEncoder.Faac; + return AudioEncoder.ffaac; } } @@ -288,43 +263,12 @@ namespace HandBrake.ApplicationServices.Utilities /// public static string GetCliAudioEncoder(AudioEncoder selectedEncoder) { - switch (selectedEncoder) - { - case AudioEncoder.Faac: - return "faac"; - case AudioEncoder.ffaac: - return "ffaac"; - - case AudioEncoder.Lame: - return "lame"; - case AudioEncoder.Vorbis: - return "vorbis"; - case AudioEncoder.Ac3Passthrough: - return "copy:ac3"; - case AudioEncoder.DtsPassthrough: - return "copy:dts"; - case AudioEncoder.DtsHDPassthrough: - return "copy:dtshd"; - case AudioEncoder.Ac3: - return "ffac3"; - case AudioEncoder.AacPassthru: - return "copy:aac"; - case AudioEncoder.Mp3Passthru: - return "copy:mp3"; - case AudioEncoder.Passthrough: - return "copy"; - case AudioEncoder.ffflac: - return "ffflac"; - case AudioEncoder.ffflac24: - return "ffflac24"; - default: - return "faac"; - } + return EnumHelper.GetShortName(selectedEncoder); } #endregion - #region Video + #region Video /// /// Get the Video Encoder for a given string @@ -339,11 +283,12 @@ namespace HandBrake.ApplicationServices.Utilities { switch (encoder) { - case "": case "ffmpeg": case "ffmpeg4": + case "mpeg4": return VideoEncoder.FFMpeg; case "ffmpeg2": + case "mpeg2": return VideoEncoder.FFMpeg2; case "x264": return VideoEncoder.X264; @@ -368,9 +313,9 @@ namespace HandBrake.ApplicationServices.Utilities switch (encoder) { case VideoEncoder.FFMpeg: - return "ffmpeg4"; + return "mpeg4"; case VideoEncoder.FFMpeg2: - return "ffmpeg2"; + return "mpeg2"; case VideoEncoder.X264: return "x264"; case VideoEncoder.Theora: diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs index c854e5a05..43667557b 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs @@ -17,6 +17,8 @@ namespace HandBrake.ApplicationServices.Utilities using System.Linq; using System.Reflection; + using HandBrake.Interop.Attributes; + /// /// Enum Helpers /// @@ -93,6 +95,23 @@ namespace HandBrake.ApplicationServices.Utilities throw new ArgumentOutOfRangeException("The Description for the enum was not recognized."); } + /// + /// The get short name. + /// + /// + /// The value. + /// + /// + /// The . + /// + public static string GetShortName(T value) + { + FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); + ShortName[] attributes = (ShortName[])fieldInfo.GetCustomAttributes(typeof(ShortName), false); + + return (attributes.Length > 0) ? attributes[0].Name : value.ToString(); + } + /// /// Return a list of all the enum values. /// diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index 356e12c8c..42f075508 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -12,11 +12,9 @@ namespace HandBrake.ApplicationServices.Utilities using System; using System.Collections.Generic; using System.Diagnostics; - using System.Globalization; using System.IO; using System.Linq; using System.Text; - using System.Text.RegularExpressions; using System.Windows.Forms; using HandBrake.ApplicationServices.Model; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs new file mode 100644 index 000000000..cf32cb802 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs @@ -0,0 +1,35 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// A Short Name for an enum value +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Attributes +{ + using System; + + /// + /// A Short Name for an enum value + /// + public class ShortName : Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The short name. + /// + public ShortName(string shortName) + { + this.Name = shortName; + } + + /// + /// Gets or sets the short name. + /// + public string Name { get; set; } + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs index e7f172e32..4e04222ed 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs @@ -78,10 +78,12 @@ namespace HandBrake.Interop return NativeConstants.HB_ACODEC_AC3_PASS; case AudioEncoder.Ac3: return NativeConstants.HB_ACODEC_AC3; - case AudioEncoder.Faac: - return NativeConstants.HB_ACODEC_FAAC; case AudioEncoder.ffaac: return NativeConstants.HB_ACODEC_FFAAC; + case AudioEncoder.fdkaac: + return NativeConstants.HB_ACODEC_FDK_AAC; + case AudioEncoder.fdkheaac: + return NativeConstants.HB_ACODEC_FDK_HAAC; case AudioEncoder.AacPassthru: return NativeConstants.HB_ACODEC_AAC_PASS; case AudioEncoder.Lame: @@ -127,9 +129,12 @@ namespace HandBrake.Interop case NativeConstants.HB_ACODEC_FFAAC: case NativeConstants.HB_ACODEC_CA_AAC: case NativeConstants.HB_ACODEC_CA_HAAC: + case NativeConstants.HB_ACODEC_FDK_HAAC: // TODO Check this is correct + case NativeConstants.HB_ACODEC_FDK_AAC: // TODO Check this is correct return AudioCodec.Aac; case NativeConstants.HB_ACODEC_FFFLAC: return AudioCodec.Flac; + default: return AudioCodec.Other; } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index 6de4a9adb..59fe341b5 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -124,6 +124,7 @@ + diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs index 23181e7fe..52d1d253e 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs @@ -12,38 +12,42 @@ namespace HandBrake.Interop.HbLib { public partial class NativeConstants { - public const uint HB_ACODEC_MASK = 0x00FFFF00; - public const uint HB_ACODEC_FAAC = 0x00000100; - public const uint HB_ACODEC_LAME = 0x00000200; - public const uint HB_ACODEC_VORBIS = 0x00000400; - public const uint HB_ACODEC_AC3 = 0x00000800; - public const uint HB_ACODEC_LPCM = 0x00001000; - public const uint HB_ACODEC_DCA = 0x00002000; - public const uint HB_ACODEC_CA_AAC = 0x00004000; - public const uint HB_ACODEC_CA_HAAC = 0x00008000; - public const uint HB_ACODEC_FFAAC = 0x00010000; - public const uint HB_ACODEC_FFMPEG = 0x00020000; - public const uint HB_ACODEC_DCA_HD = 0x00040000; - public const uint HB_ACODEC_MP3 = 0x00080000; - public const uint HB_ACODEC_FFFLAC = 0x00100000; - public const uint HB_ACODEC_FDK_AAC = 0x00400000; - public const uint HB_ACODEC_FDK_HAAC = 0x00800000; - public const uint HB_ACODEC_FF_MASK = 0x00FF2000; - public const uint HB_ACODEC_PASS_FLAG = 0x40000000; - public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_MP3 | HB_ACODEC_FFAAC | HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA); - public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG); + // Audio Encoders + public const uint HB_ACODEC_MASK = 0x00FFFF00; + public const uint HB_ACODEC_FAAC = 0x00000100; + public const uint HB_ACODEC_LAME = 0x00000200; + public const uint HB_ACODEC_VORBIS = 0x00000400; + public const uint HB_ACODEC_AC3 = 0x00000800; + public const uint HB_ACODEC_LPCM = 0x00001000; + public const uint HB_ACODEC_DCA = 0x00002000; + public const uint HB_ACODEC_CA_AAC = 0x00004000; + public const uint HB_ACODEC_CA_HAAC = 0x00008000; + public const uint HB_ACODEC_FFAAC = 0x00010000; + public const uint HB_ACODEC_FFMPEG = 0x00020000; + public const uint HB_ACODEC_DCA_HD = 0x00040000; + public const uint HB_ACODEC_MP3 = 0x00080000; + public const uint HB_ACODEC_FFFLAC = 0x00100000; + public const uint HB_ACODEC_FFFLAC24 = 0x00200000; + public const uint HB_ACODEC_FDK_AAC = 0x00400000; + public const uint HB_ACODEC_FDK_HAAC = 0x00800000; + public const uint HB_ACODEC_FF_MASK = 0x00FF2000; + public const uint HB_ACODEC_PASS_FLAG = 0x40000000; + public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_MP3 | HB_ACODEC_FFAAC | HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA); + public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG); + // Subtitle Types public const int HB_SUBSTREAM_BD_TRUEHD = 0x72; public const int HB_SUBSTREAM_BD_AC3 = 0x76; public const int HB_SUBSTREAM_BD_DTSHD = 0x72; public const int HB_SUBSTREAM_BD_DTS = 0x71; + // Video Encoders public const int HB_VCODEC_MASK = 0x0000FF; public const int HB_VCODEC_X264 = 0x000001; public const int HB_VCODEC_THEORA = 0x000002; @@ -52,6 +56,7 @@ namespace HandBrake.Interop.HbLib public const int HB_VCODEC_FFMPEG_MPEG2 = 0x000020; public const int HB_VCODEC_FFMPEG_MASK = 0x0000F0; + // Muxers public const int HB_MUX_MASK = 0xFF0000; public const int HB_MUX_MP4 = 0x010000; public const int HB_MUX_MKV = 0x200000; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs index 8fb242ac6..bc7b5bf20 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs @@ -11,48 +11,71 @@ namespace HandBrake.Interop.Model.Encoding { using System.ComponentModel.DataAnnotations; + using HandBrake.Interop.Attributes; + /// /// The audio encoder. /// public enum AudioEncoder { [Display(Name = "AAC (faac)")] - Faac = 0, + [ShortName("faac")] + faac = 0, - [Display(Name = "AAC (ffmpeg)")] + [Display(Name = "AAC (avcodec)")] + [ShortName("av_aac")] ffaac, - [Display(Name = "MP3 (lame)")] + [Display(Name = "AAC (FDK)")] + [ShortName("fdk_aac")] + fdkaac, + + [Display(Name = "HE-AAC (FDK)")] + [ShortName("fdk_haac")] + fdkheaac, + + [Display(Name = "MP3")] + [ShortName("mp3")] Lame, - [Display(Name = "AC3 (ffmpeg)")] + [Display(Name = "AC3")] + [ShortName("ac3")] Ac3, [Display(Name = "Auto Passthru")] + [ShortName("copy")] Passthrough, [Display(Name = "AC3 Passthru")] + [ShortName("copy:ac3")] Ac3Passthrough, [Display(Name = "DTS Passthru")] + [ShortName("copy:dts")] DtsPassthrough, [Display(Name = "DTS-HD Passthru")] + [ShortName("copy:dtshd")] DtsHDPassthrough, [Display(Name = "AAC Passthru")] + [ShortName("copy:aac")] AacPassthru, [Display(Name = "MP3 Passthru")] + [ShortName("copy:mp3")] Mp3Passthru, - [Display(Name = "Vorbis (vorbis)")] + [Display(Name = "Vorbis")] + [ShortName("vorbis")] Vorbis, - [Display(Name = "FLAC (ffmpeg)")] + [Display(Name = "FLAC 16-bit")] + [ShortName("flac16")] ffflac, - [Display(Name = "FLAC (24-bit)")] + [Display(Name = "FLAC 24-bit")] + [ShortName("flac24")] ffflac24, } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs index 31cc3d599..e05f74419 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs @@ -2,24 +2,36 @@ // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // +// +// The video encoder. +// // -------------------------------------------------------------------------------------------------------------------- namespace HandBrake.Interop.Model.Encoding { using System.ComponentModel.DataAnnotations; - public enum VideoEncoder + using HandBrake.Interop.Attributes; + + /// + /// The video encoder. + /// + public enum VideoEncoder { [Display(Name = "H.264 (x264)")] + [ShortName("x264")] X264 = 0, [Display(Name = "MPEG-4 (FFmpeg)")] + [ShortName("mpeg4")] FFMpeg, [Display(Name = "MPEG-2 (FFmpeg)")] + [ShortName("mpeg2")] FFMpeg2, [Display(Name = "VP3 (Theora)")] + [ShortName("theora")] Theora } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs index dce947311..d24c9998b 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs @@ -48,6 +48,6 @@ namespace HandBrake.Interop.SourceData /// /// The flac. /// - Flac + Flac, } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs index f4e805957..bd7aeffca 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs @@ -70,14 +70,10 @@ namespace HandBrakeWPF.Converters.Audio int samplerate = this.GetBestSampleRate(track); int srShift = this.GetSamplerateShift(samplerate); int lfeCount = this.GetLowFreqChannelCount(track.MixDown); - int channels = this.GetChannelCount(track.MixDown) - lfeCount; + int channels = this.GetDiscreteChannelCount(track.MixDown) - lfeCount; switch (track.Encoder) { - case AudioEncoder.Faac: - low = (channels + lfeCount) * 32; - max = (channels + lfeCount) * (192 >> srShift); - break; case AudioEncoder.ffaac: low = ((channels + lfeCount) * 32); max = ((channels + lfeCount) * ((192 + (64 * ((samplerate << srShift) >= 44100 ? 1 : 0))) >> srShift)); @@ -101,8 +97,17 @@ namespace HandBrakeWPF.Converters.Audio case AudioEncoder.Mp3Passthru: case AudioEncoder.Passthrough: case AudioEncoder.ffflac: + case AudioEncoder.ffflac24: max = 1536; // Since we don't care, just set it to the max. break; + case AudioEncoder.fdkaac: + low = channels * samplerate * 2 / 3000; + max = channels * samplerate * 6 / 1000; + break; + case AudioEncoder.fdkheaac: + low = (channels * (12 + (4 * (samplerate >= 44100 ? 1 : 0)))); + max = (channels - (channels > 2 ? 1 : 0)) * (48 + (16 * (samplerate >= 22050 ? 1 : 0))); + break; default: max = 768; break; @@ -132,7 +137,7 @@ namespace HandBrakeWPF.Converters.Audio /// /// The System.Int32. /// - private int GetChannelCount(Mixdown mixdown) + private int GetDiscreteChannelCount(Mixdown mixdown) { switch (mixdown) { @@ -228,6 +233,10 @@ namespace HandBrakeWPF.Converters.Audio { // AC-3 < 32 kHz suffers from poor hardware compatibility bestSamplerate = 32000; + } + else if ((samplerate < 16000) && (track.Encoder == AudioEncoder.fdkheaac)) + { + bestSamplerate = 16000; } else { diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs index 1db7a7c0a..27cb2e5de 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs @@ -51,6 +51,8 @@ namespace HandBrakeWPF.Converters.Audio List encoders = EnumHelper.GetEnumList().ToList(); EncodeTask task = values[1] as EncodeTask; + encoders.Remove(AudioEncoder.faac); + if (task != null && task.OutputFormat != OutputFormat.Mkv) { encoders.Remove(AudioEncoder.Vorbis); diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 222b8a71c..81ac6a688 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -938,7 +938,11 @@ namespace HandBrakeWPF.ViewModels // Perform an update check if required this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults); + // Show or Hide the Preset Panel. + this.IsPresetPanelShowing = this.userSettingService.GetUserSetting(UserSettingConstants.ShowPresetPanel); + // Setup the presets. + this.presetService.Load(); if (this.presetService.CheckIfPresetsAreOutOfDate()) if (!this.userSettingService.GetUserSetting(UserSettingConstants.PresetNotification)) this.errorService.ShowMessageBox("HandBrake has determined your built-in presets are out of date... These presets will now be updated." + Environment.NewLine + @@ -953,9 +957,6 @@ namespace HandBrakeWPF.ViewModels // Populate the Source menu with drives. this.SourceMenu = new BindingList(this.GenerateSourceMenu()); - // Show or Hide the Preset Panel. - this.IsPresetPanelShowing = this.userSettingService.GetUserSetting(UserSettingConstants.ShowPresetPanel); - // Log Cleaning if (userSettingService.GetUserSetting(UserSettingConstants.ClearOldLogs)) { -- cgit v1.2.3