IntPtr nativeBuffer = Marshal.AllocHGlobal(imageBufferSize);\r
allocatedMemory.Add(nativeBuffer);\r
HBFunctions.hb_set_job(this.hbHandle, job.Title, ref nativeJob);\r
- HBFunctions.hb_get_preview_by_index(this.hbHandle, job.Title, previewNumber, nativeBuffer);\r
+ HBFunctions.hb_get_preview(this.hbHandle, ref title, previewNumber, nativeBuffer);\r
\r
// Copy the filled image buffer to a managed array.\r
byte[] managedBuffer = new byte[imageBufferSize];\r
int refParWidth = 0;\r
int refParHeight = 0;\r
HBFunctions.hb_set_job(this.hbHandle, job.Title, ref nativeJob);\r
- HBFunctions.hb_set_anamorphic_size_by_index(this.hbHandle, job.Title, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);\r
+ //HBFunctions.hb_set_anamorphic_size_by_index(this.hbHandle, job.Title, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);\r
+ HBFunctions.hb_set_anamorphic_size(ref nativeJob, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);\r
InteropUtilities.FreeMemory(allocatedMemory);\r
\r
width = refWidth;\r
nativeJob.crop[2] = crop.Left;\r
nativeJob.crop[3] = crop.Right;\r
\r
- var filterList = new List<IntPtr>();\r
if (profile.Deinterlace != Deinterlace.Off)\r
{\r
nativeJob.deinterlace = 1;\r
break;\r
}\r
\r
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DEINTERLACE, settings, allocatedMemory);\r
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DEINTERLACE, settings, allocatedMemory);\r
}\r
else\r
{\r
settings = profile.CustomDetelecine;\r
}\r
\r
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DETELECINE, settings, allocatedMemory);\r
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DETELECINE, settings, allocatedMemory);\r
}\r
\r
if (profile.Decomb != Decomb.Off)\r
settings = profile.CustomDecomb;\r
}\r
\r
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DECOMB, settings, allocatedMemory);\r
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DECOMB, settings, allocatedMemory);\r
}\r
\r
if (profile.Deblock > 0)\r
{\r
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DEBLOCK, profile.Deblock.ToString(), allocatedMemory);\r
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DEBLOCK, profile.Deblock.ToString(), allocatedMemory);\r
}\r
\r
if (profile.Denoise != Denoise.Off)\r
break;\r
}\r
\r
- this.AddFilter(filterList, NativeConstants.HB_FILTER_DENOISE, settings, allocatedMemory);\r
+ this.AddFilter(nativeJob, NativeConstants.HB_FILTER_DENOISE, settings, allocatedMemory);\r
}\r
\r
- NativeList filterListNative = InteropUtilities.CreateIntPtrList(filterList);\r
- nativeJob.filters = filterListNative.ListPtr;\r
- allocatedMemory.AddRange(filterListNative.AllocatedMemory);\r
-\r
int width = profile.Width;\r
int height = profile.Height;\r
\r
/// <summary>\r
/// Adds a filter to the given filter list.\r
/// </summary>\r
- /// <param name="filterList">The filter list to add to.</param>\r
- /// <param name="filterType">The type of filter.</param>\r
- /// <param name="settings">Settings for the filter.</param>\r
- /// <param name="allocatedMemory">The list of allocated memory.</param>\r
- private void AddFilter(List<IntPtr> filterList, int filterType, string settings, List<IntPtr> allocatedMemory)\r
+ /// <param name="job">\r
+ /// The job.\r
+ /// </param>\r
+ /// <param name="filterType">\r
+ /// The type of filter.\r
+ /// </param>\r
+ /// <param name="settings">\r
+ /// Settings for the filter.\r
+ /// </param>\r
+ /// <param name="allocatedMemory">\r
+ /// The list of allocated memory.\r
+ /// </param>\r
+ private void AddFilter(hb_job_s job, int filterType, string settings, List<IntPtr> allocatedMemory)\r
{\r
IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings);\r
- filterList.Add(HBFunctions.hb_get_filter_object(filterType, settingsNativeString));\r
-\r
+ hb_filter_object_s filter = HBFunctions.hb_filter_init(filterType);\r
+ HBFunctions.hb_add_filter(ref job, filter, settingsNativeString);\r
allocatedMemory.Add(settingsNativeString);\r
}\r
\r
public static extern int hb_check_update(ref hb_handle_s h, ref IntPtr version);\r
\r
\r
- /// Return Type: void\r
- ///param0: hb_handle_t*\r
- ///param1: int\r
- [DllImport("hb.dll", EntryPoint = "hb_set_cpu_count", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_set_cpu_count(ref hb_handle_s param0, int param1);\r
-\r
-\r
/// Return Type: char*\r
///path: char*\r
[DllImport("hb.dll", EntryPoint = "hb_dvd_name", CallingConvention = CallingConvention.Cdecl)]\r
[DllImport("hb.dll", EntryPoint = "hb_detect_comb", CallingConvention = CallingConvention.Cdecl)]\r
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);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_get_preview_by_index", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_get_preview_by_index(IntPtr hbHandle, int title_index, int picture, IntPtr buffer);\r
-\r
/// Return Type: void\r
///param0: hb_handle_t*\r
///param1: hb_title_t*\r
[DllImport("hb.dll", EntryPoint = "hb_set_size", CallingConvention = CallingConvention.Cdecl)]\r
public static extern void hb_set_size(ref hb_job_s param0, double ratio, int pixels);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size_by_index", CallingConvention = CallingConvention.Cdecl)]\r
- 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);\r
-\r
/// Return Type: void\r
///param0: hb_job_t*\r
///output_width: int*\r
[DllImport("hb.dll", EntryPoint = "hb_stop", CallingConvention = CallingConvention.Cdecl)]\r
public static extern void hb_stop(IntPtr hbHandle);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_get_filter_object", CallingConvention = CallingConvention.Cdecl)]\r
- //public static extern IntPtr hb_get_filter_object(int filter_id, [In] [MarshalAs(UnmanagedType.LPStr)] string settings);\r
- public static extern IntPtr hb_get_filter_object(int filter_id, IntPtr settings);\r
-\r
/// Return Type: void\r
///param0: hb_handle_t*\r
///param1: hb_state_t*\r
\r
[DllImport("hb.dll", EntryPoint = "hb_get_audio_encoders_count", CallingConvention = CallingConvention.Cdecl)]\r
public static extern int hb_get_audio_encoders_count();\r
+\r
+\r
+ /// void hb_autopassthru_apply_settings( hb_job_t * job )\r
+ [DllImport("hb.dll", EntryPoint = "hb_autopassthru_apply_settings", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_autopassthru_apply_settings(ref hb_job_s job);\r
+\r
+ ///hb_title_set_t * hb_get_title_set( hb_handle_t * );\r
+ [DllImport("hb.dll", EntryPoint = "hb_get_title_set", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern hb_title_set_s hb_get_title_set(IntPtr hbHandle);\r
+\r
+ ///hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_init_by_index", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern hb_job_s hb_job_init_by_index(IntPtr hbHandle, int title_index);\r
+\r
+ ///hb_job_t * hb_job_init( hb_title_t * title );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern hb_job_s hb_job_init(ref hb_title_s title);\r
+\r
+ ///void hb_job_reset( hb_job_t * job );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_reset", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_job_reset(ref hb_job_s job);\r
+\r
+ ///void hb_job_close( hb_job_t ** job );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_close", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_job_close(ref hb_job_s job);\r
+\r
+ ///void hb_job_set_advanced_opts( hb_job_t *job, const char *advanced_opts );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_set_advanced_opts", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_job_set_advanced_opts(ref hb_job_s job, IntPtr advanced_opts);\r
+\r
+ ///void hb_job_set_file( hb_job_t *job, const char *file );\r
+ [DllImport("hb.dll", EntryPoint = "hb_job_set_file", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_job_set_file(ref hb_job_s job, IntPtr file);\r
+\r
+ ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);\r
+ [DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_chapter_set_title(ref hb_chapter_s chapter, IntPtr title);\r
+\r
+ /// void hb_add_filter( hb_job_t * job, hb_filter_object_t * filter, const char * settings ); \r
+ [DllImport("hb.dll", EntryPoint = "hb_add_filter", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern void hb_add_filter(ref hb_job_s job, hb_filter_object_s filter, IntPtr settings);\r
+\r
+ /// hb_filter_object_t * hb_filter_init( int filter_id );\r
+ [DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern hb_filter_object_s hb_filter_init(int filter_id);\r
}\r
}\r
public uint x;\r
}\r
\r
+ [StructLayout(LayoutKind.Sequential)]\r
+ public struct hb_title_set_s\r
+ {\r
+ ///hb_list_t *\r
+ public hb_list_s list_title;\r
+\r
+ // int\r
+ public int feature;\r
+ }\r
+\r
+ [StructLayout(LayoutKind.Sequential)]\r
+ public struct hb_filter_object_s\r
+ {\r
+ public int id;\r
+ public int enforce_order;\r
+ public IntPtr name;\r
+ public IntPtr settings;\r
+ }\r
+\r
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
public delegate void LoggingCallback(string message);\r
}\r
\r
public const int HB_CONFIG_MAX_SIZE = 8192;\r
\r
- public const int HB_FILTER_DETELECINE = 1;\r
- public const int HB_FILTER_DEINTERLACE = 2;\r
- public const int HB_FILTER_DEBLOCK = 3;\r
- public const int HB_FILTER_DENOISE = 4;\r
- public const int HB_FILTER_DECOMB = 5;\r
- public const int HB_FILTER_ROTATE = 6;\r
+ // First, filters that may change the framerate (drop or dup frames) \r
+ public const int HB_FILTER_DETELECINE = 1;\r
+ public const int HB_FILTER_DECOMB = 2;\r
+ public const int HB_FILTER_DEINTERLACE = 3;\r
+ public const int HB_FILTER_VFR = 4;\r
+\r
+ // Filters that must operate on the original source image are next \r
+ public const int HB_FILTER_DEBLOCK = 5;\r
+ public const int HB_FILTER_DENOISE = 6;\r
+ public const int HB_FILTER_RENDER_SUB = 7;\r
+ public const int HB_FILTER_CROP_SCALE = 8;\r
+\r
+ // Finally filters that don't care what order they are in, \r
+ // except that they must be after the above filters \r
+ public const int HB_FILTER_ROTATE = 9;\r
}\r
}\r