summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2014-12-26 22:26:22 +0000
committersr55 <[email protected]>2014-12-26 22:26:22 +0000
commit8df584534c0c39f5c2f298d8ba480cc906743bbf (patch)
tree15166de042ee466516163fdc7302ea900eeb5eb8 /win
parented414885c5411dc7f298700d0c5061385024c503 (diff)
WinGui: Initial implementation of the new JSON API for encoding. Not exposed to end users yet.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6654 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/EventArgs/EncodeProgressEventArgs.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs1317
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj29
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs5
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs43
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs149
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_chapter_s.cs58
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_error_code.cs7
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_object_s.cs36
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs79
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs16
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_set_s.cs22
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs21
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs109
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs81
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/ScanFactory.cs36
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs2
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs5
22 files changed, 227 insertions, 1806 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
index 1b93434da..87d777525 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
@@ -22,19 +22,19 @@ namespace HandBrake.ApplicationServices.Services.Encode.EventArgs
/// Gets or sets PercentComplete.
/// </summary>
[DataMember]
- public float PercentComplete { get; set; }
+ public double PercentComplete { get; set; }
/// <summary>
/// Gets or sets CurrentFrameRate.
/// </summary>
[DataMember]
- public float CurrentFrameRate { get; set; }
+ public double CurrentFrameRate { get; set; }
/// <summary>
/// Gets or sets AverageFrameRate.
/// </summary>
[DataMember]
- public float AverageFrameRate { get; set; }
+ public double AverageFrameRate { get; set; }
/// <summary>
/// Gets or sets EstimatedTimeLeft.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/EventArgs/EncodeProgressEventArgs.cs
index 9e2883e3b..9118ddd7a 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/EventArgs/EncodeProgressEventArgs.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/EventArgs/EncodeProgressEventArgs.cs
@@ -19,17 +19,17 @@ namespace HandBrake.Interop.EventArgs
/// <summary>
/// Gets or sets FractionComplete.
/// </summary>
- public float FractionComplete { get; set; }
+ public double FractionComplete { get; set; }
/// <summary>
/// Gets or sets CurrentFrameRate.
/// </summary>
- public float CurrentFrameRate { get; set; }
+ public double CurrentFrameRate { get; set; }
/// <summary>
/// Gets or sets AverageFrameRate.
/// </summary>
- public float AverageFrameRate { get; set; }
+ public double AverageFrameRate { get; set; }
/// <summary>
/// Gets or sets EstimatedTimeLeft.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
index b67c26a4e..9febb93c0 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs
@@ -26,6 +26,7 @@ namespace HandBrake.Interop
using HandBrake.Interop.HbLib;
using HandBrake.Interop.Helpers;
using HandBrake.Interop.Interfaces;
+ using HandBrake.Interop.Json.Encode;
using HandBrake.Interop.Json.Factories;
using HandBrake.Interop.Json.Scan;
using HandBrake.Interop.Json.State;
@@ -43,11 +44,6 @@ namespace HandBrake.Interop
public class HandBrakeInstance : IHandBrakeInstance, IDisposable
{
/// <summary>
- /// The modulus for picture size when auto-sizing dimensions.
- /// </summary>
- private const int PictureAutoSizeModulus = 2;
-
- /// <summary>
/// The number of MS between status polls when scanning.
/// </summary>
private const double ScanPollIntervalMs = 200;
@@ -58,11 +54,6 @@ namespace HandBrake.Interop
private const double EncodePollIntervalMs = 200;
/// <summary>
- /// X264 options to add for a turbo first pass.
- /// </summary>
- private const string TurboX264Opts = "ref=1:subme=2:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
-
- /// <summary>
/// The native handle to the HandBrake instance.
/// </summary>
private IntPtr hbHandle;
@@ -83,36 +74,16 @@ namespace HandBrake.Interop
private Timer encodePollTimer;
/// <summary>
- /// The list of original titles in native structure form.
- /// </summary>
- private List<hb_title_s> originalTitles;
-
- /// <summary>
/// The list of titles on this instance.
/// </summary>
private List<Title> titles;
/// <summary>
- /// The current encode job for this instance.
- /// </summary>
- private EncodeJob currentJob;
-
- /// <summary>
- /// True if the current job is scanning for subtitles.
- /// </summary>
- private bool subtitleScan;
-
- /// <summary>
/// The index of the default title.
/// </summary>
private int featureTitle;
/// <summary>
- /// A list of native memory locations allocated by this instance.
- /// </summary>
- private List<IntPtr> encodeAllocatedMemory;
-
- /// <summary>
/// A value indicating whether this object has been disposed or not.
/// </summary>
private bool disposed;
@@ -295,39 +266,48 @@ namespace HandBrake.Interop
/// <returns>An image with the requested preview.</returns>
public BitmapImage GetPreview(EncodeJob job, int previewNumber)
{
- IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title));
- var nativeJob = InteropUtilities.ToStructureFromPtr<hb_job_s>(nativeJobPtr);
- List<IntPtr> allocatedMemory = this.ApplyJob(ref nativeJob, job);
+ Title title = this.Titles.FirstOrDefault(t => t.TitleNumber == job.Title);
+ Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug.");
+
+ hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s
+ {
+ crop = new[] { job.EncodingProfile.Cropping.Top, job.EncodingProfile.Cropping.Bottom, job.EncodingProfile.Cropping.Left, job.EncodingProfile.Cropping.Right },
+ itu_par = 0,
+ keep = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (job.EncodingProfile.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?
+ maxWidth = job.EncodingProfile.MaxWidth,
+ maxHeight = job.EncodingProfile.MaxHeight,
+ mode = (int)(hb_anamorphic_mode_t)job.EncodingProfile.Anamorphic,
+ modulus = job.EncodingProfile.Modulus,
+ geometry = new hb_geometry_s { height = job.EncodingProfile.Height, width = job.EncodingProfile.Width,
+ par = job.EncodingProfile.Anamorphic != Anamorphic.Custom
+ ? new hb_rational_t { den = title.ParVal.Height, num = title.ParVal.Width }
+ : new hb_rational_t { den = job.EncodingProfile.PixelAspectY, num = job.EncodingProfile.PixelAspectX } }
+ };
+
+ // Sanatise the input.
+ Json.Anamorphic.Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, title, AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right.
- // There are some problems with getting previews with deinterlacing. Disabling for now.
- nativeJob.deinterlace = 0;
+ int outputWidth = resultGeometry.Width;
+ int outputHeight = resultGeometry.Height;
+ int imageBufferSize = outputWidth * outputHeight * 4;
+ IntPtr nativeBuffer = Marshal.AllocHGlobal(imageBufferSize);
- int outputWidth = nativeJob.width;
- int outputHeight = nativeJob.height;
- int imageBufferSize = outputWidth * outputHeight * 4;
- IntPtr nativeBuffer = Marshal.AllocHGlobal(imageBufferSize);
- allocatedMemory.Add(nativeBuffer);
- HBFunctions.hb_get_preview(this.hbHandle, ref nativeJob, previewNumber, nativeBuffer);
- // We've used the job to get the preview. Clean up the job.
- InteropUtilities.CloseJob(nativeJobPtr);
+ HBFunctions.hb_get_preview2(this.hbHandle, job.Title, previewNumber, ref uiGeometry, 0);
// Copy the filled image buffer to a managed array.
byte[] managedBuffer = new byte[imageBufferSize];
Marshal.Copy(nativeBuffer, managedBuffer, 0, imageBufferSize);
- // We've copied the data out of unmanaged memory. Clean up that memory now.
- InteropUtilities.FreeMemory(allocatedMemory);
-
var bitmap = new Bitmap(outputWidth, outputHeight);
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, outputWidth, outputHeight), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);
IntPtr ptr = bitmapData.Scan0;
- for (int i = 0; i < nativeJob.height; i++)
+ for (int i = 0; i < job.EncodingProfile.Height; i++)
{
- Marshal.Copy(managedBuffer, i * nativeJob.width * 4, ptr, nativeJob.width * 4);
+ Marshal.Copy(managedBuffer, i * job.EncodingProfile.Width * 4, ptr, job.EncodingProfile.Width * 4);
ptr = IntPtr.Add(ptr, bitmapData.Stride);
}
@@ -458,138 +438,28 @@ namespace HandBrake.Interop
/// <summary>
/// Starts an encode with the given job.
/// </summary>
- /// <param name="job">
- /// The job to start.
- /// </param>
- /// <param name="preview">
- /// True if this is a preview encode.
- /// </param>
- /// <param name="previewNumber">
- /// The preview number to start the encode at (0-based).
- /// </param>
- /// <param name="previewSeconds">
- /// The number of seconds in the preview.
- /// </param>
- /// <param name="overallSelectedLengthSeconds">
- /// The currently selected encode length. Used in preview
- /// for calculating bitrate when the target size would be wrong.
- /// </param>
- /// <param name="scanPreviewCount">
- /// The scan Preview Count.
- /// </param>
+ /// <param name="job">The job to start.</param>
+ /// <param name="preview">The scan Preview Count.</param>
+ /// <param name="previewNumber">Preview Feature: Preview to encode</param>
+ /// <param name="previewSeconds">Number of seconds to encode for the preview</param>
+ /// <param name="overallSelectedLengthSeconds"></param>
+ /// <param name="scanPreviewCount">Number of previews</param>
public void StartEncode(EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds, int scanPreviewCount)
{
- EncodingProfile profile = job.EncodingProfile;
- if (job.ChosenAudioTracks == null)
- {
- throw new ArgumentException("job.ChosenAudioTracks cannot be null.");
- }
-
this.previewCount = scanPreviewCount;
- this.currentJob = job;
-
- IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title));
- var nativeJob = InteropUtilities.ToStructureFromPtr<hb_job_s>(nativeJobPtr);
-
- this.encodeAllocatedMemory = this.ApplyJob(ref nativeJob, job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds);
-
- this.subtitleScan = false;
- if (job.Subtitles != null && job.Subtitles.SourceSubtitles != null)
- {
- foreach (SourceSubtitle subtitle in job.Subtitles.SourceSubtitles)
- {
- if (subtitle.TrackNumber == 0)
- {
- this.subtitleScan = true;
- break;
- }
- }
- }
-
- string videoOptions = profile.VideoOptions ?? string.Empty;
- IntPtr originalVideoOptions = Marshal.StringToHGlobalAnsi(videoOptions);
- this.encodeAllocatedMemory.Add(originalVideoOptions);
-
- if (!string.IsNullOrEmpty(profile.VideoProfile))
- {
- nativeJob.encoder_profile = Marshal.StringToHGlobalAnsi(profile.VideoProfile);
- this.encodeAllocatedMemory.Add(nativeJob.encoder_profile);
- }
-
- if (!string.IsNullOrEmpty(profile.VideoPreset))
- {
- nativeJob.encoder_preset = Marshal.StringToHGlobalAnsi(profile.VideoPreset);
- this.encodeAllocatedMemory.Add(nativeJob.encoder_preset);
- }
-
- if (profile.VideoTunes != null && profile.VideoTunes.Count > 0)
- {
- nativeJob.encoder_tune = Marshal.StringToHGlobalAnsi(string.Join(",", profile.VideoTunes));
- this.encodeAllocatedMemory.Add(nativeJob.encoder_tune);
- }
-
- if (!string.IsNullOrEmpty(job.EncodingProfile.VideoLevel))
- {
- nativeJob.encoder_level = Marshal.StringToHGlobalAnsi(job.EncodingProfile.VideoLevel);
- this.encodeAllocatedMemory.Add(nativeJob.encoder_level);
- }
- if (this.subtitleScan)
- {
- // If we need to scan subtitles, enqueue a pre-processing job to do that.
- nativeJob.pass = -1;
- nativeJob.indepth_scan = 1;
-
- nativeJob.encoder_options = IntPtr.Zero;
-
- HBFunctions.hb_add(this.hbHandle, ref nativeJob);
- }
+ JsonEncodeObject encodeObject = EncodeFactory.Create(job, lastScan);
- nativeJob.indepth_scan = 0;
-
- if (job.EncodingProfile.VideoEncodeRateType != VideoEncodeRateType.ConstantQuality && job.EncodingProfile.TwoPass)
+ JsonSerializerSettings settings = new JsonSerializerSettings
{
- // First pass. Apply turbo options if needed.
- nativeJob.pass = 1;
- string firstPassAdvancedOptions = videoOptions;
- if (job.EncodingProfile.TurboFirstPass)
- {
- if (firstPassAdvancedOptions == string.Empty)
- {
- firstPassAdvancedOptions = TurboX264Opts;
- }
- else
- {
- firstPassAdvancedOptions += ":" + TurboX264Opts;
- }
- }
-
- nativeJob.encoder_options = Marshal.StringToHGlobalAnsi(firstPassAdvancedOptions);
- this.encodeAllocatedMemory.Add(nativeJob.encoder_options);
-
- HBFunctions.hb_add(this.hbHandle, ref nativeJob);
-
- // Second pass. Apply normal options.
- nativeJob.pass = 2;
- nativeJob.encoder_options = originalVideoOptions;
-
- HBFunctions.hb_add(this.hbHandle, ref nativeJob);
- }
- else
- {
- // One pass job.
- nativeJob.pass = 0;
- nativeJob.encoder_options = originalVideoOptions;
-
- HBFunctions.hb_add(this.hbHandle, ref nativeJob);
- }
+ NullValueHandling = NullValueHandling.Ignore
+ };
+ string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings);
+ HBFunctions.hb_add_json(this.hbHandle, Marshal.StringToHGlobalAnsi(encode));
HBFunctions.hb_start(this.hbHandle);
- // Should be safe to clean up the job we started with; a copy is in the queue now.
- InteropUtilities.CloseJob(nativeJobPtr);
-
- this.encodePollTimer = new Timer();
+ this.encodePollTimer = new System.Timers.Timer();
this.encodePollTimer.Interval = EncodePollIntervalMs;
this.encodePollTimer.Elapsed += (o, e) =>
@@ -638,49 +508,6 @@ namespace HandBrake.Interop
}
/// <summary>
- /// Gets the final size for a given encode job.
- /// </summary>
- /// <param name="job">The encode job to use.</param>
- /// <param name="width">The storage width.</param>
- /// <param name="height">The storage height.</param>
- /// <param name="parWidth">The pixel aspect X number.</param>
- /// <param name="parHeight">The pixel aspect Y number.</param>
- public void GetSize(EncodeJob job, out int width, out int height, out int parWidth, out int parHeight)
- {
- Title title = this.GetTitle(job.Title);
-
- if (job.EncodingProfile.Anamorphic == Anamorphic.None)
- {
- Size storageDimensions = CalculateNonAnamorphicOutput(job.EncodingProfile, title);
-
- width = storageDimensions.Width;
- height = storageDimensions.Height;
-
- parWidth = 1;
- parHeight = 1;
-
- return;
- }
-
- IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(title));
- var nativeJob = InteropUtilities.ToStructureFromPtr<hb_job_s>(nativeJobPtr);
-
- List<IntPtr> allocatedMemory = this.ApplyJob(ref nativeJob, job);
- InteropUtilities.FreeMemory(allocatedMemory);
-
- InteropUtilities.CloseJob(nativeJobPtr);
-
- // During the ApplyJob call, it modified nativeJob to have the correct width, height and PAR.
- // We use those for the size.
- width = nativeJob.width;
- height = nativeJob.height;
- parWidth = nativeJob.anamorphic.par_width;
- parHeight = nativeJob.anamorphic.par_height;
- }
-
-
-
- /// <summary>
/// Frees any resources associated with this object.
/// </summary>
public void Dispose()
@@ -715,104 +542,6 @@ namespace HandBrake.Interop
}
/// <summary>
- /// Calculates the output size for a non-anamorphic job.
- /// </summary>
- /// <param name="profile">The encoding profile for the job.</param>
- /// <param name="title">The title being encoded.</param>
- /// <returns>The dimensions of the final encode.</returns>
- private static Size CalculateNonAnamorphicOutput(EncodingProfile profile, Title title)
- {
- int sourceWidth = title.Resolution.Width;
- int sourceHeight = title.Resolution.Height;
-
- int width = profile.Width;
- int height = profile.Height;
-
- Cropping crop;
- switch (profile.CroppingType)
- {
- case CroppingType.Automatic:
- crop = title.AutoCropDimensions;
- break;
- case CroppingType.Custom:
- crop = profile.Cropping;
- break;
- default:
- crop = new Cropping();
- break;
- }
-
- sourceWidth -= crop.Left;
- sourceWidth -= crop.Right;
-
- sourceHeight -= crop.Top;
- sourceHeight -= crop.Bottom;
-
- double croppedAspectRatio = ((double)sourceWidth * title.ParVal.Width) / (sourceHeight * title.ParVal.Height);
-
- if (width == 0)
- {
- width = sourceWidth;
- }
-
- if (profile.MaxWidth > 0 && width > profile.MaxWidth)
- {
- width = profile.MaxWidth;
- }
-
- if (height == 0)
- {
- height = sourceHeight;
- }
-
- if (profile.MaxHeight > 0 && height > profile.MaxHeight)
- {
- height = profile.MaxHeight;
- }
-
- if (profile.KeepDisplayAspect)
- {
- if ((profile.Width == 0 && profile.Height == 0) || profile.Width == 0)
- {
- width = (int)((double)height * croppedAspectRatio);
- if (profile.MaxWidth > 0 && width > profile.MaxWidth)
- {
- width = profile.MaxWidth;
- height = (int)((double)width / croppedAspectRatio);
- height = GetNearestValue(height, PictureAutoSizeModulus);
- }
-
- width = GetNearestValue(width, PictureAutoSizeModulus);
- }
- else if (profile.Height == 0)
- {
- height = (int)((double)width / croppedAspectRatio);
- if (profile.MaxHeight > 0 && height > profile.MaxHeight)
- {
- height = profile.MaxHeight;
- width = (int)((double)height * croppedAspectRatio);
- width = GetNearestValue(width, PictureAutoSizeModulus);
- }
-
- height = GetNearestValue(height, PictureAutoSizeModulus);
- }
- }
-
- return new Size(width, height);
- }
-
- /// <summary>
- /// Gets the closest value to the given number divisible by the given modulus.
- /// </summary>
- /// <param name="number">The number to approximate.</param>
- /// <param name="modulus">The modulus.</param>
- /// <returns>The closest value to the given number divisible by the given modulus.</returns>
- private static int GetNearestValue(int number, int modulus)
- {
- return modulus * ((number + modulus / 2) / modulus);
- }
-
- /// <summary>
/// Checks the status of the ongoing scan.
/// </summary>
private void PollScanProgress()
@@ -839,7 +568,6 @@ namespace HandBrake.Interop
{
this.titles = new List<Title>();
- IntPtr titleSetPtr = HBFunctions.hb_get_title_set(this.hbHandle);
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);
string scanJson = Marshal.PtrToStringAnsi(jsonMsg);
JsonScanObject scanObject = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
@@ -858,9 +586,6 @@ namespace HandBrake.Interop
this.titles.Add(title);
}
- hb_title_set_s titleSet = InteropUtilities.ToStructureFromPtr<hb_title_set_s>(titleSetPtr);
- this.originalTitles = titleSet.list_title.ToListFromHandBrakeList<hb_title_s>();
-
this.scanPollTimer.Stop();
if (this.ScanCompleted != null)
@@ -873,742 +598,43 @@ namespace HandBrake.Interop
/// <summary>
/// Checks the status of the ongoing encode.
/// </summary>
+ /// <summary>
+ /// Checks the status of the ongoing encode.
+ /// </summary>
private void PollEncodeProgress()
{
- hb_state_s state = new hb_state_s();
- HBFunctions.hb_get_state(this.hbHandle, ref state);
+ IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);
+ string statusJson = Marshal.PtrToStringAnsi(json);
+ JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
- if (state.state == NativeConstants.HB_STATE_WORKING)
+ if (state.State == NativeConstants.HB_STATE_WORKING)
{
if (this.EncodeProgress != null)
{
- int pass = 1;
- int rawJobNumber = state.param.working.job_cur;
-
- if (this.currentJob.EncodingProfile.VideoEncodeRateType != VideoEncodeRateType.ConstantQuality && this.currentJob.EncodingProfile.TwoPass)
- {
- if (this.subtitleScan)
- {
- switch (rawJobNumber)
- {
- case 1:
- pass = -1;
- break;
- case 2:
- pass = 1;
- break;
- case 3:
- pass = 2;
- break;
- default:
- break;
- }
- }
- else
- {
- switch (rawJobNumber)
- {
- case 1:
- pass = 1;
- break;
- case 2:
- pass = 2;
- break;
- default:
- break;
- }
- }
- }
- else
- {
- if (this.subtitleScan)
- {
- switch (rawJobNumber)
- {
- case 1:
- pass = -1;
- break;
- case 2:
- pass = 1;
- break;
- default:
- break;
- }
- }
- else
- {
- pass = 1;
- }
- }
-
var progressEventArgs = new EncodeProgressEventArgs
{
- FractionComplete = state.param.working.progress,
- CurrentFrameRate = state.param.working.rate_cur,
- AverageFrameRate = state.param.working.rate_avg,
- EstimatedTimeLeft = new TimeSpan(state.param.working.hours, state.param.working.minutes, state.param.working.seconds),
- Pass = pass
+ FractionComplete = state.Working.Progress,
+ CurrentFrameRate = state.Working.Rate,
+ AverageFrameRate = state.Working.RateAvg,
+ EstimatedTimeLeft = new TimeSpan(state.Working.Hours, state.Working.Minutes, state.Working.Seconds),
+ Pass = 1, // TODO
};
this.EncodeProgress(this, progressEventArgs);
}
}
- else if (state.state == NativeConstants.HB_STATE_WORKDONE)
+ else if (state.State == NativeConstants.HB_STATE_WORKDONE)
{
- InteropUtilities.FreeMemory(this.encodeAllocatedMemory);
this.encodePollTimer.Stop();
- if (this.EncodeCompleted != null)
- {
- this.EncodeCompleted(this, new EncodeCompletedEventArgs { Error = state.param.workdone.error != hb_error_code.HB_ERROR_NONE });
- }
- }
- }
-
- /// <summary>
- /// Applies the encoding job to the native memory structure and returns a list of memory
- /// locations allocated during this.
- /// </summary>
- /// <param name="nativeJob">The native structure to apply to job info to.</param>
- /// <param name="job">The job info to apply.</param>
- /// <returns>The list of memory locations allocated for the job.</returns>
- private List<IntPtr> ApplyJob(ref hb_job_s nativeJob, EncodeJob job)
- {
- return this.ApplyJob(ref nativeJob, job, false, 0, 0, 0);
- }
-
- /// <summary>
- /// Applies the encoding job to the native memory structure and returns a list of memory
- /// locations allocated during this.
- /// </summary>
- /// <param name="nativeJob">The native structure to apply to job info to.</param>
- /// <param name="job">The job info to apply.</param>
- /// <param name="preview">True if this is a preview encode.</param>
- /// <param name="previewNumber">The preview number (0-based) to encode.</param>
- /// <param name="previewSeconds">The number of seconds in the preview.</param>
- /// <param name="overallSelectedLengthSeconds">The currently selected encode length. Used in preview
- /// for calculating bitrate when the target size would be wrong.</param>
- /// <returns>The list of memory locations allocated for the job.</returns>
- private List<IntPtr> ApplyJob(ref hb_job_s nativeJob, EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds)
- {
- var allocatedMemory = new List<IntPtr>();
- Title title = this.GetTitle(job.Title);
- hb_title_s originalTitle = this.GetOriginalTitle(job.Title);
-
- EncodingProfile profile = job.EncodingProfile;
-
- if (preview)
- {
- nativeJob.start_at_preview = previewNumber + 1;
- nativeJob.seek_points = this.previewCount;
-
- // There are 90,000 PTS per second.
- nativeJob.pts_to_stop = previewSeconds * 90000;
- }
- else
- {
- switch (job.RangeType)
+ if (this.EncodeCompleted != null)
{
- case VideoRangeType.All:
- break;
- case VideoRangeType.Chapters:
- if (job.ChapterStart > 0 && job.ChapterEnd > 0)
- {
- nativeJob.chapter_start = job.ChapterStart;
- nativeJob.chapter_end = job.ChapterEnd;
- }
- else
- {
- nativeJob.chapter_start = 1;
- nativeJob.chapter_end = title.Chapters.Count;
- }
-
- break;
- case VideoRangeType.Seconds:
- if (job.SecondsStart < 0 || job.SecondsEnd < 0 || job.SecondsStart >= job.SecondsEnd)
- {
- throw new ArgumentException("Seconds range " + job.SecondsStart + "-" + job.SecondsEnd + " is invalid.", "job");
- }
-
- // If they've selected the "full" title duration, leave off the arguments to make it clean
- if (job.SecondsStart > 0 || job.SecondsEnd < title.Duration.TotalSeconds)
- {
- // For some reason "pts_to_stop" actually means the number of pts to stop AFTER the start point.
- nativeJob.pts_to_start = (int)(job.SecondsStart * 90000);
- nativeJob.pts_to_stop = (int)((job.SecondsEnd - job.SecondsStart) * 90000);
- }
- break;
- case VideoRangeType.Frames:
- if (job.FramesStart < 0 || job.FramesEnd < 0 || job.FramesStart >= job.FramesEnd)
- {
- throw new ArgumentException("Frames range " + job.FramesStart + "-" + job.FramesEnd + " is invalid.", "job");
- }
-
- // "frame_to_stop" actually means the number of frames total to encode AFTER the start point.
- nativeJob.frame_to_start = job.FramesStart;
- nativeJob.frame_to_stop = job.FramesEnd - job.FramesStart;
- break;
- }
- }
-
- // Chapter markers
- nativeJob.chapter_markers = profile.IncludeChapterMarkers ? 1 : 0;
-
- List<IntPtr> nativeChapters = nativeJob.list_chapter.ToIntPtrList();
-
- if (!preview && profile.IncludeChapterMarkers)
- {
- int numChapters = title.Chapters.Count;
-
- if (job.UseDefaultChapterNames)
- {
- for (int i = 0; i < numChapters; i++)
- {
- if (i < nativeChapters.Count)
- {
- HBFunctions.hb_chapter_set_title(nativeChapters[i], "Chapter " + (i + 1));
- }
- }
- }
- else
- {
- for (int i = 0; i < numChapters; i++)
+ this.EncodeCompleted(this, new EncodeCompletedEventArgs
{
- if (i < nativeChapters.Count && i < job.CustomChapterNames.Count)
- {
- IntPtr chapterNamePtr;
-
- if (string.IsNullOrWhiteSpace(job.CustomChapterNames[i]))
- {
- chapterNamePtr = InteropUtilities.ToUtf8PtrFromString("Chapter " + (i + 1));
- }
- else
- {
- chapterNamePtr = InteropUtilities.ToUtf8PtrFromString(job.CustomChapterNames[i]);
- }
-
- HBFunctions.hb_chapter_set_title__ptr(nativeChapters[i], chapterNamePtr);
- Marshal.FreeHGlobal(chapterNamePtr);
- }
- }
- }
- }
-
- Cropping crop = GetCropping(profile, title);
-
- nativeJob.crop[0] = crop.Top;
- nativeJob.crop[1] = crop.Bottom;
- nativeJob.crop[2] = crop.Left;
- nativeJob.crop[3] = crop.Right;
-
- var filterList = new List<hb_filter_object_s>();
-
- // FILTERS: These must be added in the correct order since we cannot depend on the automatic ordering in hb_add_filter . Ordering is determined
- // by the order they show up in the filters enum.
-
- // Detelecine
- if (profile.Detelecine != Detelecine.Off)
- {
- string settings = null;
- if (profile.Detelecine == Detelecine.Custom)
- {
- settings = profile.CustomDetelecine;
- }
-
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DETELECINE, settings, allocatedMemory);
- }
-
- // Decomb
- if (profile.Decomb != Decomb.Off)
- {
- string settings = null;
- switch (profile.Decomb)
- {
- case Decomb.Default:
- break;
- case Decomb.Fast:
- settings = "7:2:6:9:1:80";
- break;
- case Decomb.Bob:
- settings = "455";
- break;
- case Decomb.Custom:
- settings = profile.CustomDecomb;
- break;
- default:
- break;
- }
-
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DECOMB, settings, allocatedMemory);
- }
-
- // Deinterlace
- if (profile.Deinterlace != Deinterlace.Off)
- {
- nativeJob.deinterlace = 1;
- string settings = null;
-
- switch (profile.Deinterlace)
- {
- case Deinterlace.Fast:
- settings = "0";
- break;
- case Deinterlace.Slow:
- settings = "1";
- break;
- case Deinterlace.Slower:
- settings = "3";
- break;
- case Deinterlace.Bob:
- settings = "15";
- break;
- case Deinterlace.Custom:
- settings = profile.CustomDeinterlace;
- break;
- default:
- break;
- }
-
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DEINTERLACE, settings, allocatedMemory);
- }
- else
- {
- nativeJob.deinterlace = 0;
- }
-
- // VFR
- if (profile.Framerate == 0)
- {
- if (profile.ConstantFramerate)
- {
- // CFR with "Same as Source". Use the title rate
- nativeJob.cfr = 1;
- nativeJob.vrate = originalTitle.vrate.num;
- nativeJob.vrate_base = originalTitle.vrate.den;
- }
- else
- {
- // Pure VFR "Same as Source"
- nativeJob.cfr = 0;
- }
- }
- else
- {
- // Specified framerate
- if (profile.ConstantFramerate)
- {
- // Mark as pure CFR
- nativeJob.cfr = 1;
- }
- else
- {
- // Mark as peak framerate
- nativeJob.cfr = 2;
- }
-
- nativeJob.vrate = 27000000;
- nativeJob.vrate_base = Converters.Converters.FramerateToVrate(profile.Framerate);
- }
-
- string vfrSettings = string.Format(CultureInfo.InvariantCulture, "{0}:{1}:{2}", nativeJob.cfr, nativeJob.vrate, nativeJob.vrate_base);
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_VFR, vfrSettings, allocatedMemory);
-
- // Deblock
- if (profile.Deblock > 0)
- {
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_DEBLOCK, profile.Deblock.ToString(CultureInfo.InvariantCulture), allocatedMemory);
- }
-
- // Denoise
- if (profile.Denoise != Denoise.Off)
- {
- int filterType = profile.Denoise == Denoise.hqdn3d ? (int)hb_filter_ids.HB_FILTER_HQDN3D : (int)hb_filter_ids.HB_FILTER_NLMEANS;
-
- this.AddFilterFromPreset(filterList, filterType, profile.DenoisePreset, profile.DenoiseTune);
- }
-
- // Crop/scale
- int width = profile.Width;
- int height = profile.Height;
-
- int cropHorizontal = crop.Left + crop.Right;
- int cropVertical = crop.Top + crop.Bottom;
-
- if (width == 0)
- {
- width = title.Resolution.Width - cropHorizontal;
- }
-
- if (profile.MaxWidth > 0 && width > profile.MaxWidth)
- {
- width = profile.MaxWidth;
- }
-
- if (height == 0)
- {
- height = title.Resolution.Height - cropVertical;
- }
-
- if (profile.MaxHeight > 0 && height > profile.MaxHeight)
- {
- 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)
- {
- case Anamorphic.None:
- nativeJob.anamorphic.mode = 0;
-
- Size outputSize = CalculateNonAnamorphicOutput(profile, title);
- width = outputSize.Width;
- height = outputSize.Height;
-
- nativeJob.anamorphic.keep_display_aspect = 0;
- nativeJob.anamorphic.par_width = 1;
- nativeJob.anamorphic.par_height = 1;
-
- nativeJob.width = width;
- nativeJob.height = height;
-
- nativeJob.maxWidth = profile.MaxWidth;
- nativeJob.maxHeight = profile.MaxHeight;
-
- nativeJob.modulus = 2;
-
- break;
- case Anamorphic.Strict:
- nativeJob.anamorphic.mode = hb_anamorphic_mode_t.HB_ANAMORPHIC_STRICT;
-
- nativeJob.anamorphic.par_width = title.ParVal.Width;
- nativeJob.anamorphic.par_height = title.ParVal.Height;
- break;
- case Anamorphic.Loose:
- nativeJob.anamorphic.mode = hb_anamorphic_mode_t.HB_ANAMORPHIC_LOOSE;
-
- nativeJob.modulus = profile.Modulus;
-
- nativeJob.width = width;
-
- nativeJob.maxWidth = profile.MaxWidth;
-
- nativeJob.anamorphic.par_width = title.ParVal.Width;
- nativeJob.anamorphic.par_height = title.ParVal.Height;
- break;
- case Anamorphic.Custom:
- nativeJob.anamorphic.mode = hb_anamorphic_mode_t.HB_ANAMORPHIC_CUSTOM;
-
- nativeJob.modulus = profile.Modulus;
-
- if (profile.UseDisplayWidth)
- {
- if (profile.KeepDisplayAspect)
- {
- int cropWidth = title.Resolution.Width - cropHorizontal;
- int cropHeight = title.Resolution.Height - cropVertical;
-
- double displayAspect = ((double)(cropWidth * title.ParVal.Width)) / (cropHeight * title.ParVal.Height);
- int displayWidth = profile.DisplayWidth;
-
- if (profile.Height > 0)
- {
- displayWidth = (int)((double)profile.Height * displayAspect);
- }
- else if (displayWidth > 0)
- {
- height = (int)((double)displayWidth / displayAspect);
- }
- else
- {
- displayWidth = (int)((double)height * displayAspect);
- }
-
- nativeJob.anamorphic.dar_width = displayWidth;
- nativeJob.anamorphic.dar_height = height;
- nativeJob.anamorphic.keep_display_aspect = 1;
- }
- else
- {
- nativeJob.anamorphic.dar_width = profile.DisplayWidth;
- nativeJob.anamorphic.dar_height = height;
- nativeJob.anamorphic.keep_display_aspect = 0;
- }
- }
- else
- {
- nativeJob.anamorphic.par_width = profile.PixelAspectX;
- nativeJob.anamorphic.par_height = profile.PixelAspectY;
- nativeJob.anamorphic.keep_display_aspect = 0;
- }
-
- nativeJob.width = width;
- nativeJob.height = height;
-
- nativeJob.maxWidth = profile.MaxWidth;
- nativeJob.maxHeight = profile.MaxHeight;
-
- break;
- default:
- break;
- }
-
- // Need to fix up values before adding crop/scale filter
- if (profile.Anamorphic != Anamorphic.None)
- {
- int anamorphicWidth = 0, anamorphicHeight = 0, anamorphicParWidth = 0, anamorphicParHeight = 0;
-
- 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,
- "{0}:{1}:{2}:{3}:{4}:{5}",
- nativeJob.width,
- nativeJob.height,
- nativeJob.crop[0],
- nativeJob.crop[1],
- nativeJob.crop[2],
- nativeJob.crop[3]);
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_CROP_SCALE, cropScaleSettings, allocatedMemory);
-
-
-
-
-
- HBVideoEncoder videoEncoder = Encoders.VideoEncoders.FirstOrDefault(e => e.ShortName == profile.VideoEncoder);
- if (videoEncoder == null)
- {
- throw new ArgumentException("Video encoder " + profile.VideoEncoder + " not recognized.");
- }
-
- nativeJob.vcodec = videoEncoder.Id;
-
-
-
- // areBframes
- // color_matrix
- List<hb_audio_s> titleAudio = originalTitle.list_audio.ToListFromHandBrakeList<hb_audio_s>();
-
- var audioList = new List<hb_audio_s>();
- int numTracks = 0;
-
- List<Tuple<AudioEncoding, int>> outputTrackList = this.GetOutputTracks(job, title);
-
- if (!string.IsNullOrEmpty(profile.AudioEncoderFallback))
- {
- HBAudioEncoder audioEncoder = Encoders.GetAudioEncoder(profile.AudioEncoderFallback);
- if (audioEncoder == null)
- {
- throw new ArgumentException("Unrecognized fallback audio encoder: " + profile.AudioEncoderFallback);
- }
-
- nativeJob.acodec_fallback = Encoders.GetAudioEncoder(profile.AudioEncoderFallback).Id;
- }
-
- nativeJob.acodec_copy_mask = (int)NativeConstants.HB_ACODEC_ANY;
-
- foreach (Tuple<AudioEncoding, int> outputTrack in outputTrackList)
- {
- AudioEncoding encoding = outputTrack.Item1;
- int trackNumber = outputTrack.Item2;
-
- audioList.Add(this.ConvertAudioBack(encoding, titleAudio[trackNumber - 1], numTracks++, allocatedMemory));
- }
-
- NativeList nativeAudioList = InteropUtilities.ToHandBrakeListFromList<hb_audio_s>(audioList);
- nativeJob.list_audio = nativeAudioList.Ptr;
- allocatedMemory.AddRange(nativeAudioList.AllocatedMemory);
-
- if (job.Subtitles != null)
- {
- if (job.Subtitles.SourceSubtitles != null && job.Subtitles.SourceSubtitles.Count > 0)
- {
- List<hb_subtitle_s> titleSubtitles = originalTitle.list_subtitle.ToListFromHandBrakeList<hb_subtitle_s>();
-
- foreach (SourceSubtitle sourceSubtitle in job.Subtitles.SourceSubtitles)
- {
- if (sourceSubtitle.TrackNumber == 0)
- {
- // Use subtitle search.
- nativeJob.select_subtitle_config.force = sourceSubtitle.Forced ? 1 : 0;
- nativeJob.select_subtitle_config.default_track = sourceSubtitle.Default ? 1 : 0;
-
- if (!sourceSubtitle.BurnedIn)
- {
- nativeJob.select_subtitle_config.dest = hb_subtitle_config_s_subdest.PASSTHRUSUB;
- }
-
- nativeJob.indepth_scan = 1;
- }
- else
- {
- // Use specified subtitle.
- hb_subtitle_s nativeSubtitle = titleSubtitles[sourceSubtitle.TrackNumber - 1];
- var subtitleConfig = new hb_subtitle_config_s();
-
- subtitleConfig.force = sourceSubtitle.Forced ? 1 : 0;
- subtitleConfig.default_track = sourceSubtitle.Default ? 1 : 0;
-
- bool supportsBurn = nativeSubtitle.source == hb_subtitle_s_subsource.VOBSUB || nativeSubtitle.source == hb_subtitle_s_subsource.SSASUB || nativeSubtitle.source == hb_subtitle_s_subsource.PGSSUB;
- if (supportsBurn && sourceSubtitle.BurnedIn)
- {
- subtitleConfig.dest = hb_subtitle_config_s_subdest.RENDERSUB;
- }
- else
- {
- subtitleConfig.dest = hb_subtitle_config_s_subdest.PASSTHRUSUB;
- }
-
- int subtitleAddSucceded = HBFunctions.hb_subtitle_add(ref nativeJob, ref subtitleConfig, sourceSubtitle.TrackNumber - 1);
- if (subtitleAddSucceded == 0)
- {
- Debug.WriteLine("Subtitle add failed");
- }
- }
- }
- }
-
- if (job.Subtitles.SrtSubtitles != null)
- {
- foreach (SrtSubtitle srtSubtitle in job.Subtitles.SrtSubtitles)
- {
- var subtitleConfig = new hb_subtitle_config_s();
-
- subtitleConfig.dest = srtSubtitle.BurnedIn ? hb_subtitle_config_s_subdest.RENDERSUB : hb_subtitle_config_s_subdest.PASSTHRUSUB;
- subtitleConfig.src_codeset = srtSubtitle.CharacterCode;
- subtitleConfig.src_filename = srtSubtitle.FileName;
- subtitleConfig.offset = srtSubtitle.Offset;
- subtitleConfig.default_track = srtSubtitle.Default ? 1 : 0;
-
- int srtAddSucceded = HBFunctions.hb_srt_add(ref nativeJob, ref subtitleConfig, srtSubtitle.LanguageCode);
- if (srtAddSucceded == 0)
- {
- Debug.WriteLine("SRT add failed");
- }
- }
- }
-
- bool hasBurnedSubtitle = job.Subtitles.SourceSubtitles != null && job.Subtitles.SourceSubtitles.Any(s => s.BurnedIn);
- if (hasBurnedSubtitle)
- {
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_RENDER_SUB, string.Format(CultureInfo.InvariantCulture, "{0}:{1}:{2}:{3}", crop.Top, crop.Bottom, crop.Left, crop.Right), allocatedMemory);
+ Error = state.WorkDone.Error != (int)hb_error_code.HB_ERROR_NONE
+ });
}
}
-
- // Rotate
- if (profile.FlipHorizontal || profile.FlipVertical || profile.Rotation != PictureRotation.None)
- {
- bool rotate90 = false;
- bool flipHorizontal = profile.FlipHorizontal;
- bool flipVertical = profile.FlipVertical;
-
- switch (profile.Rotation)
- {
- case PictureRotation.Clockwise90:
- rotate90 = true;
- break;
- case PictureRotation.Clockwise180:
- flipHorizontal = !flipHorizontal;
- flipVertical = !flipVertical;
- break;
- case PictureRotation.Clockwise270:
- rotate90 = true;
- flipHorizontal = !flipHorizontal;
- flipVertical = !flipVertical;
- break;
- }
-
- int rotateSetting = 0;
- if (flipVertical)
- {
- rotateSetting |= 1;
- }
-
- if (flipHorizontal)
- {
- rotateSetting |= 2;
- }
-
- if (rotate90)
- {
- rotateSetting |= 4;
- }
-
- this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_ROTATE, rotateSetting.ToString(CultureInfo.InvariantCulture), allocatedMemory);
- }
-
- // Construct final filter list
- nativeJob.list_filter = this.ConvertFilterListToNative(filterList, allocatedMemory).Ptr;
-
- if (profile.ScaleMethod == ScaleMethod.Bicubic)
- {
- HBFunctions.hb_get_opencl_env();
- nativeJob.use_opencl = 1;
- }
- else
- {
- nativeJob.use_opencl = 0;
- }
-
- nativeJob.qsv.decode = profile.QsvDecode ? 1 : 0;
- nativeJob.use_hwd = job.DxvaDecoding ? 1 : 0;
-
- if (profile.ContainerName != null)
- {
- nativeJob.mux = HBFunctions.hb_container_get_from_name(profile.ContainerName);
- }
-
- if (job.OutputPath == null)
- {
- nativeJob.file = IntPtr.Zero;
- }
- else
- {
- IntPtr outputPathPtr = InteropUtilities.ToUtf8PtrFromString(job.OutputPath);
- allocatedMemory.Add(outputPathPtr);
- nativeJob.file = outputPathPtr;
- }
-
- nativeJob.largeFileSize = profile.LargeFile ? 1 : 0;
- nativeJob.mp4_optimize = profile.Optimize ? 1 : 0;
- nativeJob.ipod_atom = profile.IPod5GSupport ? 1 : 0;
-
- if (title.AngleCount > 1)
- {
- nativeJob.angle = job.Angle;
- }
-
- switch (profile.VideoEncodeRateType)
- {
- case VideoEncodeRateType.ConstantQuality:
- nativeJob.vquality = (float)profile.Quality;
- nativeJob.vbitrate = 0;
- break;
- case VideoEncodeRateType.AverageBitrate:
- nativeJob.vquality = -1;
- nativeJob.vbitrate = profile.VideoBitrate;
- break;
- case VideoEncodeRateType.TargetSize:
- nativeJob.vquality = -1;
- nativeJob.vbitrate = this.CalculateBitrate(job, profile.TargetSize, overallSelectedLengthSeconds);
- break;
- default:
- break;
- }
-
- // frames_to_skip
-
- return allocatedMemory;
}
/// <summary>
@@ -1654,68 +680,6 @@ namespace HandBrake.Interop
}
/// <summary>
- /// Adds a filter to the given filter list.
- /// </summary>
- /// <param name="filterList">The list to add the filter to.</param>
- /// <param name="filterType">The type of filter.</param>
- /// <param name="settings">Settings for the filter.</param>
- /// <param name="allocatedMemory">The list of allocated memory.</param>
- private void AddFilter(List<hb_filter_object_s> filterList, int filterType, string settings, List<IntPtr> allocatedMemory)
- {
- IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings);
- hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));
- filter.settings = settingsNativeString;
-
- allocatedMemory.Add(settingsNativeString);
- filterList.Add(filter);
- }
-
- /// <summary>
- /// Adds a filter to the given filter list with the provided preset and tune.
- /// </summary>
- /// <param name="filterList">The list to add the filter to.</param>
- /// <param name="filterType">The type of filter.</param>
- /// <param name="preset">The preset name.</param>
- /// <param name="tune">The tune name.</param>
- private void AddFilterFromPreset(List<hb_filter_object_s> filterList, int filterType, string preset, string tune)
- {
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings(filterType, preset, tune);
-
- hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));
- filter.settings = settingsPtr;
-
- filterList.Add(filter);
- }
-
- /// <summary>
- /// Converts the given filter list to a native list.
- /// </summary>
- /// <remarks>Sorts the list by filter ID before converting to a native list, as HB expects it that way.
- /// The list memory itself will be added to the allocatedMemory list.</remarks>
- /// <param name="filterList">The filter list to convert.</param>
- /// <param name="allocatedMemory">The list of allocated memory to add to.</param>
- /// <returns>The converted list.</returns>
- private NativeList ConvertFilterListToNative(List<hb_filter_object_s> filterList, List<IntPtr> allocatedMemory)
- {
- var filterPtrList = new List<IntPtr>();
-
- var sortedList = filterList.OrderBy(f => f.id);
- foreach (var filter in sortedList)
- {
- IntPtr filterPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(hb_filter_object_s)));
- Marshal.StructureToPtr(filter, filterPtr, false);
-
- allocatedMemory.Add(filterPtr);
- filterPtrList.Add(filterPtr);
- }
-
- NativeList filterListNative = InteropUtilities.ToHandBrakeListFromPtrList(filterPtrList);
- allocatedMemory.AddRange(filterListNative.AllocatedMemory);
-
- return filterListNative;
- }
-
- /// <summary>
/// Gets the title, given the 1-based title number.
/// </summary>
/// <param name="titleNumber">The number of the title (1-based).</param>
@@ -1724,170 +688,5 @@ namespace HandBrake.Interop
{
return this.Titles.SingleOrDefault(title => title.TitleNumber == titleNumber);
}
-
- /// <summary>
- /// Gets the 1-based title index of the given title.
- /// </summary>
- /// <param name="titleNumber">The 1-based title title number.</param>
- /// <returns>The 1-based title index.</returns>
- private int GetTitleIndex(int titleNumber)
- {
- Title title = this.GetTitle(titleNumber);
- return this.GetTitleIndex(title);
- }
-
- /// <summary>
- /// Gets the 1-based title index of the given title.
- /// </summary>
- /// <param name="title">The title to look up</param>
- /// <returns>The 1-based title index of the given title.</returns>
- private int GetTitleIndex(Title title)
- {
- return this.Titles.IndexOf(title) + 1;
- }
-
- /// <summary>
- /// Gets the native title object from the title index.
- /// </summary>
- /// <param name="titleIndex">The index of the title (1-based).</param>
- /// <returns>Gets the native title object for the given index.</returns>
- private hb_title_s GetOriginalTitle(int titleIndex)
- {
- List<hb_title_s> matchingTitles = this.originalTitles.Where(title => title.index == titleIndex).ToList();
- if (matchingTitles.Count == 0)
- {
- throw new ArgumentException("Could not find specified title.");
- }
-
- if (matchingTitles.Count > 1)
- {
- throw new ArgumentException("Multiple titles matched.");
- }
-
- return matchingTitles[0];
- }
-
- /// <summary>
- /// Applies an audio encoding to a native audio encoding base structure.
- /// </summary>
- /// <param name="encoding">The encoding to apply.</param>
- /// <param name="baseStruct">The base native structure.</param>
- /// <param name="outputTrack">The output track number (0-based).</param>
- /// <param name="allocatedMemory">The collection of allocated memory.</param>
- /// <returns>The resulting native audio structure.</returns>
- private hb_audio_s ConvertAudioBack(AudioEncoding encoding, hb_audio_s baseStruct, int outputTrack, List<IntPtr> allocatedMemory)
- {
- hb_audio_s nativeAudio = baseStruct;
- HBAudioEncoder encoder = Encoders.GetAudioEncoder(encoding.Encoder);
-
- if (encoder == null)
- {
- throw new InvalidOperationException("Could not find audio encoder " + encoding.Name);
- }
-
- bool isPassthrough = encoder.IsPassthrough;
-
- HBAudioEncoder inputCodec = Encoders.GetAudioEncoder((int)baseStruct.config.input.codec);
-
- uint outputCodec = (uint)encoder.Id;
- if (encoding.PassthroughIfPossible &&
- (encoder.Id == baseStruct.config.input.codec ||
- inputCodec != null && (inputCodec.ShortName.ToLowerInvariant().Contains("aac") && encoder.ShortName.ToLowerInvariant().Contains("aac") ||
- inputCodec.ShortName.ToLowerInvariant().Contains("mp3") && encoder.ShortName.ToLowerInvariant().Contains("mp3"))) &&
- (inputCodec.Id & NativeConstants.HB_ACODEC_PASS_MASK) > 0)
- {
- outputCodec = baseStruct.config.input.codec | NativeConstants.HB_ACODEC_PASS_FLAG;
- isPassthrough = true;
- }
-
- nativeAudio.config.output.track = outputTrack;
- nativeAudio.config.output.codec = outputCodec;
- nativeAudio.config.output.compression_level = -1;
- nativeAudio.config.output.samplerate = nativeAudio.config.input.samplerate;
- nativeAudio.config.output.dither_method = -1;
-
- if (!isPassthrough)
- {
- if (encoding.SampleRateRaw != 0)
- {
- nativeAudio.config.output.samplerate = encoding.SampleRateRaw;
- }
-
- HBMixdown mixdown = Encoders.GetMixdown(encoding.Mixdown);
- nativeAudio.config.output.mixdown = mixdown.Id;
-
- if (encoding.EncodeRateType == AudioEncodeRateType.Bitrate)
- {
- // Disable quality targeting.
- nativeAudio.config.output.quality = -3;
-
- if (encoding.Bitrate == 0)
- {
- // Bitrate of 0 means auto: choose the default for this codec, sample rate and mixdown.
- nativeAudio.config.output.bitrate = HBFunctions.hb_audio_bitrate_get_default(
- nativeAudio.config.output.codec,
- nativeAudio.config.output.samplerate,
- nativeAudio.config.output.mixdown);
- }
- else
- {
- nativeAudio.config.output.bitrate = encoding.Bitrate;
- }
- }
- else if (encoding.EncodeRateType == AudioEncodeRateType.Quality)
- {
- // Bitrate of -1 signals quality targeting.
- nativeAudio.config.output.bitrate = -1;
- nativeAudio.config.output.quality = encoding.Quality;
- }
-
- // If this encoder supports compression level, pass it in.
- if (encoder.SupportsCompression)
- {
- nativeAudio.config.output.compression_level = encoding.Compression;
- }
-
- nativeAudio.config.output.dynamic_range_compression = encoding.Drc;
- nativeAudio.config.output.gain = encoding.Gain;
- }
-
- if (!string.IsNullOrEmpty(encoding.Name))
- {
- IntPtr encodingNamePtr = Marshal.StringToHGlobalAnsi(encoding.Name);
- nativeAudio.config.output.name = encodingNamePtr;
- allocatedMemory.Add(encodingNamePtr);
- }
-
- if (nativeAudio.padding == null)
- {
- nativeAudio.padding = new byte[MarshalingConstants.AudioPaddingBytes];
- }
-
- return nativeAudio;
- }
-
- /// <summary>
- /// Gets the cropping to use for the given encoding profile and title.
- /// </summary>
- /// <param name="profile">The encoding profile to use.</param>
- /// <param name="title">The title being encoded.</param>
- /// <returns>The cropping to use for the encode.</returns>
- private static Cropping GetCropping(EncodingProfile profile, Title title)
- {
- Cropping crop;
- switch (profile.CroppingType)
- {
- case CroppingType.Automatic:
- crop = title.AutoCropDimensions;
- break;
- case CroppingType.Custom:
- crop = profile.Cropping;
- break;
- default:
- crop = new Cropping();
- break;
- }
- return crop;
- }
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
index f722cdabd..65f5458f0 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
@@ -159,13 +159,10 @@
<Compile Include="HandBrakeInstance.cs" />
<Compile Include="HbLib\HBDelegates.cs" />
<Compile Include="HbLib\HBFunctions.cs" />
- <Compile Include="HbLib\hb_audio.cs" />
- <Compile Include="HbLib\hb_chapter_s.cs" />
<Compile Include="HbLib\hb_container_s.cs" />
<Compile Include="HbLib\hb_encoder_s.cs" />
<Compile Include="HbLib\hb_error_code.cs" />
<Compile Include="HbLib\hb_filter_ids.cs" />
- <Compile Include="HbLib\hb_filter_object_s.cs" />
<Compile Include="HbLib\hb_geometry.cs" />
<Compile Include="HbLib\hb_handle_s.cs" />
<Compile Include="HbLib\hb_mixdown_s.cs" />
@@ -173,13 +170,37 @@
<Compile Include="HbLib\hb_state_s.cs" />
<Compile Include="HbLib\hb_subtitle.cs" />
<Compile Include="HbLib\hb_subtitle_config_s.cs" />
- <Compile Include="HbLib\hb_title_set_s.cs" />
<Compile Include="HbLib\iso639_lang_t.cs" />
<Compile Include="HbLib\hb_job_s.cs" />
<Compile Include="HbLib\hb_title_s.cs" />
<Compile Include="HbLib\NativeConstants.cs" />
+ <Compile Include="Helpers\Validate.cs" />
<Compile Include="Interfaces\IHandBrakeInstance.cs" />
<Compile Include="Helpers\InteropUtilities.cs" />
+ <Compile Include="Json\Anamorphic\AnamorphicGeometry.cs" />
+ <Compile Include="Json\Anamorphic\AnamorphicResult.cs" />
+ <Compile Include="Json\Anamorphic\DestSettings.cs" />
+ <Compile Include="Json\Anamorphic\Geometry.cs" />
+ <Compile Include="Json\Anamorphic\PAR.cs" />
+ <Compile Include="Json\Anamorphic\SourceGeometry.cs" />
+ <Compile Include="Json\Encode\Audio.cs" />
+ <Compile Include="Json\Encode\AudioList.cs" />
+ <Compile Include="Json\Encode\ChapterList.cs" />
+ <Compile Include="Json\Encode\Destination.cs" />
+ <Compile Include="Json\Encode\Filter.cs" />
+ <Compile Include="Json\Encode\FilterList.cs" />
+ <Compile Include="Json\Encode\JsonEncodeObject.cs" />
+ <Compile Include="Json\Encode\MetaData.cs" />
+ <Compile Include="Json\Encode\Mp4Options.cs" />
+ <Compile Include="Json\Encode\Range.cs" />
+ <Compile Include="Json\Encode\Search.cs" />
+ <Compile Include="Json\Encode\Source.cs" />
+ <Compile Include="Json\Encode\SRT.cs" />
+ <Compile Include="Json\Encode\Subtitle.cs" />
+ <Compile Include="Json\Encode\SubtitleList.cs" />
+ <Compile Include="Json\Encode\Video.cs" />
+ <Compile Include="Json\Factories\AnamorphicFactory.cs" />
+ <Compile Include="Json\Factories\EncodeFactory.cs" />
<Compile Include="Json\Factories\ScanFactory.cs" />
<Compile Include="Json\Scan\AudioList.cs" />
<Compile Include="Json\Scan\ChapterList.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
index 4070d8802..fb92c3783 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
@@ -11,14 +11,19 @@ namespace HandBrake.Interop
{
using System;
using System.Collections.Generic;
+ using System.Linq;
using System.Runtime.InteropServices;
using HandBrake.Interop.EventArgs;
using HandBrake.Interop.HbLib;
+ using HandBrake.Interop.Json.Anamorphic;
+ using HandBrake.Interop.Json.Scan;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Scan;
+ using Newtonsoft.Json;
+
/// <summary>
/// HandBrake Interop Utilities
/// </summary>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
index 1763d0a74..8eafea9f2 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
@@ -89,14 +89,6 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_get_titles", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_titles(IntPtr hbHandle);
- /// Return Type: void
- ///param0: hb_handle_t*
- ///param1: hb_title_t*
- ///param2: int
- ///param3: uint8_t*
- [DllImport("hb.dll", EntryPoint = "hb_get_preview", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_get_preview(IntPtr hbHandle, ref hb_job_s title, int preview, IntPtr buffer);
-
/// Return Type: void
///param0: hb_job_t*
@@ -105,15 +97,6 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_set_size", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_set_size(ref hb_job_s param0, double ratio, int pixels);
- /// Return Type: void
- ///param0: hb_job_t*
- ///output_width: int*
- ///output_height: int*
- ///output_par_width: int*
- ///output_par_height: int*
- [DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_set_anamorphic_size(ref hb_job_s job, ref int output_width, ref int output_height, ref int output_par_width, ref int output_par_height);
-
[DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size2", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_set_anamorphic_size2(ref hb_geometry_s sourceGeometry, ref hb_geometry_settings_s uiGeometry, ref hb_geometry_s result);
@@ -170,19 +153,6 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_stop", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_stop(IntPtr hbHandle);
- /// Return Type: void
- ///param0: hb_handle_t*
- ///param1: hb_state_t*
- [DllImport("hb.dll", EntryPoint = "hb_get_state", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_get_state(IntPtr hbHandle, ref hb_state_s state);
-
-
- /// Return Type: void
- ///param0: hb_handle_t*
- ///param1: hb_state_t*
- [DllImport("hb.dll", EntryPoint = "hb_get_state2", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_get_state2(IntPtr hbHandle, ref hb_state_s param1);
-
/// Return Type: int
///param0: hb_handle_t*
@@ -439,10 +409,6 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_chapter_set_title__ptr(IntPtr chapter, IntPtr title);
- /// void hb_add_filter( hb_job_t * job, hb_filter_object_t * filter, const char * settings );
- [DllImport("hb.dll", EntryPoint = "hb_add_filter", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_add_filter(ref hb_job_s job, ref hb_filter_object_s filter, IntPtr settings);
-
/// hb_filter_object_t * hb_filter_init( int filter_id );
[DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_filter_init(int filter_id);
@@ -479,6 +445,9 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_qsv_info_init", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_qsv_info_init();
+ // hb_image_t* hb_get_preview2(hb_handle_t* h, int title_idx, int picture, hb_geometry_settings_t* geo, int deinterlace);
+ [DllImport("hb.dll", EntryPoint = "hb_get_preview2", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx, ref hb_geometry_settings_s geo, int deinterlace);
/* JSON API */
@@ -496,7 +465,7 @@ namespace HandBrake.Interop.HbLib
// char * hb_job_to_json(const hb_job_t * job);
[DllImport("hb.dll", EntryPoint = "hb_job_to_json", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_job_to_json(IntPtr hb_job_t);
+ public static extern IntPtr hb_job_to_json(ref hb_job_s hb_job_t);
// hb_job_t * hb_json_to_job(hb_handle_t * h, const char * json_job);
[DllImport("hb.dll", EntryPoint = "hb_json_to_job", CallingConvention = CallingConvention.Cdecl)]
@@ -513,5 +482,9 @@ namespace HandBrake.Interop.HbLib
// char * hb_get_state_json(hb_handle_t * h);
[DllImport("hb.dll", EntryPoint = "hb_get_state_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_state_json(IntPtr hbHandle);
+
+ // char* hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, hb_geometry_settings_t *settings)
+ [DllImport("hb.dll", EntryPoint = "hb_get_preview_params_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, ref hb_geometry_settings_s settings);
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs
deleted file mode 100644
index 7814fb27b..000000000
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_audio.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="hb_audio.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the hb_audio_s type.
-// </summary>
-// <auto-generated> Disable Stylecop Warnings for this file </auto-generated>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop.HbLib
-{
- using System;
- using System.Runtime.InteropServices;
-
- using HandBrake.Interop.Helpers;
-
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_audio_s
- {
- /// int
- public int id;
-
- /// hb_audio_config_t->hb_audio_config_s
- public hb_audio_config_s config;
-
- // Padding for the part of the struct we don't care about marshaling.
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = MarshalingConstants.AudioPaddingBytes, ArraySubType = UnmanagedType.U1)]
- public byte[] padding;
-
- // Anonymous_e6c7b779_b5a3_4e80_9fa8_13619d14f545
- // public Anonymous_e6c7b779_b5a3_4e80_9fa8_13619d14f545 priv;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_audio_config_s
- {
- public hb_audio_config_output_s output;
- public hb_audio_config_input_s input;
-
- public hb_audio_config_lang_s lang;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_audio_config_output_s
- {
- public int mixdown;
-
- /// int
- public int track;
-
- /// uint32_t->unsigned int
- public uint codec;
-
- /// int
- public int samplerate;
-
- public int samples_per_frame;
-
- /// int
- public int bitrate;
-
- public double quality;
-
- public double compression_level;
-
- /// double
- public double dynamic_range_compression;
-
- public double gain;
-
- public int normalize_mix_level;
-
- public int dither_method;
-
- public IntPtr name;
-
- public int delay;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_audio_config_input_s
- {
- /// int
- public int track;
-
- /* Input audio codec */
- public uint codec;
-
- /* Per-codec config info */
- public uint codec_param;
-
- /* Registration descriptor of source */
- public uint reg_desc;
-
- /* Stream type from source stream */
- public uint stream_type;
-
- /* Substream type for multiplexed streams */
- public uint substream_type;
-
- /* Bitsream version */
- public uint version;
-
- /* Bitstream flags, codec-specific */
- public uint flags;
-
- /* Bitstream mode, codec-specific */
- public uint mode;
-
- /* Input sample rate (Hz) */
- public int samplerate;
-
- /* Number of samples per frame */
- public int samples_per_frame;
-
- /* Input bitrate (bps) */
- public int bitrate;
-
- /* Source matrix encoding mode, set by the audio decoder */
- public int matrix_encoding;
-
- /* Source channel layout, set by the audio decoder */
- public ulong channel_layout;
-
- /* Source channel map, set by the audio decoder */
- // hb_chan_map_t
- public IntPtr channel_map;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- public struct hb_audio_config_lang_s
- {
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
- public string description;
-
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
- public string simple;
-
- /// char[4]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
- public string iso639_2;
-
- /// uint8_t->unsigned char
- public byte type;
- }
-}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_chapter_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_chapter_s.cs
deleted file mode 100644
index fa3c63a8c..000000000
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_chapter_s.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="hb_chapter_s.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the hb_chapter_s type.
-// </summary>
-// <auto-generated> Disable Stylecop Warnings for this file </auto-generated>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop.HbLib
-{
- using System.Runtime.InteropServices;
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- public struct hb_chapter_s
- {
- /// int
- public int index;
-
- /// int
- public int pgcn;
-
- /// int
- public int pgn;
-
- /// int
- public int cell_start;
-
- /// int
- public int cell_end;
-
- /// int
- public ulong block_start;
-
- /// int
- public ulong block_end;
-
- /// int
- public ulong block_count;
-
- /// int
- public int hours;
-
- /// int
- public int minutes;
-
- /// int
- public int seconds;
-
- /// uint64_t->unsigned int
- public ulong duration;
-
- /// char *
- [MarshalAs(UnmanagedType.LPStr)]
- public string title;
- }
-}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_error_code.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_error_code.cs
index 86d8f3f08..7c107f41c 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_error_code.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_error_code.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace HandBrake.Interop.HbLib
+namespace HandBrake.Interop.HbLib
{
public enum hb_error_code
{
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_object_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_object_s.cs
deleted file mode 100644
index 1329b88ec..000000000
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_filter_object_s.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="hb_filter_object_s.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <auto-generated> Disable Stylecop Warnings for this file </auto-generated>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop.HbLib
-{
- using System;
- using System.Runtime.InteropServices;
-
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_filter_object_s
- {
- public int id;
- public int enforce_order;
- public IntPtr name;
- public IntPtr settings;
-
- // Internal stuff we need to marshal
- public IntPtr init;
- public IntPtr work;
- public IntPtr close;
- public IntPtr info;
- public IntPtr fifo_in;
- public IntPtr fifo_out;
- public IntPtr subtitle;
- public IntPtr private_data;
- public IntPtr thread;
- public IntPtr done;
- public int status;
- public int chapter_val;
- public long chapter_time;
- }
-}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs
index 2821b2d1c..77c21a190 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_subtitle.cs
@@ -7,84 +7,7 @@
namespace HandBrake.Interop.HbLib
{
- using System;
- using System.Runtime.InteropServices;
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- public struct hb_subtitle_s
- {
- /// int
- public int id;
-
- /// int
- public int track;
-
- public int out_track;
-
- /// hb_subtitle_config_t->hb_subtitle_config_s
- public hb_subtitle_config_s config;
-
- /// hb_subtitle_s_subtype
- public hb_subtitle_s_subtype format;
-
- /// hb_subtitle_s_subsource
- public hb_subtitle_s_subsource source;
-
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
- public string lang;
-
- /// char[4]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
- public string iso639_2;
-
- /// uint8_t->unsigned char
- public byte type;
-
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.U4)]
- public uint[] palette;
-
- public byte palette_set;
-
- public int width;
-
- public int height;
-
- public IntPtr extradata;
-
- public int extradata_size;
-
- /// int
- public int hits;
-
- /// int
- public int forced_hits;
-
- public uint codec;
-
- public uint reg_desc;
-
- public uint stream_type;
-
- public uint substream_type;
-
- /// hb_fifo_t*
- public IntPtr fifo_in;
-
- /// hb_fifo_t*
- public IntPtr fifo_raw;
-
- /// hb_fifo_t*
- public IntPtr fifo_sync;
-
- /// hb_fifo_t*
- public IntPtr fifo_out;
-
- /// hb_mux_data_t*
- public IntPtr mux_data;
- }
-
- public enum hb_subtitle_s_subtype
+ public enum hb_subtitle_s_subtype
{
PICTURESUB,
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
index 3e43ac2a6..2e9d49868 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs
@@ -16,14 +16,14 @@ namespace HandBrake.Interop.HbLib
/// Anonymous_990d28ea_6cf3_4fbc_8143_4df9513e9550
public hb_title_type_anon type;
- public uint reg_desc;
-
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
- public byte[] path;
-
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public uint reg_desc;
+
+ /// char[1024]
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
+ public byte[] path;
+
+ /// char[1024]
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string name;
/// int
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_set_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_set_s.cs
deleted file mode 100644
index 087e7cde4..000000000
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_set_s.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="hb_title_set_s.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <auto-generated> Disable Stylecop Warnings for this file </auto-generated>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop.HbLib
-{
- using System;
- using System.Runtime.InteropServices;
-
- [StructLayout(LayoutKind.Sequential)]
- public struct hb_title_set_s
- {
- ///hb_list_t *
- public IntPtr list_title;
-
- // int
- public int feature;
- }
-}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs
index ea86eb85c..64c03cbef 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs
@@ -128,26 +128,6 @@ namespace HandBrake.Interop.Interfaces
BitmapImage GetPreview(EncodeJob job, int previewNumber);
/// <summary>
- /// Gets the final size for a given encode job.
- /// </summary>
- /// <param name="job">
- /// The encode job to use.
- /// </param>
- /// <param name="width">
- /// The storage width.
- /// </param>
- /// <param name="height">
- /// The storage height.
- /// </param>
- /// <param name="parWidth">
- /// The pixel aspect X number.
- /// </param>
- /// <param name="parHeight">
- /// The pixel aspect Y number.
- /// </param>
- void GetSize(EncodeJob job, out int width, out int height, out int parWidth, out int parHeight);
-
- /// <summary>
/// Pauses the current encode.
/// </summary>
void PauseEncode();
@@ -218,7 +198,6 @@ namespace HandBrake.Interop.Interfaces
/// </param>
void StartScan(string path, int previewCount, int titleIndex);
-
/// <summary>
/// Starts a scan of the given path.
/// </summary>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs
index 684eac686..24ac9202b 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/AnamorphicGeometry.cs
@@ -17,7 +17,7 @@ namespace HandBrake.Interop.Json.Anamorphic
/// <summary>
/// Gets or sets the dest geometry.
/// </summary>
- public DestSettings DestGeometry { get; set; }
+ public DestSettings DestSettings { get; set; }
/// <summary>
/// Gets or sets the source geometry.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs
index 1f4f95542..be65d4150 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Anamorphic/DestSettings.cs
@@ -44,7 +44,7 @@ namespace HandBrake.Interop.Json.Anamorphic
/// <summary>
/// Gets or sets a value indicating whether keep display aspect.
/// </summary>
- public bool Keep { get; set; }
+ public int Keep { get; set; }
/// <summary>
/// Gets or sets the max height.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs
index c5e6c6aa1..c4849f7c5 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/JsonEncodeObject.cs
@@ -14,7 +14,7 @@ namespace HandBrake.Interop.Json.Encode
/// <summary>
/// The root object.
/// </summary>
- public class JsonEncodeObject
+ internal class JsonEncodeObject
{
/// <summary>
/// Gets or sets the audio.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs
new file mode 100644
index 000000000..cb882c126
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs
@@ -0,0 +1,109 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AnamorphicFactory.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The Anamorphic factory.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Json.Factories
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Runtime.InteropServices;
+
+ using HandBrake.Interop.HbLib;
+ using HandBrake.Interop.Json.Anamorphic;
+ using HandBrake.Interop.Model;
+ using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.Model.Scan;
+
+ using Newtonsoft.Json;
+
+ public class AnamorphicFactory
+ {
+ /// <summary>
+ /// The keep setting.
+ /// </summary>
+ public enum KeepSetting
+ {
+ HB_KEEP_WIDTH = 0x01,
+ HB_KEEP_HEIGHT = 0x02,
+ HB_KEEP_DISPLAY_ASPECT = 0x04
+ }
+
+ /// <summary>
+ /// The create geometry.
+ /// </summary>
+ /// <param name="job">
+ /// The job.
+ /// </param>
+ /// <param name="title">
+ /// The current title.
+ /// </param>
+ /// <param name="keepWidthOrHeight">
+ /// Keep Width or Height. (Not Display Aspect)
+ /// </param>
+ /// <returns>
+ /// The <see cref="Scan.Geometry"/>.
+ /// </returns>
+ public static Geometry CreateGeometry(EncodeJob job, Title title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
+ {
+ int settingMode = (int)keepWidthOrHeight + (job.EncodingProfile.KeepDisplayAspect ? 0x04 : 0);
+
+ // Sanatise the Geometry First.
+ AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
+ {
+ SourceGeometry = new SourceGeometry
+ {
+ Width = title.Resolution.Width,
+ Height = title.Resolution.Height,
+ PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }
+ },
+ DestSettings = new DestSettings
+ {
+ AnamorphicMode = (int)job.EncodingProfile.Anamorphic,
+ Geometry = {
+ Width = job.EncodingProfile.Width, Height = job.EncodingProfile.Height,
+ PAR = new PAR
+ {
+ Num = job.EncodingProfile.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : job.EncodingProfile.PixelAspectX,
+ Den = job.EncodingProfile.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : job.EncodingProfile.PixelAspectY,
+ }
+ },
+ Keep = settingMode,
+ Crop = new List<int> { job.EncodingProfile.Cropping.Top, job.EncodingProfile.Cropping.Bottom, job.EncodingProfile.Cropping.Left, job.EncodingProfile.Cropping.Right },
+ Modulus = job.EncodingProfile.Modulus,
+ MaxWidth = job.EncodingProfile.MaxWidth,
+ MaxHeight = job.EncodingProfile.MaxHeight,
+ ItuPAR = false
+ }
+ };
+
+ if (job.EncodingProfile.Anamorphic == Anamorphic.Custom)
+ {
+ anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = job.EncodingProfile.PixelAspectX, Den = job.EncodingProfile.PixelAspectY };
+ }
+ else
+ {
+ anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height };
+ }
+
+ string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
+ IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
+ string result = Marshal.PtrToStringAnsi(json);
+ AnamorphicResult resultGeometry = JsonConvert.DeserializeObject<AnamorphicResult>(result);
+
+ // Setup the Destination Gemotry.
+ Geometry geometry = new Geometry
+ {
+ Width = resultGeometry.Width,
+ Height = resultGeometry.Height,
+ PAR = resultGeometry.PAR
+ };
+ return geometry;
+ }
+
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs
index 17013ae5b..fd2274e3f 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs
@@ -419,52 +419,6 @@ namespace HandBrake.Interop.Json.Factories
}
/// <summary>
- /// The create geometry.
- /// </summary>
- /// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="Geometry"/>.
- /// </returns>
- private static Json.Anamorphic.Geometry CreateGeometry(EncodeJob job, JsonScanObject scannedSource)
- {
- TitleList title = scannedSource.TitleList.FirstOrDefault(c => c.Index == job.Title);
-
- // Sanatise the Geometry First.
- AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
- {
- DestGeometry = new DestSettings(),
- SourceGeometry =
- new SourceGeometry
- {
- Width = title.Geometry.Width,
- Height = title.Geometry.Height,
- PAR = new Json.Anamorphic.PAR { Num = title.Geometry.PAR.Num, Den = title.Geometry.PAR.Den }
- }
- };
-
- anamorphicGeometry.DestGeometry.AnamorphicMode = (int)job.EncodingProfile.Anamorphic;
- anamorphicGeometry.DestGeometry.Geometry.Width = job.EncodingProfile.Width;
- anamorphicGeometry.DestGeometry.Geometry.Height = job.EncodingProfile.Height;
- anamorphicGeometry.DestGeometry.Keep = job.EncodingProfile.KeepDisplayAspect;
- anamorphicGeometry.DestGeometry.Geometry.PAR = new Json.Anamorphic.PAR { Num = job.EncodingProfile.PixelAspectX, Den = job.EncodingProfile.PixelAspectY };
- anamorphicGeometry.DestGeometry.Crop = new List<int> { job.EncodingProfile.Cropping.Top, job.EncodingProfile.Cropping.Bottom, job.EncodingProfile.Cropping.Left, job.EncodingProfile.Cropping.Right };
-
- string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
- string statusJson = Marshal.PtrToStringAnsi(json);
- AnamorphicResult sanatisedGeometry = JsonConvert.DeserializeObject<AnamorphicResult>(statusJson);
-
- // Setup the Destination Gemotry.
- Json.Anamorphic.Geometry geometry = new Json.Anamorphic.Geometry();
- geometry.Width = sanatisedGeometry.Width;
- geometry.Height = sanatisedGeometry.Height;
- geometry.PAR = sanatisedGeometry.PAR;
- return geometry;
- }
-
- /// <summary>
/// The create meta data.
/// </summary>
/// <param name="job">
@@ -478,40 +432,5 @@ namespace HandBrake.Interop.Json.Factories
MetaData metaData = new MetaData();
return metaData;
}
-
-
- /// <summary>
- /// Adds a filter to the given filter list.
- /// </summary>
- /// <param name="filterList">The list to add the filter to.</param>
- /// <param name="filterType">The type of filter.</param>
- /// <param name="settings">Settings for the filter.</param>
- /// <param name="allocatedMemory">The list of allocated memory.</param>
- private void AddFilter(List<hb_filter_object_s> filterList, int filterType, string settings, List<IntPtr> allocatedMemory)
- {
- IntPtr settingsNativeString = Marshal.StringToHGlobalAnsi(settings);
- hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));
- filter.settings = settingsNativeString;
-
- allocatedMemory.Add(settingsNativeString);
- filterList.Add(filter);
- }
-
- /// <summary>
- /// Adds a filter to the given filter list with the provided preset and tune.
- /// </summary>
- /// <param name="filterList">The list to add the filter to.</param>
- /// <param name="filterType">The type of filter.</param>
- /// <param name="preset">The preset name.</param>
- /// <param name="tune">The tune name.</param>
- private void AddFilterFromPreset(List<hb_filter_object_s> filterList, int filterType, string preset, string tune)
- {
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings(filterType, preset, tune);
-
- hb_filter_object_s filter = InteropUtilities.ToStructureFromPtr<hb_filter_object_s>(HBFunctions.hb_filter_init(filterType));
- filter.settings = settingsPtr;
-
- filterList.Add(filter);
- }
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/ScanFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/ScanFactory.cs
index 446ae5c1b..e8153b239 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/ScanFactory.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/ScanFactory.cs
@@ -143,40 +143,9 @@ namespace HandBrake.Interop.Json.Factories
Language = subtitle.Language,
LanguageCode = subtitle.LanguageCode,
SubtitleSourceInt = subtitle.Source,
- // SubtitleSource = null,
+ SubtitleSource = (SubtitleSource)subtitle.Source // TODO Check correct
};
-
- //switch (subtitle.subsource)
- //{
- // case hb_subtitle_s_subsource.CC608SUB:
- // newSubtitle.SubtitleSource = SubtitleSource.CC608;
- // break;
- // case hb_subtitle_s_subsource.CC708SUB:
- // newSubtitle.SubtitleSource = SubtitleSource.CC708;
- // break;
- // case hb_subtitle_s_subsource.SRTSUB:
- // newSubtitle.SubtitleSource = SubtitleSource.SRT;
- // break;
- // case hb_subtitle_s_subsource.SSASUB:
- // newSubtitle.SubtitleSource = SubtitleSource.SSA;
- // break;
- // case hb_subtitle_s_subsource.TX3GSUB:
- // newSubtitle.SubtitleSource = SubtitleSource.TX3G;
- // break;
- // case hb_subtitle_s_subsource.UTF8SUB:
- // newSubtitle.SubtitleSource = SubtitleSource.UTF8;
- // break;
- // case hb_subtitle_s_subsource.VOBSUB:
- // newSubtitle.SubtitleSource = SubtitleSource.VobSub;
- // break;
- // case hb_subtitle_s_subsource.PGSSUB:
- // newSubtitle.SubtitleSource = SubtitleSource.PGS;
- // break;
- // default:
- // break;
- //}
-
subtiles.Add(newSubtitle);
currentSubtitleTrack++;
@@ -241,8 +210,7 @@ namespace HandBrake.Interop.Json.Factories
{
Name = chapter.Name,
ChapterNumber = currentTrack,
- Duration = new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds),
- // DurationPts = chapter.duration
+ Duration = new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)
};
tracks.Add(newChapter);
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs
index 42e4428ed..f410bc5bb 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs
@@ -25,4 +25,4 @@ namespace HandBrake.Interop.Model.Encoding
[Display(Name = "Custom")]
Custom = 3
}
-}
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs
index 70e35e6f3..3d7a999f8 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Scan/Chapter.cs
@@ -33,11 +33,6 @@ namespace HandBrake.Interop.Model.Scan
public TimeSpan Duration { get; set; }
/// <summary>
- /// Gets or sets the duration of this chapter in PTS.
- /// </summary>
- public ulong DurationPts { get; set; }
-
- /// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// </summary>
/// <returns>A string formatted as: {chapter #}</returns>