Commit Graph
53991 Commits
Author SHA1 Message Date
Kacper Michajłow 3d5949366c {osd,msg}: use PU{1,2} for escape codes instead of invalid Unicode
Some languages actually require strings to be valid UTF-8, unlike C
which couldn't care less as long as it is NULL terminated.

Change triggered by Python support, but is also useful for Rust and Java.
2025-04-09 18:09:03 +02:00
Dudemanguy 43ce03c519 vo_dmabuf_wayland: don't resize if dst rect is 0
Evidently it is possible for some compositors to trigger an external
resize before the very first initial reconfig. This can't work and will
fail in various ways. Check this case and bail out. Fixes #16202.
2025-04-08 22:15:57 +00:00
Kacper Michajłow 5bc5489e56 video/sws_utils: limit sws-cvs and sws-chs to [-100, 100]
Makes no sense to create filters with some huge offsets.
2025-04-08 22:24:47 +02:00
Kacper Michajłow 1bd6e28780 vd_lavc: limit frame size to 8k when fuzzing
To speed it up and avoid OOMs.
2025-04-08 22:24:47 +02:00
Kacper Michajłow 99d442d299 options/m_option: add missing newline in log 2025-04-08 22:24:47 +02:00
Kacper Michajłow 6f7e1e4359 ci/freebsd: update to 14.2
FreeBSD supports only two latest minor versions, since 14.3 has been
released, packages for 14.1 are not longer available. Bump to 14.2,
since action doesn't have images for 14.3 yet.
2025-04-08 08:51:43 +02:00
VincentVerdynanta 4a0684db33 sd_ass: handle past subs with unknown duration on every decode
Unknown duration subtitle handling must be executed on every decode
call, because we are actually adjusting the duration value of subtitles
that are decoded in the past. It should not only execute when the
newest packet has an unknown duration.
2025-04-08 00:22:54 +00:00
NRK b09e06a920 osdep/threads: prefer using thread_local
C11 uses _Thread_local as the keyword, which thread_local macro
is defined to (inside of <threads.h>, which mpv doesn't use):
https://port70.net/~nsz/c/c11/n1570.html#7.26.1p3

C23 promotes thread_local to a keyword and marks _Thread_local
as obsolete and to be avoided in new code:
https://www.iso-9899.info/n3220.html#6.4.1p3

so just use thread_local directly, which is future-proof while
having a fallback define in osdep/threads.h for pre-C23 cases.
2025-04-06 17:01:33 +02:00
Kacper Michajłow 07571859ac player/scripting: fix race condition when destroying clients
Clients run in detached threads and are waited to signal when they are
finished with self mpv_destroy() call. Problem is that after detached
thread calls this function, mpv consider this client to be done and can
do whatever. One example is when mpv exits and wait for scripts to
finish we got race condition, because mpv (main thread) can exit first
and the detached thread calls ta_free() which crashes, because we may
have already destroyed things that the thread depends on.

I've seen this crash on FreeBSD CI job (libmpv-lifetime test), where the
libmpv.so has been unloaded while the thread was still doing ta_free()

```
==5081==ERROR: AddressSanitizer: SEGV on unknoun address 0x000001111806 (pc 0x000001111806 bp 0x7fffdedf4e40 sp 0x7fffdedf4e08 T40)
==5081==The signal is caused by a READ memory access.
    #0 0x1111806  (<unknown module>)
    #1 0x803cd6900 in ta_free /home/runner/work/mpv/mpv/build/../ta/ta.c:243:5
    #2 0x803a2fc87 in run_script /home/runner/work/mpv/mpv/build/../player/scripting.c:93:5
    #3 0x803a2ffe0 in script_thread /home/runner/work/mpv/mpv/build/../player/scripting.c:99:5
    #4 0x2c451a in asan_thread_start(void*) /usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
    #5 0x80034fb04  (/lib/libthr.so.3+0x10b04)
```

Note the 0x1111806 jump which is completelly bogus.

Fix this by doing mpv_destroy() as a last step in detached threads.
2025-04-02 23:46:11 +02:00
NRK 22f4ff44c5 misc/random: add mp_rand_in_range32()
removes awkward back-and-forth int -> double -> int conversion.
the last step also broke uniformity, though it likely doesn't
matter much in mpv's playlist shuffle context.
2025-04-02 17:28:49 +02:00
NRK b968dec77d misc/random: improve the fallback case
c365e2f7 added av_random_bytes() to avoid multiple
threads/processes getting the same seed. but the fallback case
still suffers from it.

also mix in a function pointer, which hopefully is randomized
per process due to ASLR (20+ years old technology) along with
the stack position which will be different on different threads.
2025-04-02 17:28:49 +02:00
NRK b3d461e3aa misc/random: use av_random_bytes() for the whole seed
splitmix was used since it's recommended by the official xoshiro
site [0] as a "radically different" PRNG to avoid correlation of
similar seeds. av_random_bytes() is cryptographically secure
and so we don't have to worry about that. so just use it to
initialize the whole state.

[0]: https://prng.di.unimi.it/
2025-04-02 17:28:49 +02:00
NRK dd29542f6f misc/random: eliminate mutex
mutex itself was probably more costly than the PRNG itself. and
locking PRNGs is almost universally not recommended. simply add
a state parameter that the caller can hold to avoid locks.
2025-04-02 17:28:49 +02:00
Kacper Michajłow 36ea2354be ci/win32: don't use CMake 4.0
CMake has been updated to 4.0 which breaks compatibility with all
project targeting version < 3.5. See for more user stories:
https://github.com/actions/runner-images/issues/11926

Remove 4.0 from path and use the one from VS installation which is
working for now. Generally we want to use only tools from VS
installation, but unfortunately Windows image provided by GHA have
polluted PATH which already causes issues in the past, that's why we
remove yet another directory from PATH.

The affected project in our case is https://github.com/webmproject/sjpeg
which is build as part of libjxl.
2025-04-02 02:09:36 +02:00
Kacper Michajłow 30869ddb90 ci/build-win32.ps1: update wrap to expose ffmpeg executable
Also list dependencies, they are overriden now in upstream meson.build.

For subtitle selection tests.

See: https://gitlab.freedesktop.org/gstreamer/meson-ports/ffmpeg/-/commit/7601055639e789cdeeff793c48eaaf3186a70aad
2025-04-01 21:27:45 +02:00
Kacper Michajłow baf2fd2f28 osdep/language-win: fix use of GetSystemPreferredUILanguages()
The buffer size were never set to 0, after first call. To retrive the
size both buffer has to be NULL and size 0. Otherwise it fails.

While at it refactor whole thing and use returned count as sanity limit.
2025-04-01 21:27:45 +02:00
Kacper Michajłow cce45aa054 test/libmpv_test_track_selection: fix locale check
The size of the buffer was never set so the Get*PreferredUILanguages()
were just returning ERROR_INSUFFICIENT_BUFFER.

Fix the buffer size and use the returned count as sanity limit.

Fixes the test.
2025-04-01 21:27:45 +02:00
Kacper Michajłow 06a983ef2f test/libmpv_test_track_selection: fix compilation with Windows SDK 2025-04-01 21:27:45 +02:00
Leo Izen 5870c95e89 filters: automatically flip video if displaymatrix indicates so
Currently we check AV_FRAME_DATA_DISPLAYMATRIX for its rotation factor
but not for its flip factor, which could happen with some input files.
This commit adds and autovflip filter, which is applied before the
autorotate filter to flip vertically before rotating. It also changes
the displaymatrix reading code to output to mp_image->params.vflip so
it can be autoinserted as necessary.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-03-31 14:07:47 -04:00
Guido Cella 52a95d91bd positioning.lua: validate that an amount is passed
Instead of crashing, show the correct usage when running pan-x, pan-y or
cursor-centric with script-message, or with script-binding but no
argument.
2025-03-31 12:04:37 +02:00
Guido Cella f0c3d466f9 DOCS/man/osc: fix custom button example formatting
The examples for each button were rendered in the same line.
2025-03-31 12:02:03 +02:00
verygoodlee f837e951af select.lua: simplify the time formatting function
The C version of time formatting function has been exposed to lua,
so why not use it, `osc.lua` and `stats.lua` are already using it.
2025-03-31 11:57:06 +02:00
Tom Grimwood-Taylor a407e13f83 misc/language: add a forced flag to the track add commands 2025-03-31 11:47:52 +02:00
Tom Grimwood-Taylor f608780032 misc/language: parse forced tag from external subtitle tracks
Fixes: mpv-player#16060
2025-03-31 11:47:52 +02:00
Leo Izen 2e215cc6a5 demux/demux_playlist: mark fd:// as self-expanding
The playlist demuxer won't propagate the protocol forward to its entries
if its protocol is on a whitelist, for example data:// or memory:// etc.

This commit adds fd:// to that list because that should not be expected
to work.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-03-31 11:34:57 +02:00
Kacper Michajłow 5ba7ee5137 demux_mpv: add missing URL unescape 2025-03-28 22:40:09 +01:00
Kacper Michajłow 94e100e389 ci/win32: pin shaderc version to fix build errors
See: https://github.com/KhronosGroup/glslang/issues/3914
2025-03-28 19:40:44 +01:00
Kacper Michajłow 26b29fba02 demux_mkv: fix compilation after deprecated definitions removal
See: https://github.com/FFmpeg/FFmpeg/commit/822432769868da325ba03774df1084aa78b9a5a0
2025-03-28 19:40:44 +01:00
sfan5 08939665fe DOCS: clarify some minor points in the release policy 2025-03-28 16:19:48 +01:00
llyyr d20ded876d clipboard-wayland: prevent reading from hung up fd
This causes mpv to use up 100% of a core if there's an offer for a
mime_type that mpv doesn't accept with ext_data_control clipboard
backend.
2025-03-28 16:08:36 +01:00
Dudemanguy 9cca045511 wayland: lrint some width/height calculations 2025-03-28 13:53:08 +00:00
Dudemanguy 9826e96ecc wayland: use logical coordinates when setting the opaque region
Core wayland works in the surface local/logical coordinates so the width
and height values should really be divided by the scale factor.
2025-03-28 13:53:08 +00:00
Kacper Michajłow 38439dd531 threads: remove unused recursive mutex support
After removal of `MP_MUTEX_RECURSIVE` from vdpau.c there are no more
clients of recursive mutex. Remove all the code related to it. This
commit can be reverted if in the future it is needed again. For now
let's not keep dead code.
2025-03-26 19:16:21 +01:00
Lynne 9964104a6e vd_lavc: enable FFv1 hwaccel by default
FFmpeg recently got a hardware accelerated decoder for FFv1.
The decoder has been tested on all major vendors and operating systems.
Intel support is currently disabled as all of their drivers have issues
with buffer device addresses.
Since its a software-defined implementation, internal issues can be fixed
and the overall implementation optimized further.

With that, I think it should be safe to enable it by default.
2025-03-26 18:40:58 +01:00
Kacper Michajłow 74d3c2f0e7 mp_image: set repr.alpha and repr.bits when mapping AVFrame
Fixes invalid colors with gpu-next direct mapping of some formats.
2025-03-26 18:39:40 +01:00
Kacper Michajłow d9f27bd0f1 video/vdpau: change is_preempted bool to atomic
And eliminate recursive lock. This doesn't have to be guarded by mutex,
if for some reason preemption happens while we are handling preemption,
we remember the flag and do the dance gain. This is even nicer than
locking preemption callback.
2025-03-26 18:31:54 +01:00
한승민 513ccb9227 DOCS/interface-changes/kitty-passthrough: option addition notice 2025-03-26 18:25:49 +01:00
한승민 699a0bec42 vo_kitty: use priv as talloc context
- `priv` is used as `talloc_ctx`/`ta_parent` in `bstr_xappend_*` calls.
- `free_bufs` no longer frees `priv->cmd.start`.
- `bstr_*_passthrough` functions have been stripped off the `bstr_x`
  prefix.
2025-03-26 18:25:49 +01:00
한승민 ccad32e961 vo_kitty: remove DCS_GUARD_* macros
The `DCS_GUARD_*` macros have been removed in the favor of actual
functions
2025-03-26 18:25:49 +01:00
한승민 8edabd5644 vo_kitty: do not add trailing NULL byte in payload
In the past `strlen` was used in the write function, which omitted the
trailing NULL byte, however with the addition of `bstr` API the NULL
byte produced by `av_base64_encode` in the output is also written to
stdout, this causes terminals (namely Ghostty) to not display the frame.

There was also an additional edge case where if the entire output is
less than 4096 bytes the finishing escape sequence `\033_Gm=0;` was
never emitted. Adding a check for this after the for loop fixes this
behavior.
2025-03-26 18:25:49 +01:00
한승민 d9dc84c0fc vo_kitty: add auto-multiplexer-passthrough option
Terminal multiplexers like (screen, tmux, ...) do not support the kitty
image protocol (as of yet), to go around this DCS escape sequences are
used (`\ePtmux;...\e\` for tmux, `\eP...\e\` for screen). This option
allows passing thorugh the kitty image escape sequences.

`\033\\` suffixes from `KITTY_ESC_IMG_SHM` and `KITTY_ESC_DELETE_ALL`
have been removed. This makes it easier to wrap the escape sequences in
a DCS control sequence since there will be no `\033` in them to escape
(as multiplexers require escaping the escapes within the DCS data
string). `DCS_GUARD_WRITE` and `DCS_GUARD_APPEND` macros have been added
to wrap escape sequences in DCS control sequence based on the
availability of the `priv->dcs_prefix` property.
2025-03-26 18:25:49 +01:00
한승민 aad5329fd1 vo_kitty: reallocate cmd.start on reconfigure
`priv->cmd.start` is being freed in `reconfig` without being allocated
again this caused a segfault if `flip_page` was called after `reconfig`.
This segfault could be triggered by sending a SIGWINCH (resizing the
terminal).
2025-03-26 18:25:49 +01:00
Dudemanguy 0c3f1c0f6e build: make drm optional again for vo_dmabuf_wayland
We used to deal more directly with drm-specific things, but that has all
since been removed and is known to not be needed. We can relax the build
requirements some more since vo_dmabuf_wayland will simply error out if
no hwdec backend is available at init.
2025-03-26 15:31:08 +01:00
DudemanguyandKacper Michajłow a9dccf22a1 build: use a drm_fourcc header check for vaapi on gl
The underlying interop only needs the DRM fourcc defined in the header.

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2025-03-26 15:31:08 +01:00
Guido Cella e88864aef3 commands.lua: add remember_input script-opt
Allow clearing the input line on close. Fixes #16104.
2025-03-26 14:56:48 +01:00
Guido Cella ba80e447a6 console.lua: use a variadic function 2025-03-26 14:48:37 +01:00
Dudemanguy 1b231b4e57 wayland: accept version 2 of the cursor-shape protocol
The version 2 changes only add some enums which makes zero difference to
us so we can just allow the newer version.
2025-03-26 02:19:44 +00:00
Guido Cella 6ec0d06aa9 console.lua: use double quotes
Make it consistent with other scripts.
2025-03-26 02:53:01 +01:00
nanahi af1ac0f685 playloop: only notify MP_EVENT_INPUT_PROCESSED when needed
MP_EVENT_INPUT_PROCESSED is used to notify mouse and touch position
updates, but it is currently notified for all input commands even when
they have nothing to do with mouse position. This results in unnecessary
acquisition and comparision of mouse and touch positions for all commands.

Optimize this by checking whether the command is marked as requiring the
event notification, and only notify if that is true.
2025-03-26 01:33:21 +01:00
nanahi ca6e26399f input: mark mouse and touch position update in mp_cmd
This makes it possible to distinguish these dummy commands
for position update notification from other commands.
2025-03-26 01:33:21 +01:00