]> granicus.if.org Git - handbrake/commitdiff
Interop: Fixes / API Updates for Encoding.
authorsr55 <sr55.hb@outlook.com>
Sat, 31 Mar 2012 18:48:27 +0000 (18:48 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 31 Mar 2012 18:48:27 +0000 (18:48 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4573 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs

index ee3c6e2524252f83735602458963e8935bedef4b..d5bae2e97774125f32bd702f6320b8c389944635 100644 (file)
@@ -249,7 +249,7 @@ namespace HandBrake.Interop
                        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
@@ -590,7 +590,8 @@ namespace HandBrake.Interop
                        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
@@ -963,7 +964,6 @@ namespace HandBrake.Interop
                        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
@@ -987,7 +987,7 @@ namespace HandBrake.Interop
                                                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
@@ -1002,7 +1002,7 @@ namespace HandBrake.Interop
                                        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
@@ -1013,12 +1013,12 @@ namespace HandBrake.Interop
                                        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
@@ -1042,13 +1042,9 @@ namespace HandBrake.Interop
                                                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
@@ -1378,15 +1374,23 @@ namespace HandBrake.Interop
                /// <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
index 7cc7e1b40fbe57edd922e4586ce394a68491f3e8..8fa46453ddeaa2cfe71c7e89fab7f9080e00149a 100644 (file)
@@ -54,13 +54,6 @@ namespace HandBrake.Interop.HbLib
                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
@@ -104,9 +97,6 @@ namespace HandBrake.Interop.HbLib
                [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
@@ -123,9 +113,6 @@ namespace HandBrake.Interop.HbLib
                [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
@@ -191,10 +178,6 @@ namespace HandBrake.Interop.HbLib
                [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
@@ -296,5 +279,50 @@ namespace HandBrake.Interop.HbLib
 \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
index 753b7edd294587c892d3fc6b41fa3d594a797e5f..81c80ab13366ed461765721e00af15e9a7170ec3 100644 (file)
@@ -410,6 +410,25 @@ namespace HandBrake.Interop.HbLib
                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
index aae152dce76522efd32502bab230720c35f0b743..c85390a41c57ad400a5e93a07b7d692ab672ce75 100644 (file)
@@ -109,11 +109,20 @@ namespace HandBrake.Interop.HbLib
 \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