Commit Graph
100 Commits
Author SHA1 Message Date
nanahi 5659a9a9c8 DOCS/man/options: clarify --playlist expansion behavior
It's not recursive except for directories.
2026-07-26 11:50:05 +02:00
nanahi f76519ebd8 DOCS/man/options: clarify how --shuffle option works
There are many misconceptions about how this option work.
Make it more clear.
2026-07-26 11:50:05 +02:00
nanahi 05d45f4955 DOCS/man: mention when options are marked as file-local 2026-07-26 11:49:30 +02:00
nanahi 42d50061f6 DOCS/man/input: use connect terminology for file-local options
The file-local-options property sets options that are reset when file
change occurs. This is different from per-file options which are set with
--{ commandline arguments and options parameter of the loadfile command.
Per-file options use file-local option mechanism for setting options when
the file is loaded, but they are persistent and stay with the playlist
entries, unlike file-local-options set at runtime.

This corrects the on_load hook documentation about the effect of setting
file-local-options.
2026-07-26 11:49:30 +02:00
nanahi 731229bd2b options: add --playlist-inherit-options option
This allows controlling whether the files in a playlist inherit the
per-file options of the playlist file itself. For playlists created
by --autocreate-playlist, --playlist-inherit-options=current allows
inheriting only for the item the playlist is created from.
2026-07-26 11:49:16 +02:00
nanahi 19215efe61 player/loadfile: inherit file-local options when resolving playlist file
Currently, if a playlist file is played and replaced by its contents,
the per-file options of the playlist file are ignored.

This commit makes these options inherited for its contents so they work
as expected.
2026-07-26 11:49:16 +02:00
nanahi 97db44f89f common/playlist: add playlist_set_params function
Helper function to set file local options for all entries. Will be used
in the next commit.
2026-07-26 11:49:16 +02:00
nanahi 9281bccfdf osdep/compiler: don't use __has_builtin for __builtin_mul_overflow
The feature test macro is nonstandard and not available on older GCC
version, which causes build failure despite the compiler does support
__builtin_mul_overflow.

Since there are no fallback when __builtin_mul_overflow is not
available, there is no need to check, so simply remove it.
If __builtin_mul_overflow is not supported compilation will still fail
just like currently.
2026-07-06 18:25:12 +02:00
nanahi 6444c05059 filters/frame: use correct check for mp_frame_set_pts
Not effect for current handlers.

Fixes: [Bug] frame.c: Wrong handler check in mp_frame_set_pts
(get_pts instead of set_pts)
2026-06-08 01:26:23 +02:00
nanahi e7f5d8f9c8 filters/filter: fix dropping request logging
Fixes: 76276c9210
2026-06-08 01:26:23 +02:00
nanahi c42393a280 video/filter/vf_amf: fix profile option
Fixes: [Bug] vf_amf.c: Profile always forced to FRC_PROFILE_HIGH
2026-06-08 01:26:23 +02:00
nanahi c9cf510d6a video/filter/vf_format: fix changing gamma check
Fixes: 76276c9210
2026-06-08 01:26:23 +02:00
nanahi 6a5e514509 input/sdl_gamepad: move controller null check to front
No need to call SDL_GameControllerGetJoystick if controller is NULL.
2026-06-08 01:26:23 +02:00
nanahi a24227d7ad stream/stream_bluray: fix chapter range check
Fixes: 62786c0c91
2026-06-08 01:26:23 +02:00
nanahi f29fcafb81 video/filter/vf_gpu_vulkan: parent opts to ctx
And only free explicitly on success. On failure it will be freed by
parent.

Fixes: [Bug] vf_gpu_vulkan: Use-after-free of ctx_opts
2026-06-08 01:26:23 +02:00
nanahi 579a62c2ba video/filter/vf_gpu_vulkan: remove redundant frees
ractx and vk are parented to ctx. No need to free manually.
2026-06-08 01:26:23 +02:00
nanahi 1d82932cce various: use fopen wrapper for cloexec handling 2026-06-04 04:58:16 +02:00
nanahi 1f150567ac osdep/io: fix fdopen mode flag
In both C11 standard and Microsoft documentation, '+' must be placed
immediately after mode, so placing 'b' between them is incorrect.
2026-06-04 04:58:16 +02:00
nanahi f1a42eff01 osdep/io: use mp_fopen on all platforms
Currently, all fopen uses in mpv do not set cloexec flag, resulting
in fd leak whenever mpv creates a process.

This makes mpv use mp_fopen on all platforms, and always set O_CLOEXEC
on the opened fd. This is required because the "e" flag for fopen is
nonstandard and UB in C11, and unsupported on macOS.

This had been done similarly in other projects. e.g.
https://gitlab.com/graphviz/graphviz/-/merge_requests/3797
2026-06-04 04:58:16 +02:00
nanahi 21351a0580 options/m_property: only get m_option info when needed
Micro optimization.
2026-05-12 21:39:34 +02:00
nanahi f98b114d58 options/m_property: use mp_require for log
log cannot be null on write path which is true for multiply and switch.
2026-05-12 21:39:34 +02:00
nanahi ae23198144 options/m_property: simplify m_property_multiply/m_property_switch
M_PROPERTY_GET_CONSTRICTED_TYPE is already acquired, just pass m_option
directly.
2026-05-12 21:39:34 +02:00
nanahi 6320792f1b options/m_property: try to get constricted type in m_property_do
When setting properties via M_PROPERTY_SET_NODE, the property value
is limited by static declared range. However, some properties like
volume handle dynamic M_PROPERTY_GET_CONSTRICTED_TYPE requests and
return runtime determined limits. M_PROPERTY_SET_NODE in this case
does not respect that limit, and allows setting to a value out of
range.

Fix this by always trying to use M_PROPERTY_GET_CONSTRICTED_TYPE
first so that the dynamic limits will be used.
2026-05-12 21:39:34 +02:00
nanahi 27ec68fbd8 options/m_property: add log null check to m_property_multiply
Similar to m_property_switch, cannot be null for write paths.
2026-05-12 21:39:34 +02:00
nanahi 13550bd31d options/m_property: extract m_property_switch to a function
Similar to m_property_multiply.
2026-05-12 21:39:34 +02:00
nanahi 7b057f66fa DOCS/man/mpv: add usage hint alternative for pseudo-gui profile
This has been deprecated for 9 years since
9eef41dec1.
With the previous commit, this can be replaced by conditional autoprofiles.
Add usage hint to the documentation.
2026-05-09 15:01:09 +02:00
nanahi ed2e55b941 options: make player-operation-mode readable as a property
Make it readable as a property so that scripts and conditional
autoprofiles can customize behavior depending if player is
launched as pseudo gui mode.
2026-05-09 15:01:09 +02:00
nanahi 5e847889b3 osdep/win32/smtc: fix client handle leak 2026-05-01 13:42:57 +02:00
nanahi 0ec3015339 player/external_files: remove handling related to update sub exts
This is only used to update the list for player internal sub ext matching.
Since this handling now lives in the dnd client, it can be removed from
core, which also eliminates a global variable.
2026-05-01 13:42:57 +02:00
nanahi 675fb1229b input/dnd: move --drag-and-drop handling to dnd client
This unifies --drag-and-drop handling to a single place. All platforms
currently only support normal drop (mapped to "replace") and shift click
drop (mapped to "append").
2026-05-01 13:42:57 +02:00
nanahi 81611b4a4e input/dnd: move built-in drag and drop handling to mpv client
This moves the drag and drop handling to an internal mpv client,
removing the hardcoded handling from core.
2026-05-01 13:42:57 +02:00
nanahi 87ccb6022c command: add dropped-file property
This adds dropped-file property which contains a list of dropped files
and the type of the drop. This allows clients to implement custom drag
and drop handling.
2026-05-01 13:42:57 +02:00
nanahi e12ab84571 input: add --input-builtin-drag-and-drop option
This allows disabling the built-in drag and drop handler, while still
allowing VO to announce dropped files.
2026-05-01 13:42:57 +02:00
nanahi 544a56a148 input: rename notify_touch_update to notify_event_update
Will also be used to notify dnd updates.
2026-05-01 13:42:57 +02:00
nanahi 41fb7f9eb2 command: use string list helper for option-info 2026-05-01 13:42:57 +02:00
nanahi 777401d7de options/m_property: add SUB_PROP_STRING_LIST
Helper used in next commits.
2026-05-01 13:42:57 +02:00
nanahi 5e0932e785 input: rename mp_event_drop_files to mp_input_drop_files
Move it to input.c. Will be used in next commit.
2026-05-01 13:42:57 +02:00
nanahi 531fe5a43e osc.lua: make window control buttons action customizable
Use bind_mouse_buttons helper. This makes it possible to bind custom
actions, such as right click X button to quit with watch later.
2026-04-21 18:19:18 +02:00
nanahi d9e8e0bdf6 osc.lua: add option to configure skip_forward/backward buttons
This adds _down_command support to bind_mouse_buttons so it can be
used to bind button down actions like mbtn_left_down, and let forward
and backward buttons use bind_mouse_buttons. This makes mouse button
down actions customizable.
2026-04-21 18:19:18 +02:00
nanahi b3e6506d10 osc.lua: fix frame stepping with skip_backward/forward buttons
The event responder must have up, down, or press suffix, but
940ab99055 removed it for frame stepping
function, making it unusable. Fix this by using the down suffix.

Fixes: 940ab99055
2026-04-21 18:19:18 +02:00
nanahi 25e9a0c740 player/command: remove inaccurate comment in cmd_mouse 2026-04-18 21:13:46 +02:00
nanahi bceb1eeaf4 Revert "player/command: don't send mouse move event on mouse leave request"
There is no reason to do this, since VOs do report mouse position when
outside of window in some cases.

This reverts commit 3ff7b04790.
2026-04-18 21:13:46 +02:00
nanahi 891273055f DOCS/man/input: fix mouse-pos/hover documentation
The comment about video backends not updating pointer position is only
true if no mouse button is being pressed. If mouse button is pressed on
mpv window and then moves out of window region without releasing the
button, some platforms (win32, Wayland, X11) "capture" the pointer and
still report the coordinates, while some other platforms (SDL) do not.

The value of mouse-pos/hover also differs between platforms in this case.
The value is true on win32 and Wayland, but false on X11.

Fix documentation to address them.
2026-04-18 21:13:46 +02:00
nanahi 57490dd3a6 vo_gpu_next: add image-subs-hdr-peak=video-dynamic/video-static
Subtitles in general have constant brightness, but currently
--image-subs-hdr-peak=video uses detected peak value which is not synced
with scene and undesirable.

Add new modes that allow using static peak metadata or per-scene metadata.
2026-04-17 19:44:15 +02:00
nanahi 7f81e1ec8c vo_gpu_next: fix image subtitle hdr peak
704afb8968 assumed that HDR image
subtitles target SDR white. However, this is incorrect according to
UHD BD spec version 3.2:

> CLUTs of Presentation Graphics streams and Interactive Graphics streams
> are prepared by content author according to dynamic range property of
> the Primary video stream.
> If a Primary video stream is HDR, the Graphics streams have CLUTs
> expressed in BT.2020 color space primaries and ST2084 EOTF.
> If a Primary video stream is SDR, the Graphics streams have CLUTs
> expressed in BT.709 color space primaries and BT.1886 EOTF.

This means that PGS subtitles always have the same colorspace and HDR
dynamic range as the video, so the target peak should also be the same.

This is also supported by the BD-J spec (which displays PGS graphics):

> However the BD-ROM player does not support color space conversion nor
> dynamic range conversion of Java graphics and Background plane when
> mixing with video plane.

The Graphics model spec further states:

> The composited image on the graphics plane is transformed to full color
> and transparency by the CLUT module and then overlaid on the video
> image.

These sentences indicate that BD-ROM players simply overlay the decoded
graphics onto the video without any kind of conversion.

Change the default of image-subs-hdr-peak to 1000 to fix this.
This accommodates most HDR videos with a peak brightness of 1000 nits
and some bad HDR videos with 10000 nits peak brightness due to reencoding
and mixed with unmodified subtitles.
If there are compatibility issues, the option can be manually
set to sdr or video.

Fixes: 704afb8968
2026-04-17 19:44:15 +02:00
nanahi 1fea31f00c player/external_files: do not log for 0 priority files
They are not considered potential external files.
2026-04-17 04:09:23 +02:00
nanahi f5931117f0 player/external_files: fix --cover-art-whitelist priority
Since cb56c2f888, the priority of
--cover-art-auto and --cover-art-whitelist is unclear. Depending on the
number of elements in --cover-art-whitelist, the priority of
--cover-art-whitelist files can be lower, equal, or higher than
--cover-art-auto matches, creating unpredictable behavior.

Fix this by making --cover-art-whitelist priority always between "fuzzy"
and "all" priority. test_cover_filename now uses bstr_find_in_list0 to
return a negative priority value depending on the position in list.
The "all" priority is set to INT_MIN. Modify filter_subidx to use 0
priority as removal marker, since all files in the external files list
already have non-zero priority.
2026-04-17 04:09:23 +02:00
nanahi d711657833 options/m_option: use bstr_find_in_list0
Removes redundant find_list_bstr function.
2026-04-17 04:09:23 +02:00
nanahi 3d568495fc misc/bstr: move str_in_list to this file
Rename it to bstr_in_list0 and implement it in bstr_find_in_list0.
2026-04-17 04:09:23 +02:00
nanahi ac8d69e6fc misc/bstr: add bstr_find_in_list0 function
This will be used to unify several find in list handlings.
2026-04-17 04:09:23 +02:00
nanahi b20a33287b player/main: don't use atoi
Prevents UB if the value cannot be represented.
2026-04-17 04:09:23 +02:00
nanahi da2739f44f various: don't check if endptr is null for strto[udll]
These functions always set endptr to non-null so there is no need to
check.
2026-04-17 04:09:23 +02:00
nanahi 6260e7236c player/scripting: use strcasecmp for comparing script files
The documentation says that the scripts are loaded in alphabetical order,
which indicates that the case is not sensitive. Use strcasecmp to satisfy
this requirement.
2026-04-17 04:09:23 +02:00
nanahi 2b62f7c861 player/external_files: use natural sort for comparing filenames
Similar to the method used elsewhere in mpv.
2026-04-17 04:09:23 +02:00
nanahi 6b3cb12dac player/external_files: rename subtitle references to external file
These functions are used to load all external files, not only
subtitles.
2026-04-17 04:09:23 +02:00
nanahi a9e1ce9c0d DOCS/man/options: fix description for testing with all hwdec methods
The comment is not longer true since auto now means auto-safe.
Change to auto-unsafe which is the setting to use to test all methods.
2026-04-16 17:18:42 +02:00
nanahi 7ace42f505 ytdl_hook.lua: use _name key for mp.command_native 2026-04-06 18:33:20 +02:00
nanahi 1839da1d07 select.lua: use _name key for mp.command_native 2026-04-06 18:33:20 +02:00
nanahi 3b86e32c2b defaults.lua: use _name key for mp.command_native 2026-04-06 18:33:20 +02:00
nanahi 095d858a19 defaults.js: use _name key for mp.command_native 2026-04-06 18:33:20 +02:00
nanahi b0f9279824 TOOLS/lua/command-test.lua: use _name key for mp.command_native 2026-04-06 18:33:20 +02:00
nanahi dbd31fd9d3 DOCS/man: use _name key for mp.command_native 2026-04-06 18:33:20 +02:00
nanahi 80582efca5 input/cmd: use _name for command name in mpv_command_node
Some commands have named arguments named "name", which conflict with
the "name" entry used to specify command name in mpv_command_node, so
they cannot be used with mpv_command_node.

These commands include:
set, del, change-list, add, cycle, multiply, enable-section,
disable-section, define-section, script-binding, keybind, keypress,
keydown, keyup, apply-profile.

This makes mpv_command_node accept command name as key "_name", so
"name" can be used to specify command arguments. For compatibility,
if "_name" entry does not exist, then "name" is used as fallback.
2026-04-06 18:33:20 +02:00
nanahi b7377ede18 DOCS/man/options: document @ syntax for --input-ipc-server 2026-04-06 18:31:27 +02:00
nanahi b11ae04f37 input/ipc-unix: don't delete file for abstract sockets
If --input-ipc-server path name starts with "@", then "@" is replaced
with a null character, which represents the abstract socket namespace
on Linux. Because abstract sockets have no file system presence, it
should not delete the file with the same name starting with "@".
2026-04-06 18:31:27 +02:00
nanahi c2d9905598 DOCS/man/options: add note about %tX behavior change 2026-04-06 18:30:10 +02:00
nanahi edf6016ecf player/screenshot: support %s date format on all platforms
Previous commit left the common %s format extension unresolved.
This implements the format in a platform independent way so it can be
used on all platforms, including on Windows where strftime does not
support %s.
2026-04-06 18:30:10 +02:00
nanahi 87d359eabf player/screenshot: validate strftime format string
The format specifier is controlled by the user that can be arbitrary
character. Using invalid specifier in strftime is UB. Fix this by only
accepting the specifiers recognized in C11.

Partial compatibility is provided for extension formats k, l, P by
translating them to the closest standard alternative.
2026-04-06 18:30:10 +02:00
nanahi dfef53f94b player/screenshot: fix null dereference when failing to get time
localtime can fail and return NULL, which causes NULL dereference
for strftime.
2026-04-06 18:30:10 +02:00
nanahi e0fe1a45d2 command: fix race in reading pad_buttons_pressed
mp_input_get_tablet_pos stores the address to an array that is protected
by lock, and the content is accessed without acquiring lock.

Fix this by writing the values to an array inside mp_input_get_tablet_pos.

Fixes: 0fbf20f057
2026-04-06 18:28:04 +02:00
nanahi b67a5b4cd8 input: fix out of bound read/write in pad_buttons_pressed
When buttons > MP_MAX_TABLET_PAD_BUTTONS and the value is stored in
ictx->tablet_pad_buttons, the next mp_input_set_tablet_pad_focus call
will cause out of bound write, and mp_property_tablet_pos will cause
out of bound read.

Fix this by limiting ictx->tablet_pad_buttons range.

Fixes: 0fbf20f057
2026-04-06 18:28:04 +02:00
nanahi cf957b4f2a player/command: use m_property_read_sub_validate when suitable
Avoids wasting resources on trivial requests.
2026-04-06 18:26:34 +02:00
nanahi 629205280c player/command: rename to mp_property_list_editions
Use mp prefix like everything else.
2026-04-06 18:26:34 +02:00
nanahi 7f28b8818a player/command: use m_property_read_sub for mouse-pos
Allows reading using sub property syntax.
2026-04-06 18:26:34 +02:00
nanahi 9bf9bb50de options/m_option: fix valid format in geometry option help message
/WS format is accepted.
2026-04-06 18:23:25 +02:00
nanahi 94d06bc727 options/m_option: allow /WS geometry parameter usable without XYWH
This allows specifying workspace while using autofit for window size
or leave it as default instead of mandatory geometry in pixels.
2026-04-06 18:23:25 +02:00
nanahi befe1e73a2 video/out/x11_common: fix BadAtom error when getting atom name
When XdndEnter advertises format without using XdndTypeList, some of
the atoms in the 3 fixed items may be None, which causes error in
XGetAtomName. Fix this by not resolving name when atom is None.

Fixes the following error message when dragging file on mpv window:
X11 error: BadAtom (invalid Atom parameter)
2026-04-04 21:36:07 +02:00
nanahi 4e6196e1a6 player/command: fix update-clipboard text-primary
It mistakenly updates text instead.
2026-04-02 00:05:27 +02:00
nanahi e45f86225f demux_playlist: don't get config group again when checking shuffle
The shuffle option is already available as p->mp_opts->shuffle since
44a3a3293f.
There is no reason to get the config group again and free it.
2026-03-30 00:07:45 +00:00
nanahi ae6728a7c0 misc/io_utils: allow mp_save_to_file writing empty files 2026-03-25 01:41:05 +01:00
nanahi 514c8097a9 player/configfiles: use mp_hash_to_bstr 2026-03-23 15:03:38 +01:00
nanahi 1bd29b0ba2 video/out/gpu/lcms: use mp_hash_to_bstr 2026-03-23 15:03:38 +01:00
nanahi b48058e6cb video/out/gpu/shader_cache: use mp_hash_to_bstr 2026-03-23 15:03:38 +01:00
nanahi 58ee11c58a misc/hash: add mp_hash_to_bstr function
This util function uses the generic libavutil hash API to hash any data
with the specified algorithm to a bstr. It deduplicates multiple hash
routines used in mpv.
2026-03-23 15:03:38 +01:00
nanahi 6245d7e92c video/out/opengl/utils: remove redundant imports 2026-03-23 15:03:38 +01:00
nanahi edc8534d0b misc/io_utils: rename cache
The function is used for various purposes so rename cache to something
generic.
2026-03-21 20:14:09 +01:00
nanahi 8b2ab60ae3 video/out/gpu/shader_cache: use mp_save_to_file 2026-03-21 20:14:09 +01:00
nanahi 20b24a0dbd video/out/gpu/lcms: use mp_save_to_file 2026-03-21 20:14:09 +01:00
nanahi 26fbea0205 player/configfiles: check error before copying mtime
Similar to what is mp_write_watch_later_conf is already doing.
2026-03-21 20:14:09 +01:00
nanahi f5cad5c065 player/configfiles: use mp_save_to_file 2026-03-21 20:14:09 +01:00
nanahi 3a8a908641 menu.conf: use update-clipboard command
This command is now required when the default has no clipboard monitoring.
2026-03-21 16:05:36 +01:00
nanahi 59d7315fe2 console.lua: use update-clipboard command
This command is now required when the default has no clipboard monitoring.
2026-03-21 16:05:36 +01:00
nanahi bf054a8357 input.conf: use update-clipboard command
This command is now required when the default has no clipboard monitoring.
2026-03-21 16:05:36 +01:00
nanahi bc4f5ce2ba clipboard-wayland: notify clipboard updates to update-data waiters 2026-03-21 16:05:36 +01:00
nanahi 7d41ceef05 clipboard-wayland: support update_data 2026-03-21 16:05:36 +01:00
nanahi 8611b4c11e clipboard-wayland: disable automatic content fetching 2026-03-21 16:05:36 +01:00
nanahi 613b7f2a77 clipboard-x11: notify clipboard updates to update-data waiters 2026-03-21 16:05:36 +01:00
nanahi 527500b68a clipboard-x11: support update_data 2026-03-21 16:05:36 +01:00
nanahi dd9f7949a2 clipboard-x11: disable automatic content fetching when not monitoring 2026-03-21 16:05:36 +01:00
nanahi f7f7cf18f3 command: add update-clipboard command
This uses the update_data request for clipboard backends that require it.
When clipboard monitoring is disabled, the backends will no longer
fetch data when it detects data change, and will now only do that when
receiving the update_data request.

The client now needs to run this command to update the clipboard content,
otherwise the property value is outdated.

This makes sure that applications that depend on "paste once" behavior
work correctly.

This command runs in a separate worker thread so that it can be used
as a "blocking" way to update clipboard until the update notification
arrives without blocking the playback core. It accepts a maximum timeout
parameter. This uses the existing mp_cancel mechanism to make sure this
command can be aborted and the worker threads will not stall the player
too much when quitting mpv.

For backends that do not support update_data, this command does nothing.
2026-03-21 16:05:36 +01:00