IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, job.Title);\r
var nativeJob = InteropUtilities.ReadStructure<hb_job_s>(nativeJobPtr);\r
\r
- //hb_job_s nativeJob = InteropUtilities.ReadStructure<hb_job_s>(this.GetOriginalTitle(job.Title).job);\r
this.encodeAllocatedMemory = this.ApplyJob(ref nativeJob, job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds);\r
\r
- if (!preview && profile.IncludeChapterMarkers)\r
- {\r
- Title title = this.GetTitle(job.Title);\r
- int numChapters = title.Chapters.Count;\r
-\r
- if (job.UseDefaultChapterNames)\r
- {\r
- for (int i = 0; i < numChapters; i++)\r
- {\r
- HBFunctions.hb_set_chapter_name(this.hbHandle, job.Title, i + 1, "Chapter " + (i + 1));\r
- }\r
- }\r
- else\r
- {\r
- for (int i = 0; i < numChapters; i++)\r
- {\r
- HBFunctions.hb_set_chapter_name(this.hbHandle, job.Title, i + 1, job.CustomChapterNames[i]);\r
- }\r
- }\r
- }\r
-\r
this.subtitleScan = false;\r
if (job.Subtitles.SourceSubtitles != null)\r
{\r
\r
IntPtr titleSetPtr = HBFunctions.hb_get_title_set(this.hbHandle);\r
hb_title_set_s titleSet = InteropUtilities.ReadStructure<hb_title_set_s>(titleSetPtr);\r
- this.originalTitles = InteropUtilities.ConvertList<hb_title_s>(titleSet.list_title);\r
+ this.originalTitles = titleSet.list_title.ToList<hb_title_s>();\r
\r
foreach (hb_title_s title in this.originalTitles)\r
{\r
}\r
}\r
\r
+ // Chapter markers\r
nativeJob.chapter_markers = profile.IncludeChapterMarkers ? 1 : 0;\r
\r
+ List<IntPtr> nativeChapters = nativeJob.list_chapter.ToIntPtrList();\r
+\r
+ if (!preview && profile.IncludeChapterMarkers)\r
+ {\r
+ int numChapters = title.Chapters.Count;\r
+\r
+ if (job.UseDefaultChapterNames)\r
+ {\r
+ for (int i = 0; i < numChapters; i++)\r
+ {\r
+ if (i < nativeChapters.Count)\r
+ {\r
+ HBFunctions.hb_chapter_set_title(nativeChapters[i], "Chapter " + (i + 1));\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ for (int i = 0; i < numChapters; i++)\r
+ {\r
+ if (i < nativeChapters.Count && i < job.CustomChapterNames.Count)\r
+ {\r
+ HBFunctions.hb_chapter_set_title(nativeChapters[i], job.CustomChapterNames[i]);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
Cropping crop = GetCropping(profile, title);\r
\r
nativeJob.crop[0] = crop.Top;\r
\r
// areBframes\r
// color_matrix\r
- List<hb_audio_s> titleAudio = InteropUtilities.ConvertList<hb_audio_s>(originalTitle.list_audio);\r
+ List<hb_audio_s> titleAudio = originalTitle.list_audio.ToList<hb_audio_s>();\r
\r
var audioList = new List<hb_audio_s>();\r
int numTracks = 0;\r
{\r
if (job.Subtitles.SourceSubtitles != null && job.Subtitles.SourceSubtitles.Count > 0)\r
{\r
- List<hb_subtitle_s> titleSubtitles = InteropUtilities.ConvertList<hb_subtitle_s>(originalTitle.list_subtitle);\r
+ List<hb_subtitle_s> titleSubtitles = originalTitle.list_subtitle.ToList<hb_subtitle_s>();\r
\r
foreach (SourceSubtitle sourceSubtitle in job.Subtitles.SourceSubtitles)\r
{\r
}\r
\r
int currentSubtitleTrack = 1;\r
- List<hb_subtitle_s> subtitleList = InteropUtilities.ConvertList<hb_subtitle_s>(title.list_subtitle);\r
+ List<hb_subtitle_s> subtitleList = title.list_subtitle.ToList<hb_subtitle_s>();\r
foreach (hb_subtitle_s subtitle in subtitleList)\r
{\r
var newSubtitle = new Subtitle\r
}\r
\r
int currentAudioTrack = 1;\r
- List<hb_audio_s> audioList = InteropUtilities.ConvertList<hb_audio_s>(title.list_audio);\r
+ List<hb_audio_s> audioList = title.list_audio.ToList<hb_audio_s>();\r
foreach (hb_audio_s audio in audioList)\r
{\r
var newAudio = new AudioTrack\r
currentAudioTrack++;\r
}\r
\r
- List<hb_chapter_s> chapterList = InteropUtilities.ConvertList<hb_chapter_s>(title.list_chapter);\r
+ List<hb_chapter_s> chapterList = title.list_chapter.ToList<hb_chapter_s>();\r
foreach (hb_chapter_s chapter in chapterList)\r
{\r
var newChapter = new Chapter\r
fakeInterlaced ? 1 : 0) == 0;\r
}\r
\r
+ /// <summary>\r
+ /// Creates an X264 options string from the given settings.\r
+ /// </summary>\r
+ /// <param name="preset">The x264 preset.</param>\r
+ /// <param name="tunes">The x264 tunes being used.</param>\r
+ /// <param name="extraOptions">The extra options string.</param>\r
+ /// <param name="profile">The H.264 profile.</param>\r
+ /// <param name="level">The H.264 level.</param>\r
+ /// <param name="width">The width of the final picture.</param>\r
+ /// <param name="height">The height of the final picture.</param>\r
+ /// <returns>The full x264 options string from the given inputs.</returns>\r
+ public static string CreateX264OptionsString(\r
+ string preset, \r
+ IList<string> tunes, \r
+ string extraOptions, \r
+ string profile,\r
+ string level, \r
+ int width, \r
+ int height)\r
+ {\r
+ if (width <= 0)\r
+ {\r
+ throw new ArgumentException("width must be positive.");\r
+ }\r
+\r
+ if (height <= 0)\r
+ {\r
+ throw new ArgumentException("height must be positive.");\r
+ }\r
+\r
+ return HBFunctions.hb_x264_param_unparse(\r
+ preset,\r
+ string.Join(",", tunes),\r
+ extraOptions,\r
+ profile,\r
+ level,\r
+ width,\r
+ height);\r
+ }\r
+\r
/// <summary>\r
/// Gets the total number of seconds on the given encode job.\r
/// </summary>\r
[DllImport("hb.dll", EntryPoint = "hb_job", CallingConvention = CallingConvention.Cdecl)]\r
public static extern IntPtr hb_job(IntPtr hbHandle, int jobIndex);\r
\r
- [DllImport("hb.dll", EntryPoint = "hb_set_chapter_name", CallingConvention = CallingConvention.Cdecl)]\r
- public static extern void hb_set_chapter_name(IntPtr hbHandle, int title_index, int chapter_index, [In] [MarshalAs(UnmanagedType.LPStr)] string chapter_name);\r
-\r
[DllImport("hb.dll", EntryPoint = "hb_set_job", CallingConvention = CallingConvention.Cdecl)]\r
public static extern void hb_set_job(IntPtr hbHandle, int title_index, ref hb_job_s job);\r
\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
+ public static extern void hb_chapter_set_title(IntPtr chapter, [In] [MarshalAs(UnmanagedType.LPStr)] string 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
\r
[DllImport("hb.dll", EntryPoint = "hb_check_h264_level", CallingConvention = CallingConvention.Cdecl)]\r
public static extern int hb_check_h264_level([In] [MarshalAs(UnmanagedType.LPStr)] string level, int width, int height, int fps_num, int fps_den, int interlaced, int fake_interlaced);\r
+\r
+ [DllImport("hb.dll", EntryPoint = "hb_x264_param_unparse", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern string hb_x264_param_unparse(\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_preset,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_tune,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_encopts,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_profile,\r
+ [In] [MarshalAs(UnmanagedType.LPStr)] string h264_level,\r
+ int width,\r
+ int height);\r
}\r
}\r
/// <typeparam name="T">The type of structure in the list.</typeparam>\r
/// <param name="listPtr">The pointer to the native list.</param>\r
/// <returns>The converted managed list.</returns>\r
- public static List<T> ConvertList<T>(IntPtr listPtr)\r
+ public static List<T> ToList<T>(this IntPtr listPtr)\r
{\r
List<T> returnList = new List<T>();\r
hb_list_s itemList = ReadStructure<hb_list_s>(listPtr);\r
return returnList;\r
}\r
\r
+ /// <summary>\r
+ /// Converts the HB list to a managed list of pointers.\r
+ /// </summary>\r
+ /// <param name="listPtr">The list to convert.</param>\r
+ /// <returns>The managed list of pointers.</returns>\r
+ public static List<IntPtr> ToIntPtrList(this IntPtr listPtr)\r
+ {\r
+ var returnList = new List<IntPtr>();\r
+ hb_list_s itemList = ReadStructure<hb_list_s>(listPtr);\r
+\r
+ for (int i = 0; i < itemList.items_count; i++)\r
+ {\r
+ IntPtr itemPtr = Marshal.ReadIntPtr(itemList.items, i * Marshal.SizeOf(typeof(IntPtr)));\r
+ returnList.Add(itemPtr);\r
+ }\r
+\r
+ return returnList;\r
+ }\r
+\r
/// <summary>\r
/// Converts the given native array to a managed collection.\r
/// </summary>\r
// You can specify all the values or you can default the Build and Revision Numbers \r
// by using the '*' as shown below:\r
// [assembly: AssemblyVersion("1.0.*")]\r
-[assembly: AssemblyVersion("1.32.0.0")]\r
-[assembly: AssemblyFileVersion("1.32.0.0")]\r
+[assembly: AssemblyVersion("1.33.0.0")]\r
+[assembly: AssemblyFileVersion("1.33.0.0")]\r