This adds a new configuration option vidscale, which controls whether stats display is scaled with video, similar to the option for OSC.lua.
Showing the changes to player/lua/stats.lua (1 of 2 files). Show all
Unified · Split
| @@ -60,6 +60,7 @@ local o = { · 59 unmodified lines | ||
| 60 | 60 | shadow_y_offset = 0.0, |
| 61 | 61 | shadow_color = "", |
| 62 | 62 | alpha = "11", |
| 63 | + vidscale = true, | |
| 63 | 64 | |
| 64 | 65 | -- Custom header for ASS tags to style the text output. |
| 65 | 66 | -- Specifying this will ignore the text style values above and just |
| @@ -101,6 +102,12 @@ local format = string.format · 35 unmodified lines | ||
| 101 | 102 | local max = math.max |
| 102 | 103 | local min = math.min |
| 103 | 104 | |
| 105 | +-- Scaled metrics | |
| 106 | +local font_size = o.font_size | |
| 107 | +local border_size = o.border_size | |
| 108 | +local shadow_x_offset = o.shadow_x_offset | |
| 109 | +local shadow_y_offset = o.shadow_y_offset | |
| 110 | +local plot_bg_border_width = o.plot_bg_border_width | |
| 104 | 111 | -- Function used to record performance data |
| 105 | 112 | local recorder = nil |
| 106 | 113 | -- Timer used for redrawing (toggling) and clearing the screen (oneshot) |
| @@ -162,7 +169,7 @@ local function text_style() · 55 unmodified lines | ||
| 162 | 169 | if o.custom_header and o.custom_header ~= "" then |
| 163 | 170 | return o.custom_header |
| 164 | 171 | else |
| 165 | − local style = "{\\r\\an7\\fs" .. o.font_size .. "\\bord" .. o.border_size | |
| 172 | + local style = "{\\r\\an7\\fs" .. font_size .. "\\bord" .. border_size | |
| 166 | 173 | |
| 167 | 174 | if o.font ~= "" then |
| 168 | 175 | style = style .. "\\fn" .. o.font |
| @@ -180,8 +187,8 @@ local function text_style() · 11 unmodified lines | ||
| 180 | 187 | style = style .. "\\4c&H" .. o.shadow_color .. "&\\4a&H" .. o.alpha .. "&" |
| 181 | 188 | end |
| 182 | 189 | |
| 183 | − return style .. "\\xshad" .. o.shadow_x_offset .. | |
| 184 | − "\\yshad" .. o.shadow_y_offset .. "}" | |
| 190 | + return style .. "\\xshad" .. shadow_x_offset .. | |
| 191 | + "\\yshad" .. shadow_y_offset .. "}" | |
| 185 | 192 | end |
| 186 | 193 | end |
| 187 | 194 | |
| @@ -211,8 +218,8 @@ local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics) · 23 unmodified lines | ||
| 211 | 218 | end |
| 212 | 219 | |
| 213 | 220 | local x_max = (len - 1) * x_tics |
| 214 | − local y_offset = o.border_size | |
| 215 | − local y_max = o.font_size * 0.66 | |
| 221 | + local y_offset = border_size | |
| 222 | + local y_max = font_size * 0.66 | |
| 216 | 223 | local x = 0 |
| 217 | 224 | |
| 218 | 225 | if v_max > 0 then |
| @@ -237,7 +244,7 @@ local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics) · 18 unmodified lines | ||
| 237 | 244 | s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max) |
| 238 | 245 | |
| 239 | 246 | local bg_box = format("{\\bord%f}{\\3c&H%s&}{\\1c&H%s&}m 0 %f l %f %f %f 0 0 0", |
| 240 | − o.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, y_max, x_max, y_max, x_max) | |
| 241 | 248 | return format("%s{\\rDefault}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s", |
| 242 | 249 | o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style()) |
| 243 | 250 | end |
| @@ -300,7 +307,7 @@ local function scroll_hint(search) · 56 unmodified lines | ||
| 300 | 307 | end |
| 301 | 308 | hint = hint .. ")" |
| 302 | 309 | if not o.use_ass then return " " .. hint end |
| 303 | − return format(" {\\fs%s}%s{\\fs%s}", o.font_size * 0.66, hint, o.font_size) | |
| 310 | + return format(" {\\fs%s}%s{\\fs%s}", font_size * 0.66, hint, font_size) | |
| 304 | 311 | end |
| 305 | 312 | |
| 306 | 313 | local function append_perfdata(header, s, dedicated_page, print_passes) |
| @@ -347,8 +354,8 @@ local function append_perfdata(header, s, dedicated_page, print_passes) · 40 unmodified lines | ||
| 347 | 354 | local h = dedicated_page and header or s |
| 348 | 355 | h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s", |
| 349 | 356 | dedicated_page and "" or o.nl, dedicated_page and "" or o.indent, |
| 350 | − b("Frame Timings:"), o.prefix_sep, o.font_size * 0.66, | |
| 351 | − "(last/average/peak μs)", o.font_size, | |
| 357 | + b("Frame Timings:"), o.prefix_sep, font_size * 0.66, | |
| 358 | + "(last/average/peak μs)", font_size, | |
| 352 | 359 | dedicated_page and scroll_hint() or "") |
| 353 | 360 | |
| 354 | 361 | for _,frame in ipairs(sorted_keys(vo_p)) do -- ensure fixed display order |
| @@ -507,8 +514,8 @@ local function get_kbinfo_lines() · 152 unmodified lines | ||
| 507 | 514 | local kpost = term and " " or format(" {\\fn%s}", o.font) |
| 508 | 515 | local spre = term and kspaces .. " " |
| 509 | 516 | or format("{\\q2\\fn%s}%s {\\fn%s}{\\fs%d\\u1}", |
| 510 | − o.font_mono, kspaces, o.font, 1.3*o.font_size) | |
| 511 | − local spost = term and "" or format("{\\u0\\fs%d}", o.font_size) | |
| 517 | + o.font_mono, kspaces, o.font, 1.3*font_size) | |
| 518 | + local spost = term and "" or format("{\\u0\\fs%d}", font_size) | |
| 512 | 519 | |
| 513 | 520 | -- create the display lines |
| 514 | 521 | local info_lines = {} |
| @@ -1340,6 +1347,24 @@ local function print_page(page, after_scroll) · 825 unmodified lines | ||
| 1340 | 1347 | end |
| 1341 | 1348 | end |
| 1342 | 1349 | |
| 1350 | +local function update_scale(name, value) | |
| 1351 | + -- Calculate scaled metrics. | |
| 1352 | + local scale = 1 | |
| 1353 | + if not o.vidscale then | |
| 1354 | + if value <= 1 then | |
| 1355 | + value = 1 | |
| 1356 | + end | |
| 1357 | + scale = 720 / value | |
| 1358 | + end | |
| 1359 | + font_size = o.font_size * scale | |
| 1360 | + border_size = o.border_size * scale | |
| 1361 | + shadow_x_offset = o.shadow_x_offset * scale | |
| 1362 | + shadow_y_offset = o.shadow_y_offset * scale | |
| 1363 | + plot_bg_border_width = o.plot_bg_border_width * scale | |
| 1364 | + if display_timer:is_enabled() then | |
| 1365 | + print_page(curr_page) | |
| 1366 | + end | |
| 1367 | +end | |
| 1343 | 1368 | |
| 1344 | 1369 | local function clear_screen() |
| 1345 | 1370 | if o.persistent_overlay then mp.set_osd_ass(0, 0, "") else mp.osd_message("", 0) end |
| @@ -1566,3 +1591,5 @@ if o.bindlist ~= "no" then · 220 unmodified lines | ||
| 1566 | 1591 | mp.command("quit") |
| 1567 | 1592 | end) |
| 1568 | 1593 | end |
| 1594 | + | |
| 1595 | +mp.observe_property('osd-height', 'native', update_scale) | |