diff options
author | sr55 <[email protected]> | 2021-04-13 20:41:47 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2021-04-13 20:42:02 +0100 |
commit | 110f6b0ed3b3f76ab09ca575d024d99f1b8efe75 (patch) | |
tree | 787fb9ee6a7d99f33db3f38b1d847854dc798e94 /win/CS/HandBrakeWPF | |
parent | 4a4054f452defe76cd9a3735a1c5afd1fa39ddbc (diff) |
WinGui: use new api hb_get_preview3 for previews.
Diffstat (limited to 'win/CS/HandBrakeWPF')
10 files changed, 29 insertions, 75 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 062b3868f..5e8583f13 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -5923,15 +5923,6 @@ namespace HandBrakeWPF.Properties { } /// <summary> - /// Looks up a localized string similar to Preview Rotation and Flip. - /// </summary> - public static string StaticPreviewView_PreviewRotationFlip { - get { - return ResourceManager.GetString("StaticPreviewView_PreviewRotationFlip", resourceCulture); - } - } - - /// <summary> /// Looks up a localized string similar to Select a preview image. /// </summary> public static string StaticPreviewView_SelectPreviewImage { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 943cd4d64..0511fc009 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -2023,9 +2023,6 @@ Where supported, any user presets will have been imported.</value> <data name="MetadataView_TitleTag" xml:space="preserve">
<value>Title:</value>
</data>
- <data name="StaticPreviewView_PreviewRotationFlip" xml:space="preserve">
- <value>Preview Rotation and Flip</value>
- </data>
<data name="LogViewModel_Title" xml:space="preserve">
<value>Log Viewer</value>
</data>
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs index d8d8e4399..4e178ed92 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs @@ -19,21 +19,24 @@ namespace HandBrakeWPF.Services.Scan using HandBrake.Interop.Interop.Interfaces.Model; using HandBrake.Interop.Interop.Interfaces.Model.Picture; using HandBrake.Interop.Interop.Interfaces.Model.Preview; + using HandBrake.Interop.Interop.Json.Encode; using HandBrake.Interop.Interop.Json.Scan; + using HandBrakeWPF.Factories; using HandBrakeWPF.Instance; using HandBrakeWPF.Model.Filters; + using HandBrakeWPF.Services.Encode.Factories; using HandBrakeWPF.Services.Encode.Model; using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.Services.Logging.Interfaces; using HandBrakeWPF.Services.Scan.EventArgs; using HandBrakeWPF.Services.Scan.Factories; using HandBrakeWPF.Services.Scan.Interfaces; - using HandBrakeWPF.Services.Scan.Model; using HandBrakeWPF.Utilities; using ILog = Logging.Interfaces.ILog; using ScanProgressEventArgs = HandBrake.Interop.Interop.Interfaces.EventArgs.ScanProgressEventArgs; + using Source = HandBrakeWPF.Services.Scan.Model.Source; using Title = Model.Title; public class LibScan : IScan, IDisposable @@ -172,22 +175,9 @@ namespace HandBrakeWPF.Services.Scan BitmapImage bitmapImage = null; try { - 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 - }; - - RawPreviewData bitmapData = this.instance.GetPreview(settings, preview, job.DeinterlaceFilter != DeinterlaceFilter.Off); + EncodeTaskFactory factory = new EncodeTaskFactory(this.userSettingService); + JsonEncodeObject jobDict = factory.Create(job, HBConfigurationFactory.Create()); + RawPreviewData bitmapData = this.instance.GetPreview(jobDict, preview); bitmapImage = BitmapUtilities.ConvertToBitmapImage(BitmapUtilities.ConvertByteArrayToBitmap(bitmapData)); } catch (AccessViolationException e) diff --git a/win/CS/HandBrakeWPF/Services/UserSettingService.cs b/win/CS/HandBrakeWPF/Services/UserSettingService.cs index 9923482e6..90dcf04bc 100644 --- a/win/CS/HandBrakeWPF/Services/UserSettingService.cs +++ b/win/CS/HandBrakeWPF/Services/UserSettingService.cs @@ -313,7 +313,6 @@ namespace HandBrakeWPF.Services defaults.Add(UserSettingConstants.ClearOldLogs, true);
// Preview
- defaults.Add(UserSettingConstants.PreviewRotationFlip, false);
defaults.Add(UserSettingConstants.LastPreviewDuration, 30);
defaults.Add(UserSettingConstants.DefaultPlayer, false);
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index b01d6fb7b..55cd94c9b 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -71,7 +71,6 @@ namespace HandBrakeWPF public const string AutonameFilePrePostString = "AutonameFilePrePostString";
public const string WhenDonePerformActionImmediately = "WhenDonePerformActionImmediately";
public const string DarkThemeMode = "DarkThemeMode";
- public const string PreviewRotationFlip = "PreviewRotationFlip";
public const string AlwaysUseDefaultPath = "AlwaysUseDefaultPath";
public const string PauseEncodingOnLowBattery = "PauseEncodingOnLowBattery";
public const string LowBatteryLevel = "LowBatteryLevel";
diff --git a/win/CS/HandBrakeWPF/ViewModelItems/Filters/PadFilter.cs b/win/CS/HandBrakeWPF/ViewModelItems/Filters/PadFilter.cs index 5b268c2c0..108df0e8a 100644 --- a/win/CS/HandBrakeWPF/ViewModelItems/Filters/PadFilter.cs +++ b/win/CS/HandBrakeWPF/ViewModelItems/Filters/PadFilter.cs @@ -96,6 +96,7 @@ namespace HandBrakeWPF.ViewModelItems.Filters this.customColour = value; this.SetColour(); this.NotifyOfPropertyChange(() => this.CustomColour); + this.triggerTabChanged(); } } diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index 0f2cc4461..e7dad4e24 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -9,18 +9,9 @@ namespace HandBrakeWPF.ViewModels
{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Globalization;
- using System.Linq;
- using System.Windows;
-
using Caliburn.Micro;
-
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.Interfaces.Model.Picture;
-
using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Model.Picture;
using HandBrakeWPF.Properties;
@@ -30,7 +21,12 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.ViewModelItems.Filters;
using HandBrakeWPF.ViewModels.Interfaces;
using HandBrakeWPF.Views;
-
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+ using System.Windows;
using EncodeTask = Services.Encode.Model.EncodeTask;
using Size = Model.Picture.Size;
@@ -62,8 +58,8 @@ namespace HandBrakeWPF.ViewModels this.StaticPreviewViewModel.SetPictureSettingsInstance(this);
this.sourceResolution = new Size(0, 0);
this.Task = new EncodeTask();
- this.PaddingFilter = new PadFilter(this.Task, () => this.OnTabStatusChanged(null));
- this.RotateFlipFilter = new RotateFlipFilter(this.Task, () => this.OnTabStatusChanged(null));
+ this.PaddingFilter = new PadFilter(this.Task, () => this.OnFilterChanged(null));
+ this.RotateFlipFilter = new RotateFlipFilter(this.Task, () => this.OnFilterChanged(null));
this.Init();
}
@@ -257,6 +253,8 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.MaxWidth);
this.NotifyOfPropertyChange(() => this.MaxHeight);
+
+ this.OnTabStatusChanged(null);
}
}
@@ -690,6 +688,16 @@ namespace HandBrakeWPF.ViewModels this.TabStatusChanged?.Invoke(this, e);
}
+ protected virtual void OnFilterChanged(TabStatusEventArgs e)
+ {
+ if (delayedPreviewprocessor != null && this.Task != null && this.StaticPreviewViewModel != null && this.StaticPreviewViewModel.IsOpen)
+ {
+ delayedPreviewprocessor.PerformTask(() => this.StaticPreviewViewModel.UpdatePreviewFrame(this.Task, this.scannedSource), 800);
+ }
+
+ this.TabStatusChanged?.Invoke(this, e);
+ }
+
private void Init()
{
this.Task.Modulus = 16;
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs index 340090bd5..18facc3e7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -59,8 +59,6 @@ namespace HandBrakeWPF.ViewModels private double percentageValue;
private bool isEncoding;
private bool useSystemDefaultPlayer;
- private bool previewRotateFlip;
-
private bool showPictureSettingControls;
public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService, IErrorService errorService, ILog logService, ILogInstanceManager logInstanceManager, IPortService portService)
@@ -86,8 +84,6 @@ namespace HandBrakeWPF.ViewModels this.useSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);
this.showPictureSettingControls = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreviewShowPictureSettingsOverlay);
this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration);
- this.previewRotateFlip = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreviewRotationFlip);
- this.NotifyOfPropertyChange(() => this.previewRotateFlip); // Don't want to trigger an Update, so setting the backing variable.
}
public IPictureSettingsViewModel PictureSettingsViewModel { get; private set; }
@@ -146,24 +142,6 @@ namespace HandBrakeWPF.ViewModels }
}
- public bool PreviewRotateFlip
- {
- get => this.previewRotateFlip;
- set
- {
- if (value == this.previewRotateFlip)
- {
- return;
- }
-
- this.previewRotateFlip = value;
- this.NotifyOfPropertyChange(() => this.PreviewRotateFlip);
-
- this.UpdatePreviewFrame();
- this.userSettingService.SetUserSetting(UserSettingConstants.PreviewRotationFlip, value);
- }
- }
-
public EncodeTask Task { get; set; }
public Source ScannedSource { get; set; }
@@ -370,11 +348,6 @@ namespace HandBrakeWPF.ViewModels if (image != null)
{
- if (previewRotateFlip)
- {
- image = BitmapHelpers.CreateTransformedBitmap(image, this.Task.Rotation, this.Task.FlipVideo);
- }
-
PreviewNotAvailable = false;
this.Width = (int)Math.Ceiling(image.Width);
this.Height = (int)Math.Ceiling(image.Height);
diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs index 3e0655ed3..90c97a096 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs @@ -742,8 +742,6 @@ namespace HandBrakeWPF.ViewModels if (image != null) { - image = BitmapHelpers.CreateTransformedBitmap(image, this.task.Rotation, this.task.FlipVideo); - this.PreviewNotAvailable = false; this.PreviewImage = image; this.MaxWidth = (int)image.Width; diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml index 699f802cb..959643c98 100644 --- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml @@ -52,9 +52,7 @@ Background="Transparent" TickPlacement="TopLeft" Margin="0,0,0,5" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
- <CheckBox IsChecked="{Binding PreviewRotateFlip}" Content="{x:Static Properties:Resources.StaticPreviewView_PreviewRotationFlip}" Foreground="White" Margin="0,0,0,10" />
- <CheckBox IsChecked="{Binding ShowPictureSettingControls}" Content="{x:Static Properties:Resources.StaticPreviewView_ShowPictureSettingsAdjustment}" Foreground="White" Margin="10,0,0,10" />
-
+ <CheckBox IsChecked="{Binding ShowPictureSettingControls}" Content="{x:Static Properties:Resources.StaticPreviewView_ShowPictureSettingsAdjustment}" Foreground="White" Margin="0,0,0,10" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Left">
|