Commit Graph

158 Commits

Author SHA1 Message Date
Kacper Michajłow 991f834e9e stats.lua: add chroma-location 2023-10-14 12:30:46 +02:00
Kacper Michajłow 28ecbcd36b stats.lua: change "Pixel Format" to "Format" 2023-10-14 12:30:46 +02:00
Kacper Michajłow 81cf697e28 stats.lua: fix missing newline when print_perfdata_passes is enabled 2023-10-14 12:30:46 +02:00
Kacper Michajłow 73db283296 stats.lua: sort filter parameters to ensure consistent output 2023-10-14 12:30:46 +02:00
Kacper Michajłow 52fc378494 stats.lua: don't print custom pixel format, when hwdec
There is already other place to indicate hw decoding. "cuda" or "d3d11"
is not a pixel format.
2023-10-14 12:30:46 +02:00
Kacper Michajłow e5446399e1 stats.lua: remove leading zeros from pass timings
Makes it more readable in my opinion.
2023-10-14 12:30:46 +02:00
Kacper Michajłow 31ba5cd6df stats.lua: add frame info 2023-10-14 12:30:46 +02:00
Kacper Michajłow 6ff165f4a4 stats.lua: simplify fps display
- rename prefix to `Framerate:`
- if both estimated and specified values are the same display fps once
- skip the suffix if both the estimated and specified values agrees
2023-10-14 12:30:46 +02:00
Kacper Michajłow c4b8ddeee3 stats.lua: adjust spacing between values a little 2023-10-14 12:30:46 +02:00
Kacper Michajłow 499a9d90ab stats.lua: show HDR meta if not equal to 203
SDR white (203) is indeed not interesting, but anything else, even if
lower is.
2023-10-14 12:30:46 +02:00
Kacper Michajłow f2f33ac1e8 stats.lua: separate video parameters from video out
Source video parameters are interesting, but we mix them with video
output/target parameters. Which will differ. Add "Display" showing
true output params from VO, including HDR passthrough info and
everything. This makes much more consistent output and alows to quickly
diagnose how is source video translated to target display.
2023-10-14 12:30:46 +02:00
Kacper Michajłow ff7da2f5c0 stats.lua: don't display full frame crop
It is valid to have 0x0+w+h crop, but no need to print that.
2023-09-08 02:27:08 +00:00
Kacper Michajłow c865ce9455 stats.lua: display --video-crop values when used 2023-08-31 17:37:42 +00:00
Niklas Haas 7f9b1b32a5 stats.lua: enable --tone-mapping-visualize while stats shown
Except in oneshot mode. Controllable via new option.
2023-08-30 17:10:13 +02:00
Kacper Michajłow 15ada7c41c stats.lua: display hdr metadata and peak detection 2023-08-29 20:58:44 +02:00
Kacper Michajłow 2a969a833f stats.lua: add hints about scrolling 2023-08-28 21:14:26 +02:00
Kacper Michajłow ce64b5687b stats.lua: refactor video params display
- Move window scale to scaled resolution line
- add deinterlacing display
- rename "Gamma" to "Transfer"
- reorder to colormatrix/primaries/transfer as commonly used by
  ffmpeg/ffprobe
2023-08-28 21:14:26 +02:00
Kacper Michajłow 42f8c71aa0 stats.lua: remove dummy new lines from headers 2023-08-28 21:14:26 +02:00
Kacper Michajłow 52bf44d2e0 stats.lua: display actual output video size after anamorphic correction
This makes much more sens than frame size that is the same as native
one.
2023-08-28 21:14:26 +02:00
Kacper Michajłow cc3c2ad8fb stats.lua: display output resolution if it differs to native one
Useful when filters are applied that alters the video resolution, like
crop. Also display aspect ratio per each resolution.
2023-08-18 16:39:35 +02:00
Kacper Michajłow 540a5eb5ab stats.lua: hide window scale in fullscreen
It display window (not fullscreen) scale, which is quite confusing as it
doesn't match any other currently displayed values.
2023-08-18 16:39:35 +02:00
Kacper Michajłow e85d70f84f stats.lua: use video-params/aspect-name 2023-08-13 15:04:33 +00:00
m154k1 cbb1af64d5 stats.lua: set sans-serif as default font
sans is deprecated and unsupported on some platforms.
2023-07-10 16:58:54 +02:00
Harri Nieminen 292a5868cb various: fix typos
Found by codespell
2023-03-28 19:29:44 +00:00
dyphire 070287aebb stats.lua: display HDR peak in nits
The value of `sig-peak` is relative to the SDR peak. This is not
a problem when used inside the player, but the `HDR peak` in stats
should display human-readable information.
So change to return the actual nits value of HDR.
Closed https://github.com/mpv-player/mpv/issues/10127
2023-02-02 14:22:40 +00:00
Guido Cella fe9e074752 various: remove trailing whitespace 2022-05-14 14:51:34 +00:00
Cœur bb5b4b1ba6 various: fix typos 2022-04-25 09:07:18 -04:00
Avi Halachmi (:avih) 57f42cee84 stats.lua: page 2 - frame timing: use fixed display order
Page 2 displays the frame timing info for each type (currently "Fresh"
and "Redraw"), but since they're unordered keys of a map, their
iteration order and hence their order on screen could (and did) change
depending on $things, which was annoying.

haasn thinks none of them should be considered more important (and
therefore maybe worthy of being displayed on top), so we go with
lexicographic order, which currently means that "Fresh" is first.

Fixes #9901
2022-02-23 02:20:49 +02:00
Avi Halachmi (:avih) 37927b65f7 stats.lua: graphs: fix bad rendering due to division by 0
This fixes two potential divisions by 0 at generate_graph(...):
- If v_avg is (given and) 0.
- if v_max is 0.

The former doesn't seem to happen in practice because v_avg is only
used at one generate_gpah call, where it's apparently not 0.

The latter triggers if all the graph values are 0 (hence v_max is
also 0).

The implication of these divisions by 0 is an invalid y-value which
ends up at the ASS coordinates string for the graph inner content.

On linux the value ends as "nan" (luajit) or "-nan" (lua 5.1/5.2), and
on Windows it's "nan" (luajit) or "-1.#IND00" (lua 5.1/5.2), maybe due
to msvcrt's snprintf.

All these strings are wrong as ASS numbers, but due to luck in how
libass parses the coordinates, "nan" and "-nan" result in empty graph
(which looks OK for "all values are 0"), while "-1.#IND00" is parsed
as -1, which breaks the graph rendering (affects other graphs too).

One example of "all values are 0" is at page 0 (internal performance
graphs) on Windows - because the cpu metrics don't work.
So this fixes at least page 0 on Windows with lua 5.1/5.2.

While at it, move the scale calculations to one place, which now
avoids division by 0, instead of duplicating this calculation.

In the future, we can consider improving the generate_graph API:
- It needs one peak value, but takes 3 (v_max, v_avg, scale) which
  are meshed into one final value.
- v_avg is only used in 1 of 6 call sites, but at the middle of the
  arguments, so all other call sites need to pass explicit "nil".
- "scale" is arbitrary and used to leave some space at the top of the
  graph. 5 places use 0.8, one uses 0.9. Could probably be unified.
2022-02-21 16:05:02 +02:00
Stefan de Konink 0c9e1e34fd stats.lua: typo lavfi-complex
Fix typo lavi-complex to lavfi-complex.
2021-08-15 12:27:40 +03:00
Guido Cella 7eb34d2376 stats.lua: page 4 (keys): group current-window-scale under window
This groups "set current-window-scale ..." under the "window" group
instead of "current" in the list of keybindings.
2021-08-06 10:29:28 +03:00
Avi Halachmi (:avih) 416668d3c8 stats.lua: page 4 (keys): better alignment of non-ascii keys
Previously we assumed the key-name string occupies strlen(name) cells,
now we count codepoints instead.

This improves alignment of non-english key names. Still not perfect
because we don't know if the key name is single or double width, but
wcwidth not available to scripts, notoriously unreliable (depends on
locale, correct and updated tables, etc), and also not always
available (Windows).

Still, better than nothing, and we err by at most one cell - vs up to
three before this commit (4 bytes keyname codepoint).

In the future we could do the alignment using libass tags, however,
this both complicates the ass-output generation, and also not available
when we output for the terminal, so for now only count codepoints.

Also, if the key name was in a right-to-left language, then previously
the name/command were swapped visually. Now we inject a left-to-right
marker before the name to ensure direction. This works also when
harfbuzz is disabled for libass (--sub-ass-shaper=simple).
2021-07-31 11:00:07 +03:00
Avi Halachmi (:avih) 8b1930fbd6 stats.lua: page 4 (keys): detect single-quotes 2021-07-30 09:52:34 +03:00
Avi Halachmi (:avih) 955736b7b7 stats.lua: fix ass-escape while persistent_overlay=yes
mpv has two methods to display output from text input:
- show-text (scripting: mp.osd_message) has ass disabled by default
  (escaped), and the property osd-ass-cc can control escaping.
- osd-overlay (scripting: mp.set_osd_ass or mp.create_osd_overlay)
  has ass enabled (unescaped), and osd-ass-cc is NOT supported.

By default, stats.lua uses mp.osd_message which does support escaping.
That's persistent_overlay=no.

When using persistent_overlay=yes then mp.set_osd_ass is used.

Due to this, the no_ASS(..) function - which is supposed to escape
ass, simply returned its input unmodified when persistent_overlay
is enabled.

This is not a new issue, and the filters on page 1 use no_ASS() to no
avail in persistent mode, however, this content (filter name and value
strings) rarely actually needs escaping, and users didn't notice.

However, the new page 4 (keys) does break visibly when no_ASS doesn't
work, because it tries to escape arbitrary key-names and command
strings, and at the very least the key '{' is bound by default, which
is displayed incorrectly if escaping doesn't work.

Fix this by rolling our own escaping when using mp.set_osd_ass,
similar to how the mpv code does it for mp.osd_message (substrings
replacements).

However, this means that the set_ASS(..) function can no longer
behave correctly because escaping requires going through the whole
content string rather than only inserting a marker.

Luckily, other than at no_ASS, set_ASS was only used at one place
(text_style), which is only called from two places:
- generate_graph() only needs to restore styles - not to enable ass.
- add_header() is only used at the begining of page output, and
  uses set_ASS to enable ass initially when using mp.osd_message.

So remove the set_ASS function, and instead enable ass directly at
print_page using osd-ass-cc when mp.osd_message is used.

Fixes #9022
2021-07-25 15:08:44 +03:00
Guido Cella ccb87ad637 stats.lua: remove script-opts for the main keys (i/I)
Unlike the page switching/scrolling keys which are bound at runtime
and therefore we need to know which (configured) keys to bind, the
main keys (i/I by default) are static and can be bound via input.conf.
And indeed, the builtin bindings at etc/input.conf have them already.
2021-07-21 13:55:58 +03:00
Avi Halachmi (:avih) 70c9d8d5d7 stats.lua: page 4 (keys): fix "excluding stats keys" - attempt 2
Page 4 bindings listing wants to exclude the interactive keys of the
stats script itself - so that they don't hide the normal keys which
are bound when stats is not interactive.

It did so by testing that the bound command includes stats/__key
which is how it usually looks when a script binds keys.

However, if a script uses a name for the binding - like stats.lua does
for the interative keys (because it later removes them by name when
interactive mode ends), then the command has stats/name rather than
stats/__key...

To fix this, we change the names of the forced interactive bindings
to start with __forced_, and that's now also what the page-4 listing
excludes.
2021-07-20 01:00:03 +03:00
Avi Halachmi (:avih) 1e1b5a6e14 Revert "stats.lua: page 4 (keys): fix "excluding stats keys""
This reverts commit 0f1654811bda0dfdd337734ec33c59b67522234a.

It was an incorrect fix, because the key names do get used - to remove
the forced bindings once stats exits the interactive mode.

And without names - the interactive keys remained active even after
stats exited interactive mode.
2021-07-20 01:00:03 +03:00
Avi Halachmi (:avih) fab25ac004 stats.lua: page 4 (keys): fix "excluding stats keys"
The page 4 keybinding list tries to skip the interactive bindings of
stats itself (because they would hide the normal bindings of these
keys when stats is not visible), and to do that it excludes commands
containing "script-binding stats/__key" - which is how script-added
bindings usually look like.

However, keys which are added with a "name" bind stats/name rather
than stats/__key... - and that's what stats.lua did till now with its
interactive force-bindings.

Now the interactive forced bindings are added without a name, and so
they do end up using the automatic stats/__key... and get excluded.
2021-07-20 00:13:35 +03:00
Avi Halachmi (:avih) 2335ee5514 stats.lua: page 4 (keys): support help-like terminal printout
While --input-test is useful, and so is page 4 of stats, until now
there was no way to simply print the list in a help-like fashion.

This commit adds such printout, invoked by the script opt
stats-bindlist=yes, which uses the existing page 4 code. This prints
the list on startup and quits immediately - like any help page.

It's awkward to invoke compared to other help pages, and it does
require the stats page to be enabled (it is by default), however
it is a script-generated output, and currently there's no other
method to print a help page generated by a script.

The printout itself is performed using lua's io.write. While reliable,
it's not the standard way for mpv to print to the terminal.

Other possible printout methods are mp.msg.info - which also prints
"[stats]" prefix on each line (ugly), or forcing term-osd and setting
an osd-message which mpv will then print at the terminal - however
that's printed to stderr, and could also be subject to timing concerns
since we quit right afterwards.

In the future we can consider changing/integrating the invocation so
that mpv itself could print a help page generated by a script, thus
solving both the awkward invocation and printout-method issues.
2021-07-19 22:06:50 +03:00
Avi Halachmi (:avih) 9fb200b641 stats.lua: add page 4: active key-bindings list
This is a scrollable page which also works nicely with the terminal
OSD. Typically there are more than 100 bound keys.

It groups the binding using fuzzy property/command/script name after
simple analysis of the command string, and then further sorts the
binding in each group according to the "complexity" of the key itself
(plain keys -> keys with modifiers, alphabetically, etc).

The alignment/grouping style is heavily inspired by @medhefgo's #8924
but otherwise it's an independent implementation.
2021-07-19 22:06:50 +03:00
Avi Halachmi (:avih) 59c10274b4 stats.lua: scroll: allow throttling page-rebuild (no-op)
Typically the current page is rebuilt and rendered once per second,
howeve, scrolling can invoke the rebuild function very frequently,
even at a rate which is too fast for the rebuild function to keep
up. This can result in high CPU usage and input lag.

This commit adds an argument to the page-rebuild function, letting it
know whether or not it's called following a scroll keypress, thus
allowing it to cache intermediate data so that it doesn't have to
re-calculate the whole page from scratch.

This additional argument is unused currently, but it could be useful
for the internal performance page - which can be relatively heavy.
2021-07-19 22:06:50 +03:00
Avi Halachmi (:avih) 50280197e2 stats.lua: move internal performance from page 4 to page 0
This allows adding more pages without the internal performance page
getting stuck at the middle of the list.
2021-07-19 22:06:50 +03:00
Dudemanguy 76a53f9de3 stats.lua: add scaled resolution
Calculate the actual scaled size of the video from osd-dimensions and
display it on the stats page.
2021-06-25 17:54:36 +00:00
Chris Varenhorst 5824d9fff8 stats.lua: include a filter's @label when displaying filters on page 1 2021-03-15 23:00:42 +02:00
sfan5 cbbdb3fae4 stats: display hw pixel format too 2020-10-16 17:48:05 +02:00
Eva 359261c50c stats: fix crash when aspect ratio is unavailable
When switching between files it's possible that r["aspect"] returns nil, resulting in a crash.
2020-08-03 00:50:57 +03:00
sfan5 b67c7a23b8 stats: fix single invocation keybindings 2020-07-21 19:34:41 +02:00
Julian c7b94c03f1 stats: UP/DOWN scrolling on page 2 (frame stats)
Code contributed by @avih with only minor modifications to comments by
me.
Fixes #7727.
2020-05-17 20:11:50 +02:00
Avi Halachmi (:avih) 5ff215c4df stats.lua: don't disable terminal escape sequences on windows
When stats.lua is used without a video window then it uses the terminal.
On Windows, however, so far it disabled ansi escape sequences and used
plaintext unless ANSICON env is set.

It's unclear why it's disabled on windows, because at the time it was
added it only used bold by default and mpv ansi emulation on windows
already supported bold at that time.

We can guess that it was disabled because if the same config is used on
both linux and Windows, and it had complex escape sequences for
stats.lue, then it would be emulated incorrectly on Windows.

This shouldn't be an issue anymore, as the last two commits both enhance
the emulation to be quite complete (and graceful where it's not), and
also enable the much-more complete native VT terminal when possible
(Windows 10).

Just remove this windows exception at stats.lua.
2020-04-23 17:02:38 +03:00
LaserEyess 34e7d9c2f4 stats: move chapter/edition info below title
It is more consistent for editions/chapters to go below either
the title or filename. They are all descriptive strings about
the media itself and not file metadata like filesize.

Suggested by Argon-
2020-04-16 23:13:46 +02:00