summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-02-07 20:04:34 +0000
committersr55 <[email protected]>2020-02-07 20:04:34 +0000
commitb436ec04facbb390431738d37856e887fd2155e8 (patch)
treeb9c0673db490aba2374a3b758531c1fe1ddfe3e8 /win/CS/HandBrake.Interop
parent4b2b5c36bae5c88e8106c5df5283717d11c46e90 (diff)
WinGui: AutoPassthru is now implemented using libhb using hb_autopassthru_get_encoder. This should solve a number of issues around selection. Fixes #2627 and #2611
Diffstat (limited to 'win/CS/HandBrake.Interop')
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs54
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs3
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs12
3 files changed, 69 insertions, 0 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs
index d728809e3..83390faa0 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs
@@ -211,6 +211,13 @@ namespace HandBrake.Interop.Interop
return AudioEncoders.SingleOrDefault(e => e.Id == codecId);
}
+ public static HBAudioEncoder GetAutoPassthruEncoder(int inputCodec, int copyMask, int fallback, int muxer)
+ {
+ int encoder = HBFunctions.hb_autopassthru_get_encoder(inputCodec, copyMask, fallback, muxer);
+
+ return GetAudioEncoder(encoder);
+ }
+
/// <summary>
/// Gets the video encoder with the specified short name.
/// </summary>
@@ -659,5 +666,52 @@ namespace HandBrake.Interop.Interop
{
return hbFunctions.hb_audio_compression_get_default((uint)encoder.Id);
}
+
+ public static uint BuildCopyMask(bool audioAllowMP3Pass, bool audioAllowAACPass, bool audioAllowAC3Pass, bool audioAllowDTSPass, bool audioAllowDTSHDPass, bool audioAllowEac3Pass, bool audioAllowFlacPass, bool audioAllowTruehdPass)
+ {
+ uint mask = 0;
+
+ if (audioAllowMP3Pass)
+ {
+ mask |= NativeConstants.HB_ACODEC_MP3_PASS;
+ }
+
+ if (audioAllowAACPass)
+ {
+ mask |= NativeConstants.HB_ACODEC_AAC_PASS;
+ }
+
+ if (audioAllowAC3Pass)
+ {
+ mask |= NativeConstants.HB_ACODEC_AC3_PASS;
+ }
+
+ if (audioAllowDTSPass)
+ {
+ mask |= NativeConstants.HB_ACODEC_DCA_PASS;
+ }
+
+ if (audioAllowDTSHDPass)
+ {
+ mask |= NativeConstants.HB_ACODEC_DCA_HD_PASS;
+ }
+
+ if (audioAllowEac3Pass)
+ {
+ mask |= NativeConstants.HB_ACODEC_EAC3_PASS;
+ }
+
+ if (audioAllowFlacPass)
+ {
+ mask |= NativeConstants.HB_ACODEC_FLAC_PASS;
+ }
+
+ if (audioAllowTruehdPass)
+ {
+ mask |= NativeConstants.HB_ACODEC_TRUEHD_PASS;
+ }
+
+ return mask;
+ }
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
index 26dfd3d8d..742f63aea 100644
--- a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
@@ -162,6 +162,9 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_audio_can_apply_drc2", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_audio_can_apply_drc2(IntPtr handle, int title_index, int audio_index, int encoder);
+ [DllImport("hb", EntryPoint = "hb_autopassthru_get_encoder", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int hb_autopassthru_get_encoder(int in_codec, int copy_mask, int fallback, int muxer);
+
[DllImport("hb", EntryPoint = "hb_mixdown_is_supported", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout);
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs b/win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs
index 3e0e7f012..b0e5d876d 100644
--- a/win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/NativeConstants.cs
@@ -24,6 +24,18 @@ namespace HandBrake.Interop.Interop.HbLib
public const uint HB_ACODEC_PASS_FLAG = 0x40000000;
public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_AC3 | HB_ACODEC_DCA | HB_ACODEC_DCA_HD | HB_ACODEC_FFAAC | HB_ACODEC_FFEAC3 | HB_ACODEC_FFFLAC | HB_ACODEC_MP3 | HB_ACODEC_FFTRUEHD);
+ public const uint HB_ACODEC_MASK = 0x07FFFF01;
+ public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_PASS_MASK);
+ public const uint HB_ACODEC_ANY = (HB_ACODEC_PASS_FLAG | HB_ACODEC_MASK);
+ public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFAAC);
+ public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_AC3);
+ public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_DCA);
+ public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_DCA_HD);
+ public const uint HB_ACODEC_EAC3_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFEAC3);
+ public const uint HB_ACODEC_FLAC_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFFLAC);
+ public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_MP3);
+ public const uint HB_ACODEC_TRUEHD_PASS = (HB_ACODEC_PASS_FLAG | HB_ACODEC_FFTRUEHD);
+
// VideoEncoders
public const uint HB_VCODEC_QSV_H264 = 0x0000100;
public const uint HB_VCODEC_QSV_H265 = 0x0000200;