]> granicus.if.org Git - handbrake/commitdiff
Interop: Exposing raw FPS numerator/denominator on Title. Exposing IsH264LevelValid...
authorrandomengy <david.rickard@gmail.com>
Mon, 12 Nov 2012 04:35:55 +0000 (04:35 +0000)
committerrandomengy <david.rickard@gmail.com>
Mon, 12 Nov 2012 04:35:55 +0000 (04:35 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5057 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs
win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs
win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/SubtitleSource.cs
win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs

index c62f96fb6148244ac8e5bef0932f890847abe52f..6249c7f86f6e504d21b3e2996f79af31a8bb2cbf 100644 (file)
@@ -461,6 +461,12 @@ namespace HandBrake.Interop
                                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
@@ -592,8 +598,6 @@ namespace HandBrake.Interop
                        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
@@ -1159,6 +1163,11 @@ namespace HandBrake.Interop
                                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
@@ -1171,12 +1180,26 @@ namespace HandBrake.Interop
                                        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
@@ -1210,10 +1233,12 @@ namespace HandBrake.Interop
                                                        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
@@ -1222,16 +1247,28 @@ namespace HandBrake.Interop
                                                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
@@ -1617,7 +1654,9 @@ namespace HandBrake.Interop
                                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
@@ -1676,6 +1715,9 @@ namespace HandBrake.Interop
                                        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
index 9bfceb2787807afe81d9ba9bf30f69212c05c31c..496136421e1206f99f4493be84000c0783072008 100644 (file)
@@ -142,6 +142,29 @@ namespace HandBrake.Interop
                        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
index 952d9509af4ee9a7cf8d4fc80b8de30a503ca3cf..f5326e89ba9c65f70694162b8cadd7fad1619454 100644 (file)
@@ -58,6 +58,7 @@ namespace HandBrake.Interop.Model.Encoding
                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
@@ -114,6 +115,7 @@ namespace HandBrake.Interop.Model.Encoding
                                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
@@ -122,7 +124,9 @@ namespace HandBrake.Interop.Model.Encoding
                                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
index fa9e9e063d1095296ade793d022621c2893194c6..076afdeb397b9df87fbaa408a29729fbd4716c32 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // 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.27.0.0")]\r
-[assembly: AssemblyFileVersion("1.27.0.0")]\r
+[assembly: AssemblyVersion("1.31.0.0")]\r
+[assembly: AssemblyFileVersion("1.31.0.0")]\r
index 9b04e165272f41400953f694de294b8214bc99c3..f0a0b0a38f225b6d2b29a8ce715e894cf06a9221 100644 (file)
@@ -17,6 +17,7 @@ namespace HandBrake.Interop.SourceData
                CC708,\r
                UTF8,\r
                TX3G,\r
-               SSA\r
+               SSA,\r
+               PGS\r
        }\r
 }\r
index 4a668d36789d744d871ad6e23c4788ad3fbe10f6..06b1acdefa17c3ea717d3f2d85ed365f1f5da365 100644 (file)
@@ -9,12 +9,12 @@
 \r
 namespace HandBrake.Interop.SourceData\r
 {\r
-    using System;\r
-    using System.Collections.Generic;\r
+       using System;\r
+       using System.Collections.Generic;\r
 \r
-    using HandBrake.Interop.Model;\r
+       using HandBrake.Interop.Model;\r
 \r
-    /// <summary>\r
+       /// <summary>\r
        /// An object that represents a single Title of a DVD\r
        /// </summary>\r
        public class Title\r
@@ -107,6 +107,16 @@ namespace HandBrake.Interop.SourceData
                /// </summary>\r
                public double Framerate { get; set; }\r
 \r
+               /// <summary>\r
+               /// Gets or sets the video frame rate numerator.\r
+               /// </summary>\r
+               public int FramerateNumerator { get; set; }\r
+\r
+               /// <summary>\r
+               /// Gets or sets the video frame rate denominator.\r
+               /// </summary>\r
+               public int FramerateDenominator { get; set; }\r
+\r
                /// <summary>\r
                /// Gets the total number of frames in this title.\r
                /// </summary>\r