diff options
author | sr55 <[email protected]> | 2021-02-23 19:58:11 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2021-02-23 19:58:40 +0000 |
commit | a829a6f6af9539c34c9865239a54a6e51d7a7c41 (patch) | |
tree | 7dae6027d83566ffa930bd4766e5c87d082916a0 /win/CS | |
parent | d4773a2d2cb59814d2fbede899ac2038ec81288c (diff) |
WinGui: Add support for Media Foundation 264/265 encoders for QC based ARM64 devices. #2887
Diffstat (limited to 'win/CS')
7 files changed, 90 insertions, 23 deletions
diff --git a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs index a469d9ecd..4ea1900ac 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/VideoEncoderConverter.cs @@ -13,6 +13,7 @@ namespace HandBrakeWPF.Converters.Video using System.Collections.Generic;
using System.Globalization;
using System.Linq;
+ using System.Runtime.InteropServices;
using System.Windows.Data;
using HandBrake.Interop.Interop;
@@ -124,6 +125,12 @@ namespace HandBrakeWPF.Converters.Video encoders.Remove(VideoEncoder.NvencH265);
}
+ if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
+ {
+ encoders.Remove(VideoEncoder.MFH264);
+ encoders.Remove(VideoEncoder.MFH265);
+ }
+
return EnumHelper<VideoEncoder>.GetEnumDisplayValuesSubset(encoders);
}
diff --git a/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs b/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs index c3bb59168..9d6fa2971 100644 --- a/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Video/VideoOptionsTooltipConverter.cs @@ -55,6 +55,11 @@ namespace HandBrakeWPF.Converters.Video rfqp = "CQ";
}
+ if (task.VideoEncoder == VideoEncoder.MFH264 || task.VideoEncoder == VideoEncoder.MFH265)
+ {
+ rfqp = "CQ";
+ }
+
string quality = task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality ? string.Format("{0} {1}", task.Quality, rfqp) : string.Format("{0} {1}", task.VideoBitrate, " kbps");
string twoPass = null;
diff --git a/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs b/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs index bee2526c7..7585a6bf7 100644 --- a/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs +++ b/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs @@ -9,15 +9,13 @@ namespace HandBrakeWPF.Helpers { - using System.Configuration; - - using VideoEncoder = HandBrakeWPF.Model.Video.VideoEncoder; + using VideoEncoder = Model.Video.VideoEncoder; public class VideoEncoderHelpers { public static bool IsH264(VideoEncoder encoder) { - if (encoder == VideoEncoder.X264 || encoder == VideoEncoder.X264_10 || encoder == VideoEncoder.QuickSync || encoder == VideoEncoder.NvencH264) + if (encoder == VideoEncoder.X264 || encoder == VideoEncoder.X264_10 || encoder == VideoEncoder.QuickSync || encoder == VideoEncoder.NvencH264 || encoder == VideoEncoder.MFH264) { return true; } diff --git a/win/CS/HandBrakeWPF/Model/Video/VideoEncoder.cs b/win/CS/HandBrakeWPF/Model/Video/VideoEncoder.cs index 799d3403d..f9ffa16f6 100644 --- a/win/CS/HandBrakeWPF/Model/Video/VideoEncoder.cs +++ b/win/CS/HandBrakeWPF/Model/Video/VideoEncoder.cs @@ -35,7 +35,11 @@ namespace HandBrakeWPF.Model.Video [DisplayName("H.264 (Nvidia NVEnc)")] [ShortName("nvenc_h264")] NvencH264, - + + [DisplayName("H.264 (MediaFoundation)")] + [ShortName("mf_h264")] + MFH264, + [DisplayName("MPEG-4")] [ShortName("mpeg4")] FFMpeg, @@ -76,6 +80,10 @@ namespace HandBrakeWPF.Model.Video [ShortName("nvenc_h265")] NvencH265, + [DisplayName("H.265 (MediaFoundation)")] + [ShortName("mf_h265")] + MFH265, + [DisplayName("VP8")] [ShortName("VP8")] VP8, diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index 2d280aad3..11e448c62 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -16,6 +16,7 @@ namespace HandBrakeWPF.Services.Presets using System.ComponentModel;
using System.IO;
using System.Linq;
+ using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Xps.Serialization;
@@ -833,11 +834,6 @@ namespace HandBrakeWPF.Services.Presets private bool IsPresetDisabled(Preset preset)
{
- if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265)
- {
- Console.Write("tets");
- }
-
bool isQsvEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncEncoding);
bool isNvencEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableNvencEncoder);
bool isVcnEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableVceEncoder);
@@ -876,7 +872,15 @@ namespace HandBrakeWPF.Services.Presets {
return true;
}
-
+
+ if (preset.Task.VideoEncoder == VideoEncoder.MFH264 || preset.Task.VideoEncoder == VideoEncoder.MFH265)
+ {
+ if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
+ {
+ return true;
+ }
+ }
+
return false;
}
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueResourceService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueResourceService.cs index eacec676c..a02b7f9b9 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueResourceService.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueResourceService.cs @@ -28,6 +28,7 @@ namespace HandBrakeWPF.Services.Queue private readonly HashSet<Guid> qsvInstances = new HashSet<Guid>(); private readonly HashSet<Guid> nvencInstances = new HashSet<Guid>(); private readonly HashSet<Guid> vceInstances = new HashSet<Guid>(); + private readonly HashSet<Guid> mfInstances = new HashSet<Guid>(); private readonly HashSet<Guid> totalInstances = new HashSet<Guid>(); private List<int> qsvGpus = new List<int>(); @@ -37,6 +38,7 @@ namespace HandBrakeWPF.Services.Queue private int totalQsvInstances; private int totalVceInstances; private int totalNvidiaInstances; + private int totalMfInstances; public QueueResourceService(IUserSettingService userSettingService) { @@ -68,6 +70,8 @@ namespace HandBrakeWPF.Services.Queue // VCE Support still TBD this.totalVceInstances = 3; + this.totalMfInstances = 1; + // Whether using hardware or not, some CPU is needed so don't allow more jobs than CPU. if (this.maxAllowedInstances > Utilities.SystemInfo.GetCpuCoreCount) { @@ -126,6 +130,21 @@ namespace HandBrakeWPF.Services.Queue return Guid.Empty; // Busy } + case VideoEncoder.MFH264: + case VideoEncoder.MFH265: + if (this.mfInstances.Count < this.totalMfInstances && this.TotalActiveInstances <= this.maxAllowedInstances) + { + Guid guid = Guid.NewGuid(); + this.mfInstances.Add(guid); + this.totalInstances.Add(guid); + return guid; + } + else + { + return Guid.Empty; // Busy + } + + default: if (this.TotalActiveInstances <= this.maxAllowedInstances) { @@ -174,7 +193,6 @@ namespace HandBrakeWPF.Services.Queue } break; - case VideoEncoder.VceH264: case VideoEncoder.VceH265: if (this.vceInstances.Contains(unlockKey.Value)) @@ -183,6 +201,14 @@ namespace HandBrakeWPF.Services.Queue } break; + case VideoEncoder.MFH264: + case VideoEncoder.MFH265: + if (this.mfInstances.Contains(unlockKey.Value)) + { + this.mfInstances.Remove(unlockKey.Value); + } + + break; } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 779508839..976ba88e9 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -193,7 +193,9 @@ namespace HandBrakeWPF.ViewModels || this.SelectedVideoEncoder == VideoEncoder.VceH265
|| this.SelectedVideoEncoder == VideoEncoder.QuickSync
|| this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265
- || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b)
+ || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b
+ || this.SelectedVideoEncoder == VideoEncoder.MFH264
+ || this.SelectedVideoEncoder == VideoEncoder.MFH265)
{
return false;
}
@@ -337,6 +339,8 @@ namespace HandBrakeWPF.ViewModels case VideoEncoder.VceH265:
case VideoEncoder.NvencH264:
case VideoEncoder.NvencH265:
+ case VideoEncoder.MFH264:
+ case VideoEncoder.MFH265:
rfValue = 51.0 - value;
rfValue = Math.Round(rfValue, 0);
this.Task.Quality = rfValue;
@@ -442,7 +446,10 @@ namespace HandBrakeWPF.ViewModels }
if (this.SelectedVideoEncoder == VideoEncoder.NvencH264
- || this.SelectedVideoEncoder == VideoEncoder.NvencH265)
+ || this.SelectedVideoEncoder == VideoEncoder.NvencH265
+ || this.SelectedVideoEncoder == VideoEncoder.MFH264
+ || this.SelectedVideoEncoder == VideoEncoder.MFH265
+ )
{
return string.Empty;
}
@@ -600,8 +607,9 @@ namespace HandBrakeWPF.ViewModels && this.SelectedVideoEncoder != VideoEncoder.QuickSyncH265
&& this.SelectedVideoEncoder != VideoEncoder.QuickSyncH26510b
&& this.SelectedVideoEncoder != VideoEncoder.NvencH264
- && this.SelectedVideoEncoder != VideoEncoder.NvencH265;
-
+ && this.SelectedVideoEncoder != VideoEncoder.NvencH265
+ && this.SelectedVideoEncoder != VideoEncoder.MFH264
+ && this.SelectedVideoEncoder != VideoEncoder.MFH265;
}
}
@@ -961,7 +969,8 @@ namespace HandBrakeWPF.ViewModels || preset.Task.VideoEncoder == VideoEncoder.X265 || preset.Task.VideoEncoder == VideoEncoder.X265_10 || preset.Task.VideoEncoder == VideoEncoder.X265_12
|| preset.Task.VideoEncoder == VideoEncoder.QuickSync || preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265 || preset.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b
|| preset.Task.VideoEncoder == VideoEncoder.VceH264 || preset.Task.VideoEncoder == VideoEncoder.VceH265
- || preset.Task.VideoEncoder == VideoEncoder.NvencH264 || preset.Task.VideoEncoder == VideoEncoder.NvencH265)
+ || preset.Task.VideoEncoder == VideoEncoder.NvencH264 || preset.Task.VideoEncoder == VideoEncoder.NvencH265
+ || preset.Task.VideoEncoder == VideoEncoder.MFH264 || preset.Task.VideoEncoder == VideoEncoder.MFH265)
{
this.VideoLevel = preset.Task.VideoLevel != null ? preset.Task.VideoLevel.Clone() : this.VideoLevels.FirstOrDefault();
this.VideoProfile = preset.Task.VideoProfile != null ? preset.Task.VideoProfile.Clone() : this.VideoProfiles.FirstOrDefault();
@@ -1083,7 +1092,8 @@ namespace HandBrakeWPF.ViewModels || this.Task.VideoEncoder == VideoEncoder.X265_12 || this.Task.VideoEncoder == VideoEncoder.QuickSync
|| this.Task.VideoEncoder == VideoEncoder.QuickSyncH265 || this.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b
|| this.Task.VideoEncoder == VideoEncoder.VceH264 || this.Task.VideoEncoder == VideoEncoder.VceH265
- || this.Task.VideoEncoder == VideoEncoder.NvencH264 || this.Task.VideoEncoder == VideoEncoder.NvencH265)
+ || this.Task.VideoEncoder == VideoEncoder.NvencH264 || this.Task.VideoEncoder == VideoEncoder.NvencH265
+ || this.Task.VideoEncoder == VideoEncoder.MFH264 || this.Task.VideoEncoder == VideoEncoder.MFH265)
{
if (!Equals(preset.Task.VideoPreset, this.Task.VideoPreset))
{
@@ -1185,6 +1195,8 @@ namespace HandBrakeWPF.ViewModels case VideoEncoder.VceH265:
case VideoEncoder.NvencH264:
case VideoEncoder.NvencH265:
+ case VideoEncoder.MFH264:
+ case VideoEncoder.MFH265:
this.QualityMin = 0;
this.QualityMax = 51;
break;
@@ -1333,10 +1345,13 @@ namespace HandBrakeWPF.ViewModels case VideoEncoder.VceH265:
case VideoEncoder.NvencH264:
case VideoEncoder.NvencH265:
+ case VideoEncoder.MFH264:
+ case VideoEncoder.MFH265:
if (this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265 || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b
|| this.SelectedVideoEncoder == VideoEncoder.VceH264 || this.SelectedVideoEncoder == VideoEncoder.VceH265
- || this.SelectedVideoEncoder == VideoEncoder.NvencH264 || this.SelectedVideoEncoder == VideoEncoder.NvencH265)
+ || this.SelectedVideoEncoder == VideoEncoder.NvencH264 || this.SelectedVideoEncoder == VideoEncoder.NvencH265
+ || this.SelectedVideoEncoder == VideoEncoder.MFH264 || this.SelectedVideoEncoder == VideoEncoder.MFH265)
{
cqStep = 1;
}
@@ -1468,7 +1483,8 @@ namespace HandBrakeWPF.ViewModels this.SelectedVideoEncoder == VideoEncoder.X265 || this.SelectedVideoEncoder == VideoEncoder.X265_10 || this.SelectedVideoEncoder == VideoEncoder.X265_12 ||
this.SelectedVideoEncoder == VideoEncoder.QuickSync || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH265 || this.SelectedVideoEncoder == VideoEncoder.QuickSyncH26510b ||
this.SelectedVideoEncoder == VideoEncoder.VceH264 || this.SelectedVideoEncoder == VideoEncoder.VceH265 ||
- this.SelectedVideoEncoder == VideoEncoder.NvencH264 || this.SelectedVideoEncoder == VideoEncoder.NvencH265;
+ this.SelectedVideoEncoder == VideoEncoder.NvencH264 || this.SelectedVideoEncoder == VideoEncoder.NvencH265 ||
+ this.SelectedVideoEncoder == VideoEncoder.MFH264 || this.SelectedVideoEncoder == VideoEncoder.MFH265;
this.DisplayFastDecode = this.SelectedVideoEncoder == VideoEncoder.X264 || this.SelectedVideoEncoder == VideoEncoder.X264_10;
this.NotifyOfPropertyChange(() => this.DisplayFastDecode);
@@ -1489,7 +1505,9 @@ namespace HandBrakeWPF.ViewModels || this.SelectedVideoEncoder == VideoEncoder.VceH264
|| this.SelectedVideoEncoder == VideoEncoder.VceH265
|| this.SelectedVideoEncoder == VideoEncoder.NvencH264
- || this.SelectedVideoEncoder == VideoEncoder.NvencH265;
+ || this.SelectedVideoEncoder == VideoEncoder.NvencH265
+ || this.SelectedVideoEncoder == VideoEncoder.MFH264
+ || this.SelectedVideoEncoder == VideoEncoder.MFH265;
// Refresh Display
this.NotifyOfPropertyChange(() => this.Rfqp);
@@ -1507,7 +1525,9 @@ namespace HandBrakeWPF.ViewModels if (selectedEncoder == VideoEncoder.NvencH264 || selectedEncoder == VideoEncoder.NvencH265
|| selectedEncoder == VideoEncoder.VceH264
- || selectedEncoder == VideoEncoder.VceH265)
+ || selectedEncoder == VideoEncoder.VceH265
+ || selectedEncoder == VideoEncoder.MFH264
+ || selectedEncoder == VideoEncoder.MFH265)
{
this.TwoPass = false;
this.TurboFirstPass = false;
@@ -1537,7 +1557,6 @@ namespace HandBrakeWPF.ViewModels // Override for NVEnc
if (selectedEncoder == VideoEncoder.NvencH264 || selectedEncoder == VideoEncoder.NvencH265)
{
- // TODO -> is the RTX good enough to default to a more balanced preset?
defaultPreset = this.VideoPresets.IndexOf(this.VideoPresets.FirstOrDefault(s => s.ShortName == "slow"));
}
|