diff options
author | sr55 <[email protected]> | 2012-03-31 18:48:27 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-03-31 18:48:27 +0000 |
commit | 62f087933c51776ca60eb58262989acab2236fd0 (patch) | |
tree | 386c9a9d07cb7076b3c05fd312ec095b431f092e /win/CS/HandBrake.Interop/HandBrakeInterop | |
parent | 837046df088587599534fe6450e9403fcb3dd67a (diff) |
Interop: Fixes / API Updates for Encoding.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4573 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop')
4 files changed, 102 insertions, 42 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index ee3c6e252..d5bae2e97 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -249,7 +249,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_by_index(this.hbHandle, job.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];
@@ -590,7 +590,8 @@ namespace HandBrake.Interop int refParWidth = 0;
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_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);
InteropUtilities.FreeMemory(allocatedMemory);
width = refWidth;
@@ -963,7 +964,6 @@ namespace HandBrake.Interop nativeJob.crop[2] = crop.Left;
nativeJob.crop[3] = crop.Right;
- var filterList = new List<IntPtr>();
if (profile.Deinterlace != Deinterlace.Off)
{
nativeJob.deinterlace = 1;
@@ -987,7 +987,7 @@ namespace HandBrake.Interop break;
}
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DEINTERLACE, settings, allocatedMemory);
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DEINTERLACE, settings, allocatedMemory);
}
else
{
@@ -1002,7 +1002,7 @@ namespace HandBrake.Interop settings = profile.CustomDetelecine;
}
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DETELECINE, settings, allocatedMemory);
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DETELECINE, settings, allocatedMemory);
}
if (profile.Decomb != Decomb.Off)
@@ -1013,12 +1013,12 @@ namespace HandBrake.Interop settings = profile.CustomDecomb;
}
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DECOMB, settings, allocatedMemory);
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DECOMB, settings, allocatedMemory);
}
if (profile.Deblock > 0)
{
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DEBLOCK, profile.Deblock.ToString(), allocatedMemory);
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DEBLOCK, profile.Deblock.ToString(), allocatedMemory);
}
if (profile.Denoise != Denoise.Off)
@@ -1042,13 +1042,9 @@ namespace HandBrake.Interop break;
}
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DENOISE, settings, allocatedMemory);
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DENOISE, settings, allocatedMemory);
}
- NativeList filterListNative = InteropUtilities.CreateIntPtrList(filterList);
- nativeJob.filters = filterListNative.ListPtr;
- allocatedMemory.AddRange(filterListNative.AllocatedMemory);
-
int width = profile.Width;
int height = profile.Height;
@@ -1378,15 +1374,23 @@ namespace HandBrake.Interop /// <summary>
/// Adds a filter to the given filter list.
/// </summary>
- /// <param name="filterList">The filter list to add 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)
+ /// <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)
{
IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings);
- filterList.Add(HBFunctions.hb_get_filter_object(filterType, settingsNativeString));
-
+ hb_filter_object_s filter = HBFunctions.hb_filter_init(filterType);
+ HBFunctions.hb_add_filter(ref job, filter, settingsNativeString);
allocatedMemory.Add(settingsNativeString);
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs index 7cc7e1b40..8fa46453d 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs @@ -54,13 +54,6 @@ namespace HandBrake.Interop.HbLib public static extern int hb_check_update(ref hb_handle_s h, ref IntPtr version);
- /// Return Type: void
- ///param0: hb_handle_t*
- ///param1: int
- [DllImport("hb.dll", EntryPoint = "hb_set_cpu_count", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_set_cpu_count(ref hb_handle_s param0, int param1);
-
-
/// Return Type: char*
///path: char*
[DllImport("hb.dll", EntryPoint = "hb_dvd_name", CallingConvention = CallingConvention.Cdecl)]
@@ -104,9 +97,6 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_detect_comb", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_detect_comb(ref hb_buffer_s buf, int width, int height, int color_equal, int color_diff, int threshold, int prog_equal, int prog_diff, int prog_threshold);
- [DllImport("hb.dll", EntryPoint = "hb_get_preview_by_index", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_get_preview_by_index(IntPtr hbHandle, int title_index, int picture, IntPtr buffer);
-
/// Return Type: void
///param0: hb_handle_t*
///param1: hb_title_t*
@@ -123,9 +113,6 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_set_size", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_set_size(ref hb_job_s param0, double ratio, int pixels);
- [DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size_by_index", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_set_anamorphic_size_by_index(IntPtr hbHandle, int title_index, ref int output_width, ref int output_height, ref int output_par_width, ref int output_par_height);
-
/// Return Type: void
///param0: hb_job_t*
///output_width: int*
@@ -191,10 +178,6 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_stop", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_stop(IntPtr hbHandle);
- [DllImport("hb.dll", EntryPoint = "hb_get_filter_object", CallingConvention = CallingConvention.Cdecl)]
- //public static extern IntPtr hb_get_filter_object(int filter_id, [In] [MarshalAs(UnmanagedType.LPStr)] string settings);
- public static extern IntPtr hb_get_filter_object(int filter_id, IntPtr settings);
-
/// Return Type: void
///param0: hb_handle_t*
///param1: hb_state_t*
@@ -296,5 +279,50 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_get_audio_encoders_count", CallingConvention = CallingConvention.Cdecl)]
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);
+
+ ///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( 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_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_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_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 hb_filter_object_s hb_filter_init(int filter_id);
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs index 753b7edd2..81c80ab13 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs @@ -410,6 +410,25 @@ namespace HandBrake.Interop.HbLib public uint x;
}
+ [StructLayout(LayoutKind.Sequential)]
+ public struct hb_title_set_s
+ {
+ ///hb_list_t *
+ public hb_list_s list_title;
+
+ // int
+ 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 aae152dce..c85390a41 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs @@ -109,11 +109,20 @@ namespace HandBrake.Interop.HbLib public const int HB_CONFIG_MAX_SIZE = 8192;
- public const int HB_FILTER_DETELECINE = 1;
- public const int HB_FILTER_DEINTERLACE = 2;
- public const int HB_FILTER_DEBLOCK = 3;
- public const int HB_FILTER_DENOISE = 4;
- public const int HB_FILTER_DECOMB = 5;
- public const int HB_FILTER_ROTATE = 6;
+ // 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;
}
}
|