From 5b35c03bc51349dc20b6231b235738ba64e28cd0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Fri, 2 Feb 2024 09:43:46 +0100 Subject: [PATCH] Add MPV deinterlace filter setting Fix #601 --- .../Exporters/AdvancedSettingsGroupExporter.swift | 1 + .../Importers/AdvancedSettingsGroupImporter.swift | 4 ++++ Model/Player/Backends/MPVClient.swift | 1 + Shared/Defaults.swift | 1 + Shared/Settings/AdvancedSettings.swift | 3 +++ 5 files changed, 10 insertions(+) diff --git a/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift b/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift index 17e7fa7d..8c2e82a4 100644 --- a/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift +++ b/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift @@ -9,6 +9,7 @@ final class AdvancedSettingsGroupExporter: SettingsGroupExporter { "mpvEnableLogging": Defaults[.mpvEnableLogging], "mpvCacheSecs": Defaults[.mpvCacheSecs], "mpvCachePauseWait": Defaults[.mpvCachePauseWait], + "mpvDeinterlace": Defaults[.mpvDeinterlace], "showCacheStatus": Defaults[.showCacheStatus], "feedCacheSize": Defaults[.feedCacheSize] ] diff --git a/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift b/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift index 0ca6aa98..3578f8d8 100644 --- a/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift +++ b/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift @@ -25,6 +25,10 @@ struct AdvancedSettingsGroupImporter { Defaults[.mpvCachePauseWait] = mpvCachePauseWait } + if let mpvDeinterlace = json["mpvDeinterlace"].bool { + Defaults[.mpvDeinterlace] = mpvDeinterlace + } + if let showCacheStatus = json["showCacheStatus"].bool { Defaults[.showCacheStatus] = showCacheStatus } diff --git a/Model/Player/Backends/MPVClient.swift b/Model/Player/Backends/MPVClient.swift index 9b51f54a..f42b840a 100644 --- a/Model/Player/Backends/MPVClient.swift +++ b/Model/Player/Backends/MPVClient.swift @@ -67,6 +67,7 @@ final class MPVClient: ObservableObject { checkError(mpv_set_option_string(mpv, "hwdec", machine == "x86_64" ? "no" : "auto-safe")) checkError(mpv_set_option_string(mpv, "vo", "libmpv")) checkError(mpv_set_option_string(mpv, "demuxer-lavf-analyzeduration", "1")) + checkError(mpv_set_option_string(mpv, "deinterlace", Defaults[.mpvDeinterlace] ? "yes" : "no")) checkError(mpv_initialize(mpv)) diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 818e2b2d..2f5ed116 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -257,6 +257,7 @@ extension Defaults.Keys { static let mpvEnableLogging = Key("mpvEnableLogging", default: false) static let mpvCacheSecs = Key("mpvCacheSecs", default: "120") static let mpvCachePauseWait = Key("mpvCachePauseWait", default: "3") + static let mpvDeinterlace = Key("mpvDeinterlace", default: false) static let showCacheStatus = Key("showCacheStatus", default: false) static let feedCacheSize = Key("feedCacheSize", default: "50") diff --git a/Shared/Settings/AdvancedSettings.swift b/Shared/Settings/AdvancedSettings.swift index 555e061d..d711ae2d 100644 --- a/Shared/Settings/AdvancedSettings.swift +++ b/Shared/Settings/AdvancedSettings.swift @@ -5,6 +5,7 @@ struct AdvancedSettings: View { @Default(.showMPVPlaybackStats) private var showMPVPlaybackStats @Default(.mpvCacheSecs) private var mpvCacheSecs @Default(.mpvCachePauseWait) private var mpvCachePauseWait + @Default(.mpvDeinterlace) private var mpvDeinterlace @Default(.mpvEnableLogging) private var mpvEnableLogging @Default(.showCacheStatus) private var showCacheStatus @Default(.feedCacheSize) private var feedCacheSize @@ -87,6 +88,8 @@ struct AdvancedSettings: View { } .multilineTextAlignment(.trailing) + Toggle("deinterlace", isOn: $mpvDeinterlace) + if mpvEnableLogging { logButton }