Commit Graph
55342 Commits
Author SHA1 Message Date
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
llyyr 8c67647b50 wayland: don't leak wl_fixes on uninit
I fixed this locally but forgot to push it before the original commit
got merged, oh well

Fixes: 6f6c29b0b4
2026-07-24 12:53:05 +00:00
diniamo 0fb136f685 input/ipc-win: allow Windows handles for --input-ipc-client
Previously, you could only provide a CRT FD, which works great for the
most part, but when using CreateProcess on Windows, it requires the use
of the reserved fields of STARTUPINFO to inherit the FD to a child mpv
process. This becomes a problem for example if you use Go's os/exec API,
which does not expose a way to set those reserved fields. Exposing a way
to allow passing handles directly fixes the mentioned scenario, and
makes --input-ipc-client more flexible at no cost.
2026-07-23 22:06:04 +02:00
llyyr 6f6c29b0b4 wayland: use wl_fixes.ack_global_remove on global_remove
Notifies the compositor that the removed global will not be bound, so
the compositor can destroy it.

Ref: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/533
2026-07-23 12:29:49 +00:00
Guido Cella 1c4adc9819 console.lua: limit how many completions are printed to the terminal
This prevents mpv from freezing e.g. when completing very large
directories.
2026-07-23 13:04:55 +02:00
Kacper Michajłow 11a9054b1d player/lua: pre-allocate tables of known size 2026-07-23 12:16:59 +02:00
Kacper Michajłow 7ff087a6b0 options/m_property: avoid repacking list nodes if we can just steal it
Removes one redundant deep-copy. For example this makes playlist with
300_000 elements conversion to node from 800 ms to 470 ms. Not a big
improvement, but still it's free to do.
2026-07-23 12:16:59 +02:00
Kacper Michajłow e61d819bf6 console.lua: add coroutine to filter selectable items asynchronously
Make the filtering and user input render asynchronously, such that there
is no latency penalty for user typing.

A single keystroke with hundreds of thousands of selectable items blocks
the script for significant time. Especially filtering by single letter
which would produce a lot of matches. This could be fixed by delaying
filtering by the time user "stops" typing, but this adds artificial
delay on top of the filtering delay itself. Instead we start the
filtering always, but have a deadline of 5 ms, at which point the
coroutine is paused and script is allowed to process user events again.
If user typed or closed the dialog, we simply abort the filtering and
start new one. Instead of waiting for full filtering to finish when the
result is already stale.

The first slice runs synchronously, so anything but huge item lists is
still filtered within the keypress handler exactly as before.

Fixes: #18268
2026-07-23 12:16:59 +02:00
Kacper Michajłow 893ffae982 console.lua: speed up filtering of selectable items
Store just the indices of the matching items in matches. The text is
looked up in selectable_items, and the positions to highlight are
computed in get_matches_to_print() only for the rendered matches, using
the query that produced the current matches. This reduces useless work
of computing highlight positions when only handful of items can be
displayed at the time on screen in practice.

Sort matches without lua comparator, this significantly speeds up
sorting of big lists, where C->Lua round-trip was problematic.

Overall it's 10x-20x times faster in my testcase.
2026-07-23 12:16:59 +02:00
Kacper Michajłow 0583bb892e fzy.lua: use lookup table for precompute_bonus
Replace those conditions with precomputed lookup. It's not huge win, but
it's free, so we can do it.

JIT:
* score() x 44875 matches: 35 -> 25 ms
* filter_range 'p': 50 -> 25 ms
* filter_range 'pf': 61 -> 37 ms

interpreter:
* score() x 44875 matches: 295 -> 254 ms
* filter_range 'p': 412 -> 284 ms
* filter_range 'pf': 531 -> 388 ms

The lookup is dense, to avoid hash tables, which makes things slower,
but in fact the tables are reused, so it's low on memory.
2026-07-23 12:16:59 +02:00
Kacper Michajłow 181090e70d fzy.lua: add filter_range() for interactive filtering of large lists
Add fzy.filter_range() which computes only scores, appends to
caller-provided arrays instead of allocating tables per match, takes
an inclusive range so callers can process a large list in slices while
handling pending input in between, and accepts optional pre-lowercased
haystacks so repeated calls don't allocate a lowercase copy of the whole
list each time.
2026-07-23 12:16:59 +02:00
Kacper Michajłow e2eaf31ce2 fzy.lua: optimize main compute() a little
There could be a lot more done if we target luajit only. Or if we port
this to C. But for now let's keep it this way. It's 2-3x faster than
before, and the issue is mostly only on very big inputs, which are not
that common in practice.

Previously computing scores allocated two matrices of lua tables per
call. With hundreds of thousands of items this made fuzzy matching in
console.lua GC-bound.

When only the score is needed, keep two reused rolling matrix rows,
making repeated scoring allocation-free. positions() still keeps all
rows since tracing back the matched positions requires them.

fzy.filter() of 300000 items drops from 1013 ms to 356 ms (on my setup)
for a worst-case single-character needle, and a standalone score() call
no longer allocates at all.
2026-07-23 12:16:59 +02:00
Kacper Michajłow e4abaaa26b fzy.lua: do byte comparision instead string ones
This are char comparisions, but in lua they are expressed as full string
compare. Compare as bytes instead, this is significantly faster,
especially with luajit compiled code.
2026-07-23 12:16:59 +02:00
Kacper Michajłow 23d39a6048 vo_wlshm: fix leak on in flight buffer on unint 2026-07-23 10:17:00 +02:00
Kacper Michajłow 11e6a50025 vo/context_wayland: fix memory leaks on failed init 2026-07-23 10:17:00 +02:00
Kacper Michajłow 15de3e6193 vo/opengl/context: fix memory leaks on failed init 2026-07-23 10:17:00 +02:00
idontwannagoo 8ab3f8b66d options: add secondary-sub-scale
This allows scaling secondary subtitles independently from primary subtitles. The option defaults to 1 like --sub-scale and follows the other secondary-sub-* options by not inheriting from the primary subtitle setting.

Fixes #14989.
2026-07-22 19:32:01 +00:00
llyyr 25451bcc11 player/command: don't refresh sub stream on UPDATE_SUB option updates
Back when reselect_demux_stream call was added in this path in 700f72f,
sub_redecode_cached_packets only retained the last two packets. The
subtitle decoder cache was changed in 0a4b098 to retain the whole packet
sequence. Therefore sub_redecode_cached_packets by itself can rebuild
the new decoder state entirely from packets held in memory, and we no
longer need the demuxer to refresh the track.

This fixes expensive track refresh for network streams, where changing
some sub-* options during runtime of network streams would cause the
cache to be dropped
2026-07-22 20:51:55 +02:00
Dudemanguy 94335ab87a ci/build-mingw64: remove --enable-libshaderc flag
This was removed upstream.

https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/92f2e6374dfbe9bf1c8e4d879f8810deafff3710
2026-07-14 19:13:03 +00:00
dengbo e5486b96d7 ao_pipewire: treat init timeout as failure instead of success
When wait_for_init_done times out, init_state remains INIT_STATE_NONE.
The original check only handled INIT_STATE_ERROR, allowing init() to
return 0 (success) even though the stream was never properly initialized.
This could lead to an infinite reload loop when the partially initialized
stream later enters an error state.

Fix by checking for INIT_STATE_SUCCESS instead of INIT_STATE_ERROR,
so that any state other than SUCCESS (including NONE due to timeout)
is correctly treated as a failure.
2026-07-10 00:22:51 +02:00
Kacper Michajłow 115b87b521 demux_mkv: init ff-index for backward compatibility
lavf basically always provide tracks in order as they appear, so this
will match it. There is no hard guarantee, but this is documented.

`ff-index` is now optional, but both demux_mkv and demux_lavf set it, so
it should cover most cases where it's used. In all other cases it would
be wrong anyway.
2026-07-09 05:04:11 +02:00
Kacper Michajłow 5b087dfb18 demux: remove falsification of ff-index
The `ff-index` is just a index of in the track order as seen by lavf.
However, there are many cases where tracks are not related to lavf, when
it's not used or there are virtual tracks addded like DOVI EL track or
merged image tile grid. Don't conjure `ff-index` out of nothing.

Some scripts may be confused when this index does not much ffmpeg. Even
though it has always stated in docs.

Fixes #18244
2026-07-09 05:04:11 +02:00
Kacper Michajłow e517fd6043 player/command: make track-list/N/ff-index optional
The `ff-index` is just a index of in the track order, it doesn't carry
much meaning and may be wrong or unavailable when other than lavf
demuxer is used. Additionally some tracks may be virtual like DOVI EL
track or merged image tile grid. In which case those track are not
related to lavf at all.

No deprecation period. It was never guaranteed to match FFmpeg anyway,
so anyone who has a hard dependency on this property should reconsider.
It's not really possible to provide backward compatibility given the
ambiguity of this index. It's better to make it unavailable than making
mismatch. For user it's clear when it's not available, but not possible
to know when it's wrong.
2026-07-09 05:04:11 +02:00
Kacper Michajłow 68387ea859 video/vdpau: throttle reinit in all cases
If `is_preempted` flag is set during init we need to try again, but if
we do it too fast, we never let the init to finish and constantly gets
the flag re-set.

Fix this by throttling the same as error path. It's not perfect, because
we rely on init timing, but was confirmed working and this restores the
previous status quo.

Fixes: d9f27bd0f1
Fixes: #18161
2026-07-08 21:02:26 +02:00
Kacper Michajłow cc763d17dc osc.lua: fix duration when it becomes available
After recent changes OSC become defunct when duration is updated during
playback.

Fixes: 02491a3949
2026-07-08 20:43:09 +02:00
Kacper Michajłow cef62fbc39 player/command: reset playback state of edition changes
When changing MPEG-TS program (edition) it may have completelly
different time base and duration, on live, non-seekable streams we would
just hang trying to resync to revious PTS, which is not valid. Reset the
state on edition change.
2026-07-08 20:42:25 +02:00
Kacper Michajłow 7f93b06797 demux_lavf: sort AVProgram array by id
AVProgram array contains programs in order as they were discovered by
lavf. For MPEG-TS depending on the point where we start demuxing it is
effectivelly random. Sort by the id, so we have consistent order of our
editions, regardless of probing.
2026-07-08 20:42:25 +02:00
Kacper Michajłow 02baec9701 demux_lavf: change demuxer-lavf-{probesize,buffersize} to OPT_BYTE_SIZE
It's way easier to type 10M instead of typing all those zeros.

Our C API uses int64_t for properties and string for setting options, so
it's safe to bump this option type.
2026-07-08 20:42:25 +02:00
Kacper Michajłow ab34ec35d2 vo_gpu_next: use pl_color_transfer_is_hdr consistently
pl_color_space_is_hdr checks also luminance, but we don't do that in
other places, and unlikely that we want it.
2026-07-08 20:20:07 +02:00
Kacper Michajłow 4c220ffd95 vo_gpu_next: disable auto reference white on onlder libplacebo version
To avoid forcing by default values that may be problematic in some
cases, especially with ICC profiles.
2026-07-07 00:00:05 +02:00
Kacper Michajłow 6a0ef86e00 vo_gpu_next: make subtitles / osd also follow system reference white 2026-07-07 00:00:05 +02:00
Kacper Michajłow ba92eb63c4 vo_gpu_next: ignore reference white for screenshots 2026-07-07 00:00:05 +02:00
llyyr 8e88661257 video/out/hwdec_cuda: use mp_msg for ffnvcodec logging
ffnvcodec falls back to fprintf(stderr) unless FFNV_LOG_FUNC and
FFNV_DEBUG_LOG_FUNC are defined by the user
(https://github.com/FFmpeg/nv-codec-headers/blob/master/include/ffnvcodec/dynlink_loader.h#L80-L84).
Define these callbacks so CUDA loader messages go through mpv's normal
logging instead.
2026-07-06 18:26:36 +02:00
der richter 28a7932599 osxbundle: fix vulkan loader search path check
the old check stopped at the first occurrence of a vulkan loader path.
though it's possible different vulkan loaders are installed in different
paths, leading to not found vulkan loaders.

to prevent this, also check if the needed vulkan loader is actually
installed to that path.

specific case is when installing MoltenVK and KosmicKrisp at the same
time. the former is installed in the homebrew prefix under etc/ the
latter under share/. the latter wasn't found previous, since the former
was found first.
2026-07-06 18:25:28 +02:00
der richter ed9c05d06e osxbundle: fix a wrong vulkan search path
the paths in the array are meant to be base paths to the vulkan path.
remove vulkan from it so it won't end up as /usr/share/vulkan/vulkan.
2026-07-06 18:25:28 +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
llyyr c8c7d91a8e ci/freebsd: bump freebsd version to 15.1 2026-07-06 13:17:01 +02:00
Kacper Michajłow 7bf2d9cee6 vo/opengl/context_drm_egl: init fd to -1
Instead of using zero initialized value. Otherwise an early init failure
calls close(0), a descriptor we don't own, breaking whatever else
happens to hold it.

This is bit defensive, but I want to init those just after allocation,
so we don't have to trace whether they are initalized correctly or not.
2026-07-06 13:02:16 +02:00
Kacper Michajłow 318e4e21fb vo/drm_common: init fd to -1
Instead of using zero initialized value. Otherwise an early init failure
calls close(0), a descriptor we don't own, breaking whatever else
happens to hold it.

Also add missing check before close() call.
2026-07-06 13:02:16 +02:00
Kacper Michajłow f6df7dfd8b vo/vulkan/context_display: init fd to -1
Instead of using zero initialized value. Otherwise an early init failure
calls close(0), a descriptor we don't own, breaking whatever else
happens to hold it.

This is bit defensive, but I want to init those just after allocation,
so we don't have to trace whether they are initalized correctly or not.
2026-07-06 13:02:16 +02:00
Dudemanguy 33111f3212 DOCS/man/vo: remove mentions of 'experimental' for vo_dmabuf_wayland
It's fair to say that it's generally a mature and well-working VO at
this point.
2026-07-03 14:00:15 +00:00
Dudemanguy 7a94ec5719 vo_libmpv: use the VO_CAP of the renderer backend instead of the VO
The software renderer backend is not capable of using any of the VO
capabilities set globally by vo_libmpv. This can lead to assertion
errors when trying to render a video with 90 degree rotation metadata.
Instead use the ctx->renderer->driver_caps value so the source frame
doesn't have its params rotated when it's not desired.
2026-07-03 13:59:58 +00:00
Mohammad AlSaleh 7aa8580cab options: store audio/sub delay in doubles instead of floats
An `--audio-file` could be sourced from a stream. A stream could be
 using timestamps that match unix time in their segments. In that
 case, setting `audio-delay` will lead to a big unexpected A/V desync
 due to the limited precision of floats.

 This commit changes `--audio-delay` (and --sub-delay while at it) to be
 stored in `double` instead of `float`.

 `audio_delay` was already up-casted to `double` wherever it was
 evaluated. Same for `sub-delay`, except its own value was getting
 adjusted based on `double` values in one place (bad!):

 player/command.c:6297

    mpctx->opts->subs_shared->sub_delay[track_ind] -= a[0] - refpts;

 A showcase:

    mkfifo /tmp/mpv
    date=$(date +'%s')

 Before:

    mpv --input-ipc-server=/tmp/mpv -
    echo 'print-text '"${date}" | socat - /tmp/mpv # 1782890841
    echo 'set audio-delay '"${date}" | socat - /tmp/mpv
    echo 'set sub-delay '"${date}" | socat - /tmp/mpv
    echo 'print-text ${=audio-delay}' | socat - /tmp/mpv # 1782890880.000000
    echo 'print-text ${=sub-delay}' | socat - /tmp/mpv # 1782890880.000000

 After:

    mpv --input-ipc-server=/tmp/mpv -
    echo 'print-text '"${date}" | socat - /tmp/mpv # 1782890841
    echo 'set audio-delay '"${date}" | socat - /tmp/mpv
    echo 'set sub-delay '"${date}" | socat - /tmp/mpv
    echo 'print-text ${=audio-delay}' | socat - /tmp/mpv # 1782890841.000000
    echo 'print-text ${=sub-delay}' | socat - /tmp/mpv # 1782890841.000000

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2026-07-02 17:38:51 +00:00
Kacper Michajłow c02751a0bf vo: prefer dmabuf_wayland over other fallback VOs 2026-07-02 17:38:28 +00:00
Mohammad AlSaleh dc8101574d audio/filter: implement lavfi-tempo leveraging lavfi's atempo/ascale
Implement `lavfi-tempo` audio filter, which uses `atempo` or `ascale`
 form libavfilter for setting the tempo.

 Users (myself included) seem to be always looking for alternative tempo
 scalers to try, and this provides a faster implementation (or two), and
 may prove useful beyond performance/speed.

 `atempo` is picked as a default, and as a fall-back if `ascale` is not
 available.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2026-07-02 17:38:07 +00:00
Emmanuel Gil Peyrot 0279c0f07d path-unix: only accept absolute paths
The XDG Base Directory specification says “All paths set in these
environment variables must be absolute. If an implementation encounters
a relative path in any of these variables it should consider the path
invalid and ignore it.”
2026-07-02 17:36:50 +00:00
Thomas Weißschuh c22cac669e stream_env: add new stream to read from environment variables 2026-07-02 17:36:31 +00:00
Thomas Weißschuh 6d64f2867c stream_memory: split out bstr logic
This logic can then be reused by other streams that work on static data.
2026-07-02 17:36:31 +00:00
Thomas Weißschuh 1c467ad4f9 stream: drop unneeded include fcntl.h 2026-07-02 17:36:31 +00:00
Nicolas F a3d4b59197 command: plug another slop faucet
In the 2020s, now known as "the twilight years of modern
civilization", Silicon Valley's two most morbidly obese failsons
finally found their niche: a product that lets complete imbeciles
pretend to be software developers. This was, at least for a
while, a smash hit. Hordes of claudecucked vibechuds began
spamming free software projects with bogus "security bugs" and
associated even worse fixes, both of which they did not know how
to reason about, and definitely did not care to learn how to
reason about. The entire exercise, after all, was to get one's
name into the list of contributors, to get ahead in a highly
competitive job market of economies with equally torturous
education systems.

To the disturbingly moist-looking tech oligarchs recording
Goldman Sachs jerk-off instructons on their podcasts, this was a
profound shift in software development. Now, they no longer had
to pay 6 figures to some idiot who doesn't know how to program so
chooses React, and instead they can pay 6 figures to some
application that doesn't know how to program so chooses React.

For everyone else, it just added to the torment that is life in a
modern globalised service economy, where the fruits of their
labour are siphoned off and directed towards building ever
grander and more opulent paedophile island resorts.

But back to the code. Someone submitted a slop issue about how
there's UB if you run an input command with bogus parameters.
This is hardly a bug, since the commands are trusted, so the fix
is "don't do dumb shit". However, contextless vibechuddies saw
this as an opportunity to fire up their deeply subsidized
planet-burners and shit out some code they had no idea about what
it did.

LLMs, failing to have any real reasoning, tried twice, and failed
twice, to find the real """fix""" here. #18144 decided that
another condition needed to be added to the logical OR, whereas
the subsequent #18211 instead wanted to do an explicit cast to
size_t for no fucking reason. Funnily enough, the unsignedness of
size_t doesn't cause any problems here, because of the earlier
check to make sure `w` is positive.

Both of them missed that if `foo < bar * 4` overflows `bar`, you
can just check for `foo / 4 < bar`, which is an efficient
division as 4 is a power of 2, and the integer division here does
not lead to any problems because the check is a range check.

Do that, just to stop these stupid fucking PRs from popping up,
and deny these dumb shitheads the satisfaction of getting their
name into the contributor stats.

Closes #18128.
2026-07-02 00:30:18 +02:00