From e9675bb9da88b73269fd26620e6a95922433fb0e Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 18 Mar 2020 21:12:02 +0000 Subject: [PATCH] WinGui: Fix preview images for "None" when using anamorphic content. (cherry picked from commit 9541cabae0954244b3a4dab53a99830604d97719) --- .../Interop/HandBrakeInstance.cs | 4 +--- win/CS/HandBrakeWPF/Helpers/PictureSize.cs | 17 ++++++++++++++++- .../ViewModels/PictureSettingsViewModel.cs | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs index 34997f0ce..3b1295c89 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs @@ -217,9 +217,7 @@ namespace HandBrake.Interop.Interop { height = settings.Height, width = settings.Width, - par = settings.Anamorphic != Anamorphic.Custom && settings.Anamorphic != Anamorphic.Automatic - ? new hb_rational_t { den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num } - : new hb_rational_t { den = settings.PixelAspectY, num = settings.PixelAspectX } + par = new hb_rational_t { den = settings.PixelAspectY, num = settings.PixelAspectX } } }; diff --git a/win/CS/HandBrakeWPF/Helpers/PictureSize.cs b/win/CS/HandBrakeWPF/Helpers/PictureSize.cs index 553978e50..b34498348 100644 --- a/win/CS/HandBrakeWPF/Helpers/PictureSize.cs +++ b/win/CS/HandBrakeWPF/Helpers/PictureSize.cs @@ -181,6 +181,21 @@ namespace HandBrakeWPF.Helpers { 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 }, @@ -190,7 +205,7 @@ namespace HandBrakeWPF.Helpers 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 } } + geometry = new hb_geometry_s { height = job.Height, width = job.Width, par = computed_par } }; hb_geometry_s sourceGeometry = new hb_geometry_s diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index 3ee12fa6d..c8b85d7e6 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -924,8 +924,8 @@ namespace HandBrakeWPF.ViewModels Height = this.Height, ItuPar = false, Modulus = this.SelectedModulus, - ParW = this.ParWidth, - ParH = this.ParHeight, + ParW = this.SelectedAnamorphicMode == Anamorphic.None ? 1 : this.ParWidth, + ParH = this.SelectedAnamorphicMode == Anamorphic.None ? 1 : this.ParHeight, MaxWidth = this.MaxWidth, MaxHeight = this.MaxHeight, KeepDisplayAspect = this.MaintainAspectRatio,