Commit Graph

53259 Commits

Author SHA1 Message Date
Dudemanguy 3d3d06f981 ci/build-common: add -D_FORTIFY_SOURCE=3 2024-10-18 14:02:51 +00:00
Dudemanguy 04a2450aab ci/build-openbsd: don't enable cdda
We hit a -Wstrict-prototypes error which was fixed in the latest release
of libcdio-paranoia but openbsd is too old. We already have coverage of
this in other CIs so remove it.
2024-10-18 14:02:51 +00:00
Dudemanguy 09bbca8770 ci: refactor ci so common args are picked from one location
Mostly. It is annoying if we want to add some flag/option to all the cis
and then have to do it manually. Things easily get missed that way.
Skipped powershell because of course I'm not going to deal with that.
2024-10-18 14:02:51 +00:00
Kacper Michajłow 3e499ff3bc msg: fix width with ellipsis
Fixes: 6aa331289f
2024-10-18 00:25:10 +02:00
Guido Cella a0ca6ed5d5 options: rename --load-osd-console to --load-console
OSD is not accurate since when the console gained support for printing
to the terminal.
2024-10-17 23:57:24 +02:00
Kacper Michajłow b026fded7d msg: fix clipped output to non-tty
Not sure how it got lost.
2024-10-17 23:55:51 +02:00
Kacper Michajłow 6aa331289f msg: use … instead of ... dots 2024-10-17 23:55:51 +02:00
Kacper Michajłow 08e2acbae1 stats.lua: don't use io.write from builtin script
Scripts and especially internal scripts shouln't bypass msg.c logging
code for various resons, ranging from processing the input, filtering
the log levels, truncating the output and so on. io.write() is lazy way
of outputing to stdout without respecting mpv's logging module.

Uses osd message, because this has no prefixes. Added internal
flush-status-line command to flush current output without clearing
before exiting.

This commit will allow us to remove duplicated terminal handling code
from stats.lua, mpv core already handles all that and does it in better
way, without taking shortcuts.
2024-10-17 22:32:10 +02:00
Kacper Michajłow 2df582b839 msg: don't format status line if not printing to terminal 2024-10-17 22:32:10 +02:00
Kacper Michajłow c3404fdf37 console.lua: don't clear not ours osd messages
Note that this still is not perfect, because if osd message is changed,
console cannot know about it and would still clear it, but this change
make it at least not do it to every message even if console is not used.
2024-10-17 22:32:10 +02:00
nanahi 6880178269 DOCS/man/console.rst: document mouse bindings
Hiding console, pasting and history navigation are available
with mouse inputs.
2024-10-17 16:58:13 +02:00
Guido Cella 50faafd8bd stats.lua: exit with ESC if being toggled
If not opened in oneshot mode, close the stats with ESC. Especially now
that ? toggles showing key bindings by default, this provides an
intuitive way to close the stats.

Also do some minor reformatting of key binding documentation.
2024-10-17 16:57:35 +02:00
Dudemanguy 7e834ce870 meson: add back '-Wno-unused-result' for gcc
0fd4c84a5e removed this, but it turns out
gcc acts differently and (void) doesn't silence the warning. Hence why
the flag was there. Add it back.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
2024-10-16 20:57:25 +00:00
Kacper Michajłow e40442676a DOCS: explain origin of sigmoidization 2024-10-16 15:17:48 +02:00
Kacper Michajłow cd9761651f filter_kernels: explain origin of LanczosSharp(est) filters 2024-10-16 15:17:48 +02:00
Kacper Michajłow 742142ca92 filter_kernels: link to explanation of ginseng filter 2024-10-16 15:17:48 +02:00
llyyr 198f2e7451 wayland: don't access vo->target_params directly
Use vo_get_target_params instead.
2024-10-16 15:11:05 +02:00
Guido Cella 1a558bf5c2 osc.lua: remove NIH list formatting
All of the code to format playlist/track-list/chapter-list is
unnecessary when mpv's core can already show-text these properties.

Also an issue with this custom formatting is that showing fewer entries
than can fit on the OSD can make it seem like the playlist ends there
and there are no entries afterwards.

Also remove lots of pointless code around the track-list (mpv's track id
and the osc_id are exactly the same).

This simplification will make it easier to bind customizable commands,
otherwise yet another script message to call set_track would have to be
added, when cycle sub/audio already output information about the new
track on their own.
2024-10-16 15:10:23 +02:00
Guido Cella 65135e0f44 DOCS/input: list property values are not useless
The raw value of these properties is definitely not useless since they
return the whole list.
2024-10-16 15:10:23 +02:00
Guido Cella 3522dd836e command: implement printing ${track-list/{video,audio,sub}}
This brings show-text ${track-list} in line with osc.lua's
get_tracklist(type) before replacing it with show-text.
2024-10-16 15:10:23 +02:00
Guido Cella 89d78369c6 command: print the number of chapters in show-text ${chapter-list}
Call cut_osd_list() like with ${playlist} to print position/count above
the chapters. This is useful for movies with many chapters.

Stop printing the chapter numbers because they are not useful here, they
are only useful when navigating to a chapter.

Remove one of the spaces before the circles because they are too many.

This replicates osc-chapterlist before replacing it with show-text
${chapter-list}.
2024-10-16 15:10:23 +02:00
Guido Cella 841b66d3ec command: consider the terminal height in cut_osd_list()
cut_osd_list() calls osd_get_text_size() even when outputting to the
terminal, which results in max_lines = 19. Use the actual terminal
height instead.
2024-10-16 15:10:23 +02:00
Guido Cella be1be8ca61 command: print position/count in show-text ${playlist}
...instead of "n hidden items". This brings it in line with osc-playlist
before replacing it with show-text ${playlist}. Also make count_lines()
return the correct count.
2024-10-16 15:10:23 +02:00
Guido Cella 4e4d6a16d8 osd_libass: fix integer overflow in osd_get_text_size()
If show-text ${playlist} is used with --osd-scale-by-window=no while
printing to the terminal or while mpv is starting, the out_screen_h
assignment in osd_get_text_size() causes runtime error: signed integer
overflow: 288 - -2147483648 cannot be represented in type 'int'. Fix
this by not making prepare_osd_ass() use an infinite playresy.

This prevents printing show-text ${playlist} without a line limit to the
terminal with --osd-scale-by-window=no, which makes only the last
playlist entries be printed, and the selected one is not printed if it
isn't among them. A later commit will make the line calculation
accurate.
2024-10-16 15:10:23 +02:00
Guido Cella 0f74b1bc2d console.lua: improve hovered line calculation
- Don't do anything if clicking on the top counter, the input line or
  the new line between the items and the input line

- Don't scroll upwards when hovering the counter

- Don't redraw before clicking to avoid quickly updating the overlay
  before closing it with touch input, where the item you touch can be
  different from the one that was highlighted
2024-10-16 14:29:21 +02:00
Guido Cella b0f1830a8e console.lua: make the wheel scroll selectable items instead of the match
This makes scrolling with the wheel more usable because it doesn't
matter if the focused item is reset by moving the mouse slightly, and
scrolling always begins immediately.

This makes the MBTN_MID binding to handle_enter() unnecessary so it is
removed.
2024-10-16 14:29:21 +02:00
Guido Cella e88a1a7de7 console.lua: print position/count instead of n hidden items
This makes it consistent with the new changes to show-text ${playlist}
and greatly simplifies the logic, making it sane to implement scrolling
the view with the wheel in the commit.
2024-10-16 14:29:21 +02:00
Dudemanguy 77239b87f1 sub/sd_ass: handle subs with unknown durations on a per packet basis
A packet with an unknown duration flagged the entire context and then
this was saved forever throughout the entire lifetime of the object.
This inherently doesn't work with the redecoding sub logic which will go
through all the packets again. So the second time around, packets with
known durations get treated as if they were unknown and things go awry.
Rework this so it is per packet like it should be and not a global
state. Note that f9cefbfec4 originally
added this for specifically eia-608 subtitles but their packets are all
detected as unknown anyway due to the durations so this is not needed
anymore and interferes with other things.
2024-10-16 02:26:06 +00:00
Dudemanguy 0721b87237 player: make redraw_sub flag work on a per track basis
There can be multiple subtitle tracks (secondary subs) so this logic
should be handled separately.
2024-10-16 02:26:06 +00:00
Dudemanguy fe758a1761 player/command: destroy cached packets after UPDATE_SUB_{FILT,HARD}
Otherwise, the index can technically grow forever because
sub_read_packets will trigger again, read the same packets, then add
them to the list. We should just clear the cache here in this case to
reset it back to 0. Also flag redraw_subs here as well.
2024-10-16 02:26:06 +00:00
Dudemanguy d2d8667259 player: move a redraw_subs edgecase to loadfile
Putting this in handle_osd_redraw was strange and my own comments didn't
help me remember what this was even for. The actual purpose here is that
the osd needs to be redrawn in the still image edge case as you go
through a playlist. This is because all the logic with checking
timestamps isn't applicable and we need to essentially clear the screen
with another redraw. Clearly, it makes more sense for this to be done
when a new file is successfully loaded and not in the osd_redraw where
that happens to work but was called repeatedly pointlessly.
2024-10-16 02:26:06 +00:00
Dudemanguy dfe3edee76 player/sub: avoid pointlessly redecoding subs
This was added in 8f043de961 but the
redecode is a special case that is only ever needed for subtitles on a
still image. Normal video never needs this so just modify the
conditional to avoid doing more work.
2024-10-16 02:26:06 +00:00
Dudemanguy 4c24eae220 wayland: map BT.1886 to BT.709 for color-management protocol
Fixes #14592 as long as the compositor supports it.
2024-10-15 19:27:46 +00:00
Kacper Michajłow f33b89ca29 osdep/subprocess: log subprocess error as verbose if killed by us
Fixes: https://github.com/po5/thumbfast/issues/133#issuecomment-2413618437
2024-10-15 19:15:20 +02:00
Dudemanguy 187fffd0f5 wayland: add support for xx-color-management-v4 for vo_dmabuf_wayland
Although this protocol isn't official yet, several compositors are known
to support it to some extent and this lets users actually view HDR with
less hacks/workarounds. The actual protocol here is simply copy and
pasted from the upstream fork* where these are developed. There is also
icc profile support in the protocol, but this is omitted for now in
favor of setting colorspaces and signalling hdr metadata. However for
mpv, this only actually has any practical use with vo_dmabuf_wayland so
this is the only VO that will make use of the protocol. When using
vulkan, this is already handled via vulkan extensions by compositors and
vo_gpu_next. So actually we don't want to use the wayland protocol in
that case since it will just get in the way. The only known limitation
on that front is driver support for hdr vulkan surfaces but as soon as
that is available it should just work with no code changes. For opengl,
hdr support there is a whole other mess with a lot of unknowns but
simply using this protocol isn't good enough and would require changes
elsewhere. vo_wlshm is currently too stupid to pick any format besides
bgr0 or 0rgb, so any color management there is meaningless at this
stage.

So this means that only vo_dmabuf_wayland can actually use this
protocol. But that's perfectly fine. Without this, vo_dmabuf_wayland has
a very bad limitation in that it cannot communicate colorspaces at all
and compositors have to guess. Using xx-color-management-v4 fixes this.
For the other VOs, merely having the common protocol setup stuff in the
common code does no harm and later if they get smarter, it's easy for
them to use the stuff since it is written generically anyway.

*: https://gitlab.freedesktop.org/swick/wayland-protocols/-/tree/color-xx/staging/color-management
2024-10-15 00:15:40 +00:00
der richter ff64d87bb4 mac/common: fix usage of vo struct after vo uninit race
we keep track of the current vo struct to flag for events that are
initiated async by various thread from different system notifications.
the problem here is the usage of that vo struct after uninit.

make accessing of that vo struct atomic and clear it on uninit, so it
can't be used afterwards by concurrent threads from system
notifications or events.

Fixes #15088
2024-10-15 00:48:43 +02:00
der richter 3172186226 cocoa-cb: only request EDR on opengl layer for supported color spaces
this apparently has some performance drawbacks when not needed. so only
request EDR when we need it.

Fixes #14465
2024-10-15 00:46:45 +02:00
der richter d6aef54adb mac/app: add homebrew ARM install paths to the bundle PATH environment
since the bundle operates in a different shell environment than the one
from the terminal, it only has a few default paths set.

add the homebrew ARM default install paths to the PATH environment
variable, so the bundle can also find the needed binaries like yt-dl.
2024-10-15 00:45:51 +02:00
der richter 9a1c637e9e cocoa-cb: fix race on shutdown and toggling fullscreen
since commit 15c48f3 we were force to start drawing on the main queue
again. this has several unintended side effects due to the nature of the
main queue. in this case fullscreen event and shutdown event are
executed out of order and fullscreening is done after shutdown, leading
to accessing options that are already de-initialised.

just nil the window on shutdown and make it impossible to fullscreen
after shutdown.

Fixes #14810
2024-10-15 00:44:57 +02:00
Guido Cella 23e774d514 input.conf: bind ? to show key bindings
This should help new users to view mpv's key bindings as it's easier to
discover than shift+i and 4, because many other websites and terminal
applications show key bindings upon pressing ?.
2024-10-14 20:33:27 +02:00
Guido Cella 661bd61af8 console.lua: center selectable items around the default item 2024-10-14 20:14:27 +02:00
Guido Cella 3e63c97677 console.lua: highlight the select menu's preselected item
Requested in
https://github.com/mpv-player/mpv/pull/14087#issuecomment-2110889436 and
https://github.com/mpv-player/mpv/pull/15031#issuecomment-2401328081

This is mainly useful to keep highlighting the current playlist entry
after moving the mouse.
2024-10-14 20:14:27 +02:00
Guido Cella ad0c29e5ac console.lua: close with right click
Useful to close the console after it was opened with the mouse.

Also fix the spacing of the previous line.
2024-10-14 20:14:27 +02:00
nanahi 4ab1ab8284 video/out/x11_common: make IME work (for libmpv usage)
The implementation is minimal since it already uses XIM for UTF-8 text
input. The only changes needed are small fixes: setting the IC focus and
correct the usage of window param for XFilterEvent, and IME will
"just work"...

...after setting 2 process-wide global values before VO creation:
LC_CTYPE and X locale modifiers. So this usage is currently limited to
libmpv clients which don't want to do their own IME processing.

locale strikes once again:
XIM input methods require them to be set before creating the XIM context to
work, even though they don't matter after the context is created. Both of
these values being process-wide global means that the only time to safely
set these values is before the process creates any thread.

In theory, mpv could set LC_CTYPE in the main when running standalone,
but locale being locale means something is always messed up. In this case,
setting LC_CTYPE changes "Character classification and case conversion"
behavior. While mpv uses its own ASCII-only is*() and to*() functions to
avoid some of the issues, it also uses strcasecmp() and POSIX regex which
behaviors are affected by LC_CTYPE.

In summary, to avoid unavoidable race conditions mpv won't do this in
standalone mode right now.
It's now libmpv users' responsibility to:

- set LC_CTYPE to a locale usable for XIM, such as a UTF-8 locale
- set X locale modifiers with XSetLocaleModifiers
- hope that all stars align if trying to switch locale back afterwards

On most setups, both of these can be empty strings, In this case, the usual
XMODIFIERS environment variable must be set to enable IME support.
(e.g. XMODIFIERS=@im=fcitx)
2024-10-14 02:05:17 +02:00
Kacper Michajłow baabc291f1 build: fix dynamic generation of mpv.desktop file protocols
Running cross-compiled binaries may be possible, but the runtime
environment must be configured correctly. In some configurations, an
exe_wrapper needs to be used, and in all cases, the library path must be
set correctly for the given binary. Fortunately, Meson handles all of
this if cross-compilation is configured correctly.

Fix this by having Meson run the mpv binary directly, instead of as a
subprocess of a Python script. This ensures that the environment is
properly set for running host binaries, if possible.

Fixes: #15075
Fixes: 056b03f9ed
2024-10-14 01:56:25 +02:00
nanahi 86e8cae9ca stats.lua: add nonscalable prefix to cmd_prefixes 2024-10-14 01:55:49 +02:00
nanahi 72a705c598 console.lua: add nonscalable prefix to command_prefixes 2024-10-14 01:55:49 +02:00
nanahi da0160b0ee input/cmd: add nonscalable prefix
Some keys like WHEEL_UP are "scaled" if the input source is high
resolution, like touchpad. However, sometimes it's desirable to
disable this scaling and only active the key binding in discrete
steps, such as relative keyframe seeking which interacts poorly
if the command is scaled.

This adds the nonscalable prefix to disable this scaling.
2024-10-14 01:55:49 +02:00
Kacper Michajłow 228f38606b ci/build-linux-old: add missing Werror
Note that deprecated warnings are not disabled on this build, as the
idea is that on "old" one we shouldn't have any depracated warnings
anymore.
2024-10-13 00:46:58 +02:00
Guido Cella e34f6569ee stats.lua: rename a variable 2024-10-12 21:24:41 +02:00