summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.Interop')
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs71
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs170
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj1
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs14
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs82
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs21
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs60
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs58
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs22
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs37
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs5
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioTrack.cs2
16 files changed, 284 insertions, 279 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
index bc34ac380..00fc4e4e8 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs
@@ -61,77 +61,6 @@ namespace HandBrake.Interop
}
/// <summary>
- /// Convert a Mixdown object to HandBrakes native mixdown constant.
- /// </summary>
- /// <param name="mixdown">
- /// The mixdown.
- /// </param>
- /// <returns>
- /// NativeContstant that represents the mixdown.
- /// </returns>
- /// <exception cref="ArgumentException">
- /// Thrown for an invalid mixodown.
- /// </exception>
- public static int MixdownToNative(Mixdown mixdown)
- {
- if (mixdown == Mixdown.Auto)
- {
- throw new ArgumentException("Cannot convert Auto to native.");
- }
-
- switch (mixdown)
- {
- case Mixdown.None:
- return NativeConstants.HB_AMIXDOWN_NONE;
- case Mixdown.DolbyProLogicII:
- return NativeConstants.HB_AMIXDOWN_DOLBYPLII;
- case Mixdown.DolbySurround:
- return NativeConstants.HB_AMIXDOWN_DOLBY;
- case Mixdown.Mono:
- return NativeConstants.HB_AMIXDOWN_MONO;
- case Mixdown.FivePoint1Channels:
- return NativeConstants.HB_AMIXDOWN_6CH;
- case Mixdown.Stereo:
- return NativeConstants.HB_AMIXDOWN_STEREO;
- }
-
- return 0;
- }
-
- /// <summary>
- /// Convert an native internal handbrake mixdown to a local mixdown enum.
- /// </summary>
- /// <param name="mixdown">
- /// The mixdown.
- /// </param>
- /// <returns>
- /// A mixdown object.
- /// </returns>
- /// <exception cref="ArgumentException">
- /// thrown when mixdown is invalid.
- /// </exception>
- public static Mixdown NativeToMixdown(int mixdown)
- {
- switch (mixdown)
- {
- case NativeConstants.HB_AMIXDOWN_NONE:
- return Mixdown.None;
- case NativeConstants.HB_AMIXDOWN_MONO:
- return Mixdown.Mono;
- case NativeConstants.HB_AMIXDOWN_STEREO:
- return Mixdown.Stereo;
- case NativeConstants.HB_AMIXDOWN_DOLBY:
- return Mixdown.DolbySurround;
- case NativeConstants.HB_AMIXDOWN_DOLBYPLII:
- return Mixdown.DolbyProLogicII;
- case NativeConstants.HB_AMIXDOWN_6CH:
- return Mixdown.FivePoint1Channels;
- }
-
- throw new ArgumentException("Unrecognized mixdown: " + mixdown, "mixdown");
- }
-
- /// <summary>
/// Gets the native code for the given encoder.
/// </summary>
/// <param name="encoder">The audio encoder to convert.</param>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
index e019e9610..c62f96fb6 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
@@ -11,6 +11,7 @@ namespace HandBrake.Interop
{
using System;
using System.Collections.Generic;
+ using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
@@ -251,7 +252,7 @@ namespace HandBrake.Interop
IntPtr nativeBuffer = Marshal.AllocHGlobal(imageBufferSize);
allocatedMemory.Add(nativeBuffer);
HBFunctions.hb_set_job(this.hbHandle, job.Title, ref nativeJob);
- HBFunctions.hb_get_preview(this.hbHandle, ref title, previewNumber, nativeBuffer);
+ HBFunctions.hb_get_preview(this.hbHandle, ref title, previewNumber, nativeBuffer);
// Copy the filled image buffer to a managed array.
byte[] managedBuffer = new byte[imageBufferSize];
@@ -593,7 +594,7 @@ namespace HandBrake.Interop
int refParHeight = 0;
HBFunctions.hb_set_job(this.hbHandle, job.Title, ref nativeJob);
//HBFunctions.hb_set_anamorphic_size_by_index(this.hbHandle, job.Title, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);
- HBFunctions.hb_set_anamorphic_size(ref nativeJob, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);
+ HBFunctions.hb_set_anamorphic_size(ref nativeJob, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);
InteropUtilities.FreeMemory(allocatedMemory);
width = refWidth;
@@ -988,6 +989,48 @@ namespace HandBrake.Interop
nativeJob.crop[2] = crop.Left;
nativeJob.crop[3] = crop.Right;
+ var filterList = new List<IntPtr>();
+
+ // FILTERS: These must be added in the correct order since we cannot depend on the automatic ordering in hb_add_filter . Ordering is determined
+ // by the order they show up in the filters enum.
+
+ // Detelecine
+ if (profile.Detelecine != Detelecine.Off)
+ {
+ string settings = null;
+ if (profile.Detelecine == Detelecine.Custom)
+ {
+ settings = profile.CustomDetelecine;
+ }
+
+ this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DETELECINE, settings, allocatedMemory);
+ }
+
+ // Decomb
+ if (profile.Decomb != Decomb.Off)
+ {
+ string settings = null;
+ switch (profile.Decomb)
+ {
+ case Decomb.Default:
+ break;
+ case Decomb.Fast:
+ settings = "7:2:6:9:1:80";
+ break;
+ case Decomb.Bob:
+ settings = "455";
+ break;
+ case Decomb.Custom:
+ settings = profile.CustomDecomb;
+ break;
+ default:
+ break;
+ }
+
+ this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DECOMB, settings, allocatedMemory);
+ }
+
+ // Deinterlace
if (profile.Deinterlace != Deinterlace.Off)
{
nativeJob.deinterlace = 1;
@@ -996,13 +1039,16 @@ namespace HandBrake.Interop
switch (profile.Deinterlace)
{
case Deinterlace.Fast:
- settings = "-1";
+ settings = "0";
break;
case Deinterlace.Slow:
- settings = "2";
+ settings = "1";
break;
case Deinterlace.Slower:
- settings = "0";
+ settings = "3";
+ break;
+ case Deinterlace.Bob:
+ settings = "15";
break;
case Deinterlace.Custom:
settings = profile.CustomDeinterlace;
@@ -1011,40 +1057,57 @@ namespace HandBrake.Interop
break;
}
- this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DEINTERLACE, settings, allocatedMemory);
+ this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DEINTERLACE, settings, allocatedMemory);
}
else
{
nativeJob.deinterlace = 0;
}
- if (profile.Detelecine != Detelecine.Off)
+ // VFR
+ if (profile.Framerate == 0)
{
- string settings = null;
- if (profile.Detelecine == Detelecine.Custom)
+ if (profile.ConstantFramerate)
{
- settings = profile.CustomDetelecine;
+ // CFR with "Same as Source". Use the title rate
+ nativeJob.cfr = 1;
+ nativeJob.vrate = originalTitle.rate;
+ nativeJob.vrate_base = originalTitle.rate_base;
+ }
+ else
+ {
+ // Pure VFR "Same as Source"
+ nativeJob.cfr = 0;
}
-
- this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DETELECINE, settings, allocatedMemory);
}
-
- if (profile.Decomb != Decomb.Off)
+ else
{
- string settings = null;
- if (profile.Decomb == Decomb.Custom)
+ // Specified framerate
+ if (profile.ConstantFramerate)
+ {
+ // Mark as pure CFR
+ nativeJob.cfr = 1;
+ }
+ else
{
- settings = profile.CustomDecomb;
+ // Mark as peak framerate
+ nativeJob.cfr = 2;
}
- this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DECOMB, settings, allocatedMemory);
+ nativeJob.vrate = 27000000;
+ nativeJob.vrate_base = Converters.FramerateToVrate(profile.Framerate);
}
+ string vfrSettings = string.Format(CultureInfo.InvariantCulture, "{0}:{1}:{2}", nativeJob.cfr, nativeJob.vrate, nativeJob.vrate_base);
+ this.AddFilter(filterList, (int) hb_filter_ids.HB_FILTER_VFR, vfrSettings, allocatedMemory);
+
+ // Deblock
if (profile.Deblock > 0)
{
- this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DEBLOCK, profile.Deblock.ToString(), allocatedMemory);
+ this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DEBLOCK, profile.Deblock.ToString(CultureInfo.InvariantCulture), allocatedMemory);
}
+ // Denoise
if (profile.Denoise != Denoise.Off)
{
string settings = null;
@@ -1066,9 +1129,10 @@ namespace HandBrake.Interop
break;
}
- this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DENOISE, settings, allocatedMemory);
+ this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DENOISE, settings, allocatedMemory);
}
+ // Crop/scale
int width = profile.Width;
int height = profile.Height;
@@ -1169,6 +1233,24 @@ namespace HandBrake.Interop
nativeJob.maxWidth = profile.MaxWidth;
nativeJob.maxHeight = profile.MaxHeight;
+ string cropScaleSettings = string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}:{1}:{2}:{3}:{4}:{5}",
+ nativeJob.width,
+ nativeJob.height,
+ nativeJob.crop[0],
+ nativeJob.crop[1],
+ nativeJob.crop[2],
+ nativeJob.crop[3]);
+ this.AddFilter(filterList, (int) hb_filter_ids.HB_FILTER_CROP_SCALE, cropScaleSettings, allocatedMemory);
+
+ // Construct final filter list
+ NativeList filterListNative = InteropUtilities.CreateIntPtrList(filterList);
+ nativeJob.list_filter = filterListNative.ListPtr;
+ allocatedMemory.AddRange(filterListNative.AllocatedMemory);
+
+
+
HBVideoEncoder videoEncoder = Encoders.VideoEncoders.FirstOrDefault(e => e.ShortName == profile.VideoEncoder);
if (videoEncoder == null)
{
@@ -1177,26 +1259,8 @@ namespace HandBrake.Interop
nativeJob.vcodec = videoEncoder.Id;
- if (profile.Framerate == 0)
- {
- nativeJob.cfr = 0;
- }
- else
- {
- if (profile.PeakFramerate)
- {
- nativeJob.cfr = 2;
- }
- else
- {
- nativeJob.cfr = 1;
- }
- nativeJob.vrate = 27000000;
- nativeJob.vrate_base = Converters.FramerateToVrate(profile.Framerate);
- }
- // vfr
// areBframes
// color_matrix
List<hb_audio_s> titleAudio = InteropUtilities.ConvertList<hb_audio_s>(originalTitle.list_audio);
@@ -1277,7 +1341,7 @@ namespace HandBrake.Interop
subtitleConfig.force = sourceSubtitle.Forced ? 1 : 0;
subtitleConfig.default_track = sourceSubtitle.Default ? 1 : 0;
- bool supportsBurn = nativeSubtitle.source == hb_subtitle_s_subsource.VOBSUB || nativeSubtitle.source == hb_subtitle_s_subsource.SSASUB;
+ bool supportsBurn = nativeSubtitle.source == hb_subtitle_s_subsource.VOBSUB || nativeSubtitle.source == hb_subtitle_s_subsource.SSASUB || nativeSubtitle.source == hb_subtitle_s_subsource.PGSSUB;
if (supportsBurn && sourceSubtitle.BurnedIn)
{
subtitleConfig.dest = hb_subtitle_config_s_subdest.RENDERSUB;
@@ -1404,24 +1468,22 @@ namespace HandBrake.Interop
/// <summary>
/// Adds a filter to the given filter list.
/// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <param name="filterType">
- /// The type of filter.
- /// </param>
- /// <param name="settings">
- /// Settings for the filter.
- /// </param>
- /// <param name="allocatedMemory">
- /// The list of allocated memory.
- /// </param>
- private void AddFilter(hb_job_s job, int filterType, string settings, List<IntPtr> allocatedMemory)
+ /// <param name="filterList">The list to add the filter to.</param>
+ /// <param name="filterType">The type of filter.</param>
+ /// <param name="settings">Settings for the filter.</param>
+ /// <param name="allocatedMemory">The list of allocated memory.</param>
+ private void AddFilter(List<IntPtr> filterList, int filterType, string settings, List<IntPtr> allocatedMemory)
{
IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings);
- hb_filter_object_s filter = HBFunctions.hb_filter_init(filterType);
- HBFunctions.hb_add_filter(ref job, filter, settingsNativeString);
+ hb_filter_object_s filter = InteropUtilities.ReadStructure<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));
+ filter.settings = settingsNativeString;
+
+ IntPtr filterPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(hb_filter_object_s)));
+ Marshal.StructureToPtr(filter, filterPtr, false);
+
+ filterList.Add(filterPtr);
allocatedMemory.Add(settingsNativeString);
+ allocatedMemory.Add(filterPtr);
}
/// <summary>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
index 8155e16f1..7d9ac2a82 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
@@ -138,6 +138,7 @@
<Compile Include="HbLib\HBFunctions.cs" />
<Compile Include="HbLib\hb_audio.cs" />
<Compile Include="HbLib\hb_chapter_s.cs" />
+ <Compile Include="HbLib\hb_filter.cs" />
<Compile Include="HbLib\hb_handle_s.cs" />
<Compile Include="HbLib\hb_subtitle.cs" />
<Compile Include="HbLib\Misc.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
index 8bd8125ee..9bfceb278 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
@@ -11,7 +11,7 @@ namespace HandBrake.Interop
{
using System;
using System.Collections.Generic;
-
+ using System.Runtime.InteropServices;
using HandBrake.Interop.HbLib;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
@@ -131,6 +131,18 @@ namespace HandBrake.Interop
}
/// <summary>
+ /// Gets the standard x264 option name given the starting point.
+ /// </summary>
+ /// <returns>The standard x264 option name.</returns>
+ public static string SanitizeX264OptName(string name)
+ {
+ IntPtr namePtr = Marshal.StringToHGlobalAnsi(name);
+ string sanitizedName = Marshal.PtrToStringAnsi(HBFunctions.hb_x264_encopt_name(namePtr));
+ Marshal.FreeHGlobal(namePtr);
+ return sanitizedName;
+ }
+
+ /// <summary>
/// Gets the total number of seconds on the given encode job.
/// </summary>
/// <param name="job">The encode job to query.</param>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
index 8fa46453d..428a58304 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
@@ -213,11 +213,20 @@ namespace HandBrake.Interop.HbLib
public static extern int hb_srt_add(ref hb_job_s job, ref hb_subtitle_config_s subtitleConfig, string lang);
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_is_supported", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout);
+
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_remix_support", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int hb_mixdown_has_remix_support(int mixdown, ulong layout);
+
+ [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_codec_support", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int hb_mixdown_has_codec_support(int mixdown, uint codec);
+
[DllImport("hb.dll", EntryPoint = "hb_get_default_mixdown", CallingConvention = CallingConvention.Cdecl)]
- public static extern int hb_get_default_mixdown(uint codec, int layout);
+ public static extern int hb_get_default_mixdown(uint codec, ulong layout);
[DllImport("hb.dll", EntryPoint = "hb_get_best_mixdown", CallingConvention = CallingConvention.Cdecl)]
- public static extern int hb_get_best_mixdown(uint codec, int layout, int mixdown);
+ public static extern int hb_get_best_mixdown(uint codec, ulong layout, int mixdown);
[DllImport("hb.dll", EntryPoint = "hb_get_best_audio_bitrate", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_get_best_audio_bitrate(uint codec, int bitrate, int samplerate, int mixdown);
@@ -281,48 +290,51 @@ namespace HandBrake.Interop.HbLib
public static extern int hb_get_audio_encoders_count();
- /// void hb_autopassthru_apply_settings( hb_job_t * job )
- [DllImport("hb.dll", EntryPoint = "hb_autopassthru_apply_settings", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_autopassthru_apply_settings(ref hb_job_s job);
+ /// void hb_autopassthru_apply_settings( hb_job_t * job )
+ [DllImport("hb.dll", EntryPoint = "hb_autopassthru_apply_settings", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_autopassthru_apply_settings(ref hb_job_s job);
+
+ ///hb_title_set_t * hb_get_title_set( hb_handle_t * );
+ [DllImport("hb.dll", EntryPoint = "hb_get_title_set", CallingConvention = CallingConvention.Cdecl)]
+ public static extern hb_title_set_s hb_get_title_set(IntPtr hbHandle);
- ///hb_title_set_t * hb_get_title_set( hb_handle_t * );
- [DllImport("hb.dll", EntryPoint = "hb_get_title_set", CallingConvention = CallingConvention.Cdecl)]
- public static extern hb_title_set_s hb_get_title_set(IntPtr hbHandle);
+ ///hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index );
+ [DllImport("hb.dll", EntryPoint = "hb_job_init_by_index", CallingConvention = CallingConvention.Cdecl)]
+ public static extern hb_job_s hb_job_init_by_index(IntPtr hbHandle, int title_index);
- ///hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index );
- [DllImport("hb.dll", EntryPoint = "hb_job_init_by_index", CallingConvention = CallingConvention.Cdecl)]
- public static extern hb_job_s hb_job_init_by_index(IntPtr hbHandle, int title_index);
+ ///hb_job_t * hb_job_init( hb_title_t * title );
+ [DllImport("hb.dll", EntryPoint = "hb_job_init", CallingConvention = CallingConvention.Cdecl)]
+ public static extern hb_job_s hb_job_init(ref hb_title_s title);
- ///hb_job_t * hb_job_init( hb_title_t * title );
- [DllImport("hb.dll", EntryPoint = "hb_job_init", CallingConvention = CallingConvention.Cdecl)]
- public static extern hb_job_s hb_job_init(ref hb_title_s title);
+ ///void hb_job_reset( hb_job_t * job );
+ [DllImport("hb.dll", EntryPoint = "hb_job_reset", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_job_reset(ref hb_job_s job);
- ///void hb_job_reset( hb_job_t * job );
- [DllImport("hb.dll", EntryPoint = "hb_job_reset", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_job_reset(ref hb_job_s job);
+ ///void hb_job_close( hb_job_t ** job );
+ [DllImport("hb.dll", EntryPoint = "hb_job_close", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_job_close(ref hb_job_s job);
- ///void hb_job_close( hb_job_t ** job );
- [DllImport("hb.dll", EntryPoint = "hb_job_close", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_job_close(ref hb_job_s job);
+ ///void hb_job_set_advanced_opts( hb_job_t *job, const char *advanced_opts );
+ [DllImport("hb.dll", EntryPoint = "hb_job_set_advanced_opts", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_job_set_advanced_opts(ref hb_job_s job, IntPtr advanced_opts);
- ///void hb_job_set_advanced_opts( hb_job_t *job, const char *advanced_opts );
- [DllImport("hb.dll", EntryPoint = "hb_job_set_advanced_opts", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_job_set_advanced_opts(ref hb_job_s job, IntPtr advanced_opts);
+ ///void hb_job_set_file( hb_job_t *job, const char *file );
+ [DllImport("hb.dll", EntryPoint = "hb_job_set_file", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_job_set_file(ref hb_job_s job, IntPtr file);
- ///void hb_job_set_file( hb_job_t *job, const char *file );
- [DllImport("hb.dll", EntryPoint = "hb_job_set_file", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_job_set_file(ref hb_job_s job, IntPtr file);
+ ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);
+ [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_chapter_set_title(ref hb_chapter_s chapter, IntPtr title);
- ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);
- [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_chapter_set_title(ref hb_chapter_s chapter, IntPtr title);
+ /// void hb_add_filter( hb_job_t * job, hb_filter_object_t * filter, const char * settings );
+ [DllImport("hb.dll", EntryPoint = "hb_add_filter", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_add_filter(ref hb_job_s job, ref hb_filter_object_s filter, IntPtr settings);
- /// void hb_add_filter( hb_job_t * job, hb_filter_object_t * filter, const char * settings );
- [DllImport("hb.dll", EntryPoint = "hb_add_filter", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_add_filter(ref hb_job_s job, hb_filter_object_s filter, IntPtr settings);
+ /// hb_filter_object_t * hb_filter_init( int filter_id );
+ [DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_filter_init(int filter_id);
- /// hb_filter_object_t * hb_filter_init( int filter_id );
- [DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]
- public static extern hb_filter_object_s hb_filter_init(int filter_id);
+ [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/Misc.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs
index 81c80ab13..36820c0c4 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs
@@ -212,18 +212,6 @@ namespace HandBrake.Interop.HbLib
public hb_state_param_u param;
}
- [StructLayout(LayoutKind.Explicit)]
- public struct Anonymous_a0a59d69_d9a4_4003_a198_f7c51511e31d
- {
- /// int
- [FieldOffset(0)]
- public int ac3;
-
- /// int
- [FieldOffset(0)]
- public int dca;
- }
-
[StructLayout(LayoutKind.Sequential)]
public struct hb_fifo_s
{
@@ -420,15 +408,6 @@ namespace HandBrake.Interop.HbLib
public int feature;
}
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_filter_object_s
- {
- public int id;
- public int enforce_order;
- public IntPtr name;
- public IntPtr settings;
- }
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LoggingCallback(string message);
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs
index c9f4f9aeb..e7a841251 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs
@@ -26,7 +26,7 @@ namespace HandBrake.Interop.HbLib
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_FF_MASK = 0x001f0000;
+ public const uint HB_ACODEC_FF_MASK = 0x001f2000;
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);
@@ -42,34 +42,6 @@ namespace HandBrake.Interop.HbLib
public const int HB_SUBSTREAM_BD_DTSHD = 0x72;
public const int HB_SUBSTREAM_BD_DTS = 0x71;
- public const int HB_AMIXDOWN_DCA_FORMAT_MASK = 0x00FFF000;
- public const int HB_AMIXDOWN_A52_FORMAT_MASK = 0x00000FF0;
- public const int HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK = 0x0000000F;
- public const int HB_AMIXDOWN_NONE = 0x00000000;
- public const int HB_AMIXDOWN_MONO = 0x01000011;
- public const int HB_AMIXDOWN_STEREO = 0x02002022;
- public const int HB_AMIXDOWN_DOLBY = 0x042070A2;
- public const int HB_AMIXDOWN_DOLBYPLII = 0x084094A2;
- public const int HB_AMIXDOWN_6CH = 0x10089176;
-
- public const int HB_INPUT_CH_LAYOUT_MONO = 0x0110010;
- public const int HB_INPUT_CH_LAYOUT_STEREO = 0x0220020;
- public const int HB_INPUT_CH_LAYOUT_DOLBY = 0x0320031;
- public const int HB_INPUT_CH_LAYOUT_3F = 0x0430030;
- public const int HB_INPUT_CH_LAYOUT_2F1R = 0x0521021;
- public const int HB_INPUT_CH_LAYOUT_3F1R = 0x0631031;
- public const int HB_INPUT_CH_LAYOUT_2F2R = 0x0722022;
- public const int HB_INPUT_CH_LAYOUT_3F2R = 0x0832032;
- public const int HB_INPUT_CH_LAYOUT_4F2R = 0x0942042;
- public const int HB_INPUT_CH_LAYOUT_3F4R = 0x0a34034;
- public const int HB_INPUT_CH_LAYOUT_HAS_LFE = 0x0000100;
- public const int HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK = 0x00F0000;
- public const int HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK = 0x000F000;
- public const int HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK = 0x0000F00;
- public const int HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK = 0xFFFF0FF;
- public const int HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK = 0x00000F0;
- public const int HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK = 0x000000F;
-
public const int HB_VCODEC_MASK = 0x0000FF;
public const int HB_VCODEC_X264 = 0x000001;
public const int HB_VCODEC_THEORA = 0x000002;
@@ -109,20 +81,20 @@ namespace HandBrake.Interop.HbLib
public const int HB_CONFIG_MAX_SIZE = 8192;
- // First, filters that may change the framerate (drop or dup frames)
- public const int HB_FILTER_DETELECINE = 1;
- public const int HB_FILTER_DECOMB = 2;
- public const int HB_FILTER_DEINTERLACE = 3;
- public const int HB_FILTER_VFR = 4;
-
- // Filters that must operate on the original source image are next
- public const int HB_FILTER_DEBLOCK = 5;
- public const int HB_FILTER_DENOISE = 6;
- public const int HB_FILTER_RENDER_SUB = 7;
- public const int HB_FILTER_CROP_SCALE = 8;
-
- // Finally filters that don't care what order they are in,
- // except that they must be after the above filters
- public const int HB_FILTER_ROTATE = 9;
+ // see https://developer.apple.com/quicktime/icefloe/dispatch019.html#colr
+ public const int HB_COLR_PRI_BT709 = 1;
+ public const int HB_COLR_PRI_UNDEF = 2;
+ public const int HB_COLR_PRI_EBUTECH = 5; // use for bt470bg
+ public const int HB_COLR_PRI_SMPTEC = 6; // smpte170m; also use for bt470m and smpte240m
+ // 0, 3-4, 7-65535: reserved
+ public const int HB_COLR_TRA_BT709 = 1; // also use for bt470m, bt470bg and smpte170m
+ public const int HB_COLR_TRA_UNDEF = 2;
+ public const int HB_COLR_TRA_SMPTE240M = 7;
+ // 0, 3-6, 8-65535: reserved
+ public const int HB_COLR_MAT_BT709 = 1;
+ public const int HB_COLR_MAT_UNDEF = 2;
+ public const int HB_COLR_MAT_SMPTE170M = 6; // also use for fcc and bt470bg
+ public const int HB_COLR_MAT_SMPTE240M = 7;
+ // 0, 3-5, 8-65535: reserved
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs
index 6decf10d0..26b836094 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs
@@ -36,15 +36,14 @@ namespace HandBrake.Interop.HbLib
public hb_audio_config_output_s output;
public hb_audio_config_input_s input;
- /// Anonymous_a0a59d69_d9a4_4003_a198_f7c51511e31d
- public Anonymous_a0a59d69_d9a4_4003_a198_f7c51511e31d flags;
-
public hb_audio_config_lang_s lang;
}
[StructLayout(LayoutKind.Sequential)]
public struct hb_audio_config_output_s
{
+ public int mixdown;
+
/// int
public int track;
@@ -63,57 +62,76 @@ namespace HandBrake.Interop.HbLib
public float compression_level;
- /// int
- public int mixdown;
-
/// double
public double dynamic_range_compression;
public double gain;
- /// char*
- //[MarshalAs(UnmanagedType.LPStr)]
- //public string name;
+ public int normalize_mix_level;
public IntPtr name;
}
+ public enum hb_mixdown
+ {
+ HB_INVALID_AMIXDOWN = -1,
+ HB_AMIXDOWN_NONE = 0,
+ HB_AMIXDOWN_MONO,
+ HB_AMIXDOWN_LEFT,
+ HB_AMIXDOWN_RIGHT,
+ HB_AMIXDOWN_STEREO,
+ HB_AMIXDOWN_DOLBY,
+ HB_AMIXDOWN_DOLBYPLII,
+ HB_AMIXDOWN_5POINT1,
+ HB_AMIXDOWN_6POINT1,
+ HB_AMIXDOWN_7POINT1,
+ HB_AMIXDOWN_5_2_LFE,
+ }
+
[StructLayout(LayoutKind.Sequential)]
public struct hb_audio_config_input_s
{
/// int
public int track;
- /// uint32_t->unsigned int
+ /* Input audio codec */
public uint codec;
+ /* Per-codec config info */
+ public uint codec_param;
+
+ /* Registration descriptor of source */
public uint reg_desc;
+ /* Stream type from source stream */
public uint stream_type;
+ /* Substream type for multiplexed streams */
public uint substream_type;
- /// uint32_t->unsigned int
- public uint codec_param;
-
- /// uint32_t->unsigned int
+ /* Bitsream version */
public uint version;
- /// uint32_t->unsigned int
+ /* Bitstream flags, codec-specific */
+ public uint flags;
+
+ /* Bitstream mode, codec-specific */
public uint mode;
- /// int
+ /* Input sample rate (Hz) */
public int samplerate;
+ /* Number of samples per frame */
public int samples_per_frame;
- /// int
+ /* Input bitrate (bps) */
public int bitrate;
- /// int
- public int channel_layout;
+ /* Source channel layout, set by the audio decoder */
+ public ulong channel_layout;
- // hb_chan_map_t *
+ /* Source channel map, set by the audio decoder */
+ // hb_chan_map_t
public IntPtr channel_map;
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs
index ab333ce50..cb70f83ef 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs
@@ -41,7 +41,7 @@ namespace HandBrake.Interop.HbLib
public int deinterlace;
/// hb_list_t*
- public IntPtr filters;
+ public IntPtr list_filter;
/// int
public int width;
@@ -90,7 +90,7 @@ namespace HandBrake.Interop.HbLib
/// int
public int pass;
- public int fastfirstpass;
+ public int fastfirstpass;
public IntPtr advanced_opts;
@@ -100,7 +100,7 @@ namespace HandBrake.Interop.HbLib
public IntPtr x264_tune;
- public IntPtr h264_level;
+ public IntPtr h264_level;
/// int
public int areBframes;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs
index 5365e2ebe..b3a5af3e8 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs
@@ -10,10 +10,10 @@
namespace HandBrake.Interop.HbLib
{
- using System;
- using System.Runtime.InteropServices;
+ using System;
+ using System.Runtime.InteropServices;
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct hb_subtitle_s
{
/// int
@@ -22,6 +22,8 @@ namespace HandBrake.Interop.HbLib
/// int
public int track;
+ public int out_track;
+
/// hb_subtitle_config_t->hb_subtitle_config_s
public hb_subtitle_config_s config;
@@ -45,6 +47,8 @@ namespace HandBrake.Interop.HbLib
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.U4)]
public uint[] palette;
+ public byte palette_set;
+
public int width;
public int height;
@@ -59,6 +63,14 @@ namespace HandBrake.Interop.HbLib
/// int
public int forced_hits;
+ public uint codec;
+
+ public uint reg_desc;
+
+ public uint stream_type;
+
+ public uint substream_type;
+
/// hb_fifo_t*
public IntPtr fifo_in;
@@ -127,6 +139,8 @@ namespace HandBrake.Interop.HbLib
TX3GSUB,
- SSASUB
+ SSASUB,
+
+ PGSSUB
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
index a67a9e3b1..f6d9c0ffd 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
@@ -92,9 +92,9 @@ namespace HandBrake.Interop.HbLib
/// int
public int pixel_aspect_height;
- public int color_prim;
- public int color_transfer;
- public int color_matrix;
+ public int color_prim;
+ public int color_transfer;
+ public int color_matrix;
/// int
public int rate;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
index 5f894dda2..a5406a70a 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs
@@ -148,25 +148,26 @@ namespace HandBrake.Interop.Model
}
/// <summary>
- /// Finds the highest possible mixdown for a given audio encoder.
+ /// Determines if the given mixdown supports the given channel layout.
/// </summary>
- /// <param name="audioEncoder">The audio encoder in question.</param>
- /// <returns>The highest possible mixdown for that audio encoder.</returns>
- public static int GetMaxMixdownIndex(HBAudioEncoder audioEncoder)
+ /// <param name="mixdown">The mixdown to evaluate.</param>
+ /// <param name="layout">The channel layout to evaluate.</param>
+ /// <returns>True if the mixdown supports the given channel layout.</returns>
+ public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout)
{
- // To find best case scenario, pass in highest number of channels and 6-channel discrete mixdown.
- int maxMixdownId = HBFunctions.hb_get_best_mixdown((uint)audioEncoder.Id, NativeConstants.HB_INPUT_CH_LAYOUT_3F4R | NativeConstants.HB_INPUT_CH_LAYOUT_HAS_LFE, NativeConstants.HB_AMIXDOWN_6CH);
-
- for (int i = 0; i < Mixdowns.Count; i++)
- {
- if (Mixdowns[i].Id == maxMixdownId)
- {
- return i;
- }
- }
+ return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0;
+ }
- return -1;
- }
+ /// <summary>
+ /// Determines if the given encoder supports the given mixdown.
+ /// </summary>
+ /// <param name="mixdown">The mixdown to evaluate.</param>
+ /// <param name="encoder">The encoder to evaluate.</param>
+ /// <returns>True if the encoder supports the mixdown.</returns>
+ public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)
+ {
+ return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0;
+ }
/// <summary>
/// Sanitizes a mixdown given the output codec and input channel layout.
@@ -175,7 +176,7 @@ namespace HandBrake.Interop.Model
/// <param name="encoder">The output encoder to be used.</param>
/// <param name="layout">The input channel layout.</param>
/// <returns>A sanitized mixdown value.</returns>
- public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, int layout)
+ public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout)
{
int sanitizedMixdown = HBFunctions.hb_get_best_mixdown((uint)encoder.Id, layout, mixdown.Id);
return Mixdowns.Single(m => m.Id == sanitizedMixdown);
@@ -187,7 +188,7 @@ namespace HandBrake.Interop.Model
/// <param name="encoder">The output codec to be used.</param>
/// <param name="layout">The input channel layout.</param>
/// <returns>The default mixdown for the given codec and channel layout.</returns>
- public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, int layout)
+ public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout)
{
int defaultMixdown = HBFunctions.hb_get_default_mixdown((uint)encoder.Id, layout);
return Mixdowns.Single(m => m.Id == defaultMixdown);
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs
index 2e98daf4a..7b03410d0 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs
@@ -13,8 +13,8 @@ namespace HandBrake.Interop.Model.Encoding
{
Off = 0,
Default,
- Custom,
- Bob,
- Fast
+ Fast,
+ Bob,
+ Custom
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs
index 5d51fe6d5..91d828576 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs
@@ -15,7 +15,7 @@ namespace HandBrake.Interop.Model.Encoding
Fast,
Slow,
Slower,
- Bob,
+ Bob,
Custom
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
index 25da728ef..952d9509a 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
@@ -9,6 +9,7 @@
namespace HandBrake.Interop.Model.Encoding
{
+ using System;
using System.Collections.Generic;
using HandBrake.Interop.Model;
@@ -64,6 +65,9 @@ namespace HandBrake.Interop.Model.Encoding
public bool TwoPass { get; set; }
public bool TurboFirstPass { get; set; }
public double Framerate { get; set; }
+ public bool ConstantFramerate { get; set; }
+
+ [Obsolete("This setting is obsolete. Use Framerate and ConstantFramerate instead.")]
public bool PeakFramerate { get; set; }
public List<AudioEncoding> AudioEncodings { get; set; }
@@ -117,6 +121,7 @@ namespace HandBrake.Interop.Model.Encoding
TwoPass = this.TwoPass,
TurboFirstPass = this.TurboFirstPass,
Framerate = this.Framerate,
+ ConstantFramerate = this.ConstantFramerate,
PeakFramerate = this.PeakFramerate,
AudioEncodings = new List<AudioEncoding>(this.AudioEncodings)
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioTrack.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioTrack.cs
index bd7ca3ef2..2e78951da 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioTrack.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioTrack.cs
@@ -47,7 +47,7 @@ namespace HandBrake.Interop.SourceData
/// <summary>
/// Gets or sets the channel layout of this Audio Track.
/// </summary>
- public int ChannelLayout { get; set; }
+ public ulong ChannelLayout { get; set; }
/// <summary>
/// Gets or sets the frequency (in Hz) of this Audio Track