Commit Graph

1042 Commits

Author SHA1 Message Date
Dudemanguy 76367dae35 m_config_core: fix forced option notification with m_config_cache
bc28f7693d originally added this, but the
implementation isn't correct and causes excessive notifications when
writing to other options which may have bad behavior in some some
circumstances. Fix this by reworking the implementation for force
options so that the timestamps of the option update compared instead.
Whenever an option gets changed, the internal timestamp in the cache is
always incremented. For a special force option, we can save this
timestamp internally as well.

Because cache_check_update is always checked before potentially sending
an option notification, we know that if the internal timestamp is equal
to the timestamp saved by a force update option, it must have been
previously written. Thus, the notification can be sent. This lets
options like geometry work repeatedly but without constantly sending
notifications. Fixes #13954.
2024-04-26 17:42:52 +00:00
Dudemanguy dc9da5d463 options: flag geometry/autofit options with force_update
Same reasoning as window-scale. This still requires that the windowing
backend correctly reacts to the notification.
2024-04-18 17:40:16 +00:00
Dudemanguy bd1bcc1f31 player: always notify when writing window-scale option
As described in the previous commit, update_window_scale will always
execute whenever window-scale is written even if the value doesn't
change.
2024-04-18 17:40:16 +00:00
Dudemanguy bc28f7693d m_option: add a force_update boolean
mpv's core does not propagate option notifications unless they actually
change to the rest of the player. Most of the time, this makes perfect
sense. If the user sets fullscreen multiple times, there's no reason to
care about anything other than the change in state. However, there are
certain options where it makes sense to always broadcast a notification
even if the value doesn't change. For example, consider the window-scale
case. A user may set window-scale to some value, resize the window
further through some other means (such as mouse resizing) and then want
to set the window-scale again to the same value as earlier. The
window-scale value did not change from before so no notification is sent
and nothing happens even though it is desirable and expected that it
operates again.

This was solved by making the current-window-scale property writable a
few years ago, but actually the easier solution is to just always force
the option to update on any write. For the big callback, the needed
changes are trivial. Unfortunately, it requires a hot mess in order to
have this work with the m_config_cache_update APIs. Spooky stuff in
there, but it does send the notification now.
2024-04-18 17:40:16 +00:00
nanahi 750dec880c m_option: change confusing error messages for obj_settings_list
This option type is not used only by filter options: they're already
used by --ao, --vo, and --gpu-context. Replace the mentions of
"filter" to "item" instead, and changes some languages to improve clarity.

Also change the documentation on "Filter options" to describe what it
really is, and fix a typo.
2024-04-18 16:28:21 +02:00
llyyr 805577c792 sd_ass: add `sub-vsfilter-bidi-compat` to enable vsfilter bidi compat
Enable ASS_FEATURE_{WHOLE_TEXT_LAYOUT, BIDI_BRACKETS} and auto base
detection by default, and add an option to disable this if needed.

This is strictly an improvement for webvtt files as they always use
auto base detection. This _fixes_ right-to-left text rendering for
webvtt files which correctly mark rtl/ltr. Webvtt files obtained from
sources which sideload the RTL information through css also see an
improvement due to the auto detection.

Generally SRT files also want this, but some are also written to
workaround VSFilter quirks.

See also: https://github.com/mpv-player/mpv/pull/12985#issuecomment-1839565138
2024-04-18 00:14:44 +02:00
nanahi dcd1034529 x11_common: implement --show-in-taskbar option
This adds a new option --show-in-taskbar, which controls whether
mpv appears in taskbars. This is useful for picture-in-picture
setups where the video window should not appear in taskbars.

On X11, this can be controled by setting the
_NET_WM_STATE_SKIP_TASKBAR window state.
2024-04-18 00:09:09 +02:00
Kacper Michajłow 7b181c989e options: fix runtime update of teletext-page 2024-04-17 23:41:30 +02:00
Dudemanguy 91489c9466 options: add --input-commands option
Basically a simple way to perform any command/property action from the
command line. This takes the exact same syntax as input.conf but not
including the key naturally. Potentially useful for weird properties
that don't map well to options (like ao-volume). Fixes #12353.
2024-03-21 14:48:53 +00:00
Kacper Michajłow 8708f4dc91 m_property: add `>` for fixed precision floating-point expansion
This enhancement makes it easier to create constant width property
expansions, useful for the `--term-status-msg`. Additionally, it changes
to `%f` printing with manual zero trimming, which is easier to control
than `%g`. With this method, we can directly specify precision, not just
significant numbers. This approach also avoids overly high precision for
values less than 1, which is not necessary for a generic floating-point
print function.

A new print helper function is added, which can be used with adjusted
precision for specific cases where a different default is needed. This
also unifies the code slightly.
2024-03-21 03:50:11 +01:00
nanahi 302ccf18ef options/m_config: fix no newline at end of file 2024-03-19 08:58:18 +01:00
sfan5 ead9f892b3 various: use static assertions where appropriate 2024-03-17 20:04:04 +01:00
llyyr 084a8782e3 path: don't load any files if --no-config is passed
`--no-config` should prevent loading any user files, whether it be
config, cache, watch_later state etc. This functionality was changed by
df758880e2 because internally `--no-config` is equivalent to passing
`--config-dir=""` which resulted in cache and state being auto-detected
even if `--no-config` was passed.

Fixes: df758880e2 ("path: don't override "cache" and "state" paths with configdir")
2024-03-11 21:29:46 +01:00
der richter 94e5a0ffb2 options: remove trailing whitespaces 2024-03-10 14:53:07 +01:00
der richter 0ec385bc76 options: remove --focus-on-open and add --focus-on
replaces the old focus-on-open option with a more generic focus-on
options that can be extended.

adjust the only platform that uses that option.

Fixes #8337
2024-03-10 14:53:07 +01:00
1nsane000 38a8e9bcba options: add --deinterlace-field-parity option
Previously there was no way to specify the field order of interlaced videos
when deinterlacing with inbuilt filters. Lavfi deinterlacers seemed to prefer
top field order while inbuilt ones (vdpaupp, vavpp, d3d11vpp) seemed to prefer
bottom field order. The default "auto" option should work exactly as before
while specifying either "tff" or "bff" should force the specified field order
2024-03-04 17:41:40 -08:00
Dudemanguy 4560d93bf0 Revert "player: add ao-volume option, to set the system volume at startup"
Ended up being a bad idea. As a property, this inherently has more
functionality and the tradeoff of being able to do --ao-volume wasn't
worth it.

This reverts commit 58ed620c06.
2024-03-01 09:20:15 -06:00
Kacper Michajłow 0897604298 various: avoid function pointer casts
The opt validator functions are casted to generic validator, which has
erased type for value. Calling function by pointer of different
definition is an UB.

Avoid that by generating wrapper function that does proper argument type
conversion and calls validator function. Type erased functions have
mangled type in the name.

Fixes UBSAN failures on Clang 17, which enabled fsanitize=function by
default.
2024-02-28 16:04:02 +00:00
der richter 86fa9b18a3 osdep/mac: make mac naming of files, folders and function consistent
rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to
make naming consistent.
2024-02-28 15:52:47 +01:00
Guido Cella 09f6f28cc2 osd_libass: update the OSD bar's dent and border size
Make the OSD bar markers bigger so we can default to a smaller,
better-looking border size, without sacrificing markers' visibility.
2024-02-26 16:01:21 +00:00
David Vaughan da753196af player: change insert_next to insert_at
Change the `playlist_insert_next` function to `playlist_insert_at` (ie,
insert at the location of an entry, rather than after it, and rename to
be clearer that it doesn't have anything to do with the
currently-playing entry).

Also, replace calls to `playlist_add` with calls to
`playlist_insert_at`, since the former has become redundant.
2024-02-26 02:03:21 +00:00
David Vaughan a8a314b829 input: add insert-next support for drag-and-drop
This commit adds a DND_INSERT_NEXT action option for drag-and-drop,
allows for selecting it through the --drag-and-drop=insert-next option,
and adds the necessary plumbing to make that happen when something is
dragged onto the player.
2024-02-26 02:03:21 +00:00
Leonardo Boss 58ed620c06 player: add ao-volume option, to set the system volume at startup
closes #12353
2024-02-25 23:57:35 +00:00
Dudemanguy 74b4c3c531 player: set hidpi-window-scale to no by default
This has defaulted to yes for a very long time, but evidentally it
annoys a lot of people (including myself). My argument is that this
makes no sense. mpv is for videos; not text. A 1920x1080 video should
open as 1920x1080 regardless of whatever the DPI settings of the OS is.
This can get very silly when you consider watching a 4k video which will
get this additional scale factor which is virtually never desirable.
Whether or not the OS and/or WM prevents it from getting larger than the
screen depends on a lot of things.

Previously some windowing backends required that this option be set to
yes in order to report a dpi scale value other than 1, but this should
be fixed with the previous commits. The only difference is whether or
not to scale the window by the additional factor.

Fixes #13465.
2024-02-24 20:31:08 +00:00
nanahi 4e73602ae5 options/path: move path utility functions to misc/path_utils
These utility functions have nothing to do with user and config dir/file.
Move them to a separate file.
2024-02-23 21:35:57 +01:00
der richter d954646d29 various: make mentions of macOS consistent
change all mentions and variations of OSX, OS X, MacOSX, MacOS X, etc
consistent. use the official naming macOS.
2024-02-21 20:46:53 +01:00
Dudemanguy 85e84f6d92 vo_gpu_next: move gpu-next opts to specific sub option
This matches the general workflow in the codebase. We keep a cache of
these new options and update them if needed.

Fixes #13481 and fixes #11518.
2024-02-17 18:56:20 +00:00
Kacper Michajłow 024e49010c m_option: fix memory leak in parse_obj_settings_list
Found by fuzzing.
2024-02-15 16:43:37 +00:00
Mohammad AlSaleh a1bda5b34d sub: allow setting lavc txt_page special values via teletext_page
* Range of accepted values for teletext_page now include 0 and -1.
 * 0 means "subtitle" and -1 means "*".
 * Make 0 the default.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-02-13 10:44:41 +01:00
Dudemanguy 8dbbc2ad82 player: add an auto option to deinterlace
Deinterlacing required that the user set it on/off themselves, but we
actually have handy flags for detecting if a frame is interlaced. So
it's pretty simple to make an auto option using that. Unfortunately,
life is not quite that simple and there are known cases of false
positives from the ffmpeg flags so we can't make auto the default value.
However, it still may have some utility for some people, and the
detection could potentially be improved upon later. Closes #10358.
2024-02-07 14:50:09 +00:00
Dudemanguy 531868fe0d player: ensure runtime updates of certain rendering options
When adding things like brightness or gamma, the video obviously needs a
redraw if paused. This happened to work in the normal case because the
OSD notification triggered a redraw, but if you use no-osd the picture
won't change. Fix this by adding another option flag, UPDATE_VIDEO, and
simply signalling we want a redraw. This gets handled along with the
normal osd redrawing check in the playloop so something like "no-osd add
gamma 1" actually works.
2024-02-05 17:23:47 +00:00
Kacper Michajłow ab491472f4 options/m_option: suppress warning about validate function call
It is expected. Last argument of validate functions is always a pointer,
but not always void* which triggers UBSAN warning.

meson since 1.3.1 halts on UBSAN errors in tests, which is good thing.
2024-01-26 03:28:55 +00:00
Mohammad AlSaleh 02a20b4ebe sub: add `--sub-lavc-o` option
We have `--vd-lavc-o` and `--ad-lavc-o`, but no equivalent option for
 subtitles.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-21 17:55:11 +00:00
Dudemanguy a39f9b6181 player: remove --term-remaining-playtime option
This wasn't useful and didn't even really do what it said anyway.
Closes #12167.
2024-01-20 23:24:48 +00:00
nanahi f04727145b audio: add --volume-gain options to control volume in decibels
This adds volume-gain, volume-gain-max, volume-gain-min options, which
can be used to control audio volume and target dynamic range in decibels.
The gain is applied on top of the existing volume setting.
2024-01-20 16:08:33 +00:00
Dudemanguy 2ad96079e9 player: add forced choice to subs-with-matching-audio
fe875083b3 confused things a bit and made
--no-subs-with-matching-audio actually mean what it says: no subtitles
if the languages match. However, the option actually meant no non-forced
subtitles not no subtitles at all. This isn't really intuitive so
instead of changing the behavior back to the old way (we already have a
release since then), add a third option "forced" which is equivalent to
the old meaning of --no-subs-with-matching audio. Fixes #13151.
2024-01-13 03:26:06 +00:00
dyphire b563b2aed0 options: add --secondary-sub-ass-override
Default: strip. preserve the old behavior
2023-12-18 14:58:34 +00:00
Dudemanguy b0f31a7637 player: refactor secondary subtitle options and properties
Over the years, we've accumulated several secondary subtitle related
options and properties, but the implementation was not really consistent
and it wasn't clear what the right process for adding more should be. So
to make things nicer, let's refactor all of the subtitle options with
secondary variants (sub-delay, sub-pos, and sub-visibility) and split
them off to a new, separate struct. All of the underlying values are
stored in an array instead for simplicity. Additionally, the
implementation of some secondary-sub-* properties were slightly changed
so there would be less redundancy.
2023-12-16 15:25:32 +00:00
karelrooted 3250f6e447 options: add --secondary-sub-pos
The default value is 0 (on the top of the screen)
2023-12-13 21:18:57 +00:00
Dudemanguy 6d1383383b playlist: correctly populate playlist-path with the --playlist option
When using the --playlist option on the commandline, it would mark all
entries on the command as having the playlist-path of the value of that
passed option, not just the ones that were expanded from it. Fix this by
moving the playlist_populate_playlist_path to the same place where the
playlist file gets expanded.

Ref https://github.com/mpv-player/mpv/issues/13075#issuecomment-1852179164
2023-12-13 15:25:14 +00:00
Dudemanguy 443c2487d7 filter_sdh: add full width parentheses to the enclosures string
Since these are technically parentheses, we'll treat them the same way
as normal parenthesis. Fixes #11155.
2023-12-08 18:14:06 +00:00
Dudemanguy ce958b7742 filter_sdh: add --sub-filter-sdh-enclosures option
This filter is a bit complicated, but one of the essential parts of it
is removing text enclosed by particular set of characters (e.g. text
inbetween []). This was previously hardcoded to only take into account
parenthesis and brackets, but people may want to filter more things so
make this customizable. The option only takes "left hand characters" so
the right pair is mapped internally if applicable. If not, then we just
use the same character. Fixes #8268 since the unicode character in
question can just be passed to this option.
2023-12-08 18:14:06 +00:00
llyyr 562450f59e m_option: respect pathlist seperator when printing
Apparently we never did this
2023-12-04 20:35:50 +01:00
Guido Cella 0c4812aa72 options: add --osd-bar-border-size
Closes #1484. The default size is smaller than the previous
--osd-border-size default value of 3 with the default --osd-bar-h.
2023-11-27 15:02:28 +00:00
Ripose dea512ea38 options: add secondary-sub-delay
Add --secondary-sub-delay option and decouple --sub-delay from secondary
subtitles. This produces desirable behavior in most cases as secondary
and primary subtitles tracks tend to be timed independently of one
another.

This feature is implemented by turning the sub_delay field in
mp_subtitle_opts into an array of 2 floats. From here the track index is
either passed around or derived when sub_delay is needed. There are some
cases in dec_sub.c where it is possible for dec_sub.order (equivalent to
track index) to be -1. In these cases, sub_delay is inferred as 0.
2023-11-26 23:22:05 +01:00
Kacper Michajłow e669493e6e options: add more properties to default watch-later-options
Adds:
--secondary-sub-visibility
--video-aspect-method
--video-unscaled
--video-pan-x
--video-pan-y
--video-rotate
--video-crop
--video-zoom
--video-scale-x
--video-scale-y
--video-align-x
--video-align-y

Those properties are related to playback state and are likely expected
to be restored when resuming playback.
2023-11-12 21:25:22 +00:00
Kacper Michajłow cb30c497c2 options: remove not relevant props from default watch-later-options
Removes:
--border
--fullscreen
--ontop
--osd-level
--pause

Those options are not really content related. I don't see much gain to
save them per each watch later entry.
2023-11-12 21:25:22 +00:00
Guido Cella 8b3075c9be m_option: remove leftovers of del action
b56e63e2a9 removed -del for list options but it is still listed in the
list structs, which means that it is still tab completed on the CLI like
the other actions, and seems to behave like -set. Remove it so it is no
longer tab completed.

Also remove the description of -del from the help output of object
settings lists --(ao|vo|af|vf)-help, and update a comment.
2023-11-12 18:48:25 +00:00
Mohammad AlSaleh d470766000 sub: add --sub-stretch-durations option
Stretch a subtitle duration so it ends when the next one starts.
 Should help with subtitles which erroneously have zero durations.

 I found such a subrip substitles stream in the wild.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2023-11-07 20:46:40 +00:00
Dudemanguy cf69fa03ca vo: replace max swapchain depth magic number 2023-11-07 00:52:46 +00:00