浏览代码

Add a way to select a compatible hardware decoding mode on OSX

This changes the "hardware_decoding" setting from bool to a selection.
This breaks/discards the old setting. (I had an idea to keep it
compatible, but it seems web-client or maybe something else doesn't
like it at all if a setting in the user's config has the wrong
type, and the UI will basically become unfunctional.)

If users had a "videotoolbox-format" option set in their mpv.conf file,
it will be overwritten. (Which might be annoying for users who needed
this - they will have to explicitly select the mode in the UI after
updating.)

Actually applying the format requires a restart for silly technical
reasons. This can probably be improved later on.
Vincent Lang 9 年之前
父节点
当前提交
37ffa472c3
共有 2 个文件被更改,包括 22 次插入5 次删除
  1. 9 3
      resources/settings/settings_description.json
  2. 13 2
      src/player/PlayerComponent.cpp

+ 9 - 3
resources/settings/settings_description.json

@@ -213,16 +213,22 @@
         "hidden": true
       },
       {
-        "value": "hardware_decoding",
+        "value": "hardwareDecoding",
         "default": [
           {
-            "value": true,
+            "value": "enabled",
             "platforms": [ "oe" ]
           },
           {
-            "value": false
+            "value": "disabled"
           }
         ],
+        "possible_values": [
+          [ "enabled", "Enabled", { "platforms_excluded": "osx" } ],
+          [ "enabled", "Enabled (modern hardware)", { "platforms": "osx" } ],
+          [ "osx_compat", "Enabled (older hardware)", { "platforms": "osx" } ],
+          [ "disabled", "Disabled" ]
+        ],
         "platforms_excluded": "oe_rpi"
       },
       {

+ 13 - 2
src/player/PlayerComponent.cpp

@@ -849,8 +849,19 @@ void PlayerComponent::updateVideoSettings()
 {
   QVariant syncMode = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "sync_mode");
   mpv::qt::set_option_variant(m_mpv, "video-sync", syncMode);
-  QVariant hardwareDecoding = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "hardware_decoding");
-  mpv::qt::set_property_variant(m_mpv, "hwdec", hardwareDecoding.toBool() ? "auto" : "no");
+
+  QString hardwareDecodingMode = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "hardwareDecoding").toString();
+  bool hwdecEnabled = false;
+  QString hwdecVTFormat = "nv12";
+  if (hardwareDecodingMode == "enabled") {
+    hwdecEnabled = true;
+  } else if (hardwareDecodingMode == "osx_compat") {
+    hwdecEnabled = true;
+    hwdecVTFormat = "uyvy422";
+  }
+  mpv::qt::set_property_variant(m_mpv, "hwdec", hwdecEnabled);
+  mpv::qt::set_option_variant(m_mpv, "videotoolbox-format", hwdecVTFormat);
+
   QVariant deinterlace = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "deinterlace");
   mpv::qt::set_option_variant(m_mpv, "deinterlace", deinterlace.toBool() ? "yes" : "no");