From cc3c2ad8fb5c12a22f220a9191e4d9b563532e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 13 Aug 2023 17:20:03 +0200 Subject: stats.lua: display output resolution if it differs to native one Useful when filters are applied that alters the video resolution, like crop. Also display aspect ratio per each resolution. --- player/lua/stats.lua | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'player/lua/stats.lua') diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 46cf81e434..bcfd29e9dd 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -670,11 +670,29 @@ local function add_file(s) end +local function append_resolution(s, r, prefix) + if not r then + return + end + if append(s, r["w"], {prefix=prefix}) then + append(s, r["h"], {prefix="x", nl="", indent=" ", prefix_sep=" ", + no_prefix_markup=true}) + if r["aspect"] ~= nil then + append(s, format("%.2f:1", r["aspect"]), {prefix=", ", nl="", indent="", + no_prefix_markup=true}) + append(s, r["aspect-name"], {prefix="(", suffix=")", nl="", indent=" ", + prefix_sep="", no_prefix_markup=true}) + end + end +end + + local function add_video(s) local r = mp.get_property_native("video-params") + local ro = mp.get_property_native("video-out-params") -- in case of e.g. lavfi-complex there can be no input video, only output if not r then - r = mp.get_property_native("video-out-params") + r = ro end if not r then return @@ -712,20 +730,14 @@ local function add_video(s) append_display_sync(s) append_perfdata(s, o.print_perfdata_passes) - if append(s, r["w"], {prefix="Native Resolution:"}) then - append(s, r["h"], {prefix="x", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true}) - end - if append(s, scaled_width, {prefix="Scaled Resolution:"}) then - append(s, scaled_height, {prefix="x", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true}) + append_resolution(s, r, "Native Resolution:") + if ro and (r["w"] ~= ro["w"] or r["h"] ~= ro["h"]) then + append_resolution(s, ro, "Output Resolution:") end + append_resolution(s, {w=scaled_width, h=scaled_height}, "Scaled Resolution:") if not mp.get_property_native("fullscreen") then append_property(s, "current-window-scale", {prefix="Window Scale:"}) end - if r["aspect"] ~= nil then - append(s, format("%.2f:1", r["aspect"]), {prefix="Aspect Ratio:"}) - append(s, r["aspect-name"], {prefix="(", suffix=")", nl="", indent=" ", - prefix_sep="", no_prefix_markup=true}) - end append(s, r["pixelformat"], {prefix="Pixel Format:"}) if r["hw-pixelformat"] ~= nil then append(s, r["hw-pixelformat"], {prefix_sep="[", nl="", indent=" ", -- cgit v1.2.3