History

stats.lua: fix some lint warnings

Kacper Michajłow committed 2 years ago

Commit f348a8b1 parent 8fa0e091 file · +37 −34Browse files

Showing the changes to player/lua/stats.lua (1 of 1 file). Show all

Unified · Split

player/lua/stats.lua+37−34
@@ -30,8 +30,8 @@ local o = { · 29 unmodified lines
30 ass_formatting = true,30 ass_formatting = true,
31 persistent_overlay = false, -- whether the stats can be overwritten by other output31 persistent_overlay = false, -- whether the stats can be overwritten by other output
32 print_perfdata_passes = false, -- when true, print the full information about all passes32 print_perfdata_passes = false, -- when true, print the full information about all passes
33 filter_params_max_length = 100, -- a filter list longer than this many characters will be shown one filter per line instead33 filter_params_max_length = 100, -- show one filter per line if list exceeds this length
34 show_frame_info = false, -- whether to show the current frame info34 show_frame_info = false, -- whether to show the current frame info
35 term_width_limit = -1, -- overwrites the terminal width35 term_width_limit = -1, -- overwrites the terminal width
36 term_height_limit = -1, -- overwrites the terminal height36 term_height_limit = -1, -- overwrites the terminal height
37 debug = false,37 debug = false,
@@ -113,7 +113,7 @@ local recorder = nil · 75 unmodified lines
113-- Timer used for redrawing (toggling) and clearing the screen (oneshot)113-- Timer used for redrawing (toggling) and clearing the screen (oneshot)
114local display_timer = nil114local display_timer = nil
115-- Timer used to update cache stats.115-- Timer used to update cache stats.
116local cache_recorder_timer = nil116local cache_recorder_timer
117-- Current page and <page key>:<page function> mappings117-- Current page and <page key>:<page function> mappings
118local curr_page = o.key_page_1118local curr_page = o.key_page_1
119local pages = {}119local pages = {}
@@ -152,7 +152,7 @@ local function no_ASS(t) · 32 unmodified lines
152end152end
153 153
154 154
155local function b(t)155local function bold(t)
156 return o.b1 .. t .. o.b0156 return o.b1 .. t .. o.b0
157end157end
158 158
@@ -233,7 +233,7 @@ local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics) · 74 unmodified lines
233 local s = {format("m 0 0 n %f %f l ", x, y_max - scale * values[i])}233 local s = {format("m 0 0 n %f %f l ", x, y_max - scale * values[i])}
234 i = ((i - 2) % len) + 1234 i = ((i - 2) % len) + 1
235 235
236 for p = 1, len - 1 do236 for _ = 1, len - 1 do
237 if values[i] then237 if values[i] then
238 x = x - x_tics238 x = x - x_tics
239 s[#s+1] = format("%f %f ", x, y_max - scale * values[i])239 s[#s+1] = format("%f %f ", x, y_max - scale * values[i])
@@ -244,8 +244,10 @@ local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics) · 4 unmodified lines
244 s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max)244 s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max)
245 245
246 local bg_box = format("{\\bord%f}{\\3c&H%s&}{\\1c&H%s&}m 0 %f l %f %f %f 0 0 0",246 local bg_box = format("{\\bord%f}{\\3c&H%s&}{\\1c&H%s&}m 0 %f l %f %f %f 0 0 0",
247 plot_bg_border_width, o.plot_bg_border_color, o.plot_bg_color, y_max, x_max, y_max, x_max)247 plot_bg_border_width, o.plot_bg_border_color, o.plot_bg_color,
248 return format("%s{\\rDefault}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s",248 y_max, x_max, y_max, x_max)
249 return format("%s{\\rDefault}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}" ..
250 "{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s",
249 o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style())251 o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style())
250end252end
251 253
@@ -260,7 +262,7 @@ local function append(s, str, attr) · 8 unmodified lines
260 attr.suffix = attr.suffix or ""262 attr.suffix = attr.suffix or ""
261 attr.prefix = attr.prefix or ""263 attr.prefix = attr.prefix or ""
262 attr.no_prefix_markup = attr.no_prefix_markup or false264 attr.no_prefix_markup = attr.no_prefix_markup or false
263 attr.prefix = attr.no_prefix_markup and attr.prefix or b(attr.prefix)265 attr.prefix = attr.no_prefix_markup and attr.prefix or bold(attr.prefix)
264 s[#s+1] = format("%s%s%s%s%s%s", attr.nl, attr.indent,266 s[#s+1] = format("%s%s%s%s%s%s", attr.nl, attr.indent,
265 attr.prefix, attr.prefix_sep, no_ASS(str), attr.suffix)267 attr.prefix, attr.prefix_sep, no_ASS(str), attr.suffix)
266 return true268 return true
@@ -316,11 +318,6 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 49 unmodified lines
316 return318 return
317 end319 end
318 320
319 local ds = mp.get_property_bool("display-sync-active", false)
320 local target_fps = ds and mp.get_property_number("display-fps", 0)
321 or mp.get_property_number("container-fps", 0)
322 if target_fps > 0 then target_fps = 1 / target_fps * 1e9 end
323
324 -- Sums of all last/avg/peak values321 -- Sums of all last/avg/peak values
325 local last_s, avg_s, peak_s = {}, {}, {}322 local last_s, avg_s, peak_s = {}, {}, {}
326 for frame, data in pairs(vo_p) do323 for frame, data in pairs(vo_p) do
@@ -354,7 +351,7 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 27 unmodified lines
354 local h = dedicated_page and header or s351 local h = dedicated_page and header or s
355 h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s",352 h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s",
356 dedicated_page and "" or o.nl, dedicated_page and "" or o.indent,353 dedicated_page and "" or o.nl, dedicated_page and "" or o.indent,
357 b("Frame Timings:"), o.prefix_sep, font_size * 0.66,354 bold("Frame Timings:"), o.prefix_sep, font_size * 0.66,
358 "(last/average/peak μs)", font_size,355 "(last/average/peak μs)", font_size,
359 dedicated_page and scroll_hint() or "")356 dedicated_page and scroll_hint() or "")
360 357
@@ -364,7 +361,7 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 3 unmodified lines
364 361
365 if print_passes then362 if print_passes then
366 s[#s+1] = format("%s%s%s:", o.nl, o.indent,363 s[#s+1] = format("%s%s%s:", o.nl, o.indent,
367 b(frame:gsub("^%l", string.upper)))364 bold(frame:gsub("^%l", string.upper)))
368 365
369 for _, pass in ipairs(data) do366 for _, pass in ipairs(data) do
370 s[#s+1] = format(f, o.nl, o.indent, o.indent,367 s[#s+1] = format(f, o.nl, o.indent, o.indent,
@@ -386,7 +383,7 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 15 unmodified lines
386 s[#s+1] = format(f, o.nl, o.indent, o.indent,383 s[#s+1] = format(f, o.nl, o.indent, o.indent,
387 o.font_mono, pp(last_s[frame]),384 o.font_mono, pp(last_s[frame]),
388 pp(avg_s[frame]), pp(peak_s[frame]),385 pp(avg_s[frame]), pp(peak_s[frame]),
389 o.prefix_sep, b("Total"), o.font, "", "", "")386 o.prefix_sep, bold("Total"), o.font, "", "", "")
390 else387 else
391 -- for the simplified view, we just print the sum of each pass388 -- for the simplified view, we just print the sum of each pass
392 s[#s+1] = format(f, o.nl, o.indent, o.indent, o.font_mono,389 s[#s+1] = format(f, o.nl, o.indent, o.indent, o.font_mono,
@@ -539,7 +536,7 @@ local function append_general_perfdata(s) · 146 unmodified lines
539 append(s, data.text or data.value, {prefix="["..tostring(i).."] "..data.name..":"})536 append(s, data.text or data.value, {prefix="["..tostring(i).."] "..data.name..":"})
540 537
541 if o.plot_perfdata and o.use_ass and data.value then538 if o.plot_perfdata and o.use_ass and data.value then
542 buf = perf_buffers[data.name]539 local buf = perf_buffers[data.name]
543 if not buf then540 if not buf then
544 buf = {0, pos = 1, len = 50, max = 0}541 buf = {0, pos = 1, len = 50, max = 0}
545 perf_buffers[data.name] = buf542 perf_buffers[data.name] = buf
@@ -574,13 +571,17 @@ local function append_display_sync(s) · 28 unmodified lines
574 local ratio_graph = ""571 local ratio_graph = ""
575 local jitter_graph = ""572 local jitter_graph = ""
576 if o.plot_vsync_ratio then573 if o.plot_vsync_ratio then
577 ratio_graph = generate_graph(vsratio_buf, vsratio_buf.pos, vsratio_buf.len, vsratio_buf.max, nil, 0.8, 1)574 ratio_graph = generate_graph(vsratio_buf, vsratio_buf.pos,
575 vsratio_buf.len, vsratio_buf.max, nil, 0.8, 1)
578 end576 end
579 if o.plot_vsync_jitter then577 if o.plot_vsync_jitter then
580 jitter_graph = generate_graph(vsjitter_buf, vsjitter_buf.pos, vsjitter_buf.len, vsjitter_buf.max, nil, 0.8, 1)578 jitter_graph = generate_graph(vsjitter_buf, vsjitter_buf.pos,
579 vsjitter_buf.len, vsjitter_buf.max, nil, 0.8, 1)
581 end580 end
582 append_property(s, "vsync-ratio", {prefix="VSync Ratio:", suffix=o.prefix_sep .. ratio_graph})581 append_property(s, "vsync-ratio", {prefix="VSync Ratio:",
583 append_property(s, "vsync-jitter", {prefix="VSync Jitter:", suffix=o.prefix_sep .. jitter_graph})582 suffix=o.prefix_sep .. ratio_graph})
583 append_property(s, "vsync-jitter", {prefix="VSync Jitter:",
584 suffix=o.prefix_sep .. jitter_graph})
584 else585 else
585 -- Since no graph is needed we can print ratio/jitter on the same line and save some space586 -- Since no graph is needed we can print ratio/jitter on the same line and save some space
586 local vr = append_property(s, "vsync-ratio", {prefix="VSync Ratio:"})587 local vr = append_property(s, "vsync-ratio", {prefix="VSync Ratio:"})
@@ -627,7 +628,7 @@ local function append_filters(s, prop, prefix) · 40 unmodified lines
627 local sep = o.nl .. o.indent .. o.indent628 local sep = o.nl .. o.indent .. o.indent
628 ret = sep .. table.concat(filters, sep)629 ret = sep .. table.concat(filters, sep)
629 end630 end
630 s[#s+1] = o.nl .. o.indent .. b(prefix) .. o.prefix_sep .. ret631 s[#s+1] = o.nl .. o.indent .. bold(prefix) .. o.prefix_sep .. ret
631 end632 end
632end633end
633 634
@@ -640,7 +641,7 @@ end · 6 unmodified lines
640local function add_file(s)641local function add_file(s)
641 append(s, "", {prefix="File:", nl="", indent=""})642 append(s, "", {prefix="File:", nl="", indent=""})
642 append_property(s, "filename", {prefix_sep="", nl="", indent=""})643 append_property(s, "filename", {prefix_sep="", nl="", indent=""})
643 if not (mp.get_property_osd("filename") == mp.get_property_osd("media-title")) then644 if mp.get_property_osd("filename") ~= mp.get_property_osd("media-title") then
644 append_property(s, "media-title", {prefix="Title:"})645 append_property(s, "media-title", {prefix="Title:"})
645 end646 end
646 647
@@ -897,7 +898,7 @@ local function add_video_out(s) · 250 unmodified lines
897 898
898 local od = mp.get_property_native("osd-dimensions")899 local od = mp.get_property_native("osd-dimensions")
899 local rt = mp.get_property_native("video-target-params")900 local rt = mp.get_property_native("video-target-params")
900 r = rt or {}901 local r = rt or {}
901 902
902 -- Add window scale903 -- Add window scale
903 r["s"] = scale904 r["s"] = scale
@@ -983,9 +984,9 @@ local function add_audio(s) · 79 unmodified lines
983 return984 return
984 end985 end
985 986
986 local merge = function(r, ro, prop)987 local merge = function(rr, rro, prop)
987 local a = r[prop] or ro[prop]988 local a = rr[prop] or rro[prop]
988 local b = ro[prop] or r[prop]989 local b = rro[prop] or rr[prop]
989 return (a == b or a == nil) and a or (a .. " ➜ " .. b)990 return (a == b or a == nil) and a or (a .. " ➜ " .. b)
990 end991 end
991 992
@@ -1046,7 +1047,7 @@ end · 54 unmodified lines
1046-- printable codepoints occupy one terminal cell (we don't have wcwidth)1047-- printable codepoints occupy one terminal cell (we don't have wcwidth)
1047-- tabstops are 8, 16, 24..., and the output starts at 0 or a tabstop1048-- tabstops are 8, 16, 24..., and the output starts at 0 or a tabstop
1048-- note: if maxwidth <= 2 and s doesn't fit: the result is "..." (more than 2)1049-- note: if maxwidth <= 2 and s doesn't fit: the result is "..." (more than 2)
1049function term_ellipsis(s, maxwidth)1050local function term_ellipsis(s, maxwidth)
1050 local TAB, ESC, SGR_END = 9, 27, ("m"):byte()1051 local TAB, ESC, SGR_END = 9, 27, ("m"):byte()
1051 local width, ellipsis = 0, "..."1052 local width, ellipsis = 0, "..."
1052 local fit_len, in_sgr1053 local fit_len, in_sgr
@@ -1266,9 +1267,9 @@ local function cache_stats() · 213 unmodified lines
1266 {prefix = "End Cached:"})1267 {prefix = "End Cached:"})
1267 1268
1268 local ranges = info["seekable-ranges"] or {}1269 local ranges = info["seekable-ranges"] or {}
1269 for n, r in ipairs(ranges) do1270 for n, range in ipairs(ranges) do
1270 append(stats, mp.format_time(r["start"]) .. " - " ..1271 append(stats, mp.format_time(range["start"]) .. " - " ..
1271 mp.format_time(r["end"]),1272 mp.format_time(range["end"]),
1272 {prefix = format("Range %s:", n)})1273 {prefix = format("Range %s:", n)})
1273 end1274 end
1274 1275
@@ -1352,7 +1353,7 @@ local function print_page(page, after_scroll) · 77 unmodified lines
1352 end1353 end
1353end1354end
1354 1355
1355local function update_scale(name, value)1356local function update_scale(_, value)
1356 -- Calculate scaled metrics.1357 -- Calculate scaled metrics.
1357 local scale = 11358 local scale = 1
1358 if not o.vidscale then1359 if not o.vidscale then
@@ -1390,8 +1391,10 @@ local function reset_scroll_offsets() · 31 unmodified lines
1390end1391end
1391local function bind_scroll()1392local function bind_scroll()
1392 if not scroll_bound then1393 if not scroll_bound then
1393 mp.add_forced_key_binding(o.key_scroll_up, "__forced_"..o.key_scroll_up, scroll_up, {repeatable=true})1394 mp.add_forced_key_binding(o.key_scroll_up, "__forced_" .. o.key_scroll_up,
1394 mp.add_forced_key_binding(o.key_scroll_down, "__forced_"..o.key_scroll_down, scroll_down, {repeatable=true})1395 scroll_up, {repeatable=true})
1396 mp.add_forced_key_binding(o.key_scroll_down, "__forced_" .. o.key_scroll_down,
1397 scroll_down, {repeatable=true})
1395 scroll_bound = true1398 scroll_bound = true
1396 end1399 end
1397end1400end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t