<Compile Include="Interop\Model\Encoding\HBMixdown.cs" />\r
<Compile Include="Interop\Model\Encoding\HBRate.cs" />\r
<Compile Include="Interop\Model\Encoding\HBVideoEncoder.cs" />\r
- <Compile Include="Interop\Model\Encoding\Mixdown.cs" />\r
<Compile Include="Interop\Model\Encoding\PictureRotation.cs" />\r
<Compile Include="Interop\Model\Encoding\ScaleMethod.cs" />\r
<Compile Include="Interop\Model\Encoding\VideoEncoder.cs" />\r
return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0;\r
}\r
\r
+ /// <summary>\r
+ /// Determines if a mixdown is available for a given track and encoder.\r
+ /// </summary>\r
+ /// <param name="mixdown">\r
+ /// The mixdown to evaluate.\r
+ /// </param>\r
+ /// <param name="encoder">\r
+ /// The encoder to evaluate.\r
+ /// </param>\r
+ /// <param name="channelLayout">channel layout of the source track</param>\r
+ /// <returns>True if available.</returns>\r
+ public static bool MixdownIsSupported(HBMixdown mixdown, HBAudioEncoder encoder, int channelLayout)\r
+ {\r
+ return HBFunctions.hb_mixdown_is_supported(mixdown.Id, (uint)encoder.Id, (uint)channelLayout) > 0;\r
+ }\r
+\r
/// <summary>\r
/// Determines if DRC can be applied to the given track with the given encoder.\r
/// </summary>\r
public string AudioEncoder { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the audio mixdown.\r
+ /// Gets or sets the audio mixdown. (ShortName)\r
/// </summary>\r
public string AudioMixdown { get; set; }\r
\r
+++ /dev/null
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="Mixdown.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
-// Defines the Mixdown type.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Interop.Model.Encoding\r
-{\r
- using System.ComponentModel.DataAnnotations;\r
- using HandBrake.ApplicationServices.Attributes;\r
-\r
- /// <summary>\r
- /// The Audio Mixdown Enumeration\r
- /// </summary>\r
- public enum Mixdown\r
- {\r
- [Display(Name = "Dolby Pro Logic II")]\r
- [ShortName("dpl2")]\r
- DolbyProLogicII = 0,\r
-\r
- [Display(Name = "None")]\r
- [ShortName("none")]\r
- None,\r
-\r
- [Display(Name = "Automatic")]\r
- [ShortName("none")]\r
- Auto,\r
-\r
- [Display(Name = "Mono")]\r
- [ShortName("mono")]\r
- Mono,\r
-\r
- [Display(Name = "Mono (Left Only)")]\r
- [ShortName("left_only")]\r
- LeftOnly,\r
-\r
- [Display(Name = "Mono (Right Only)")]\r
- [ShortName("right_only")]\r
- RightOnly,\r
-\r
- [Display(Name = "Stereo")]\r
- [ShortName("stereo")]\r
- Stereo,\r
-\r
- [Display(Name = "Dolby Surround")]\r
- [ShortName("dpl1")]\r
- DolbySurround,\r
-\r
- [Display(Name = "5.1 Channels")]\r
- [ShortName("5point1")]\r
- FivePoint1Channels,\r
-\r
- [Display(Name = "6.1 Channels")]\r
- [ShortName("6point1")]\r
- SixPoint1Channels,\r
-\r
- [Display(Name = "7.1 Channels")]\r
- [ShortName("7point1")]\r
- SevenPoint1Channels,\r
-\r
- [Display(Name = "7.1 (5F/2R/LFE)")]\r
- [ShortName("5_2_lfe")]\r
- Five_2_LFE,\r
- }\r
-}\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioMixdownConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the AudioMixdownConverter type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Audio
+{
+ using System.Globalization;
+ using System.Windows.Data;
+ using System;
+
+ using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+
+ /// <summary>
+ /// The audio mixdown converter.
+ /// Handles conversion between HBMixdown and it's shortname.
+ /// </summary>
+ public class AudioMixdownConverter : IValueConverter
+ {
+ /// <summary>
+ /// Converts a value.
+ /// </summary>
+ /// <returns>
+ /// A converted value. If the method returns null, the valid null value is used.
+ /// </returns>
+ /// <param name="value">The value produced by the binding source.</param><param name="targetType">The type of the binding target property.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string mixdown = value as string;
+ if (!string.IsNullOrEmpty(mixdown))
+ {
+ return HandBrakeEncoderHelpers.GetMixdown(mixdown);
+ }
+
+ return HandBrakeEncoderHelpers.GetMixdown("dpl2"); // Default
+ }
+
+ /// <summary>
+ /// Converts a value.
+ /// </summary>
+ /// <returns>
+ /// A converted value. If the method returns null, the valid null value is used.
+ /// </returns>
+ /// <param name="value">The value that is produced by the binding target.</param><param name="targetType">The type to convert to.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ HBMixdown mixdown = value as HBMixdown;
+ if (mixdown != null)
+ {
+ return mixdown.ShortName;
+ }
+
+ return "none";
+ }
+ }
+}
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioMixdownListConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the AudioMixdownListConverter type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Audio
+{
+ using System.Globalization;
+ using System.Windows.Data;
+ using System;
+ using System.ComponentModel;
+
+ using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+
+ using HandBrakeWPF.Services.Encode.Model.Models;
+ using HandBrakeWPF.Utilities;
+
+ /// <summary>
+ /// The audio mixdown converter.
+ /// Returns the list of available mixdowns for the given track and encoder.
+ /// </summary>
+ public class AudioMixdownListConverter : IValueConverter
+ {
+ /// <summary>
+ /// Converts a value.
+ /// </summary>
+ /// <returns>
+ /// A converted value. If the method returns null, the valid null value is used.
+ /// </returns>
+ /// <param name="value">The value produced by the binding source.</param><param name="targetType">The type of the binding target property.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ AudioTrack track = value as AudioTrack;
+ if (track != null && track.ScannedTrack != null)
+ {
+ HBAudioEncoder encoder =
+ HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(track.Encoder));
+
+ BindingList<HBMixdown> mixdowns = new BindingList<HBMixdown>();
+ foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns)
+ {
+ if (HandBrakeEncoderHelpers.MixdownIsSupported(
+ mixdown,
+ encoder,
+ track.ScannedTrack.ChannelLayout))
+ {
+ mixdowns.Add(mixdown);
+ }
+ }
+
+ return mixdowns;
+ }
+
+ return value;
+ }
+
+ /// <summary>
+ /// Converts a value.
+ /// </summary>
+ /// <returns>
+ /// A converted value. If the method returns null, the valid null value is used.
+ /// </returns>
+ /// <param name="value">The value that is produced by the binding target.</param><param name="targetType">The type to convert to.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+
+ return value;
+ }
+ }
+}
{\r
return EnumHelper<VideoEncoder>.GetEnumDisplayValues(typeof(VideoEncoder));\r
}\r
- if (value is IEnumerable<Mixdown>)\r
- {\r
- return EnumHelper<Mixdown>.GetEnumDisplayValues(typeof(Mixdown));\r
- }\r
if (value is IEnumerable<PresetPictureSettingsMode>)\r
{\r
return EnumHelper<PresetPictureSettingsMode>.GetEnumDisplayValues(typeof(PresetPictureSettingsMode));\r
if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))\r
{\r
return EnumHelper<VideoEncoder>.GetDisplay((VideoEncoder)value);\r
- }\r
- if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown))\r
- {\r
- return EnumHelper<Mixdown>.GetDisplay((Mixdown)value);\r
- }\r
- \r
+ } \r
if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode))\r
{\r
return EnumHelper<PresetPictureSettingsMode>.GetDisplay((PresetPictureSettingsMode)value);\r
{\r
return EnumHelper<VideoEncoder>.GetValue(value.ToString());\r
}\r
- if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown))\r
- {\r
- return EnumHelper<Mixdown>.GetValue(value.ToString());\r
- }\r
if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode))\r
{\r
return EnumHelper<PresetPictureSettingsMode>.GetValue(value.ToString());\r
<Compile Include="Controls\AlertPanel.xaml.cs">\r
<DependentUpon>AlertPanel.xaml</DependentUpon>\r
</Compile>\r
+ <Compile Include="Converters\Audio\AudioMixdownListConverter.cs" />\r
+ <Compile Include="Converters\Audio\AudioMixdownConverter.cs" />\r
<Compile Include="Converters\Audio\AudioRateTypeConverter.cs" />\r
<Compile Include="Converters\Audio\AudioTrackDefaultBehaviourConverter.cs" />\r
<Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />\r
HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(item.Encoder));
Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);
- HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(item.MixDown));
+ HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(item.MixDown);
Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.MixDown);
HBRate sampleRate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(s => s.Name == item.SampleRate.ToString(CultureInfo.InvariantCulture));
private double drc;
private HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder encoder;
private int gain;
- private Mixdown mixDown;
+ private string mixDown;
private double sampleRate;
[NonSerialized]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
{
// Default Values
this.Encoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder.ffaac;
- this.MixDown = Mixdown.DolbyProLogicII;
+ this.MixDown = HandBrakeEncoderHelpers.Mixdowns.FirstOrDefault(m => m.ShortName == "dpl2")?.ShortName;
this.SampleRate = 48;
this.Bitrate = 160;
this.DRC = 0;
}
/// <summary>
- /// Gets or sets Audio Mixdown
+ /// Gets or sets Audio Mixdown (ShortName)
/// </summary>
- public Mixdown MixDown
+ public string MixDown
{
get
{
- return this.IsPassthru ? Mixdown.Auto : this.mixDown;
+ return this.IsPassthru ? null : this.mixDown;
}
set
this.mixDown = value;
this.NotifyOfPropertyChange(() => this.MixDown);
this.SetupLimits();
- this.NotifyOfPropertyChange(() => this.TrackReference);
}
}
this.NotifyOfPropertyChange(() => this.IsBitrateVisible);
this.NotifyOfPropertyChange(() => this.IsQualityVisible);
this.NotifyOfPropertyChange(() => this.IsRateTypeVisible);
- this.SetupLimits();
this.NotifyOfPropertyChange(() => this.TrackReference);
+ this.GetDefaultMixdownIfNull();
+ this.SetupLimits();
// Refresh the available encoder rate types.
this.NotifyOfPropertyChange(() => this.AudioEncoderRateTypes);
this.sampleRate = value;
this.NotifyOfPropertyChange(() => this.SampleRate);
this.SetupLimits();
- this.NotifyOfPropertyChange(() => this.TrackReference);
}
}
}
}
- /// <summary>
- /// Gets AudioMixdownDisplayValue.
- /// </summary>
- [JsonIgnore]
- public string AudioMixdownDisplayValue
- {
- get
- {
- return EnumHelper<Mixdown>.GetDisplay(this.MixDown);
- }
- }
-
/// <summary>
/// Gets the The UI display value for bit rate
/// </summary>
{
this.scannedTrack = value;
this.NotifyOfPropertyChange(() => this.ScannedTrack);
+ this.NotifyOfPropertyChange(() => this.TrackReference);
+
+ this.GetDefaultMixdownIfNull();
}
}
// Based on the users settings, find the high and low bitrates.
HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder>.GetShortName(this.Encoder));
HBRate rate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(t => t.Name == this.SampleRate.ToString(CultureInfo.InvariantCulture));
- HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(this.MixDown));
+ HBMixdown mixdown = this.mixDown != null ? HandBrakeEncoderHelpers.GetMixdown(this.mixDown) : HandBrakeEncoderHelpers.GetMixdown("dpl2");
BitrateLimits limits = HandBrakeEncoderHelpers.GetBitrateLimits(hbaenc, rate != null ? rate.Rate : 48000, mixdown);
if (limits != null)
this.NotifyOfPropertyChange(() => this.EncoderQualityValues);
}
+ /// <summary>
+ /// Set the default mixdown when the mixdown is null or "none"
+ /// </summary>
+ private void GetDefaultMixdownIfNull()
+ {
+ if ((this.mixDown == null || this.mixDown == "none" ) && this.ScannedTrack != null)
+ {
+ HBAudioEncoder aencoder =
+ HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.encoder));
+
+ HBMixdown mixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(aencoder, (uint)this.ScannedTrack.ChannelLayout);
+
+ this.MixDown = mixdown.ShortName;
+ }
+ }
+
#endregion
}
}
\ No newline at end of file
using System.Globalization;\r
using System.Linq;\r
\r
+ using HandBrake.ApplicationServices.Interop;\r
using HandBrake.ApplicationServices.Interop.Json.Presets;\r
using HandBrake.ApplicationServices.Interop.Model;\r
using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
// track.CompressionLevel = audioTrack.AudioCompressionLevel;\r
// track.AudioDitherMethod = audioTrack.AudioDitherMethod;\r
track.Encoder = EnumHelper<AudioEncoder>.GetValue(audioTrack.AudioEncoder);\r
- track.MixDown = EnumHelper<Mixdown>.GetValue(audioTrack.AudioMixdown);\r
+ track.MixDown = audioTrack.AudioMixdown;\r
\r
// track.AudioNormalizeMixLevel = audioTrack.AudioNormalizeMixLevel;\r
track.SampleRate = audioTrack.AudioSamplerate == "auto" ? 0 : double.Parse(audioTrack.AudioSamplerate);\r
AudioCompressionLevel = 0, // TODO\r
AudioDitherMethod = null, // TODO\r
AudioEncoder = EnumHelper<AudioEncoder>.GetShortName(item.Encoder),\r
- AudioMixdown = EnumHelper<Mixdown>.GetShortName(item.MixDown),\r
+ AudioMixdown = item.MixDown,\r
AudioNormalizeMixLevel = false, // TODO\r
AudioSamplerate = item.SampleRate == 0 ? "auto" : item.SampleRate.ToString(), // TODO check formatting.\r
AudioTrackDRCSlider = item.DRC,\r
int currentAudioTrack = 1;
foreach (SourceAudioTrack track in title.AudioList)
{
- converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate));
+
+ converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate, track.ChannelLayout));
currentAudioTrack++;
}
/// <param name="bitrate">
/// The bitrate.
/// </param>
- public Audio(int trackNumber, string language, string languageCode, string description, string format, int sampleRate, int bitrate)
+ /// <param name="channelLayout">
+ /// The channel Layout.
+ /// </param>
+ public Audio(int trackNumber, string language, string languageCode, string description, string format, int sampleRate, int bitrate, int channelLayout)
{
+ this.ChannelLayout = channelLayout;
this.TrackNumber = trackNumber;
this.Language = language;
this.LanguageCode = languageCode;
/// </summary>
public int Bitrate { get; set; }
+ /// <summary>
+ /// Gets or sets the channel layout of the source track (mixdown)
+ /// </summary>
+ public int ChannelLayout { get; set; }
+
/// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// </summary>
}\r
\r
this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();\r
- this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList();\r
this.SourceTracks = new List<Audio>();\r
}\r
\r
/// </summary>\r
public IEnumerable<AudioEncoder> AudioEncoders { get; set; }\r
\r
- /// <summary>\r
- /// Gets or sets AudioMixdowns.\r
- /// </summary>\r
- public IEnumerable<Mixdown> AudioMixdowns { get; set; }\r
-\r
/// <summary>\r
/// Gets or sets SampleRates.\r
/// </summary>\r
<Conveters:BooleanToHiddenVisibilityConverter x:Key="boolToHiddenVisConverter" />\r
<Audio:AudioEncoderConverter x:Key="audioEncoderConverter" />\r
<Audio:AudioRateTypeConverter x:Key="audioRateTypeConverter" />\r
+ <Audio:AudioMixdownConverter x:Key="audioMixdownConverter" />\r
+ <Audio:AudioMixdownListConverter x:Key="audioMixdownListConverter" />\r
</UserControl.Resources>\r
\r
<Grid>\r
<TextBlock Grid.Row="0" Grid.Column="6" VerticalAlignment="Center" FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.AudioView_Mixdown}"\r
Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />\r
<ComboBox Grid.Row="0" Grid.Column="7" Height="22" Width="120" Margin="5,0,5,0" HorizontalAlignment="Stretch"\r
- ItemsSource="{Binding DataContext.AudioMixdowns, Converter={StaticResource enumComboConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"\r
- SelectedItem="{Binding MixDown, Converter={StaticResource enumComboConverter}}"\r
+ ItemsSource="{Binding TrackReference, Converter={StaticResource audioMixdownListConverter}}"\r
+ SelectedItem="{Binding MixDown, Converter={StaticResource audioMixdownConverter}}"\r
+ DisplayMemberPath="DisplayName"\r
Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />\r
\r
\r