summaryrefslogtreecommitdiffstats
path: root/player/lua/stats.lua
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-08-31 23:57:51 +0200
committerDudemanguy <random342@airmail.cc>2023-09-08 02:27:08 +0000
commitff7da2f5c0ec0bded0c843c04cdbe1adba976a45 (patch)
treef54b93e2dcfee73246d77d2eda8c8dfcdb6f0145 /player/lua/stats.lua
parent96c16625746c3253f47a3ad66e8455fcf2063f46 (diff)
downloadmpv-ff7da2f5c0ec0bded0c843c04cdbe1adba976a45.tar.bz2
mpv-ff7da2f5c0ec0bded0c843c04cdbe1adba976a45.tar.xz
stats.lua: don't display full frame crop
It is valid to have 0x0+w+h crop, but no need to print that.
Diffstat (limited to 'player/lua/stats.lua')
-rw-r--r--player/lua/stats.lua28
1 files changed, 23 insertions, 5 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 0c6c2e2240..28a0151eae 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -673,7 +673,19 @@ local function add_file(s)
end
-local function append_resolution(s, r, prefix, w_prop, h_prop)
+local function crop_noop(w, h, r)
+ return r["crop-x"] == 0 and r["crop-y"] == 0 and
+ r["crop-w"] == w and r["crop-h"] == h
+end
+
+
+local function crop_equal(r, ro)
+ return r["crop-x"] == ro["crop-x"] and r["crop-y"] == ro["crop-y"] and
+ r["crop-w"] == ro["crop-w"] and r["crop-h"] == ro["crop-h"]
+end
+
+
+local function append_resolution(s, r, prefix, w_prop, h_prop, video_res)
if not r then
return
end
@@ -693,9 +705,12 @@ local function append_resolution(s, r, prefix, w_prop, h_prop)
indent=" ", prefix_sep="",
no_prefix_markup=true})
end
- if r["crop-w"] and r["crop-w"] > 0 then
- append(s, format("[x: %d, y: %d, w: %d, h: %d]", r["crop-x"], r["crop-y"], r["crop-w"],
- r["crop-h"]), {prefix=", ", nl="", indent="", no_prefix_markup=true})
+ -- We can skip crop if it is the same as video decoded resolution
+ if r["crop-w"] and (not video_res or
+ not crop_noop(r[w_prop], r[h_prop], r)) then
+ append(s, format("[x: %d, y: %d, w: %d, h: %d]",
+ r["crop-x"], r["crop-y"], r["crop-w"], r["crop-h"]),
+ {prefix=", ", nl="", indent="", no_prefix_markup=true})
end
end
end
@@ -804,8 +819,11 @@ local function add_video(s)
append_display_sync(s)
append_perfdata(s, o.print_perfdata_passes)
- append_resolution(s, r, "Native Resolution:")
+ append_resolution(s, r, "Native Resolution:", "w", "h", true)
if ro and (r["w"] ~= ro["dw"] or r["h"] ~= ro["dh"]) then
+ if ro["crop-w"] and (crop_noop(r["w"], r["h"], ro) or crop_equal(r, ro)) then
+ ro["crop-w"] = nil
+ end
append_resolution(s, ro, "Output Resolution:", "dw", "dh")
end
local scale = nil