<Compile Include="LibHb\AudioVideoHelpers.cs" />\r
<Compile Include="Model\Audio\AudioBehaviourModes.cs" />\r
<Compile Include="Model\Audio\AudioBehaviours.cs" />\r
+ <Compile Include="Model\Encoding\DenoisePreset.cs" />\r
+ <Compile Include="Model\Encoding\DenoiseTune.cs" />\r
<Compile Include="Model\HBConfiguration.cs" />\r
<Compile Include="Model\Subtitle\SubtitleBehaviourModes.cs" />\r
<Compile Include="Model\Subtitle\SubtitleBehaviours.cs" />\r
// </summary>\r
// --------------------------------------------------------------------------------------------------------------------\r
\r
-namespace HandBrake.Interop.Model.Encoding\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
{\r
using System.ComponentModel.DataAnnotations;\r
\r
// </summary>\r
// --------------------------------------------------------------------------------------------------------------------\r
\r
-namespace HandBrake.Interop.Model.Encoding\r
+namespace HandBrake.ApplicationServices.Model.Encoding\r
{\r
using System.ComponentModel.DataAnnotations;\r
\r
// Denoise\r
if (profile.Denoise != Denoise.Off)\r
{\r
- string settings = null;\r
- switch (profile.DenoisePreset)\r
- {\r
- case DenoisePreset.Weak:\r
- settings = "2:1:1:2:3:3";\r
- break;\r
- case DenoisePreset.Medium:\r
- settings = "3:2:2:2:3:3";\r
- break;\r
- case DenoisePreset.Strong:\r
- settings = "7:7:7:5:5:5";\r
- break;\r
- case DenoisePreset.Custom:\r
- settings = profile.CustomDenoise;\r
- break;\r
- // TODO Add new Presets.\r
- default:\r
- break;\r
- }\r
+ int filterType = profile.Denoise == Denoise.hqdn3d ? (int)hb_filter_ids.HB_FILTER_HQDN3D : (int)hb_filter_ids.HB_FILTER_NLMEANS;\r
\r
- // TODO Add Tunes\r
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DENOISE, settings, allocatedMemory);\r
+ this.AddFilterFromPreset(filterList, filterType, profile.DenoisePreset, profile.DenoiseTune);\r
}\r
\r
// Crop/scale\r
width = outputSize.Width;\r
height = outputSize.Height;\r
\r
- nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;\r
+ nativeJob.anamorphic.keep_display_aspect = 0;\r
+ nativeJob.anamorphic.par_width = 1;\r
+ nativeJob.anamorphic.par_height = 1;\r
\r
nativeJob.width = width;\r
nativeJob.height = height;\r
filterList.Add(filter);\r
}\r
\r
+ /// <summary>\r
+ /// Adds a filter to the given filter list with the provided preset and tune.\r
+ /// </summary>\r
+ /// <param name="filterList">The list to add the filter to.</param>\r
+ /// <param name="filterType">The type of filter.</param>\r
+ /// <param name="preset">The preset name.</param>\r
+ /// <param name="tune">The tune name.</param>\r
+ private void AddFilterFromPreset(List<hb_filter_object_s> filterList, int filterType, string preset, string tune)\r
+ {\r
+ IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings(filterType, preset, tune);\r
+\r
+ hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));\r
+ filter.settings = settingsPtr;\r
+\r
+ filterList.Add(filter);\r
+ }\r
+\r
/// <summary>\r
/// Converts the given filter list to a native list.\r
/// </summary>\r
\r
bool isPassthrough = encoder.IsPassthrough;\r
\r
+ HBAudioEncoder inputCodec = Encoders.GetAudioEncoder((int)baseStruct.config.input.codec);\r
+\r
uint outputCodec = (uint)encoder.Id;\r
if (encoding.PassthroughIfPossible && \r
- encoder.Id == baseStruct.config.input.codec && \r
- (encoder.Id & NativeConstants.HB_ACODEC_PASS_MASK) > 0)\r
+ (encoder.Id == baseStruct.config.input.codec || \r
+ inputCodec != null && (inputCodec.ShortName.ToLowerInvariant().Contains("aac") && encoder.ShortName.ToLowerInvariant().Contains("aac") ||\r
+ inputCodec.ShortName.ToLowerInvariant().Contains("mp3") && encoder.ShortName.ToLowerInvariant().Contains("mp3"))) &&\r
+ (inputCodec.Id & NativeConstants.HB_ACODEC_PASS_MASK) > 0)\r
{\r
- outputCodec |= NativeConstants.HB_ACODEC_PASS_FLAG;\r
+ outputCodec = baseStruct.config.input.codec | NativeConstants.HB_ACODEC_PASS_FLAG;\r
isPassthrough = true;\r
}\r
\r
<Compile Include="HbLib\NativeConstants.cs" />\r
<Compile Include="Interfaces\IHandBrakeInstance.cs" />\r
<Compile Include="Helpers\InteropUtilities.cs" />\r
- <Compile Include="Model\Encoding\DenoisePreset.cs" />\r
- <Compile Include="Model\Encoding\DenoiseTune.cs" />\r
<Compile Include="Model\Encoding\PictureRotation.cs" />\r
<Compile Include="Model\Encoding\x265\x265Preset.cs" />\r
<Compile Include="Model\Encoding\x265\x265Profile.cs" />\r
[DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]\r
public static extern IntPtr hb_filter_init(int filter_id);\r
\r
+ [DllImport("hb.dll", EntryPoint = "hb_generate_filter_settings", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern IntPtr hb_generate_filter_settings(\r
+ int filter_id,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string preset,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string tune);\r
+\r
[DllImport("hb.dll", EntryPoint = "hb_x264_encopt_name", CallingConvention = CallingConvention.Cdecl)]\r
public static extern IntPtr hb_x264_encopt_name(IntPtr name);\r
\r
HB_FILTER_VFR,\r
// Filters that must operate on the original source image are next\r
HB_FILTER_DEBLOCK,\r
- HB_FILTER_DENOISE,\r
+ HB_FILTER_HQDN3D,\r
+ HB_FILTER_NLMEANS,\r
HB_FILTER_RENDER_SUB,\r
HB_FILTER_CROP_SCALE,\r
// Finally filters that don't care what order they are in,\r
return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName);\r
}\r
\r
+ /// <summary>\r
+ /// Gets the audio encoder with the specified codec ID.\r
+ /// </summary>\r
+ /// <param name="codecId">The ID of the audio encoder.</param>\r
+ /// <returns>The requested audio encoder.</returns>\r
+ public static HBAudioEncoder GetAudioEncoder(int codecId)\r
+ {\r
+ return AudioEncoders.SingleOrDefault(e => e.Id == codecId);\r
+ }\r
+\r
/// <summary>\r
/// Gets the video encoder with the specified short name.\r
/// </summary>\r
return HBFunctions.hb_audio_can_apply_drc(track.CodecId, track.CodecParam, encoder.Id) > 0;\r
}\r
\r
+ /// <summary>\r
+ /// Determines if the given input audio codec can be passed through.\r
+ /// </summary>\r
+ /// <param name="codecId">The input codec to consider.</param>\r
+ /// <returns>True if the codec can be passed through.</returns>\r
+ public static bool CanPassthroughAudio(int codecId)\r
+ {\r
+ return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0;\r
+ }\r
+\r
/// <summary>\r
/// Sanitizes a mixdown given the output codec and input channel layout.\r
/// </summary>\r
public Denoise Denoise { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the denoise preset.\r
+ /// Gets or sets the denoise preset name.\r
/// </summary>\r
- public DenoisePreset DenoisePreset { get; set; }\r
+ public string DenoisePreset { get; set; }\r
\r
/// <summary>\r
- /// Gets or sets the denoise tune.\r
+ /// Gets or sets the denoise tune name.\r
/// </summary>\r
- public DenoiseTune DenoiseTune { get; set; }\r
+ public string DenoiseTune { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether we should use the provided\r
+ /// custom denoise string or we should use the preset and tune.\r
+ /// </summary>\r
+ public bool UseCustomDenoise { get; set; }\r
\r
/// <summary>\r
/// Gets or sets the custom denoise.\r
Detelecine = this.Detelecine,\r
CustomDetelecine = this.CustomDetelecine,\r
Denoise = this.Denoise,\r
+ DenoisePreset = this.DenoisePreset,\r
+ DenoiseTune = this.DenoiseTune,\r
+ UseCustomDenoise = this.UseCustomDenoise,\r
CustomDenoise = this.CustomDenoise,\r
Deblock = this.Deblock,\r
Grayscale = this.Grayscale,\r
using System.Linq;\r
using System.Windows.Data;\r
\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
using HandBrake.Interop.Model.Encoding;\r
\r
/// <summary>\r
using Caliburn.Micro;\r
\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
using HandBrake.ApplicationServices.Parsing;\r
using HandBrake.ApplicationServices.Utilities;\r
using HandBrake.Interop.Model.Encoding;\r