summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-06-20 19:45:31 +0000
committersr55 <[email protected]>2015-06-20 19:45:31 +0000
commitae9dbce961c2d87e5f52288c35fbf882de8430c7 (patch)
treec8da7e616457a9fa67505de26ad3dfffcdb8dc8f
parent9192276e8bfde8ac2ce798edf677be141ad5e9b5 (diff)
WinGui: Initial implementation of quality based encoding option. Please note, the preset version has been bumped so user presets will need to be re-created.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7306 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj3
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs89
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs51
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoder.cs (renamed from win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs)2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs31
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs269
-rw-r--r--win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs94
-rw-r--r--win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs1
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj1
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs2
-rw-r--r--win/CS/HandBrakeWPF/Views/AudioView.xaml25
12 files changed, 467 insertions, 102 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index a5feef9b2..524729f20 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -150,7 +150,7 @@
<Compile Include="Interop\Model\BitrateLimits.cs" />
<Compile Include="Interop\Model\Cropping.cs" />
<Compile Include="Interop\Model\Encoding\Anamorphic.cs" />
- <Compile Include="Interop\Model\Encoding\AudioEncoder.cs" />
+ <Compile Include="Services\Encode\Model\Models\AudioEncoder.cs" />
<Compile Include="Interop\Model\Encoding\Container.cs" />
<Compile Include="Interop\Model\Encoding\Decomb.cs" />
<Compile Include="Interop\Model\Encoding\Deinterlace.cs" />
@@ -176,6 +176,7 @@
<Compile Include="Services\Encode\Factories\VideoPresetFactory.cs" />
<Compile Include="Services\Encode\Factories\VideoLevelFactory.cs" />
<Compile Include="Services\Encode\Factories\VideoTuneFactory.cs" />
+ <Compile Include="Services\Encode\Model\Models\AudioEncoderRateType.cs" />
<Compile Include="Services\Encode\Model\Models\DenoisePreset.cs" />
<Compile Include="Services\Encode\Model\Models\DenoiseTune.cs" />
<Compile Include="Model\HBConfiguration.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs
index 524b6b0ad..cddfd3634 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs
@@ -9,7 +9,6 @@
namespace HandBrake.ApplicationServices.Interop
{
- using System;
using System.Collections.Generic;
using System.Linq;
@@ -45,7 +44,7 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// List of HandBrake containers.
- /// </summary>
+ /// </summary>
private static List<HBContainer> containers;
/// <summary>
@@ -262,8 +261,12 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// Returns true if the subtitle source type can be set to forced only.
/// </summary>
- /// <param name="source">The subtitle source type (SSA, VobSub, etc)</param>
- /// <returns>True if the subtitle source type can be set to forced only.</returns>
+ /// <param name="source">
+ /// The subtitle source type (SSA, VobSub, etc)
+ /// </param>
+ /// <returns>
+ /// True if the subtitle source type can be set to forced only.
+ /// </returns>
public static bool SubtitleCanSetForcedOnly(int source)
{
return HBFunctions.hb_subtitle_can_force(source) > 0;
@@ -272,8 +275,12 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// Returns true if the subtitle source type can be burned in.
/// </summary>
- /// <param name="source">The subtitle source type (SSA, VobSub, etc)</param>
- /// <returns>True if the subtitle source type can be burned in.</returns>
+ /// <param name="source">
+ /// The subtitle source type (SSA, VobSub, etc)
+ /// </param>
+ /// <returns>
+ /// True if the subtitle source type can be burned in.
+ /// </returns>
public static bool SubtitleCanBurn(int source)
{
return HBFunctions.hb_subtitle_can_burn(source) > 0;
@@ -282,9 +289,15 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// Returns true if the subtitle type can be passed through using the given muxer.
/// </summary>
- /// <param name="subtitleSourceType">The subtitle source type (SSA, VobSub, etc)</param>
- /// <param name="muxer">The ID of the muxer.</param>
- /// <returns>True if the subtitle type can be passed through with the given muxer.</returns>
+ /// <param name="subtitleSourceType">
+ /// The subtitle source type (SSA, VobSub, etc)
+ /// </param>
+ /// <param name="muxer">
+ /// The ID of the muxer.
+ /// </param>
+ /// <returns>
+ /// True if the subtitle type can be passed through with the given muxer.
+ /// </returns>
public static bool SubtitleCanPassthrough(int subtitleSourceType, int muxer)
{
return HBFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0;
@@ -293,8 +306,12 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// Gets the subtitle source type's name.
/// </summary>
- /// <param name="source">The subtitle source type (SSA, VobSub, etc).</param>
- /// <returns>The name of the subtitle source.</returns>
+ /// <param name="source">
+ /// The subtitle source type (SSA, VobSub, etc).
+ /// </param>
+ /// <returns>
+ /// The name of the subtitle source.
+ /// </returns>
public static string GetSubtitleSourceName(int source)
{
switch ((hb_subtitle_s_subsource)source)
@@ -492,9 +509,9 @@ namespace HandBrake.ApplicationServices.Interop
return new VideoQualityLimits
{
- Low = low,
- High = high,
- Granularity = granularity,
+ Low = low,
+ High = high,
+ Granularity = granularity,
Ascending = direction == 0
};
}
@@ -551,7 +568,7 @@ namespace HandBrake.ApplicationServices.Interop
/// <returns>
/// Limits on the audio quality for the given encoder.
/// </returns>
- internal static RangeLimits GetAudioQualityLimits(int encoderId)
+ public static RangeLimits GetAudioQualityLimits(int encoderId)
{
float low = 0, high = 0, granularity = 0;
int direction = 0;
@@ -559,9 +576,9 @@ namespace HandBrake.ApplicationServices.Interop
return new RangeLimits
{
- Low = low,
- High = high,
- Granularity = granularity,
+ Low = low,
+ High = high,
+ Granularity = granularity,
Ascending = direction == 0
};
}
@@ -575,7 +592,7 @@ namespace HandBrake.ApplicationServices.Interop
/// <returns>
/// Limits on the audio compression for the given encoder.
/// </returns>
- internal static RangeLimits GetAudioCompressionLimits(int encoderId)
+ public static RangeLimits GetAudioCompressionLimits(int encoderId)
{
float low = 0, high = 0, granularity = 0;
int direction = 0;
@@ -583,11 +600,39 @@ namespace HandBrake.ApplicationServices.Interop
return new RangeLimits
{
- Low = low,
- High = high,
- Granularity = granularity,
+ Low = low,
+ High = high,
+ Granularity = granularity,
Ascending = direction == 0
};
}
+
+ /// <summary>
+ /// The get default quality.
+ /// </summary>
+ /// <param name="encoder">
+ /// The encoder.
+ /// </param>
+ /// <returns>
+ /// The <see cref="double"/>.
+ /// </returns>
+ public static double GetDefaultQuality(HBAudioEncoder encoder)
+ {
+ return HBFunctions.hb_audio_quality_get_default((uint)encoder.Id);
+ }
+
+ /// <summary>
+ /// The get default audio compression.
+ /// </summary>
+ /// <param name="encoder">
+ /// The encoder.
+ /// </param>
+ /// <returns>
+ /// The <see cref="double"/>.
+ /// </returns>
+ public static double GetDefaultAudioCompression(HBAudioEncoder encoder)
+ {
+ return HBFunctions.hb_audio_compression_get_default((uint)encoder.Id);
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs
index a1e93f28b..1b68df438 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs
@@ -402,7 +402,6 @@ namespace HandBrake.ApplicationServices.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_image_close", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_image_close(IntPtr image);
-
/* JSON API */
// char * hb_get_title_set_json(hb_handle_t * h);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
index 12c06f011..e133492ff 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
@@ -11,6 +11,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
{
using System;
using System.Collections.Generic;
+ using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
@@ -341,6 +342,8 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(EnumHelper<Mixdown>.GetShortName(item.MixDown));
Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.MixDown);
+ HBRate sampleRate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(s => s.Name == item.SampleRate.ToString(CultureInfo.InvariantCulture));
+
HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack audioTrack = new HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack
{
Track = (item.Track.HasValue ? item.Track.Value : 0) - 1,
@@ -349,27 +352,21 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
Gain = item.Gain,
Mixdown = mixdown.Id,
NormalizeMixLevel = false,
- Samplerate = GetSampleRateRaw(item.SampleRate),
+ Samplerate = sampleRate != null ? sampleRate.Rate : 0,
Name = item.TrackName,
};
if (!item.IsPassthru)
{
- // TODO Impiment Quality and Compression. We only support bitrate right now.
- // if (item.EncodeRateType == AudioEncodeRateType.Quality)
- // {
- // audioTrack.Quality = item.Quality;
- // }
-
- // if (item.EncodeRateType == AudioEncodeRateType.Compression)
- // {
- // audioTrack.CompressionLevel = item.Compression;
- // }
-
- // if (item.EncodeRateType == AudioEncodeRateType.Bitrate)
- // {
- audioTrack.Bitrate = item.Bitrate;
- // }
+ if (item.EncoderRateType == AudioEncoderRateType.Quality)
+ {
+ audioTrack.Quality = item.Quality;
+ }
+
+ if (item.EncoderRateType == AudioEncoderRateType.Bitrate)
+ {
+ audioTrack.Bitrate = item.Bitrate;
+ }
}
audio.AudioList.Add(audioTrack);
@@ -379,28 +376,6 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories
}
/// <summary>
- /// The get sample rate raw.
- /// </summary>
- /// <param name="rate">
- /// The rate.
- /// </param>
- /// <returns>
- /// The <see cref="int"/>.
- /// </returns>
- private static int GetSampleRateRaw(double rate)
- {
- if (rate == 22.05)
- return 22050;
- else if (rate == 24)
- return 24000;
- else if (rate == 44.1)
- return 32000;
- else if (rate == 48)
- return 48000;
- else return 48000;
- }
-
- /// <summary>
/// The create filter.
/// </summary>
/// <param name="job">
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoder.cs
index 3aef81c38..0b152b656 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoder.cs
@@ -7,7 +7,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Interop.Model.Encoding
+namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
{
using System.ComponentModel.DataAnnotations;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs
new file mode 100644
index 000000000..fb245a9b5
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioEncoderRateType.cs
@@ -0,0 +1,31 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioEncoderRateType.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>
+// The audio encoder rate type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The audio encoder rate type.
+ /// </summary>
+ public enum AudioEncoderRateType
+ {
+ /// <summary>
+ /// The bitrate.
+ /// </summary>
+ [Display(Name = "Bitrate: ")]
+ Bitrate,
+
+ /// <summary>
+ /// The quality.
+ /// </summary>
+ [Display(Name = "Quality: ")]
+ Quality,
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs
index d1c980e54..d59bf8701 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs
@@ -14,6 +14,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
using System.ComponentModel;
using System.Globalization;
using System.Linq;
+ using System.Runtime.CompilerServices;
using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.Model;
@@ -39,6 +40,9 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
private Audio scannedTrack;
private bool isDefault;
private IEnumerable<int> bitrates;
+ private IEnumerable<double> encoderQualityValues;
+ private AudioEncoderRateType encoderRateType;
+ private double? quality;
/// <summary>
/// Initializes a new instance of the <see cref = "AudioTrack" /> class.
@@ -55,7 +59,8 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
this.TrackName = string.Empty;
// Setup Backing Properties
- this.SetupBitrateLimits();
+ this.EncoderRateType = AudioEncoderRateType.Bitrate;
+ this.SetupLimits();
}
/// <summary>
@@ -81,32 +86,16 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
this.scannedTrack = track.ScannedTrack ?? new Audio();
}
this.TrackName = track.TrackName;
+ this.Quality = track.Quality;
// Setup Backing Properties
- this.SetupBitrateLimits();
+ this.encoderRateType = track.EncoderRateType;
+ this.SetupLimits();
}
#region Track Properties
/// <summary>
- /// Gets or sets Audio Bitrate
- /// </summary>
- public int Bitrate
- {
- get
- {
- return this.bitrate;
- }
-
- set
- {
- this.bitrate = value;
- this.NotifyOfPropertyChange(() => this.Bitrate);
- }
- }
-
-
- /// <summary>
/// Gets or sets Dynamic Range Compression
/// </summary>
public double DRC
@@ -160,7 +149,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
{
this.mixDown = value;
this.NotifyOfPropertyChange(() => this.MixDown);
- this.SetupBitrateLimits();
+ this.SetupLimits();
this.NotifyOfPropertyChange(() => this.TrackReference);
}
}
@@ -180,9 +169,18 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
this.encoder = value;
this.NotifyOfPropertyChange(() => this.Encoder);
this.NotifyOfPropertyChange(() => this.IsPassthru);
- this.NotifyOfPropertyChange(() => this.CannotSetBitrate);
- this.SetupBitrateLimits();
+ this.NotifyOfPropertyChange(() => this.IsBitrateVisible);
+ this.NotifyOfPropertyChange(() => this.IsQualityVisible);
+ this.NotifyOfPropertyChange(() => this.IsRateTypeVisible);
+ this.SetupLimits();
this.NotifyOfPropertyChange(() => this.TrackReference);
+
+ // Refresh the available encoder rate types.
+ this.NotifyOfPropertyChange(() => this.AudioEncoderRateTypes);
+ if (!this.AudioEncoderRateTypes.Contains(this.EncoderRateType))
+ {
+ this.EncoderRateType = AudioEncoderRateType.Bitrate; // Default to bitrate.
+ }
}
}
@@ -200,16 +198,81 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
{
this.sampleRate = value;
this.NotifyOfPropertyChange(() => this.SampleRate);
- this.SetupBitrateLimits();
+ this.SetupLimits();
this.NotifyOfPropertyChange(() => this.TrackReference);
}
}
+ /// <summary>
+ /// Gets or sets the encoder rate type.
+ /// </summary>
+ public AudioEncoderRateType EncoderRateType
+ {
+ get
+ {
+ return this.encoderRateType;
+ }
+
+ set
+ {
+ this.encoderRateType = value;
+ this.SetupLimits();
+ this.NotifyOfPropertyChange(() => this.EncoderRateType);
+ this.NotifyOfPropertyChange(() => this.IsBitrateVisible);
+ this.NotifyOfPropertyChange(() => this.IsQualityVisible);
+
+ if (!this.Quality.HasValue)
+ {
+ HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
+ this.Quality = HandBrakeEncoderHelpers.GetDefaultQuality(hbAudioEncoder);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets Audio Bitrate
+ /// </summary>
+ public int Bitrate
+ {
+ get
+ {
+ return this.bitrate;
+ }
+
+ set
+ {
+ this.bitrate = value;
+ this.NotifyOfPropertyChange(() => this.Bitrate);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets Audio quality
+ /// </summary>
+ public double? Quality
+ {
+ get
+ {
+ return this.quality;
+ }
+
+ set
+ {
+ this.quality = value;
+ this.NotifyOfPropertyChange(() => this.quality);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the track name.
+ /// </summary>
+ public string TrackName { get; set; }
#endregion
/// <summary>
/// Gets AudioEncoderDisplayValue.
/// </summary>
+ [JsonIgnore]
public string AudioEncoderDisplayValue
{
get
@@ -221,6 +284,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
/// <summary>
/// Gets AudioMixdownDisplayValue.
/// </summary>
+ [JsonIgnore]
public string AudioMixdownDisplayValue
{
get
@@ -232,6 +296,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
/// <summary>
/// Gets the The UI display value for bit rate
/// </summary>
+ [JsonIgnore]
public string BitRateDisplayValue
{
get
@@ -244,12 +309,13 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
return this.Bitrate.ToString();
}
- }
+ }
/// <summary>
/// Gets or sets a value indicating whether is default.
/// TODO - Can this be removed? May have been added as a quick fix for a styling quirk.
/// </summary>
+ [JsonIgnore]
public bool IsDefault
{
get
@@ -265,6 +331,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
/// <summary>
/// Gets or sets the The UI display value for sample rate
/// </summary>
+ [JsonIgnore]
public string SampleRateDisplayValue
{
get
@@ -307,6 +374,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
/// <summary>
/// Gets the Audio Track Name
/// </summary>
+ [JsonIgnore]
public int? Track
{
get
@@ -323,6 +391,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
/// <summary>
/// Gets a value indicating whether IsPassthru.
/// </summary>
+ [JsonIgnore]
public bool IsPassthru
{
get
@@ -342,6 +411,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
/// <summary>
/// Gets the bitrates.
/// </summary>
+ [JsonIgnore]
public IEnumerable<int> Bitrates
{
get
@@ -351,19 +421,91 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
}
/// <summary>
+ /// Gets the quality compression values.
+ /// </summary>
+ [JsonIgnore]
+ public IEnumerable<double> EncoderQualityValues
+ {
+ get
+ {
+ return this.encoderQualityValues;
+ }
+ }
+
+ /// <summary>
+ /// Gets the audio encoder rate types.
+ /// </summary>
+ [JsonIgnore]
+ public IEnumerable<AudioEncoderRateType> AudioEncoderRateTypes
+ {
+ get
+ {
+ IList<AudioEncoderRateType> types = EnumHelper<AudioEncoderRateType>.GetEnumList().ToList();
+ HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
+ if (hbaenc == null || !hbaenc.SupportsQuality)
+ {
+ types.Remove(AudioEncoderRateType.Quality);
+ }
+
+ return types;
+ }
+ }
+
+ /// <summary>
/// Gets a value indicating whether can set bitrate.
/// </summary>
- public bool CannotSetBitrate
+ [JsonIgnore]
+ public bool IsBitrateVisible
+ {
+ get
+ {
+ if (this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24)
+ {
+ return false;
+ }
+
+ return Equals(this.EncoderRateType, AudioEncoderRateType.Bitrate);
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether is quality visible.
+ /// </summary>
+ [JsonIgnore]
+ public bool IsQualityVisible
{
get
{
- return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24;
+ if (this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24)
+ {
+ return false;
+ }
+
+ return Equals(this.EncoderRateType, AudioEncoderRateType.Quality);
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether is rate type visible.
+ /// </summary>
+ [JsonIgnore]
+ public bool IsRateTypeVisible
+ {
+ get
+ {
+ if (this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24)
+ {
+ return false;
+ }
+
+ return true;
}
}
/// <summary>
/// Gets a value indicating whether IsLossless.
/// </summary>
+ [JsonIgnore]
public bool IsLossless
{
get
@@ -381,10 +523,16 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
get { return this; }
}
+ #region Handler Methods
+
/// <summary>
- /// Gets or sets the track name.
+ /// The setup limits.
/// </summary>
- public string TrackName { get; set; }
+ private void SetupLimits()
+ {
+ this.SetupBitrateLimits();
+ this.SetupQualityCompressionLimits();
+ }
/// <summary>
/// The calculate bitrate limits.
@@ -421,5 +569,68 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models
this.Bitrate = HandBrakeEncoderHelpers.GetDefaultBitrate(hbaenc, rate != null ? rate.Rate : 48000, mixdown);
}
}
+
+ /// <summary>
+ /// The setup quality compression limits.
+ /// </summary>
+ private void SetupQualityCompressionLimits()
+ {
+ HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder));
+ if (hbAudioEncoder.SupportsQuality)
+ {
+ RangeLimits limits = null;
+
+ if (hbAudioEncoder.SupportsQuality)
+ {
+ limits = hbAudioEncoder.QualityLimits;
+ }
+
+ if (limits != null)
+ {
+ double value = limits.Ascending ? limits.Low : limits.High;
+ List<double> values = new List<double> { value };
+
+ if (limits.Ascending)
+ {
+ while (value < limits.High)
+ {
+ value += limits.Granularity;
+ values.Add(value);
+ }
+ }
+ else
+ {
+ while (value > limits.Low)
+ {
+ value -= limits.Granularity;
+ values.Add(value);
+ }
+ }
+
+ this.encoderQualityValues = values;
+ }
+ else
+ {
+ this.encoderQualityValues = new List<double>();
+ }
+ }
+ else
+ {
+ this.encoderQualityValues = new List<double>();
+ }
+
+ // Default the audio quality value if it's out of range.
+ if (Equals(this.EncoderRateType, AudioEncoderRateType.Quality))
+ {
+ if (this.Quality.HasValue && !this.encoderQualityValues.Contains(this.Quality.Value))
+ {
+ this.Quality = HandBrakeEncoderHelpers.GetDefaultQuality(hbAudioEncoder);
+ }
+ }
+
+ this.NotifyOfPropertyChange(() => this.EncoderQualityValues);
+ }
+
+ #endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs
new file mode 100644
index 000000000..1aaba88a2
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioRateTypeConverter.cs
@@ -0,0 +1,94 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioRateTypeConverter.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>
+// The audio rate type converter.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Audio
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Globalization;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Services.Encode.Model.Models;
+ using HandBrake.ApplicationServices.Utilities;
+
+ /// <summary>
+ /// The audio rate type converter.
+ /// </summary>
+ public class AudioRateTypeConverter : IValueConverter
+ {
+ /// <summary>
+ /// The convert.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ var types = value as IEnumerable<AudioEncoderRateType>;
+ if (types != null)
+ {
+ List<string> rateTypes = new List<string>();
+ foreach (var item in types)
+ {
+ rateTypes.Add(EnumHelper<AudioEncoderRateType>.GetDisplay(item));
+ }
+
+ return rateTypes;
+ }
+
+
+ if (targetType == typeof(AudioEncoderRateType) || value.GetType() == typeof(AudioEncoderRateType))
+ {
+ return EnumHelper<AudioEncoderRateType>.GetDisplay((AudioEncoderRateType)value);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// The convert back.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+
+ return EnumHelper<AudioEncoderRateType>.GetValue(value.ToString());
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
index 10fb8fd3c..4c5599d62 100644
--- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
+++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs
@@ -134,6 +134,7 @@ namespace HandBrakeWPF.Converters
return EnumHelper<OutputFormat>.GetDisplay((OutputFormat)value);
}
+
return null;
}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index 5cbc6d1b2..87a26cade 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -140,6 +140,7 @@
<Compile Include="Controls\AlertPanel.xaml.cs">
<DependentUpon>AlertPanel.xaml</DependentUpon>
</Compile>
+ <Compile Include="Converters\Audio\AudioRateTypeConverter.cs" />
<Compile Include="Converters\Audio\AudioTrackDefaultBehaviourConverter.cs" />
<Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />
<Compile Include="Converters\Filters\DenoisePresetConverter.cs" />
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index 87f6188b5..ec0098358 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -38,7 +38,7 @@ namespace HandBrakeWPF.Services.Presets
{
#region Private Variables
- private static readonly int CurrentPresetVersion = 3;
+ private static readonly int CurrentPresetVersion = 4;
/// <summary>
/// User Preset Default Catgory Name
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml
index ef8a29cf9..1a7048b60 100644
--- a/win/CS/HandBrakeWPF/Views/AudioView.xaml
+++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml
@@ -24,6 +24,7 @@
<Audio:AudioEncoderConverter x:Key="audioEncoderConverter" />
<Audio:AudioBehaviourConverter x:Key="audioBehaviourConverter" />
<Audio:AudioTrackDefaultBehaviourConverter x:Key="audioTrackDefaultBehaviourConverter" />
+ <Audio:AudioRateTypeConverter x:Key="audioRateTypeConverter" />
</UserControl.Resources>
<Grid>
@@ -145,7 +146,7 @@
<Image Grid.Column="0" Grid.Row="0"
Width="16"
Height="16"
- Margin="10,0,10,0"
+ Margin="8,0,8,0"
Source="Images/Movies.png" />
<!-- Settings -->
@@ -188,12 +189,18 @@
</ComboBox.ItemsSource>
</ComboBox>
- <TextBlock Grid.Column="4" VerticalAlignment="Center" FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.AudioView_Bitrate}"
- Visibility="{Binding CannotSetBitrate, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
+ <ComboBox Grid.Column="4" Height="22" Width="65" HorizontalAlignment="Stretch"
+ ItemsSource="{Binding AudioEncoderRateTypes, Converter={StaticResource audioRateTypeConverter}}"
+ SelectedItem="{Binding EncoderRateType, Converter={StaticResource audioRateTypeConverter}}"
+ Visibility="{Binding IsRateTypeVisible, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
+
+ <ComboBox Grid.Column="5" Width="55" Height="22" Margin="5,0,5,0" ItemsSource="{Binding EncoderQualityValues}"
+ SelectedItem="{Binding Quality}"
+ Visibility="{Binding IsQualityVisible, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
+
<ComboBox Grid.Column="5" Width="55" Height="22" Margin="5,0,5,0" ItemsSource="{Binding Bitrates}"
SelectedItem="{Binding Bitrate}"
- Visibility="{Binding CannotSetBitrate, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
-
+ Visibility="{Binding IsBitrateVisible, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
<!-- Row 2 -->
<TextBlock Grid.Row="0" Grid.Column="6" VerticalAlignment="Center" FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.AudioView_Mixdown}"
@@ -204,18 +211,18 @@
Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
-
- <ToggleButton Name="advancedOptionsToggle" VerticalAlignment="Center" Grid.Column="8" Grid.Row="0" Grid.ColumnSpan="2"
+ <ToggleButton Name="advancedOptionsToggle" VerticalAlignment="Center" Grid.Column="8" Grid.Row="0" Grid.ColumnSpan="2" Margin="5,0,0,0"
Padding="3,0" Height="22" HorizontalAlignment="Left" >
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Content" Value="Show"/>
+ <Setter Property="FontWeight" Value="Bold" />
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
- <Setter Property="Content" Value="Hide"/>
+ <Setter Property="Content" Value="˄"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
- <Setter Property="Content" Value="Show"/>
+ <Setter Property="Content" Value="˅" />
</Trigger>
</Style.Triggers>
</Style>