summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian <MyFakeAcc.4@googlemail.com>2020-05-17 13:55:38 +0200
committerJulian <Argon-@users.noreply.github.com>2020-05-17 20:11:50 +0200
commitc7b94c03f1c85f2da07ed9268119a54653b9b31c (patch)
tree0d5f932df7416d6da9a3a95140e3d85c692cf236
parent3cb9e93cdf8a71154a70d0cfa1e0676905d5a436 (diff)
downloadmpv-c7b94c03f1c85f2da07ed9268119a54653b9b31c.tar.bz2
mpv-c7b94c03f1c85f2da07ed9268119a54653b9b31c.tar.xz
stats: UP/DOWN scrolling on page 2 (frame stats)
Code contributed by @avih with only minor modifications to comments by me. Fixes #7727.
-rw-r--r--DOCS/man/stats.rst2
-rw-r--r--player/lua/stats.lua26
2 files changed, 25 insertions, 3 deletions
diff --git a/DOCS/man/stats.rst b/DOCS/man/stats.rst
index 1d7e653b08..4f9496f4de 100644
--- a/DOCS/man/stats.rst
+++ b/DOCS/man/stats.rst
@@ -22,7 +22,7 @@ stats:
==== ==================
1 Show usual stats
-2 Show frame timings
+2 Show frame timings (scroll)
3 Input cache stats
4 Internal stuff (scroll)
==== ==================
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 8e1940d75f..6ee9e3154b 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -306,6 +306,8 @@ local function append_perfdata(s, dedicated_page)
return format("{\\b%d}%02d%%{\\b0}", w, i * 100)
end
+ -- ensure that the fixed title is one element and every scrollable line is
+ -- also one single element.
s[#s+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}",
dedicated_page and "" or o.nl, dedicated_page and "" or o.indent,
b("Frame Timings:"), o.prefix_sep, o.font_size * 0.66,
@@ -326,7 +328,9 @@ local function append_perfdata(s, dedicated_page)
o.font, o.prefix_sep, o.prefix_sep, pass["desc"])
if o.plot_perfdata and o.use_ass then
- s[#s+1] = generate_graph(pass["samples"], pass["count"],
+ -- use the same line that was already started for this iteration
+ s[#s] = s[#s] ..
+ generate_graph(pass["samples"], pass["count"],
pass["count"], pass["peak"],
pass["avg"], 0.9, 0.25)
end
@@ -616,13 +620,31 @@ local function default_stats()
return table.concat(stats)
end
+local function scroll_vo_stats(stats, fixed_items, offset)
+ local ret = {}
+ local count = #stats - fixed_items
+ offset = max(1, min((offset or 1), count))
+
+ for i, line in pairs(stats) do
+ if i <= fixed_items or i >= fixed_items + offset then
+ ret[#ret+1] = stats[i]
+ end
+ end
+ return ret, offset
+end
-- Returns an ASS string with extended VO stats
local function vo_stats()
local stats = {}
eval_ass_formatting()
add_header(stats)
+
+ -- first line (title) added next is considered fixed
+ local fixed_items = #stats + 1
append_perfdata(stats, true)
+
+ local page = pages[o.key_page_2]
+ stats, page.offset = scroll_vo_stats(stats, fixed_items, page.offset)
return table.concat(stats)
end
@@ -759,7 +781,7 @@ cache_recorder_timer:kill()
curr_page = o.key_page_1
pages = {
[o.key_page_1] = { f = default_stats, desc = "Default" },
- [o.key_page_2] = { f = vo_stats, desc = "Extended Frame Timings" },
+ [o.key_page_2] = { f = vo_stats, desc = "Extended Frame Timings", scroll = true },
[o.key_page_3] = { f = cache_stats, desc = "Cache Statistics" },
[o.key_page_4] = { f = perf_stats, desc = "Internal performance info", scroll = true },
}