diff options
author | randomengy <[email protected]> | 2012-11-12 04:35:55 +0000 |
---|---|---|
committer | randomengy <[email protected]> | 2012-11-12 04:35:55 +0000 |
commit | cf1f034f914348d0f0bfcd5f8902f0a3fb519273 (patch) | |
tree | e2ed9ad176ca3c877252c0038c930a1a83ab07af /win | |
parent | 271400970da9fa01bec9132e7357fb0d013b33b5 (diff) |
Interop: Exposing raw FPS numerator/denominator on Title. Exposing IsH264LevelValid function. Adding additional subtitle types. Fixing Anamorphic size calculation. Adding H.264 level to encode options.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5057 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
6 files changed, 98 insertions, 18 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index c62f96fb6..6249c7f86 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -461,6 +461,12 @@ namespace HandBrake.Interop this.encodeAllocatedMemory.Add(nativeJob.x264_tune);
}
+ if (!string.IsNullOrEmpty(job.EncodingProfile.H264Level))
+ {
+ nativeJob.h264_level = Marshal.StringToHGlobalAnsi(job.EncodingProfile.H264Level);
+ this.encodeAllocatedMemory.Add(nativeJob.h264_level);
+ }
+
if (this.subtitleScan)
{
// If we need to scan subtitles, enqueue a pre-processing job to do that.
@@ -592,8 +598,6 @@ namespace HandBrake.Interop int refHeight = 0;
int refParWidth = 0;
int refParHeight = 0;
- HBFunctions.hb_set_job(this.hbHandle, job.Title, ref nativeJob);
- //HBFunctions.hb_set_anamorphic_size_by_index(this.hbHandle, job.Title, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);
HBFunctions.hb_set_anamorphic_size(ref nativeJob, ref refWidth, ref refHeight, ref refParWidth, ref refParHeight);
InteropUtilities.FreeMemory(allocatedMemory);
@@ -1159,6 +1163,11 @@ namespace HandBrake.Interop height = profile.MaxHeight;
}
+ // The job width can sometimes start not clean, due to interference from
+ // preview generation. We reset it here to allow good calculations.
+ nativeJob.width = width;
+ nativeJob.height = height;
+
nativeJob.grayscale = profile.Grayscale ? 1 : 0;
switch (profile.Anamorphic)
@@ -1171,12 +1180,26 @@ namespace HandBrake.Interop height = outputSize.Height;
nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;
+
+ nativeJob.width = width;
+ nativeJob.height = height;
+
+ nativeJob.maxWidth = profile.MaxWidth;
+ nativeJob.maxHeight = profile.MaxHeight;
+
break;
case Anamorphic.Strict:
nativeJob.anamorphic.mode = 1;
break;
case Anamorphic.Loose:
nativeJob.anamorphic.mode = 2;
+
+ nativeJob.modulus = profile.Modulus;
+
+ nativeJob.width = width;
+
+ nativeJob.maxWidth = profile.MaxWidth;
+
break;
case Anamorphic.Custom:
nativeJob.anamorphic.mode = 3;
@@ -1210,10 +1233,12 @@ namespace HandBrake.Interop nativeJob.anamorphic.dar_height = height;
nativeJob.anamorphic.keep_display_aspect = 1;
}
-
- nativeJob.anamorphic.dar_width = profile.DisplayWidth;
- nativeJob.anamorphic.dar_height = height;
- nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;
+ else
+ {
+ nativeJob.anamorphic.dar_width = profile.DisplayWidth;
+ nativeJob.anamorphic.dar_height = height;
+ nativeJob.anamorphic.keep_display_aspect = profile.KeepDisplayAspect ? 1 : 0;
+ }
}
else
{
@@ -1222,16 +1247,28 @@ namespace HandBrake.Interop nativeJob.anamorphic.keep_display_aspect = 0;
}
+ nativeJob.width = width;
+ nativeJob.height = height;
+
+ nativeJob.maxWidth = profile.MaxWidth;
+ nativeJob.maxHeight = profile.MaxHeight;
+
break;
default:
break;
}
- nativeJob.width = width;
- nativeJob.height = height;
+ // Need to fix up values before adding crop/scale filter
+ if (profile.Anamorphic != Anamorphic.None)
+ {
+ int anamorphicWidth = 0, anamorphicHeight = 0, anamorphicParWidth = 0, anamorphicParHeight = 0;
- nativeJob.maxWidth = profile.MaxWidth;
- nativeJob.maxHeight = profile.MaxHeight;
+ HBFunctions.hb_set_anamorphic_size(ref nativeJob, ref anamorphicWidth, ref anamorphicHeight, ref anamorphicParWidth, ref anamorphicParHeight);
+ nativeJob.width = anamorphicWidth;
+ nativeJob.height = anamorphicHeight;
+ nativeJob.anamorphic.par_width = anamorphicParWidth;
+ nativeJob.anamorphic.par_height = anamorphicParHeight;
+ }
string cropScaleSettings = string.Format(
CultureInfo.InvariantCulture,
@@ -1617,7 +1654,9 @@ namespace HandBrake.Interop AspectRatio = title.aspect,
AngleCount = title.angle_count,
VideoCodecName = title.video_codec_name,
- Framerate = ((double)title.rate) / title.rate_base
+ Framerate = ((double)title.rate) / title.rate_base,
+ FramerateNumerator = title.rate,
+ FramerateDenominator = title.rate_base
};
switch (title.type)
@@ -1676,6 +1715,9 @@ namespace HandBrake.Interop case hb_subtitle_s_subsource.VOBSUB:
newSubtitle.SubtitleSource = SubtitleSource.VobSub;
break;
+ case hb_subtitle_s_subsource.PGSSUB:
+ newSubtitle.SubtitleSource = SubtitleSource.PGS;
+ break;
default:
break;
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 9bfceb278..496136421 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -143,6 +143,29 @@ namespace HandBrake.Interop }
/// <summary>
+ /// Checks to see if the given H.264 level is valid given the inputs.
+ /// </summary>
+ /// <param name="level">The level to check.</param>
+ /// <param name="width">The output picture width.</param>
+ /// <param name="height">The output picture height.</param>
+ /// <param name="fpsNumerator">The rate numerator.</param>
+ /// <param name="fpsDenominator">The rate denominator.</param>
+ /// <param name="interlaced">True if x264 interlaced output is enabled.</param>
+ /// <param name="fakeInterlaced">True if x264 fake interlacing is enabled.</param>
+ /// <returns>True if the level is valid.</returns>
+ public static bool IsH264LevelValid(string level, int width, int height, int fpsNumerator, int fpsDenominator, bool interlaced, bool fakeInterlaced)
+ {
+ return HBFunctions.hb_check_h264_level(
+ level,
+ width,
+ height,
+ fpsNumerator,
+ fpsDenominator,
+ interlaced ? 1 : 0,
+ fakeInterlaced ? 1 : 0) == 0;
+ }
+
+ /// <summary>
/// Gets the total number of seconds on the given encode job.
/// </summary>
/// <param name="job">The encode job to query.</param>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs index 952d9509a..f5326e89b 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs @@ -58,6 +58,7 @@ namespace HandBrake.Interop.Model.Encoding public string X264Profile { get; set; }
public string X264Preset { get; set; }
public string X264Tune { get; set; }
+ public string H264Level { get; set; }
public VideoEncodeRateType VideoEncodeRateType { get; set; }
public double Quality { get; set; }
public int TargetSize { get; set; }
@@ -114,6 +115,7 @@ namespace HandBrake.Interop.Model.Encoding X264Profile = this.X264Profile,
X264Preset = this.X264Preset,
X264Tune = this.X264Tune,
+ H264Level = this.H264Level,
VideoEncodeRateType = this.VideoEncodeRateType,
Quality = this.Quality,
TargetSize = this.TargetSize,
@@ -122,7 +124,9 @@ namespace HandBrake.Interop.Model.Encoding TurboFirstPass = this.TurboFirstPass,
Framerate = this.Framerate,
ConstantFramerate = this.ConstantFramerate,
+#pragma warning disable 612,618
PeakFramerate = this.PeakFramerate,
+#pragma warning restore 612,618
AudioEncodings = new List<AudioEncoding>(this.AudioEncodings)
};
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs index fa9e9e063..076afdeb3 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.27.0.0")]
-[assembly: AssemblyFileVersion("1.27.0.0")]
+[assembly: AssemblyVersion("1.31.0.0")]
+[assembly: AssemblyFileVersion("1.31.0.0")]
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/SubtitleSource.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/SubtitleSource.cs index 9b04e1652..f0a0b0a38 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/SubtitleSource.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/SubtitleSource.cs @@ -17,6 +17,7 @@ namespace HandBrake.Interop.SourceData CC708,
UTF8,
TX3G,
- SSA
+ SSA,
+ PGS
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs index 4a668d367..06b1acdef 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs @@ -9,12 +9,12 @@ namespace HandBrake.Interop.SourceData
{
- using System;
- using System.Collections.Generic;
+ using System;
+ using System.Collections.Generic;
- using HandBrake.Interop.Model;
+ using HandBrake.Interop.Model;
- /// <summary>
+ /// <summary>
/// An object that represents a single Title of a DVD
/// </summary>
public class Title
@@ -108,6 +108,16 @@ namespace HandBrake.Interop.SourceData public double Framerate { get; set; }
/// <summary>
+ /// Gets or sets the video frame rate numerator.
+ /// </summary>
+ public int FramerateNumerator { get; set; }
+
+ /// <summary>
+ /// Gets or sets the video frame rate denominator.
+ /// </summary>
+ public int FramerateDenominator { get; set; }
+
+ /// <summary>
/// Gets the total number of frames in this title.
/// </summary>
public int Frames
|