This adds a new configuration option vidscale, which controls whether stats display is scaled with video, similar to the option for OSC.lua.
Unified · Split
| @@ -198,6 +198,12 @@ Configurable Options · 197 unmodified lines | |||
| 198 | 198 | ||
| 199 | Color used for drawing graphs. | 199 | Color used for drawing graphs. |
| 200 | 200 | ||
| 201 | ``vidscale`` | ||
| 202 | Default: yes | ||
| 203 | |||
| 204 | Scale the text and graphs with the video. | ||
| 205 | ``no`` tries to keep the sizes constant. | ||
| 206 | |||
| 201 | Note: colors are given as hexadecimal values and use ASS tag order: BBGGRR | 207 | Note: colors are given as hexadecimal values and use ASS tag order: BBGGRR |
| 202 | (blue green red). | 208 | (blue green red). |
| 203 | 209 | ||
| @@ -60,6 +60,7 @@ local o = { · 59 unmodified lines | |||
| 60 | shadow_y_offset = 0.0, | 60 | shadow_y_offset = 0.0, |
| 61 | shadow_color = "", | 61 | shadow_color = "", |
| 62 | alpha = "11", | 62 | alpha = "11", |
| 63 | vidscale = true, | ||
| 63 | 64 | ||
| 64 | -- Custom header for ASS tags to style the text output. | 65 | -- Custom header for ASS tags to style the text output. |
| 65 | -- Specifying this will ignore the text style values above and just | 66 | -- Specifying this will ignore the text style values above and just |
| @@ -101,6 +102,12 @@ local format = string.format · 35 unmodified lines | |||
| 101 | local max = math.max | 102 | local max = math.max |
| 102 | local min = math.min | 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 | -- Function used to record performance data | 111 | -- Function used to record performance data |
| 105 | local recorder = nil | 112 | local recorder = nil |
| 106 | -- Timer used for redrawing (toggling) and clearing the screen (oneshot) | 113 | -- Timer used for redrawing (toggling) and clearing the screen (oneshot) |
| @@ -162,7 +169,7 @@ local function text_style() · 55 unmodified lines | |||
| 162 | if o.custom_header and o.custom_header ~= "" then | 169 | if o.custom_header and o.custom_header ~= "" then |
| 163 | return o.custom_header | 170 | return o.custom_header |
| 164 | else | 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 | if o.font ~= "" then | 174 | if o.font ~= "" then |
| 168 | style = style .. "\\fn" .. o.font | 175 | style = style .. "\\fn" .. o.font |
| @@ -180,8 +187,8 @@ local function text_style() · 11 unmodified lines | |||
| 180 | style = style .. "\\4c&H" .. o.shadow_color .. "&\\4a&H" .. o.alpha .. "&" | 187 | style = style .. "\\4c&H" .. o.shadow_color .. "&\\4a&H" .. o.alpha .. "&" |
| 181 | end | 188 | end |
| 182 | 189 | ||
| 183 | return style .. "\\xshad" .. o.shadow_x_offset .. | 190 | return style .. "\\xshad" .. shadow_x_offset .. |
| 184 | "\\yshad" .. o.shadow_y_offset .. "}" | 191 | "\\yshad" .. shadow_y_offset .. "}" |
| 185 | end | 192 | end |
| 186 | end | 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 | end | 218 | end |
| 212 | 219 | ||
| 213 | local x_max = (len - 1) * x_tics | 220 | local x_max = (len - 1) * x_tics |
| 214 | local y_offset = o.border_size | 221 | local y_offset = border_size |
| 215 | local y_max = o.font_size * 0.66 | 222 | local y_max = font_size * 0.66 |
| 216 | local x = 0 | 223 | local x = 0 |
| 217 | 224 | ||
| 218 | if v_max > 0 then | 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 | 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) |
| 238 | 245 | ||
| 239 | 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", |
| 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 | return format("%s{\\rDefault}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s", | 248 | return format("%s{\\rDefault}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s", |
| 242 | o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style()) | 249 | o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style()) |
| 243 | end | 250 | end |
| @@ -300,7 +307,7 @@ local function scroll_hint(search) · 56 unmodified lines | |||
| 300 | end | 307 | end |
| 301 | hint = hint .. ")" | 308 | hint = hint .. ")" |
| 302 | if not o.use_ass then return " " .. hint end | 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 | end | 311 | end |
| 305 | 312 | ||
| 306 | local function append_perfdata(header, s, dedicated_page, print_passes) | 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 | local h = dedicated_page and header or s | 354 | local h = dedicated_page and header or s |
| 348 | h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s", | 355 | h[#h+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}%s", |
| 349 | dedicated_page and "" or o.nl, dedicated_page and "" or o.indent, | 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, | 357 | b("Frame Timings:"), o.prefix_sep, font_size * 0.66, |
| 351 | "(last/average/peak μs)", o.font_size, | 358 | "(last/average/peak μs)", font_size, |
| 352 | dedicated_page and scroll_hint() or "") | 359 | dedicated_page and scroll_hint() or "") |
| 353 | 360 | ||
| 354 | for _,frame in ipairs(sorted_keys(vo_p)) do -- ensure fixed display order | 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 | local kpost = term and " " or format(" {\\fn%s}", o.font) | 514 | local kpost = term and " " or format(" {\\fn%s}", o.font) |
| 508 | local spre = term and kspaces .. " " | 515 | local spre = term and kspaces .. " " |
| 509 | or format("{\\q2\\fn%s}%s {\\fn%s}{\\fs%d\\u1}", | 516 | or format("{\\q2\\fn%s}%s {\\fn%s}{\\fs%d\\u1}", |
| 510 | o.font_mono, kspaces, o.font, 1.3*o.font_size) | 517 | o.font_mono, kspaces, o.font, 1.3*font_size) |
| 511 | local spost = term and "" or format("{\\u0\\fs%d}", o.font_size) | 518 | local spost = term and "" or format("{\\u0\\fs%d}", font_size) |
| 512 | 519 | ||
| 513 | -- create the display lines | 520 | -- create the display lines |
| 514 | local info_lines = {} | 521 | local info_lines = {} |
| @@ -1340,6 +1347,24 @@ local function print_page(page, after_scroll) · 825 unmodified lines | |||
| 1340 | end | 1347 | end |
| 1341 | end | 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 | local function clear_screen() | 1369 | local function clear_screen() |
| 1345 | if o.persistent_overlay then mp.set_osd_ass(0, 0, "") else mp.osd_message("", 0) end | 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 | mp.command("quit") | 1591 | mp.command("quit") |
| 1567 | end) | 1592 | end) |
| 1568 | end | 1593 | end |
| 1594 | |||
| 1595 | mp.observe_property('osd-height', 'native', update_scale) | ||