this.encodeAllocatedMemory.Add(nativeJob.x264_tune);\r
}\r
\r
+ if (!string.IsNullOrEmpty(job.EncodingProfile.H264Level))\r
+ {\r
+ nativeJob.h264_level = Marshal.StringToHGlobalAnsi(job.EncodingProfile.H264Level);\r
+ this.encodeAllocatedMemory.Add(nativeJob.h264_level);\r
+ }\r
+\r
if (this.subtitleScan)\r
{\r
// If we need to scan subtitles, enqueue a pre-processing job to do that.\r
int refHeight = 0;\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(ref nativeJob, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);\r
InteropUtilities.FreeMemory(allocatedMemory);\r
\r
height = profile.MaxHeight;\r
}\r
\r
+ // The job width can sometimes start not clean, due to interference from\r
+ // preview generation. We reset it here to allow good calculations.\r
+ nativeJob.width = width;\r
+ nativeJob.height = height;\r
+\r
nativeJob.grayscale = profile.Grayscale ? 1 : 0;\r
\r
switch (profile.Anamorphic)\r
height = outputSize.Height;\r
\r
nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;\r
+\r
+ nativeJob.width = width;\r
+ nativeJob.height = height;\r
+\r
+ nativeJob.maxWidth = profile.MaxWidth;\r
+ nativeJob.maxHeight = profile.MaxHeight;\r
+\r
break;\r
case Anamorphic.Strict:\r
nativeJob.anamorphic.mode = 1;\r
break;\r
case Anamorphic.Loose:\r
nativeJob.anamorphic.mode = 2;\r
+\r
+ nativeJob.modulus = profile.Modulus;\r
+\r
+ nativeJob.width = width;\r
+\r
+ nativeJob.maxWidth = profile.MaxWidth;\r
+\r
break;\r
case Anamorphic.Custom:\r
nativeJob.anamorphic.mode = 3;\r
nativeJob.anamorphic.dar_height = height;\r
nativeJob.anamorphic.keep_display_aspect = 1;\r
}\r
-\r
- nativeJob.anamorphic.dar_width = profile.DisplayWidth;\r
- nativeJob.anamorphic.dar_height = height;\r
- nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;\r
+ else\r
+ {\r
+ nativeJob.anamorphic.dar_width = profile.DisplayWidth;\r
+ nativeJob.anamorphic.dar_height = height;\r
+ nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;\r
+ }\r
}\r
else\r
{\r
nativeJob.anamorphic.keep_display_aspect = 0;\r
}\r
\r
+ nativeJob.width = width;\r
+ nativeJob.height = height;\r
+\r
+ nativeJob.maxWidth = profile.MaxWidth;\r
+ nativeJob.maxHeight = profile.MaxHeight;\r
+\r
break;\r
default:\r
break;\r
}\r
\r
- nativeJob.width = width;\r
- nativeJob.height = height;\r
+ // Need to fix up values before adding crop/scale filter\r
+ if (profile.Anamorphic != Anamorphic.None)\r
+ {\r
+ int anamorphicWidth = 0, anamorphicHeight = 0, anamorphicParWidth = 0, anamorphicParHeight = 0;\r
\r
- nativeJob.maxWidth = profile.MaxWidth;\r
- nativeJob.maxHeight = profile.MaxHeight;\r
+ HBFunctions.hb_set_anamorphic_size(ref nativeJob, ref anamorphicWidth, ref anamorphicHeight, ref anamorphicParWidth, ref anamorphicParHeight);\r
+ nativeJob.width = anamorphicWidth;\r
+ nativeJob.height = anamorphicHeight;\r
+ nativeJob.anamorphic.par_width = anamorphicParWidth;\r
+ nativeJob.anamorphic.par_height = anamorphicParHeight;\r
+ }\r
\r
string cropScaleSettings = string.Format(\r
CultureInfo.InvariantCulture,\r
AspectRatio = title.aspect,\r
AngleCount = title.angle_count,\r
VideoCodecName = title.video_codec_name,\r
- Framerate = ((double)title.rate) / title.rate_base\r
+ Framerate = ((double)title.rate) / title.rate_base,\r
+ FramerateNumerator = title.rate,\r
+ FramerateDenominator = title.rate_base\r
};\r
\r
switch (title.type)\r
case hb_subtitle_s_subsource.VOBSUB:\r
newSubtitle.SubtitleSource = SubtitleSource.VobSub;\r
break;\r
+ case hb_subtitle_s_subsource.PGSSUB:\r
+ newSubtitle.SubtitleSource = SubtitleSource.PGS;\r
+ break;\r
default:\r
break;\r
}\r
return sanitizedName;\r
}\r
\r
+ /// <summary>\r
+ /// Checks to see if the given H.264 level is valid given the inputs.\r
+ /// </summary>\r
+ /// <param name="level">The level to check.</param>\r
+ /// <param name="width">The output picture width.</param>\r
+ /// <param name="height">The output picture height.</param>\r
+ /// <param name="fpsNumerator">The rate numerator.</param>\r
+ /// <param name="fpsDenominator">The rate denominator.</param>\r
+ /// <param name="interlaced">True if x264 interlaced output is enabled.</param>\r
+ /// <param name="fakeInterlaced">True if x264 fake interlacing is enabled.</param>\r
+ /// <returns>True if the level is valid.</returns>\r
+ public static bool IsH264LevelValid(string level, int width, int height, int fpsNumerator, int fpsDenominator, bool interlaced, bool fakeInterlaced)\r
+ {\r
+ return HBFunctions.hb_check_h264_level(\r
+ level, \r
+ width, \r
+ height, \r
+ fpsNumerator, \r
+ fpsDenominator, \r
+ interlaced ? 1 : 0,\r
+ fakeInterlaced ? 1 : 0) == 0;\r
+ }\r
+\r
/// <summary>\r
/// Gets the total number of seconds on the given encode job.\r
/// </summary>\r
public string X264Profile { get; set; }\r
public string X264Preset { get; set; }\r
public string X264Tune { get; set; }\r
+ public string H264Level { get; set; }\r
public VideoEncodeRateType VideoEncodeRateType { get; set; }\r
public double Quality { get; set; }\r
public int TargetSize { get; set; }\r
X264Profile = this.X264Profile,\r
X264Preset = this.X264Preset,\r
X264Tune = this.X264Tune,\r
+ H264Level = this.H264Level,\r
VideoEncodeRateType = this.VideoEncodeRateType,\r
Quality = this.Quality,\r
TargetSize = this.TargetSize,\r
TurboFirstPass = this.TurboFirstPass,\r
Framerate = this.Framerate,\r
ConstantFramerate = this.ConstantFramerate,\r
+#pragma warning disable 612,618\r
PeakFramerate = this.PeakFramerate,\r
+#pragma warning restore 612,618\r
\r
AudioEncodings = new List<AudioEncoding>(this.AudioEncodings)\r
};\r