diff options
author | Scott <[email protected]> | 2015-09-18 21:41:57 +0100 |
---|---|---|
committer | Scott <[email protected]> | 2015-09-18 21:41:57 +0100 |
commit | 7e266c63e5241289d6fb9645ea932a35de07bb18 (patch) | |
tree | 78ac4ff63dd0a98bb9df6fdfcec41cec91960f49 | |
parent | 8ea1a78f7ac7e4f9bec9cb551b029754c613f642 (diff) |
WinGui: Starting work on more API cleanup in ApplicationServices library.
3 files changed, 47 insertions, 99 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs index 5c49c5073..35ec20ba9 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs @@ -16,7 +16,6 @@ namespace HandBrake.ApplicationServices.Interop.Factories using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Interop.Model.Preview;
- using HandBrake.ApplicationServices.Services.Encode.Model;
/// <summary>
/// The anamorphic factory.
@@ -28,79 +27,34 @@ namespace HandBrake.ApplicationServices.Interop.Factories /// </summary>
public enum KeepSetting
{
- HB_KEEP_WIDTH = 0x01,
- HB_KEEP_HEIGHT = 0x02,
+ /// <summary>
+ /// The h b_ kee p_ width.
+ /// </summary>
+ HB_KEEP_WIDTH = 0x01,
+
+ /// <summary>
+ /// The h b_ kee p_ height.
+ /// </summary>
+ HB_KEEP_HEIGHT = 0x02,
+
+ /// <summary>
+ /// The h b_ kee p_ displa y_ aspect.
+ /// </summary>
HB_KEEP_DISPLAY_ASPECT = 0x04
}
/// <summary>
- /// The create geometry.
+ /// Finds output geometry for the given preview settings and title.
/// </summary>
- /// <param name="job">
- /// The job.
+ /// <param name="settings">
+ /// The preview settings.
/// </param>
/// <param name="title">
- /// The current title.
- /// </param>
- /// <param name="keepWidthOrHeight">
- /// Keep Width or Height. (Not Display Aspect)
+ /// Information on the title to consider.
/// </param>
/// <returns>
- /// The <see cref="Geometry"/>.
+ /// Geometry Information
/// </returns>
- public static Geometry CreateGeometry(EncodeTask job, SourceVideoInfo title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
- {
- int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);
-
- // Sanitize the Geometry First.
- AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
- {
- SourceGeometry = new Geometry
- {
- 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.Anamorphic,
- Geometry =
- {
- Width = job.Width ?? 0,
- Height = job.Height ?? 0,
- PAR = new PAR
- {
- Num = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : job.PixelAspectX,
- Den = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : job.PixelAspectY,
- }
- },
- Keep = settingMode,
- Crop = new List<int> { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right },
- Modulus = job.Modulus ?? 16,
- MaxWidth = job.MaxWidth ?? 0,
- MaxHeight = job.MaxHeight ?? 0,
- ItuPAR = false
- }
- };
-
- if (job.Anamorphic == Anamorphic.Custom)
- {
- anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = job.PixelAspectX, Den = job.PixelAspectY };
- }
- else
- {
- anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height };
- }
-
- return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);
- }
-
- /// <summary>
- /// Finds output geometry for the given preview settings and title.
- /// </summary>
- /// <param name="settings">The preview settings.</param>
- /// <param name="title">Information on the title to consider.</param>
- /// <returns>Geometry Information</returns>
public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title)
{
int settingMode = settings.KeepDisplayAspect ? 0x04 : 0;
@@ -110,28 +64,28 @@ namespace HandBrake.ApplicationServices.Interop.Factories {
SourceGeometry = new Geometry
{
- Width = title.Resolution.Width,
- Height = title.Resolution.Height,
+ Width = title.Resolution.Width,
+ Height = title.Resolution.Height,
PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }
- },
+ },
DestSettings = new DestSettings
{
- AnamorphicMode = (int)settings.Anamorphic,
+ AnamorphicMode = (int)settings.Anamorphic,
Geometry =
{
- Width = settings.Width,
- Height = settings.Height,
+ Width = settings.Width,
+ Height = settings.Height,
PAR = new PAR
{
- Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,
- Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,
+ Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,
+ Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,
}
- },
- Keep = settingMode,
- Crop = new List<int> { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
- Modulus = settings.Modulus ?? 16,
- MaxWidth = settings.MaxWidth,
- MaxHeight = settings.MaxHeight,
+ },
+ Keep = settingMode,
+ Crop = new List<int> { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
+ Modulus = settings.Modulus ?? 16,
+ MaxWidth = settings.MaxWidth,
+ MaxHeight = settings.MaxHeight,
ItuPAR = false
}
};
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs index 8cf266d7e..d413e003b 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs @@ -10,7 +10,6 @@ namespace HandBrake.ApplicationServices.Interop.Model.Preview
{
using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Services.Encode.Model;
/// <summary>
/// The preview settings.
@@ -25,25 +24,6 @@ namespace HandBrake.ApplicationServices.Interop.Model.Preview }
/// <summary>
- /// Initializes a new instance of the <see cref="PreviewSettings"/> class.
- /// </summary>
- /// <param name="task">The task.</param>
- public PreviewSettings(EncodeTask task)
- {
- this.Cropping = new Cropping(task.Cropping);
- this.MaxWidth = task.MaxWidth ?? 0;
- this.MaxHeight = task.MaxHeight ?? 0;
- this.KeepDisplayAspect = task.KeepDisplayAspect;
- this.TitleNumber = task.Title;
- this.Anamorphic = task.Anamorphic;
- this.Modulus = task.Modulus;
- this.Width = task.Width ?? 0;
- this.Height = task.Height ?? 0;
- this.PixelAspectX = task.PixelAspectX;
- this.PixelAspectY = task.PixelAspectY;
- }
-
- /// <summary>
/// Gets or sets the cropping.
/// </summary>
public Cropping Cropping { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs index b67513826..c7a97fa42 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs @@ -272,7 +272,21 @@ namespace HandBrake.ApplicationServices.Services.Scan BitmapImage bitmapImage = null;
try
{
- PreviewSettings settings = new PreviewSettings(job);
+ PreviewSettings settings = new PreviewSettings
+ {
+ Cropping = new Cropping(job.Cropping),
+ MaxWidth = job.MaxWidth ?? 0,
+ MaxHeight = job.MaxHeight ?? 0,
+ KeepDisplayAspect = job.KeepDisplayAspect,
+ TitleNumber = job.Title,
+ Anamorphic = job.Anamorphic,
+ Modulus = job.Modulus,
+ Width = job.Width ?? 0,
+ Height = job.Height ?? 0,
+ PixelAspectX = job.PixelAspectX,
+ PixelAspectY = job.PixelAspectY
+ };
+
bitmapImage = this.instance.GetPreview(settings, preview);
}
catch (AccessViolationException e)
|