Commit Graph

53673 Commits

Author SHA1 Message Date
llyyr 834f99e469 DOCS/man/input: adjust ao-volume documentation to state reality 2025-02-14 22:48:19 +00:00
Kacper Michajłow f8cbe7b6a6 vo_gpu_next: allow to disable error diffusion when changing --dither
error_diffusion was not disabled even if --dither were changed.
2025-02-14 21:13:18 +01:00
Kacper Michajłow 6294e4846d demux/stheader: use atomic types for mp_codec_params names
Notably they are exchanged between demux and decode thread. It's fine
because we know those pointers will be alive as long as avctx is alive.
And only the value may change during decoding in rare situations. Make
those pointers atomic for the sake of it.

It shouldn't change anything, except some codegen.

From https://www.gnu.org/software/libc/manual/html_node/Atomic-Types.html#Atomic-Types:

In practice, you can assume that int is atomic. You can also assume that
pointer types are atomic; that is very convenient. Both of these
assumptions are true on all of the machines that the GNU C Library
supports and on all POSIX systems we know of.
2025-02-14 16:29:47 +01:00
Guido Cella e9c895f135 DOCS/man/options: explain the difference between panscan and zoom
Also suggest checking --panscan docs from its key bindings.
2025-02-14 15:28:41 +01:00
llyyr d766875587 DOCS/man/input: fix required protocol docs for wayland clipboard
We use the ext protocol, not the wlr specific protocol. Moreover,
"zwlr_data_control_manager_v1" is an interface within the protocol, not
the protocol name itself.
2025-02-14 15:22:58 +01:00
Guido Cella 90480f7ea1 DOCS/man/input: document the clock property
Finally document the property added in 953d225368.
2025-02-14 15:21:54 +01:00
Dudemanguy 1b63b33871 player/sub: eliminate redundancy when printing terminal subtitles
track->selected works for the primary and secondary subtitle.
2025-02-14 15:21:35 +01:00
Kacper Michajłow de837aa80b test/libmpv_common: ensure our atexit clean fires before internal ones
This allow to use MPV_LEAK_REPORT and makes exit order more predictable
when debugging.
2025-02-14 15:21:02 +01:00
Kacper Michajłow d739df9ec3 player/loadfile: don't use ta_set_parent directly 2025-02-14 15:21:02 +01:00
Dudemanguy 58f46e7f0b test/libmpv_test_track_selection: add another multilang selection test
Because you can never have too many tests. This covers some scenarios
that the other multilang one doesn't (multiple tracks with the same
language).
2025-02-13 23:22:28 +00:00
Dudemanguy 9e38208951 test/libmpv_test_track_selection: eliminate reloading redundancy
Loading the file and then waiting it for it to be loaded again doesn't
need to be two separate functions. Combine it into a simple
"reload_file" so it's more readable.
2025-02-13 23:22:28 +00:00
Dudemanguy dba53e1b5b test/libmpv_test_track_selection: remove unneeded option resetting
This got refactored so it only loads one file at a time and not
everything in a loop. The option resetting at the end of conditional
branches is pointless.
2025-02-13 23:22:28 +00:00
Dudemanguy f7a681b362 test: add default track selection testing
The amount of options we have that are related track selection is insane
and touching any of this stuff is scary. Add some track selection
testing to the CI to hopefully make it slightly less scary to touch any
of that. Since trying to work in media files from some outside source
would be a pain and need to live in some repo somewhere, it's nicer to
just generate dummy files on the fly with ffmpeg during the ci runs and
use that. Obviously, the actual tests themselves could be even more
thorough (external tracks were not even considered), but this is more
than a good enough start for now.
2025-02-12 15:29:07 +00:00
Dudemanguy 25067e845c test: split libmpv_test into separate files
The big libmpv test file is really actually three different tests shoved
together into one. They do all use fairly similar underlying structures,
so put the shared stuff into an inline header. There's a little bit of
duplication with regards to the main function, but it's cleaner to
separate out the tests.
2025-02-12 15:29:07 +00:00
Dudemanguy d980e950c6 test: group together all the libmpv tests under the libmpv suite 2025-02-12 15:29:07 +00:00
Dudemanguy 2e1f89a0df github/workflows: drop mingw32
Upstream dropped libplacebo* so we're pretty much out of luck here. It's
not worth it to bother building a subproject for just this one.

*: https://github.com/msys2/MINGW-packages/commit/c3a79e8ae9a8e7f2215db210ba3f44d91d7e23b6
2025-02-12 11:15:04 +01:00
sfan5 bfa3e90867 video/out/android: don't assert-fail if WinID is not set
This matches the behavior of every other GPU context and is the only
behavior that makes sense.
2025-02-11 19:19:36 +01:00
Kacper Michajłow f385a6b253 demux_lavf: fix demuxer-lavf-format usage
mpv internally treats all string options/properties with NULL or an empty string the same way. client.h explicitly forbids MPV_FORMAT_STRING from being NULL, but in the C API, it has been working accidentally due to how strings are copied. Nevertheless, none of the APIs allow this; JavaScript, Lua, IPC, and CLI all require strings to be at least empty. We cannot pass NULL.

Furthermore, currently passing NULL causes an assertion failure in the JSON formatter, so it is clearly not intended to be used that way.

Internally, all string options default to NULL, but in this case, they should behave exactly the same as an empty string. Hence, this change is applied to the `demuxer-lavf-format` option.

Note that get_property will never return a NULL value, regardless of the internal value.

Fixes: #15840
2025-02-10 04:29:55 +01:00
Guido Cella 73b84595a8 select.lua: change the --save-watch-history warning text
The current warning was fine when you select history directly, but
giving more information can be useful when you happen to see it by right
clicking the title without prior information.

Fixes https://github.com/mpv-player/mpv/pull/15655#discussion_r1948053973
2025-02-09 23:30:54 +01:00
Kamikadze e4b64fba9c DOCS/man/options: Clarify what --tone-mapping=auto does 2025-02-08 06:16:38 +01:00
Kacper Michajłow f14660b446 Revert "vo_gpu_next: set --target-colorspace-hint to yes by default"
HDR or any color-space pass-through should be opt-in, as we cannot
control the user's compositor or display. Allowing HDR signals to be
pushed by default may lead to surprising results for some users.
Additionally, for an optimal experience, this option should be paired
with the target-peak of the display.

Make the pass-through opt-in and let the user decide if they want or
need it. By default, mpv should render a safe and consistent sRGB
output. mpv's tone mapping is generally of higher quality than any
external solution.

This reverts commit 23843b4aa5.
2025-02-08 06:15:32 +01:00
Kacper Michajłow bc430fdbb8 player/command: don't synthesize property names with a trailing /
This is not only cosmetic, but also avoids dummy get key action with
empty key. While this was allowed previously, I'm bit concerned about
Hyrum's law. But let's be strict about it.

This commit fixes current-tracks property.

Fixes: 95019fc256
2025-02-08 05:45:57 +01:00
Dudemanguy f9b95cb83d command: disallow trailing / in track-list/N/metadata
To have consistency with 95019fc256
2025-02-08 05:44:06 +01:00
Kacper Michajłow 50f3c1c243 player/command: disable input-commands for fuzzing
Updating input-commands string list causes all commands to be rerun.
This happens during load-config-file command, so even with few commands
it is easy to amplify single command to run hundreds of times instead of
one. This causes timeouts and OOMs when specific command for example
reopens current playlist appending an item.

Also avoid even single input-commands, we want to test load-config-file
parsing and input-commands can do loadfile and trigger heavy code
paths. We don't want to mix this. Unfortunately parsing of
input-commands will not be tested.
2025-02-08 05:41:22 +01:00
Kacper Michajłow 95019fc256 m_property: fix playlist property parsing
Disallow silly things like ${playlist//} and trailing slashes
${playlist/0/}.
2025-02-08 02:01:52 +00:00
Guido Cella 3c1ddc411c console.lua: fix completion after command prefixes
I'm not sure when this broke but completions after command prefixes were
not being updated.
2025-02-08 02:01:40 +00:00
Guido Cella a62c559d82 command: show Loop playlist when changing --loop-playlist at runtime
Just "Loop" is a leftover from when --loop-playlist was called --loop.
2025-02-08 02:01:25 +00:00
Dudemanguy 18257375e4 m_option: deprecate setting -1 to --video-aspect-override
It's unfortunate that it is implemented this way since changing it will
take time. This option should *really* be like OPT_CHOICE but with
doubles and not integers. We don't have that though and implementing it
is something for the future. Even if that was done today, this still
couldn't be switched to since setting -1 has been the effective way for
years to undo video-aspect stuff. So the approach is to just add another
special keyword for this and tell people to use that instead. Note that
setting 0 isn't deprecated since M_RANGE(0, 10) is totally fine and
would work in the future if this option type ever gets redone.
2025-02-08 02:01:13 +00:00
Dudemanguy cb91de2a34 m_option: forbid non -1 negative values for video-aspect-override
Setting this to M_RANGE(-1, 10) meant that you could pass fractional
negative values without it being an error. This is, of course, nonsense.
-1 is the only special negative value with a meaning. Error out if we
get anything else by doing some additional parsing before we send it off
to parse_double which will then restrict the range to 0, 10 with these
changes. Note that this approach requires defval to be there which is
not the most extensible thing in the world. But there's literally only
two OPT_ASPECT type options out of the hundreds we have so not a big
deal. Ideally, this type should be OPT_CHOICE but with underlying
doubles but that's too much effort to implement cleanly.
2025-02-08 02:01:13 +00:00
Dudemanguy 16828aa952 command: convert aspect, par, and sar sub-properties to double
These were still set to float. For some common aspect ratios (e.g. like
4:3), the loss of precision is significant. The underlying calculations
are already done with doubles so all that needs to be done is to change
the type of the sub-property.
2025-02-08 02:01:13 +00:00
Kacper Michajłow 17db9bdc50 build: add early exit if git is not found
Also fallback to `--always` only if first `git describe` returned
errors, but were called successfully.
2025-02-06 02:16:51 +01:00
Kacper Michajłow 2596c4d930 github/workflows/lint: show ruff suggested changes 2025-02-06 01:33:09 +01:00
Kacper Michajłow cd439acce2 github/workflows/lint: update astral-sh/ruff-action to v3
This enables GitHub style output, along with other improvements.
2025-02-06 01:33:09 +01:00
Dudemanguy d19bb08bef ci/lint: disable isort checks
The error message is completely incomprehensible and also inconsistent
about whether it wants two newlines or just one after an import.

Consider this python script:

import sys

sys.stdout.write("garbage")

That passes the ruff isort check just fine. But this does not:

import sys

def fake_function():
    sys.stdout.write("garbage")

fake_function()

This will fail. Why? Because there should be two newlines after imports
but only for functions. This is because of PEP8 rules about blank lines,
but this is not explained or referenced anywhere in output from the
lint. You only get a cryptic "Import block is un-sorted or un-formatted"
with some visual that isn't clear in what it's trying to communicate.
Additionally, it seems to go a bit beyond PEP8 and also will fail if you
have too many blank lines (i.e. more than 1) in certain cases if the
succeeding line isn't a function or class definition.

Furthermore consider this example:

import os
import sys
from subprocess import check_output, DEVNULL

This also fails the lint. Why? Because DEVNULL should come before
check_output. Again, the lint doesn't explain this and you're left
guessing what horrible formatting sin you committed.

Considering the amount of time I wasted trying to even understand this
and I still don't, just delete it. How are contributors supposed to
understand what this lint wants when the project's own developers were
confused by it. Please just alphabetically sort your python imports and
don't do "from foo import *".
2025-02-05 23:46:30 +00:00
Kacper Michajłow 05ff82e153 build: use a more user-friendly version string for shallow clones
If the cloned repo is shallow (e.g. like the default github actions
settings), the git describe command won't actually be able to fetch any
tags and will instead just get a hash. The resulting binary version
string will end up being that git hash. While it does tell you the exact
commit, it's not exactly helpful when wanting to know the general
version at a glance. For the case where we do have a git directory but
no available tags, build a version string using the mpv version + the
commit hash.

Fixes #15789.
2025-02-05 23:17:06 +00:00
Dudemanguy 8e97f41849 build: prepend version strings with 'v' for release tarball builds
This was an inconsistency with the git tagging since the meson project
version is just a number.
2025-02-05 23:17:06 +00:00
Kacper Michajłow 28ab3aec6a github/workflows/lint: add umpv to Python linting
It doesn't have extension.
2025-02-05 20:22:01 +01:00
Kacper Michajłow 48f944d21b TOOLS/umpv: add Windows support
While there are native ways to implement this in mpv itself on Windows.
We can also support this script without any problem.
2025-02-05 20:22:01 +01:00
Kacper Michajłow f9a7179f37 TOOLS/umpv: use append-play
It makes more sense to star playback if nothing is playing.
2025-02-05 20:22:01 +01:00
Kacper Michajłow dfbd60f9bb TOOLS/umpv: don't wait for mpv after it is run
We just want to start mpv, there is no need to keep umpv script alive.
2025-02-05 20:22:01 +01:00
Kacper Michajłow b870d1933a TOOLS/umpv: use builtin profile for pseudo gui options 2025-02-05 20:22:01 +01:00
Kacper Michajłow 62847c9f39 TOOLS/umpv: handle the case when mpv disappears during adding files 2025-02-05 20:22:01 +01:00
Kacper Michajłow 7372bc5f12 TOOLS/umpv: minor fixes to style and typing
Add UMPV_SOCKET_DIR for socket base dir selection and fallback to TMPDIR
as last resort.
2025-02-05 20:22:01 +01:00
Dudemanguy 493cc877cf m_option: fix parsing of OP_APPEND for string lists
While parsing through the separators, the OP_APPEND also needs to use 0
for the separator since it is supposed to be unescaped. This was missed
in the code reorganization of d2c409c56b.
Keyvalue lists were unaffected because only OP_DELETE and OP_REMOVE use
this code.
2025-02-05 18:38:46 +00:00
Kacper Michajłow 3717a530ca player/loadfile: we shouldn't unescape inplace
I got mesmerized by the simplicity of the original commit, but in fact
it was not a correct thing to do.

Fixes: c0366cfa42
2025-02-05 18:04:11 +01:00
Kacper Michajłow de4004c61d meson: add disable-packet-pool option
For debugging without a pool, maybe.
2025-02-05 05:09:33 +01:00
Kacper Michajłow 038d66549d demux: reclaim demux_packets to reduce memory allocator pressure
This update introduces a demux_packet_pool, allowing for the reuse of
previously allocated packets when needed.

sizeof(AVPacket) is not a part of the lavc public ABI, which prevents us
to allocate memory in larger blocks. However, we can substantially
decrease the amount of alloc/free operations during playback by reusing
both mpv's demux_packet and AVPacket.

This adjustment addresses the root cause of issue #12076, which,
although resolved upstream, did not fully tackle the persistent problem
of allocating small blocks of aligned memory. This issue largely stems
from the FFmpeg design of the AVPacket API. After this change memory
will no longer be allocated once cache limits is reached.

The demux_packet_pool is shared as a global pool of packets for a given
MPContext.

This change significantly speeds up the demuxer deinitialization,
benefiting file switching scenarios, especially when a large demuxer
cache is used.

See: #12294
See: #12563
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-02-05 05:09:33 +01:00
Nikolai Vavilov c0366cfa42 loadfile: unescape display filenames
This makes OSD more usable when the filename contains non-ASCII characters.
2025-02-05 05:04:33 +01:00
Guido Cella 6f0a077d9b DOCS/man/options: document that --d3d11-flip=no enables transparency 2025-02-05 04:56:01 +01:00
Guido Cella b0364f8761 osc.lua: bind right clicking the title to show history
And move show-text ${path} to middle click. This is more useful than the
replaced show-text ${filename} binding since the left click stats
binding already shows the filename, and it matches how right clicking
other buttons shows menus. Alternatively middle click could also be
bound to select-watch-later.
2025-02-05 04:55:37 +01:00