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
3030 ass_formatting = true,
3131 persistent_overlay = false, -- whether the stats can be overwritten by other output
3232 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 instead
34− show_frame_info = false, -- whether to show the current frame info
33+ 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 info
3535 term_width_limit = -1, -- overwrites the terminal width
3636 term_height_limit = -1, -- overwrites the terminal height
3737 debug = false,
@@ -113,7 +113,7 @@ local recorder = nil · 75 unmodified lines
113113 -- Timer used for redrawing (toggling) and clearing the screen (oneshot)
114114 local display_timer = nil
115115 -- Timer used to update cache stats.
116−local cache_recorder_timer = nil
116+local cache_recorder_timer
117117 -- Current page and <page key>:<page function> mappings
118118 local curr_page = o.key_page_1
119119 local pages = {}
@@ -152,7 +152,7 @@ local function no_ASS(t) · 32 unmodified lines
152152 end
153153
154154
155−local function b(t)
155+local function bold(t)
156156 return o.b1 .. t .. o.b0
157157 end
158158
@@ -233,7 +233,7 @@ local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics) · 74 unmodified lines
233233 local s = {format("m 0 0 n %f %f l ", x, y_max - scale * values[i])}
234234 i = ((i - 2) % len) + 1
235235
236− for p = 1, len - 1 do
236+ for _ = 1, len - 1 do
237237 if values[i] then
238238 x = x - x_tics
239239 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
244244 s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max)
245245
246246 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)
248− return format("%s{\\rDefault}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s",
247+ plot_bg_border_width, o.plot_bg_border_color, o.plot_bg_color,
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",
249251 o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style())
250252 end
251253
@@ -260,7 +262,7 @@ local function append(s, str, attr) · 8 unmodified lines
260262 attr.suffix = attr.suffix or ""
261263 attr.prefix = attr.prefix or ""
262264 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)
264266 s[#s+1] = format("%s%s%s%s%s%s", attr.nl, attr.indent,
265267 attr.prefix, attr.prefix_sep, no_ASS(str), attr.suffix)
266268 return true
@@ -316,11 +318,6 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 49 unmodified lines
316318 return
317319 end
318320
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−
324321 -- Sums of all last/avg/peak values
325322 local last_s, avg_s, peak_s = {}, {}, {}
326323 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
354351 local h = dedicated_page and header or s
355352 h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s",
356353 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,
358355 "(last/average/peak μs)", font_size,
359356 dedicated_page and scroll_hint() or "")
360357
@@ -364,7 +361,7 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 3 unmodified lines
364361
365362 if print_passes then
366363 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)))
368365
369366 for _, pass in ipairs(data) do
370367 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
386383 s[#s+1] = format(f, o.nl, o.indent, o.indent,
387384 o.font_mono, pp(last_s[frame]),
388385 pp(avg_s[frame]), pp(peak_s[frame]),
389− o.prefix_sep, b("Total"), o.font, "", "", "")
386+ o.prefix_sep, bold("Total"), o.font, "", "", "")
390387 else
391388 -- for the simplified view, we just print the sum of each pass
392389 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
539536 append(s, data.text or data.value, {prefix="["..tostring(i).."] "..data.name..":"})
540537
541538 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]
543540 if not buf then
544541 buf = {0, pos = 1, len = 50, max = 0}
545542 perf_buffers[data.name] = buf
@@ -574,13 +571,17 @@ local function append_display_sync(s) · 28 unmodified lines
574571 local ratio_graph = ""
575572 local jitter_graph = ""
576573 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)
578576 end
579577 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)
581580 end
582− append_property(s, "vsync-ratio", {prefix="VSync Ratio:", suffix=o.prefix_sep .. ratio_graph})
583− append_property(s, "vsync-jitter", {prefix="VSync Jitter:", suffix=o.prefix_sep .. jitter_graph})
581+ append_property(s, "vsync-ratio", {prefix="VSync Ratio:",
582+ suffix=o.prefix_sep .. ratio_graph})
583+ append_property(s, "vsync-jitter", {prefix="VSync Jitter:",
584+ suffix=o.prefix_sep .. jitter_graph})
584585 else
585586 -- Since no graph is needed we can print ratio/jitter on the same line and save some space
586587 local vr = append_property(s, "vsync-ratio", {prefix="VSync Ratio:"})
@@ -627,7 +628,7 @@ local function append_filters(s, prop, prefix) · 40 unmodified lines
627628 local sep = o.nl .. o.indent .. o.indent
628629 ret = sep .. table.concat(filters, sep)
629630 end
630− s[#s+1] = o.nl .. o.indent .. b(prefix) .. o.prefix_sep .. ret
631+ s[#s+1] = o.nl .. o.indent .. bold(prefix) .. o.prefix_sep .. ret
631632 end
632633 end
633634
@@ -640,7 +641,7 @@ end · 6 unmodified lines
640641 local function add_file(s)
641642 append(s, "", {prefix="File:", nl="", indent=""})
642643 append_property(s, "filename", {prefix_sep="", nl="", indent=""})
643− if not (mp.get_property_osd("filename") == mp.get_property_osd("media-title")) then
644+ if mp.get_property_osd("filename") ~= mp.get_property_osd("media-title") then
644645 append_property(s, "media-title", {prefix="Title:"})
645646 end
646647
@@ -897,7 +898,7 @@ local function add_video_out(s) · 250 unmodified lines
897898
898899 local od = mp.get_property_native("osd-dimensions")
899900 local rt = mp.get_property_native("video-target-params")
900− r = rt or {}
901+ local r = rt or {}
901902
902903 -- Add window scale
903904 r["s"] = scale
@@ -983,9 +984,9 @@ local function add_audio(s) · 79 unmodified lines
983984 return
984985 end
985986
986− local merge = function(r, ro, prop)
987− local a = r[prop] or ro[prop]
988− local b = ro[prop] or r[prop]
987+ local merge = function(rr, rro, prop)
988+ local a = rr[prop] or rro[prop]
989+ local b = rro[prop] or rr[prop]
989990 return (a == b or a == nil) and a or (a .. " ➜ " .. b)
990991 end
991992
@@ -1046,7 +1047,7 @@ end · 54 unmodified lines
10461047 -- printable codepoints occupy one terminal cell (we don't have wcwidth)
10471048 -- tabstops are 8, 16, 24..., and the output starts at 0 or a tabstop
10481049 -- note: if maxwidth <= 2 and s doesn't fit: the result is "..." (more than 2)
1049−function term_ellipsis(s, maxwidth)
1050+local function term_ellipsis(s, maxwidth)
10501051 local TAB, ESC, SGR_END = 9, 27, ("m"):byte()
10511052 local width, ellipsis = 0, "..."
10521053 local fit_len, in_sgr
@@ -1266,9 +1267,9 @@ local function cache_stats() · 213 unmodified lines
12661267 {prefix = "End Cached:"})
12671268
12681269 local ranges = info["seekable-ranges"] or {}
1269− for n, r in ipairs(ranges) do
1270− append(stats, mp.format_time(r["start"]) .. " - " ..
1271− mp.format_time(r["end"]),
1270+ for n, range in ipairs(ranges) do
1271+ append(stats, mp.format_time(range["start"]) .. " - " ..
1272+ mp.format_time(range["end"]),
12721273 {prefix = format("Range %s:", n)})
12731274 end
12741275
@@ -1352,7 +1353,7 @@ local function print_page(page, after_scroll) · 77 unmodified lines
13521353 end
13531354 end
13541355
1355−local function update_scale(name, value)
1356+local function update_scale(_, value)
13561357 -- Calculate scaled metrics.
13571358 local scale = 1
13581359 if not o.vidscale then
@@ -1390,8 +1391,10 @@ local function reset_scroll_offsets() · 31 unmodified lines
13901391 end
13911392 local function bind_scroll()
13921393 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_down, "__forced_"..o.key_scroll_down, scroll_down, {repeatable=true})
1394+ mp.add_forced_key_binding(o.key_scroll_up, "__forced_" .. o.key_scroll_up,
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})
13951398 scroll_bound = true
13961399 end
13971400 end

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