Showing the changes to player/lua/stats.lua (1 of 1 file). Show all
Unified · Split
| @@ -30,8 +30,8 @@ local o = { · 29 unmodified lines | ||
| 30 | 30 | ass_formatting = true, |
| 31 | 31 | persistent_overlay = false, -- whether the stats can be overwritten by other output |
| 32 | 32 | 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 | |
| 35 | 35 | term_width_limit = -1, -- overwrites the terminal width |
| 36 | 36 | term_height_limit = -1, -- overwrites the terminal height |
| 37 | 37 | debug = false, |
| @@ -113,7 +113,7 @@ local recorder = nil · 75 unmodified lines | ||
| 113 | 113 | -- Timer used for redrawing (toggling) and clearing the screen (oneshot) |
| 114 | 114 | local display_timer = nil |
| 115 | 115 | -- Timer used to update cache stats. |
| 116 | −local cache_recorder_timer = nil | |
| 116 | +local cache_recorder_timer | |
| 117 | 117 | -- Current page and <page key>:<page function> mappings |
| 118 | 118 | local curr_page = o.key_page_1 |
| 119 | 119 | local pages = {} |
| @@ -152,7 +152,7 @@ local function no_ASS(t) · 32 unmodified lines | ||
| 152 | 152 | end |
| 153 | 153 | |
| 154 | 154 | |
| 155 | −local function b(t) | |
| 155 | +local function bold(t) | |
| 156 | 156 | return o.b1 .. t .. o.b0 |
| 157 | 157 | end |
| 158 | 158 | |
| @@ -233,7 +233,7 @@ local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics) · 74 unmodified lines | ||
| 233 | 233 | local s = {format("m 0 0 n %f %f l ", x, y_max - scale * values[i])} |
| 234 | 234 | i = ((i - 2) % len) + 1 |
| 235 | 235 | |
| 236 | − for p = 1, len - 1 do | |
| 236 | + for _ = 1, len - 1 do | |
| 237 | 237 | if values[i] then |
| 238 | 238 | x = x - x_tics |
| 239 | 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 | 244 | s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max) |
| 245 | 245 | |
| 246 | 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) | |
| 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", | |
| 249 | 251 | o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style()) |
| 250 | 252 | end |
| 251 | 253 | |
| @@ -260,7 +262,7 @@ local function append(s, str, attr) · 8 unmodified lines | ||
| 260 | 262 | attr.suffix = attr.suffix or "" |
| 261 | 263 | attr.prefix = attr.prefix or "" |
| 262 | 264 | 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 | 266 | s[#s+1] = format("%s%s%s%s%s%s", attr.nl, attr.indent, |
| 265 | 267 | attr.prefix, attr.prefix_sep, no_ASS(str), attr.suffix) |
| 266 | 268 | return true |
| @@ -316,11 +318,6 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 49 unmodified lines | ||
| 316 | 318 | return |
| 317 | 319 | 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 | 321 | -- Sums of all last/avg/peak values |
| 325 | 322 | local last_s, avg_s, peak_s = {}, {}, {} |
| 326 | 323 | 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 | 351 | local h = dedicated_page and header or s |
| 355 | 352 | h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s", |
| 356 | 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 | 355 | "(last/average/peak μs)", font_size, |
| 359 | 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 | 362 | if print_passes then |
| 366 | 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 | 366 | for _, pass in ipairs(data) do |
| 370 | 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 | 383 | s[#s+1] = format(f, o.nl, o.indent, o.indent, |
| 387 | 384 | o.font_mono, pp(last_s[frame]), |
| 388 | 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 | 387 | else |
| 391 | 388 | -- for the simplified view, we just print the sum of each pass |
| 392 | 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 | 536 | append(s, data.text or data.value, {prefix="["..tostring(i).."] "..data.name..":"}) |
| 540 | 537 | |
| 541 | 538 | 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 | 540 | if not buf then |
| 544 | 541 | buf = {0, pos = 1, len = 50, max = 0} |
| 545 | 542 | perf_buffers[data.name] = buf |
| @@ -574,13 +571,17 @@ local function append_display_sync(s) · 28 unmodified lines | ||
| 574 | 571 | local ratio_graph = "" |
| 575 | 572 | local jitter_graph = "" |
| 576 | 573 | 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 | 576 | end |
| 579 | 577 | 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 | 580 | 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}) | |
| 584 | 585 | else |
| 585 | 586 | -- Since no graph is needed we can print ratio/jitter on the same line and save some space |
| 586 | 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 | 628 | local sep = o.nl .. o.indent .. o.indent |
| 628 | 629 | ret = sep .. table.concat(filters, sep) |
| 629 | 630 | 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 | |
| 631 | 632 | end |
| 632 | 633 | end |
| 633 | 634 | |
| @@ -640,7 +641,7 @@ end · 6 unmodified lines | ||
| 640 | 641 | local function add_file(s) |
| 641 | 642 | append(s, "", {prefix="File:", nl="", indent=""}) |
| 642 | 643 | 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 | |
| 644 | 645 | append_property(s, "media-title", {prefix="Title:"}) |
| 645 | 646 | end |
| 646 | 647 | |
| @@ -897,7 +898,7 @@ local function add_video_out(s) · 250 unmodified lines | ||
| 897 | 898 | |
| 898 | 899 | local od = mp.get_property_native("osd-dimensions") |
| 899 | 900 | local rt = mp.get_property_native("video-target-params") |
| 900 | − r = rt or {} | |
| 901 | + local r = rt or {} | |
| 901 | 902 | |
| 902 | 903 | -- Add window scale |
| 903 | 904 | r["s"] = scale |
| @@ -983,9 +984,9 @@ local function add_audio(s) · 79 unmodified lines | ||
| 983 | 984 | return |
| 984 | 985 | end |
| 985 | 986 | |
| 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] | |
| 989 | 990 | return (a == b or a == nil) and a or (a .. " ➜ " .. b) |
| 990 | 991 | end |
| 991 | 992 | |
| @@ -1046,7 +1047,7 @@ end · 54 unmodified lines | ||
| 1046 | 1047 | -- printable codepoints occupy one terminal cell (we don't have wcwidth) |
| 1047 | 1048 | -- tabstops are 8, 16, 24..., and the output starts at 0 or a tabstop |
| 1048 | 1049 | -- 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) | |
| 1050 | 1051 | local TAB, ESC, SGR_END = 9, 27, ("m"):byte() |
| 1051 | 1052 | local width, ellipsis = 0, "..." |
| 1052 | 1053 | local fit_len, in_sgr |
| @@ -1266,9 +1267,9 @@ local function cache_stats() · 213 unmodified lines | ||
| 1266 | 1267 | {prefix = "End Cached:"}) |
| 1267 | 1268 | |
| 1268 | 1269 | 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"]), | |
| 1272 | 1273 | {prefix = format("Range %s:", n)}) |
| 1273 | 1274 | end |
| 1274 | 1275 | |
| @@ -1352,7 +1353,7 @@ local function print_page(page, after_scroll) · 77 unmodified lines | ||
| 1352 | 1353 | end |
| 1353 | 1354 | end |
| 1354 | 1355 | |
| 1355 | −local function update_scale(name, value) | |
| 1356 | +local function update_scale(_, value) | |
| 1356 | 1357 | -- Calculate scaled metrics. |
| 1357 | 1358 | local scale = 1 |
| 1358 | 1359 | if not o.vidscale then |
| @@ -1390,8 +1391,10 @@ local function reset_scroll_offsets() · 31 unmodified lines | ||
| 1390 | 1391 | end |
| 1391 | 1392 | local function bind_scroll() |
| 1392 | 1393 | 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}) | |
| 1395 | 1398 | scroll_bound = true |
| 1396 | 1399 | end |
| 1397 | 1400 | end |