summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorrandomengy <[email protected]>2014-08-03 04:33:09 +0000
committerrandomengy <[email protected]>2014-08-03 04:33:09 +0000
commit9474387d2ae72794970b8ca2a9e8f8facdc0fdab (patch)
tree11ac1b628d8c43af0301bd45be0089ad2d7b50ce /win/CS
parente4b94f18017bcbf9d7f26fb2486ff3a745d55eef (diff)
Interop: Added support for NL-Means denoise.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6260 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Encoding/DenoisePreset.cs (renamed from win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs)2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Encoding/DenoiseTune.cs (renamed from win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs)2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs54
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_ids.cs3
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs20
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs17
-rw-r--r--win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs1
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs1
11 files changed, 76 insertions, 34 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 0f082f0f3..2a45218f3 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -114,6 +114,8 @@
<Compile Include="LibHb\AudioVideoHelpers.cs" />
<Compile Include="Model\Audio\AudioBehaviourModes.cs" />
<Compile Include="Model\Audio\AudioBehaviours.cs" />
+ <Compile Include="Model\Encoding\DenoisePreset.cs" />
+ <Compile Include="Model\Encoding\DenoiseTune.cs" />
<Compile Include="Model\HBConfiguration.cs" />
<Compile Include="Model\Subtitle\SubtitleBehaviourModes.cs" />
<Compile Include="Model\Subtitle\SubtitleBehaviours.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/DenoisePreset.cs
index b26635052..a411d19ae 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoisePreset.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/DenoisePreset.cs
@@ -7,7 +7,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.Interop.Model.Encoding
+namespace HandBrake.ApplicationServices.Model.Encoding
{
using System.ComponentModel.DataAnnotations;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/DenoiseTune.cs
index 35b5843a8..2fd13cfca 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/DenoiseTune.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/DenoiseTune.cs
@@ -7,7 +7,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.Interop.Model.Encoding
+namespace HandBrake.ApplicationServices.Model.Encoding
{
using System.ComponentModel.DataAnnotations;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
index 0e484794c..b08facbd2 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
@@ -1212,28 +1212,9 @@ namespace HandBrake.Interop
// Denoise
if (profile.Denoise != Denoise.Off)
{
- string settings = null;
- switch (profile.DenoisePreset)
- {
- case DenoisePreset.Weak:
- settings = "2:1:1:2:3:3";
- break;
- case DenoisePreset.Medium:
- settings = "3:2:2:2:3:3";
- break;
- case DenoisePreset.Strong:
- settings = "7:7:7:5:5:5";
- break;
- case DenoisePreset.Custom:
- settings = profile.CustomDenoise;
- break;
- // TODO Add new Presets.
- default:
- break;
- }
+ int filterType = profile.Denoise == Denoise.hqdn3d ? (int)hb_filter_ids.HB_FILTER_HQDN3D : (int)hb_filter_ids.HB_FILTER_NLMEANS;
- // TODO Add Tunes
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DENOISE, settings, allocatedMemory);
+ this.AddFilterFromPreset(filterList, filterType, profile.DenoisePreset, profile.DenoiseTune);
}
// Crop/scale
@@ -1279,7 +1260,9 @@ namespace HandBrake.Interop
width = outputSize.Width;
height = outputSize.Height;
- nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;
+ nativeJob.anamorphic.keep_display_aspect = 0;
+ nativeJob.anamorphic.par_width = 1;
+ nativeJob.anamorphic.par_height = 1;
nativeJob.width = width;
nativeJob.height = height;
@@ -1677,6 +1660,23 @@ namespace HandBrake.Interop
filterList.Add(filter);
}
+ /// <summary>
+ /// Adds a filter to the given filter list with the provided preset and tune.
+ /// </summary>
+ /// <param name="filterList">The list to add the filter to.</param>
+ /// <param name="filterType">The type of filter.</param>
+ /// <param name="preset">The preset name.</param>
+ /// <param name="tune">The tune name.</param>
+ private void AddFilterFromPreset(List<hb_filter_object_s> filterList, int filterType, string preset, string tune)
+ {
+ IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings(filterType, preset, tune);
+
+ hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));
+ filter.settings = settingsPtr;
+
+ filterList.Add(filter);
+ }
+
/// <summary>
/// Converts the given filter list to a native list.
/// </summary>
@@ -1777,12 +1777,16 @@ namespace HandBrake.Interop
bool isPassthrough = encoder.IsPassthrough;
+ HBAudioEncoder inputCodec = Encoders.GetAudioEncoder((int)baseStruct.config.input.codec);
+
uint outputCodec = (uint)encoder.Id;
if (encoding.PassthroughIfPossible &&
- encoder.Id == baseStruct.config.input.codec &&
- (encoder.Id & NativeConstants.HB_ACODEC_PASS_MASK) > 0)
+ (encoder.Id == baseStruct.config.input.codec ||
+ inputCodec != null && (inputCodec.ShortName.ToLowerInvariant().Contains("aac") && encoder.ShortName.ToLowerInvariant().Contains("aac") ||
+ inputCodec.ShortName.ToLowerInvariant().Contains("mp3") && encoder.ShortName.ToLowerInvariant().Contains("mp3"))) &&
+ (inputCodec.Id & NativeConstants.HB_ACODEC_PASS_MASK) > 0)
{
- outputCodec |= NativeConstants.HB_ACODEC_PASS_FLAG;
+ outputCodec = baseStruct.config.input.codec | NativeConstants.HB_ACODEC_PASS_FLAG;
isPassthrough = true;
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
index a1f1b076b..59d7835f3 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
@@ -174,8 +174,6 @@
<Compile Include="HbLib\NativeConstants.cs" />
<Compile Include="Interfaces\IHandBrakeInstance.cs" />
<Compile Include="Helpers\InteropUtilities.cs" />
- <Compile Include="Model\Encoding\DenoisePreset.cs" />
- <Compile Include="Model\Encoding\DenoiseTune.cs" />
<Compile Include="Model\Encoding\PictureRotation.cs" />
<Compile Include="Model\Encoding\x265\x265Preset.cs" />
<Compile Include="Model\Encoding\x265\x265Profile.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
index 9402d0940..cf8193f52 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
@@ -444,6 +444,12 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_filter_init(int filter_id);
+ [DllImport("hb.dll", EntryPoint = "hb_generate_filter_settings", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_generate_filter_settings(
+ int filter_id,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string preset,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string tune);
+
[DllImport("hb.dll", EntryPoint = "hb_x264_encopt_name", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_x264_encopt_name(IntPtr name);
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_ids.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_ids.cs
index 3c56b7f75..90b60d846 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_ids.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_ids.cs
@@ -17,7 +17,8 @@ namespace HandBrake.Interop.HbLib
HB_FILTER_VFR,
// Filters that must operate on the original source image are next
HB_FILTER_DEBLOCK,
- HB_FILTER_DENOISE,
+ HB_FILTER_HQDN3D,
+ HB_FILTER_NLMEANS,
HB_FILTER_RENDER_SUB,
HB_FILTER_CROP_SCALE,
// Finally filters that don't care what order they are in,
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
index f27fad285..295586c8f 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
@@ -201,6 +201,16 @@ namespace HandBrake.Interop.Model
}
/// <summary>
+ /// Gets the audio encoder with the specified codec ID.
+ /// </summary>
+ /// <param name="codecId">The ID of the audio encoder.</param>
+ /// <returns>The requested audio encoder.</returns>
+ public static HBAudioEncoder GetAudioEncoder(int codecId)
+ {
+ return AudioEncoders.SingleOrDefault(e => e.Id == codecId);
+ }
+
+ /// <summary>
/// Gets the video encoder with the specified short name.
/// </summary>
/// <param name="shortName">The name of the video encoder.</param>
@@ -276,6 +286,16 @@ namespace HandBrake.Interop.Model
}
/// <summary>
+ /// Determines if the given input audio codec can be passed through.
+ /// </summary>
+ /// <param name="codecId">The input codec to consider.</param>
+ /// <returns>True if the codec can be passed through.</returns>
+ public static bool CanPassthroughAudio(int codecId)
+ {
+ return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0;
+ }
+
+ /// <summary>
/// Sanitizes a mixdown given the output codec and input channel layout.
/// </summary>
/// <param name="mixdown">The desired mixdown.</param>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
index 834ef5576..bcabcf282 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
@@ -185,14 +185,20 @@ namespace HandBrake.Interop.Model.Encoding
public Denoise Denoise { get; set; }
/// <summary>
- /// Gets or sets the denoise preset.
+ /// Gets or sets the denoise preset name.
/// </summary>
- public DenoisePreset DenoisePreset { get; set; }
+ public string DenoisePreset { get; set; }
/// <summary>
- /// Gets or sets the denoise tune.
+ /// Gets or sets the denoise tune name.
/// </summary>
- public DenoiseTune DenoiseTune { get; set; }
+ public string DenoiseTune { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether we should use the provided
+ /// custom denoise string or we should use the preset and tune.
+ /// </summary>
+ public bool UseCustomDenoise { get; set; }
/// <summary>
/// Gets or sets the custom denoise.
@@ -343,6 +349,9 @@ namespace HandBrake.Interop.Model.Encoding
Detelecine = this.Detelecine,
CustomDetelecine = this.CustomDetelecine,
Denoise = this.Denoise,
+ DenoisePreset = this.DenoisePreset,
+ DenoiseTune = this.DenoiseTune,
+ UseCustomDenoise = this.UseCustomDenoise,
CustomDenoise = this.CustomDenoise,
Deblock = this.Deblock,
Grayscale = this.Grayscale,
diff --git a/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs b/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs
index bb0ec1b7e..58576d747 100644
--- a/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs
+++ b/win/CS/HandBrakeWPF/Converters/Filters/DenoisePresetConverter.cs
@@ -15,6 +15,7 @@ namespace HandBrakeWPF.Converters.Filters
using System.Linq;
using System.Windows.Data;
+ using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.Interop.Model.Encoding;
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
index 70921b23f..5fdeb9c44 100644
--- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
@@ -15,6 +15,7 @@ namespace HandBrakeWPF.ViewModels
using Caliburn.Micro;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;