Browse Source

Add PHT-style aspect setting

Very unsure about this. One problem is that it interferes with some
useful settings (like setting panscan to anything between 0 and 1). The
"custom" mode stops PMP itself from overwriting these mpv settings, but
it can't restore them at runtime. (Read: if users want to do custom
stuff with mpv.conf, they need to set aspect to "custom", and then
restart PMP.)
Vincent Lang 8 years ago
parent
commit
97e1573758

+ 1 - 0
resources/inputmaps/keyboard.json

@@ -57,6 +57,7 @@
     "I": "host:toggleDebug",
     "W": "toggle_watched",
     "\\\\": "host:fullscreen",
+    "Z": "host:cycle_setting video.aspect",
 
     // media keys from the FLIRC and on Linux keyboards
     "Toggle Media Play\\/Pause": "play_pause",

+ 13 - 0
resources/settings/settings_description.json

@@ -282,6 +282,19 @@
           [ 150, "Large (150 MB)", { "platforms_excluded": "oe_rpi" } ],
           [ 500, "Very Large (500 MB)", { "platforms_excluded": "oe_rpi" } ]
         ]
+      },
+      {
+        "value": "aspect",
+        "default": "normal",
+        "possible_values": [
+          [ "normal", "Display normally" ],
+          [ "zoom", "Zoom (can crop off video)" ],
+          [ "force_4_3", "Force video to 4:3" ],
+          [ "force_16_9", "Force video to 16:9" ],
+          [ "stretch", "Stretch video to screen" ],
+          [ "noscaling", "Disable all scaling" ],
+          [ "custom", "Custom" ]
+        ]
       }
     ]
   },

+ 42 - 0
src/player/PlayerComponent.cpp

@@ -844,6 +844,46 @@ void PlayerComponent::updateSubtitleSettings()
   }
 }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+void PlayerComponent::updateVideoAspectSettings()
+{
+  QVariant mode = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "aspect").toString();
+  bool disableScaling = false;
+  bool keepAspect = true;
+  QString forceAspect = "-1";
+  double panScan = 0.0;
+  if (mode == "custom")
+  {
+    // in particular, do not restore anything - the intention is not to touch the user's mpv.conf settings, or whatever
+    return;
+  }
+  else if (mode == "zoom")
+  {
+    panScan = 1.0;
+  }
+  else if (mode == "force_4_3")
+  {
+    forceAspect = "4:3";
+  }
+  else if (mode == "force_16_9")
+  {
+    forceAspect = "16:9";
+  }
+  else if (mode == "stretch")
+  {
+    keepAspect = false;
+  }
+  else if (mode == "noscaling")
+  {
+    disableScaling = true;
+  }
+
+  mpv::qt::set_property_variant(m_mpv, "video-unscaled", disableScaling);
+  mpv::qt::set_property_variant(m_mpv, "video-aspect", forceAspect);
+  mpv::qt::set_option_variant(m_mpv, "keepaspect", keepAspect);
+  mpv::qt::set_property_variant(m_mpv, "panscan", panScan);
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 void PlayerComponent::updateVideoSettings()
 {
@@ -874,6 +914,8 @@ void PlayerComponent::updateVideoSettings()
 
   QVariant cache = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "cache");
   mpv::qt::set_option_variant(m_mpv, "cache", cache.toInt() * 1024);
+
+  updateVideoAspectSettings();
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////

+ 1 - 0
src/player/PlayerComponent.h

@@ -188,6 +188,7 @@ private:
   // Determine the required codecs and possibly download them.
   // Call resume() when done.
   void startCodecsLoading(std::function<void()> resume);
+  void updateVideoAspectSettings();
 
   mpv::qt::Handle m_mpv;