浏览代码

feat: add --hwdec CLI option (#670)

枫莹 1 月之前
父节点
当前提交
a76a18af48

+ 1 - 0
README.md

@@ -178,6 +178,7 @@ If you're one of those developers, feel free to open an issue to get your projec
 | `--noautomute` | Don't mute when other apps play audio |
 | `--no-audio-processing` | Disable audio reactive features |
 | `--fps <val>` | Limit frame rate |
+| `--hwdec <mode>` | Set libmpv hardware decoding: `auto`, `nvdec-copy`, or `no` (default: `auto`) |
 | `--window <XxYxWxH>` | Run in windowed mode with custom size/position |
 | `--screen-root <screen>` | Set as background for specific screen |
 | `--screen-span <screen-1>,<screen-2>,...` | Stretch a single wallpaper across multiple screens |

+ 5 - 0
src/WallpaperEngine/Application/ApplicationContext.cpp

@@ -493,6 +493,11 @@ void ApplicationContext::loadSettingsFromArgv () {
 	.default_value (30)
 	.store_into (this->settings.render.maximumFPS);
 
+    performanceGroup.add_argument ("--hwdec")
+	.help ("Selects the libmpv hardware decoder (auto, nvdec-copy, or no). Default: auto")
+	.choices ("auto", "nvdec-copy", "no")
+	.store_into (this->settings.render.hwdec);
+
     performanceGroup.add_argument ("--no-fullscreen-pause")
 	.help ("Prevents the background pausing when an app is fullscreen")
 	.flag ()

+ 3 - 0
src/WallpaperEngine/Application/ApplicationContext.h

@@ -113,6 +113,8 @@ public:
 	    WINDOW_MODE mode;
 	    /** Maximum FPS */
 	    int maximumFPS;
+	    /** Hardware decoder passed to libmpv */
+	    std::string hwdec;
 	    /** Indicates if pausing should happen when something goes fullscreen */
 	    bool pauseOnFullscreen;
 	    /**
@@ -200,6 +202,7 @@ public:
         .render = {
             .mode = NORMAL_WINDOW,
             .maximumFPS = 30,
+            .hwdec = "auto",
             .pauseOnFullscreen = true,
             .pauseOnFullscreenOnlyWhenActive = false,
             .fullscreenPauseIgnoreAppIds = {},

+ 3 - 2
src/WallpaperEngine/VideoPlayback/MPV/GLPlayer.cpp

@@ -234,7 +234,8 @@ void GLPlayer::init () {
     }
 
     // ensure video is muted and plays in a loop
-    mpv_set_property_string (this->m_handle, "hwdec", "auto");
+    const auto& hwdec = this->getContext ().getApp ().getContext ().settings.render.hwdec;
+    mpv_set_property_string (this->m_handle, "hwdec", hwdec.c_str ());
     mpv_set_property_string (this->m_handle, "loop", "inf");
     mpv_set_property (this->m_handle, "volume", MPV_FORMAT_DOUBLE, &this->m_volume);
 
@@ -299,4 +300,4 @@ void GLPlayer::stop () {
 	mpv_terminate_destroy (this->m_handle);
 	this->m_handle = nullptr;
     }
-}
+}