/// <summary> /// The hb_set_anamorphic_size 2. /// </summary> /// <param name="job"> /// The job. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="setting"> /// The setting. /// </param> /// <returns> /// The <see cref="AnamorphicResult"/>. /// </returns> public static AnamorphicResult hb_set_anamorphic_size2(PictureSettingsJob job, PictureSettingsTitle title, KeepSetting setting) { int settingMode = (int)setting + (job.KeepDisplayAspect ? 0x04 : 0); hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s { crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }, itu_par = 0, keep = settingMode, maxWidth = job.MaxWidth, maxHeight = job.MaxHeight, mode = (int)(hb_anamorphic_mode_t)job.AnamorphicMode, modulus = job.Modulus.HasValue ? job.Modulus.Value : 16, geometry = new hb_geometry_s { height = job.Height, width = job.Width, par = job.AnamorphicMode != Anamorphic.Custom ? new hb_rational_t { den = title.ParH, num = title.ParW } : new hb_rational_t { den = job.ParH, num = job.ParW }} }; hb_geometry_s sourceGeometry = new hb_geometry_s { width = title.Width, height = title.Height, par = new hb_rational_t { den = title.ParH, num = title.ParW } }; hb_geometry_s result = new hb_geometry_s(); HBFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result); int outputWidth = result.width; int outputHeight = result.height; int outputParWidth = result.par.num; int outputParHeight = result.par.den; Debug.WriteLine("hb_set_anamorphic_size2: {0}x{1}", outputWidth, outputHeight); return new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight }; }
/// <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="Geometry"/>. /// </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)); }
// Todo remove the need for these objects. Should use simpler objects. /// <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="Geometry"/>. /// </returns> public static Geometry CreateGeometry(EncodeTask job, SourceVideoInfo title, KeepSetting keepWidthOrHeight) { 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> /// 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.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.Anamorphic, Geometry = { Width = job.Width, Height = job.Height, 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, MaxWidth = job.MaxWidth, MaxHeight = job.MaxHeight, 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 }; } 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); }
/// <summary> /// The hb_set_anamorphic_size 2. /// </summary> /// <param name="job"> /// The job. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="setting"> /// The setting. /// </param> /// <returns> /// The <see cref="AnamorphicResult"/>. /// </returns> public static AnamorphicResult hb_set_anamorphic_size2(PictureSettingsJob job, PictureSettingsTitle title, KeepSetting setting) { int settingMode = (int)setting + (job.KeepDisplayAspect ? 0x04 : 0); hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s { crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }, itu_par = 0, keep = settingMode, maxWidth = job.MaxWidth, maxHeight = job.MaxHeight, mode = (int)job.AnamorphicMode, modulus = job.Modulus.HasValue ? job.Modulus.Value : 16, geometry = new hb_geometry_s { height = job.Height, width = job.Width, par = job.AnamorphicMode != Anamorphic.Custom ? new hb_rational_t { den = title.ParH, num = title.ParW } : new hb_rational_t { den = job.ParH, num = job.ParW } } }; hb_geometry_s sourceGeometry = new hb_geometry_s { width = title.Width, height = title.Height, par = new hb_rational_t { den = title.ParH, num = title.ParW } }; hb_geometry_s result = new hb_geometry_s(); HBFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result); int outputWidth = result.width; int outputHeight = result.height; int outputParWidth = result.par.num; int outputParHeight = result.par.den; Debug.WriteLine("hb_set_anamorphic_size2: {0}x{1}", outputWidth, outputHeight); return(new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight }); }
public static AnamorphicResult GetAnamorphicSize(PictureSettingsJob job, PictureSettingsTitle sourceTitle, KeepSetting keepSetting, FlagsSetting flagSetting) { hb_rational_t computedPar; switch (job.AnamorphicMode) { case Anamorphic.None: computedPar = new hb_rational_t { den = 1, num = 1 }; break; case Anamorphic.Custom: computedPar = new hb_rational_t { den = job.ParH, num = job.ParW }; break; default: computedPar = new hb_rational_t { den = sourceTitle.ParH, num = sourceTitle.ParW }; break; } hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s { crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }, pad = new[] { job.Pad.Top, job.Pad.Bottom, job.Pad.Left, job.Pad.Right }, flags = (int)flagSetting, itu_par = 0, keep = (int)keepSetting, maxWidth = job.MaxWidth, maxHeight = job.MaxHeight, mode = (int)job.AnamorphicMode, modulus = 2, geometry = new hb_geometry_s { height = job.Height, width = job.Width, par = computedPar }, displayWidth = job.DarWidth }; // If we are rotated, the source title geometry must also be rotated. int titleWidth, titleHeight, titleParW, titleParH; if (job.RotateAngle != 0) { PictureSettingsJob titleRepresentation = new PictureSettingsJob { Width = sourceTitle.Width, Height = sourceTitle.Height, RotateAngle = job.RotateAngle, Hflip = job.Hflip, ParW = sourceTitle.ParW, ParH = sourceTitle.ParH, Crop = new Cropping(), Pad = new Padding() }; RotateResult titleRotation = HandBrakePictureHelpers.RotateGeometry(titleRepresentation); titleWidth = titleRotation.Width; titleHeight = titleRotation.Height; titleParW = titleRotation.ParNum; titleParH = titleRotation.ParDen; } else { titleWidth = sourceTitle.Width; titleHeight = sourceTitle.Height; titleParW = sourceTitle.ParW; titleParH = sourceTitle.ParH; } hb_geometry_s sourceGeometry = new hb_geometry_s { width = titleWidth, height = titleHeight, par = new hb_rational_t { den = titleParH, num = titleParW } }; hb_geometry_s result = new hb_geometry_s(); HBFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result); int outputWidth = result.width; int outputHeight = result.height; int outputParWidth = result.par.num; int outputParHeight = result.par.den; return(new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight }); }
public static AnamorphicResult hb_set_anamorphic_size2(PictureSettingsJob job, PictureSettingsTitle title, KeepSetting setting) { int settingMode = (int)setting + (job.KeepDisplayAspect ? 0x04 : 0); hb_rational_t computed_par = new hb_rational_t(); switch (job.AnamorphicMode) { case Anamorphic.None: computed_par = new hb_rational_t { den = 1, num = 1 }; break; case Anamorphic.Custom: computed_par = new hb_rational_t { den = job.ParH, num = job.ParW }; break; default: computed_par = new hb_rational_t { den = title.ParH, num = title.ParW }; break; } hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s { crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }, itu_par = 0, keep = settingMode, maxWidth = job.MaxWidth, maxHeight = job.MaxHeight, mode = (int)job.AnamorphicMode, modulus = job.Modulus.HasValue ? job.Modulus.Value : 16, geometry = new hb_geometry_s { height = job.Height, width = job.Width, par = computed_par } }; hb_geometry_s sourceGeometry = new hb_geometry_s { width = title.Width, height = title.Height, par = new hb_rational_t { den = title.ParH, num = title.ParW } }; hb_geometry_s result = HandBrakePictureHelpers.GetAnamorphicSizes(sourceGeometry, uiGeometry); int outputWidth = result.width; int outputHeight = result.height; int outputParWidth = result.par.num; int outputParHeight = result.par.den; return(new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight }); }
/// <summary> /// The hb_set_anamorphic_size 2. /// </summary> /// <param name="job"> /// The job. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="setting"> /// The setting. /// </param> /// <returns> /// The <see cref="AnamorphicResult"/>. /// </returns> public static AnamorphicResult hb_set_anamorphic_size2(PictureSettingsJob job, PictureSettingsTitle title, KeepSetting setting) { int settingMode = (int)setting + (job.KeepDisplayAspect ? 0x04 : 0); hb_rational_t computed_par = new hb_rational_t(); switch (job.AnamorphicMode) { case Anamorphic.None: computed_par = new hb_rational_t { den = 1, num = 1 }; break; case Anamorphic.Custom: computed_par = new hb_rational_t { den = job.ParH, num = job.ParW }; break; default: computed_par = new hb_rational_t { den = title.ParH, num = title.ParW }; break; } hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s { crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }, itu_par = 0, keep = settingMode, maxWidth = job.MaxWidth, maxHeight = job.MaxHeight, mode = (int)job.AnamorphicMode, modulus = job.Modulus.HasValue ? job.Modulus.Value : 16, geometry = new hb_geometry_s { height = job.Height, width = job.Width, par = computed_par } }; hb_geometry_s sourceGeometry = new hb_geometry_s { width = title.Width, height = title.Height, par = new hb_rational_t { den = title.ParH, num = title.ParW } }; hb_geometry_s result = new hb_geometry_s(); IHbFunctionsProvider provider = IoC.Get <IHbFunctionsProvider>(); // TODO make this method non static and remove IoC call. IHbFunctions hbFunctions = provider.GetHbFunctionsWrapper(); hbFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result); int outputWidth = result.width; int outputHeight = result.height; int outputParWidth = result.par.num; int outputParHeight = result.par.den; return(new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight }); }