From 659c52cb3ce465139f4de7f8fa3ed85cc5f70d9d Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 13 Sep 2026 11:01:34 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxyForge/ProxyForgeSettings.cs | 103 +++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 ProxyForge/ProxyForgeSettings.cs diff --git a/ProxyForge/ProxyForgeSettings.cs b/ProxyForge/ProxyForgeSettings.cs new file mode 100644 index 0000000..afe6fbb --- /dev/null +++ b/ProxyForge/ProxyForgeSettings.cs @@ -0,0 +1,103 @@ +using ProxyForge.Cache; +using ProxyForge.Encoding; +using YukkuriMovieMaker.Plugin; + +namespace ProxyForge; + +internal sealed class ProxyForgeSettings : SettingsBase +{ + public const int MinimumScale = ProxyGeometryCalculator.MinimumScale; + public const int MaximumScale = ProxyGeometryCalculator.MaximumScale; + public const int MinimumFileSizeMegabytesLowerBound = 1; + public const int MinimumFileSizeMegabytesUpperBound = 100_000; + public const int MinimumBitrateScale = 1; + public const int MaximumBitrateScale = 200; + public const int MinimumKeyFrameInterval = 1; + public const int MaximumKeyFrameInterval = 300; + public const int MinimumCacheLimitGigabytes = 1; + public const int MaximumCacheLimitGigabytes = 1024; + const long BytesPerMegabyte = 1024L * 1024L; + const long BytesPerGigabyte = 1024L * 1024L * 1024L; + + bool isEnabled = true; + bool generatesAutomatically = true; + int scale = 50; + int minimumFileSizeMegabytes = 100; + int bitrateScale = 50; + int keyFrameInterval = 30; + bool usesHardwareEncoder = true; + int cacheLimitGigabytes = 10; + bool showsProgressWindow = true; + + public override SettingsCategory Category => SettingsCategory.VideoFileSource; + + public override string Name => Texts.ProxyForge; + + public override bool HasSettingView => false; + + public override object? SettingView => null; + + public bool IsEnabled + { + get => isEnabled; + set => Set(ref isEnabled, value); + } + + public bool GeneratesAutomatically + { + get => generatesAutomatically; + set => Set(ref generatesAutomatically, value); + } + + public int Scale + { + get => scale; + set => Set(ref scale, Math.Clamp(value, MinimumScale, MaximumScale)); + } + + public int MinimumFileSizeMegabytes + { + get => minimumFileSizeMegabytes; + set => Set(ref minimumFileSizeMegabytes, Math.Clamp(value, MinimumFileSizeMegabytesLowerBound, MinimumFileSizeMegabytesUpperBound)); + } + + public int BitrateScale + { + get => bitrateScale; + set => Set(ref bitrateScale, Math.Clamp(value, MinimumBitrateScale, MaximumBitrateScale)); + } + + public int KeyFrameInterval + { + get => keyFrameInterval; + set => Set(ref keyFrameInterval, Math.Clamp(value, MinimumKeyFrameInterval, MaximumKeyFrameInterval)); + } + + public bool UsesHardwareEncoder + { + get => usesHardwareEncoder; + set => Set(ref usesHardwareEncoder, value); + } + + public int CacheLimitGigabytes + { + get => cacheLimitGigabytes; + set + { + if (Set(ref cacheLimitGigabytes, Math.Clamp(value, MinimumCacheLimitGigabytes, MaximumCacheLimitGigabytes))) + ApplyCacheLimit(); + } + } + + public bool ShowsProgressWindow + { + get => showsProgressWindow; + set => Set(ref showsProgressWindow, value); + } + + public long MinimumFileSizeBytes => minimumFileSizeMegabytes * BytesPerMegabyte; + + public override void Initialize() => ApplyCacheLimit(); + + void ApplyCacheLimit() => ProxyCache.Shared.LimitBytes = cacheLimitGigabytes * BytesPerGigabyte; +}