From 95a7f638ad658a7fe3c37200f6dd877a32df5f72 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 25 Oct 2014 17:50:08 +0000 Subject: WinGui: Fix for quality slider on queue edit. Was not updating correctly. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6468 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 115 +++++++++++++---------- 1 file changed, 66 insertions(+), 49 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index aff9d6101..41371e99d 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -1108,55 +1108,8 @@ namespace HandBrakeWPF.ViewModels break; } - double cqStep = userSettingService.GetUserSetting(UserSettingConstants.X264Step); - double rfValue = 0; - this.SetQualitySliderBounds(); - switch (this.SelectedVideoEncoder) - { - case VideoEncoder.FFMpeg: - case VideoEncoder.FFMpeg2: - if (preset.Task.Quality.HasValue) - { - int cq; - int.TryParse(preset.Task.Quality.Value.ToString(CultureInfo.InvariantCulture), out cq); - this.RF = 32 - cq; - } - break; - case VideoEncoder.VP8: - if (preset.Task.Quality.HasValue) - { - int cq; - int.TryParse(preset.Task.Quality.Value.ToString(CultureInfo.InvariantCulture), out cq); - this.RF = 63 - cq; - } - break; - case VideoEncoder.X265: - case VideoEncoder.X264: - case VideoEncoder.QuickSync: - - if (this.SelectedVideoEncoder == VideoEncoder.QuickSync) - { - cqStep = 1; - } - double multiplier = 1.0 / cqStep; - if (preset.Task.Quality.HasValue) - { - rfValue = preset.Task.Quality.Value * multiplier; - } - - this.RF = this.QualityMax - (int)Math.Round(rfValue, 0); - - break; - - case VideoEncoder.Theora: - - if (preset.Task.Quality.HasValue) - { - this.RF = (int)preset.Task.Quality.Value; - } - break; - } - + this.SetRF(preset.Task.Quality); + this.TwoPass = preset.Task.TwoPass; this.TurboFirstPass = preset.Task.TurboFirstPass; this.Task.VideoBitrate = preset.Task.VideoBitrate; @@ -1234,15 +1187,21 @@ namespace HandBrakeWPF.ViewModels public void UpdateTask(EncodeTask task) { this.Task = task; + this.SetRF(task.Quality); + this.NotifyOfPropertyChange(() => this.IsConstantFramerate); this.NotifyOfPropertyChange(() => this.IsConstantQuantity); this.NotifyOfPropertyChange(() => this.IsPeakFramerate); this.NotifyOfPropertyChange(() => this.IsVariableFramerate); this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder); this.NotifyOfPropertyChange(() => this.SelectedFramerate); + this.NotifyOfPropertyChange(() => this.QualityMax); + this.NotifyOfPropertyChange(() => this.QualityMin); this.NotifyOfPropertyChange(() => this.RF); this.NotifyOfPropertyChange(() => this.DisplayRF); + this.NotifyOfPropertyChange(() => this.IsLossless); this.NotifyOfPropertyChange(() => this.Task.VideoBitrate); + this.NotifyOfPropertyChange(() => this.Task.Quality); this.NotifyOfPropertyChange(() => this.Task.TwoPass); this.NotifyOfPropertyChange(() => this.Task.TurboFirstPass); @@ -1436,5 +1395,63 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.ShowAdvancedTab); } } + + /// + /// The set rf. + /// + /// + /// The quality. + /// + private void SetRF(double? quality) + { + double cqStep = userSettingService.GetUserSetting(UserSettingConstants.X264Step); + double rfValue = 0; + this.SetQualitySliderBounds(); + switch (this.SelectedVideoEncoder) + { + case VideoEncoder.FFMpeg: + case VideoEncoder.FFMpeg2: + if (quality.HasValue) + { + int cq; + int.TryParse(quality.Value.ToString(CultureInfo.InvariantCulture), out cq); + this.RF = 32 - cq; + } + break; + case VideoEncoder.VP8: + if (quality.HasValue) + { + int cq; + int.TryParse(quality.Value.ToString(CultureInfo.InvariantCulture), out cq); + this.RF = 63 - cq; + } + break; + case VideoEncoder.X265: + case VideoEncoder.X264: + case VideoEncoder.QuickSync: + + if (this.SelectedVideoEncoder == VideoEncoder.QuickSync) + { + cqStep = 1; + } + double multiplier = 1.0 / cqStep; + if (quality.HasValue) + { + rfValue = quality.Value * multiplier; + } + + this.RF = this.QualityMax - (int)Math.Round(rfValue, 0); + + break; + + case VideoEncoder.Theora: + + if (quality.HasValue) + { + this.RF = (int)quality.Value; + } + break; + } + } } } \ No newline at end of file -- cgit v1.2.3