Commit Graph

6340 Commits

Author SHA1 Message Date
Kacper Michajłow 4b11f66eb1 various: use avcodec_get_supported_config() to resolve deprecation warn
See: 3305767560
2024-11-20 20:42:33 +01:00
Kacper Michajłow 23262308d6 vo_gpu_next: restore initial hook param value
If the parameter is removed from the `glsl-shader-opts` list, it should
be restored to initial value.
2024-11-20 20:41:49 +01:00
Kacper Michajłow 012d317a1e vo_gpu_next: clear renderer cache on options update
This ensures that options are applied to current frame, even in paused
state.
2024-11-20 20:41:49 +01:00
Kacper Michajłow ef6052c01e vo_gpu_next: remove colospace overrides
Hacks like that has no place here, mp_image should be tagged correctly,
across the player, gpu-next is not special.
2024-11-20 20:40:05 +01:00
Kacper Michajłow 4e5cc9cf1d video/mp_image: fix vf=format colorspace override for XYZ
If format is RGB but flagged as XYZ it should be used instead.
2024-11-20 20:40:05 +01:00
der richter 45c1c58680 mac/compat: fix compatibility for deployment targets lower than SDK ver
the swift parts can't be nicely encapsulated in the compat file because
it lags proper target version compile time checks.

Fixes #15292
2024-11-18 19:28:35 +01:00
M Stoeckl 46574d479d console.lua,wayland_common: also detect Wayland if WAYLAND_SOCKET set
While most Wayland compositors provide a socket path indicated by
environment variable WAYLAND_DISPLAY, others may sometimes bequeath a
socket file descriptor specified by WAYLAND_SOCKET.
2024-11-18 16:35:57 +00:00
llyyr 43d896657e wayland: cleanup check_for_resize function
xdg_toplevel_resize_edge enum values allow for this to work, e.g.
`TOP | LEFT = TOP_LEFT`

No functional change.
2024-11-11 22:11:23 +00:00
nanahi ca7aeb71ee video/out/gpu/video: fix chroma offset rotation matrix calculation
82231fd74d mentioned that for the "rot"
transform flip=true must be set, which "makes no sense at all".

The reason this is happening is that the rotation matrix calculation
is only valid for the 2D coordinate system where y axis is 90 degrees
counterclockwise from x axis, but the coordinate system of chroma
offset has its origin at top-left so it is the opposite, which results
in the rotation going to the opposite way. Setting flip=true fixes the
rotation direction, but results in a flipped y coordinate.

Fix this by reversing the rotation angle for chroma offset rotation
matrix calculation. This also allows removing some duplicated code.
2024-11-11 02:30:26 +01:00
nanahi 70b202a8f4 video/out/gpu/video: prevent OOB access when larger angles are used 2024-11-11 02:30:26 +01:00
der richter c80757d782 videotoolbox: silence OpenGL deprecation warnings 2024-11-05 18:34:15 +01:00
der richter 6f009a91a6 mac/common: fix light sensor deprecations 2024-11-05 18:34:15 +01:00
Dudemanguy 23843b4aa5 vo_gpu_next: set --target-colorspace-hint to `yes` by default
It simply does not make any sense to not signal the correct colorspace
and metadata by default.
2024-11-04 19:35:28 +00:00
Dudemanguy d5f1cd07dc vo_gpu_next: add a pass_colorspace override for drm
The libplacebo colorspace hint api makes sense for things like vulkan,
but for other APIs like drm that are capable of directly handling
colorspaces and hdr metadata it's a nuisance. Add a pass_colorspace fns
that signals to vo_gpu_next that the backend doesn't need the color
information to be manipulated and can handle the metadata itself.
2024-11-04 19:35:28 +00:00
Dudemanguy ca31b94843 wayland: guard devices_are_equal completely
Only used if we have drm. Avoids a -Wunused-function error.
2024-11-04 19:35:28 +00:00
Dudemanguy a4d9bdd262 drm: parse edid using libdisplay-info
libdrm unfortunately doesn't give us what is actually supported by the
connector in question. To do that, we would have to parse the edid blob.
Use libdisplay-info to do this and make it required for drm support.
Using what we get back from the library, we can do a bit of sanity
checking for hdr metadata to make sure that the display in question can
handle it before we try setting the metadata. Strictly speaking,
libdisplay-info has stuff for dynamic metadata that we could potentially
use, but as a first pass and for simplicity, only static is considered
for now.
2024-11-04 19:35:28 +00:00
Dudemanguy 8039128693 vo_gpu: explicitly set target_params to NULL on uninit
Prevents vo_get_target_params from segfaulting if called somewhere else
in the code since the underlying p->renderer was just freed.
2024-11-04 19:35:28 +00:00
Dudemanguy 2827c9f323 context_drm_gl: add support for hdr metadata
It seems what we can do on this level is a bit limited but it's better
than nothing. Closes #8219.
2024-11-04 19:35:28 +00:00
Kacper Michajłow b057af0a56 w32_common: update window style after changing maximized state
Maximized state is not allowed without WS_OVERLAPPEDWINDOW style and
doesn't stick. Set the style after.

Fixes: #15093
2024-11-03 02:21:15 +01:00
Kacper Michajłow 42ff6f92c3 vo_gpu_next: add chroma location and HDR metadata to shader parameters 2024-11-02 21:20:20 +01:00
Niklas Haas 89e608e169 vo_gpu_next: add dynamic hook parameters
Fixes: https://github.com/haasn/libplacebo/issues/230
Fixes: https://github.com/mpv-player/mpv/issues/8206
2024-11-02 21:20:20 +01:00
nanahi e734f5ae33 video/out/w32_common: don't move window if position isn't set
The geometry output of vo_calc_window_geometry does not have
any information about the current window position. This causes
the window to move when setting geometry even without setting
x/y.

Change it so that the window position is unchanged if x/y are not
set and after startup.
2024-11-02 11:14:57 +01:00
nanahi 512f5e2e82 video/out/w32_common: always move window when setting state
Make sure the window is at the correct position when
fullscreen while geometry is set.

Fixes: e5159de811
2024-11-02 11:14:57 +01:00
Kacper Michajłow 41cff490ad drm: don't print extra newline on connectors/modes help 2024-10-30 11:49:22 +01:00
nanahi 98ed972246 video/mp_image: fix original param copy implementation
Fixes: 9b571a7aa7
2024-10-29 16:22:14 +01:00
Dudemanguy 851df7088a video/out/gpu/context: prefer vulkan over opengl when reasonable
For most actual desktop users, vulkan should be the a superior
experience over opengl as this point and our autoprobe should pick that.
For linux users, vulkan on wayland is rapidly seeing improvements and is
far ahead of egl. There is no sign of that changing anytime soon and
working fifo is on the horizon, so really wayland users should just all
be using vulkan from now on. For x11, there is not a big difference
between using egl vs vulkan as far as I know and both work well. macOS
already prefers the vulkan backend over the libmpv one anyways, and
finally windows still defaults to d3d11. Probably virtually no one uses
opengl on windows, but vulkan is reasonably common among windows users
and it doesn't make any sense to prefer opengl over it.

The two outliers here are Android and VK_KHR_display. On Android, vulkan
drivers are probably just a total disaster and let's not put ourselves
in that mess if there's no reason to. For VK_KHR_display, it actually
works fine except for one really big problem: VT switching doesn't work.
If you try it, enjoy losing all input and being forced to do a hard
reboot. It might be fixable if you use logind or something, but the
method of using signals like the drm context does won't work because
VK_KHR_display uses render nodes not primary nodes. Also, the opengl drm
context could support hdr in theory (some attempts were made but none
succesful) so it is probably "better". Maybe. Anyways, for these two
platforms, we still prefer opengl.
2024-10-23 19:09:20 +00:00
der richter a8d91b0b13 mac/vulkan: add retrieval of color depth and return auto (0)
this effectively disables the workaround that picks the color/dither
depth based on the source and instead picks it based on the output
surface/pixel format.

macOS apparently always operates at 10bit internally regardless of the
display's bit depth. this changed at some point in the more recent macOS
versions, where previously macOS operated at a frame buffer depth
corresponding to the display. either 30-Bit Color (ARGB2101010) for
10bit or 24-Bit Color (ARGB8888) for 8bit.

Fixes #13767
2024-10-23 19:39:20 +02:00
der richter 3c76afa05b vo_gpu_next/vulkan: add mechanism to retrieve color depth in gpu context 2024-10-23 19:39:20 +02:00
Rasmus Porsager 3d443cb267 x11: fix --fs-screen=all
The logic for getting the display edges was wrong and always resulting in 0 0 0 0 instead of the full desktop. This also fixes #11716
2024-10-23 14:22:39 +02:00
Mohammad AlSaleh d027e02d37 vo_gpu_next: raise LUT file max size and report an error if exceeded
First of all, `lutdata` was passed to `pl_lut_parse_cube()` even if
 it was empty. This caused a bogus error message to be printed by
 the LUT parsing code in libplacebo.

 "[vo/gpu-next/libplacebo] Missing LUT size specification?"

 One of the reasons why `lutdata` can be empty is if the LUT file size
 exceeds the `max_size` limit passed to `stream_read_file()`.

 So in this commit, `lutdata` is checked first before getting passed to
 libplacebo, and a non-bogus error message is printed if it's empty.

 And secondly, the max size allowed is raised from the quite limiting
 value of 100MB to 1.5GiB. The new max matches the limit in LUT cache
 which is used to support up to 512x512x512 LUTs.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-10-22 18:49:21 +02:00
Dudemanguy 0f78584518 x11: remove nvidia blacklist logic from --x11-present=auto
When the present extension was originally implemented, nvidia was
specifically blacklisted. The reason was because at the time it would
give bogus values that appeared to be real but actively made playback
worse. So out of an abundance of caution, any nvidia detection at all
(e.g. on a multi-gpu system) would disable the use of the extension.
Well times have changed and actually presentation-time on wayland for
nvidia works now amazingly enough. For xorg, the extension still doesn't
work, but from user testing it does not seem to be harmful anymore. It
just does nothing. So we can remove the blacklist part and just only use
a whitelist. Like before, we only enable the extension for mesa drivers
by default so no practical change for anyone except multi-gpu systems
whom may have this enabled now but should not see any negative behavior
change.
2024-10-21 15:13:47 +00:00
Dudemanguy c0fb6d0d62 wayland: be less stupid with color surface creation
Basically we only want to create the color surface if the compositor
supports parametric image descriptions and if the vo is dmabuf-wayland.
Instead of doing the weird dance of creating it in one spot and
destroying it later, just only make the wayland object when we actually
want it. It makes the logging less confusing as well.
2024-10-19 05:09:58 +00:00
llyyr 7fe12574fa wayland: don't use functions not available in libplacebo338
Fixes #15120
2024-10-18 14:47:06 +00:00
Kacper Michajłow cd9761651f filter_kernels: explain origin of LanczosSharp(est) filters 2024-10-16 15:17:48 +02:00
Kacper Michajłow 742142ca92 filter_kernels: link to explanation of ginseng filter 2024-10-16 15:17:48 +02:00
llyyr 198f2e7451 wayland: don't access vo->target_params directly
Use vo_get_target_params instead.
2024-10-16 15:11:05 +02:00
Dudemanguy 4c24eae220 wayland: map BT.1886 to BT.709 for color-management protocol
Fixes #14592 as long as the compositor supports it.
2024-10-15 19:27:46 +00:00
Dudemanguy 187fffd0f5 wayland: add support for xx-color-management-v4 for vo_dmabuf_wayland
Although this protocol isn't official yet, several compositors are known
to support it to some extent and this lets users actually view HDR with
less hacks/workarounds. The actual protocol here is simply copy and
pasted from the upstream fork* where these are developed. There is also
icc profile support in the protocol, but this is omitted for now in
favor of setting colorspaces and signalling hdr metadata. However for
mpv, this only actually has any practical use with vo_dmabuf_wayland so
this is the only VO that will make use of the protocol. When using
vulkan, this is already handled via vulkan extensions by compositors and
vo_gpu_next. So actually we don't want to use the wayland protocol in
that case since it will just get in the way. The only known limitation
on that front is driver support for hdr vulkan surfaces but as soon as
that is available it should just work with no code changes. For opengl,
hdr support there is a whole other mess with a lot of unknowns but
simply using this protocol isn't good enough and would require changes
elsewhere. vo_wlshm is currently too stupid to pick any format besides
bgr0 or 0rgb, so any color management there is meaningless at this
stage.

So this means that only vo_dmabuf_wayland can actually use this
protocol. But that's perfectly fine. Without this, vo_dmabuf_wayland has
a very bad limitation in that it cannot communicate colorspaces at all
and compositors have to guess. Using xx-color-management-v4 fixes this.
For the other VOs, merely having the common protocol setup stuff in the
common code does no harm and later if they get smarter, it's easy for
them to use the stuff since it is written generically anyway.

*: https://gitlab.freedesktop.org/swick/wayland-protocols/-/tree/color-xx/staging/color-management
2024-10-15 00:15:40 +00:00
der richter ff64d87bb4 mac/common: fix usage of vo struct after vo uninit race
we keep track of the current vo struct to flag for events that are
initiated async by various thread from different system notifications.
the problem here is the usage of that vo struct after uninit.

make accessing of that vo struct atomic and clear it on uninit, so it
can't be used afterwards by concurrent threads from system
notifications or events.

Fixes #15088
2024-10-15 00:48:43 +02:00
der richter 3172186226 cocoa-cb: only request EDR on opengl layer for supported color spaces
this apparently has some performance drawbacks when not needed. so only
request EDR when we need it.

Fixes #14465
2024-10-15 00:46:45 +02:00
der richter 9a1c637e9e cocoa-cb: fix race on shutdown and toggling fullscreen
since commit 15c48f3 we were force to start drawing on the main queue
again. this has several unintended side effects due to the nature of the
main queue. in this case fullscreen event and shutdown event are
executed out of order and fullscreening is done after shutdown, leading
to accessing options that are already de-initialised.

just nil the window on shutdown and make it impossible to fullscreen
after shutdown.

Fixes #14810
2024-10-15 00:44:57 +02:00
nanahi 4ab1ab8284 video/out/x11_common: make IME work (for libmpv usage)
The implementation is minimal since it already uses XIM for UTF-8 text
input. The only changes needed are small fixes: setting the IC focus and
correct the usage of window param for XFilterEvent, and IME will
"just work"...

...after setting 2 process-wide global values before VO creation:
LC_CTYPE and X locale modifiers. So this usage is currently limited to
libmpv clients which don't want to do their own IME processing.

locale strikes once again:
XIM input methods require them to be set before creating the XIM context to
work, even though they don't matter after the context is created. Both of
these values being process-wide global means that the only time to safely
set these values is before the process creates any thread.

In theory, mpv could set LC_CTYPE in the main when running standalone,
but locale being locale means something is always messed up. In this case,
setting LC_CTYPE changes "Character classification and case conversion"
behavior. While mpv uses its own ASCII-only is*() and to*() functions to
avoid some of the issues, it also uses strcasecmp() and POSIX regex which
behaviors are affected by LC_CTYPE.

In summary, to avoid unavoidable race conditions mpv won't do this in
standalone mode right now.
It's now libmpv users' responsibility to:

- set LC_CTYPE to a locale usable for XIM, such as a UTF-8 locale
- set X locale modifiers with XSetLocaleModifiers
- hope that all stars align if trying to switch locale back afterwards

On most setups, both of these can be empty strings, In this case, the usual
XMODIFIERS environment variable must be set to enable IME support.
(e.g. XMODIFIERS=@im=fcitx)
2024-10-14 02:05:17 +02:00
Julian Orth 1821c065b1 wayland: use wp-presentation v2 if available
Version 2 allows the compositor to send an appropriate refresh rate if
the output uses VRR. There are no changes to the API. Since mpv would
otherwise use a heuristic based on the last-seen output, it does not
matter to mpv if the output uses VRR.

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/320/diffs
2024-10-12 13:59:14 +00:00
Kacper Michajłow 3c57b395d3 hwdec_vaapi: try format upload lazily
Uploading all available formats has proven to be problematic because
more unusual ones can crash the driver, even when no upload is
necessary. Check the upload only if needed to avoid issues with broken
drivers.

This also might speedup the init process.

Fixes: #14956
Fixes: #15030
2024-10-12 01:36:44 +02:00
Kacper Michajłow 65c81c3a39 vo_gpu_next: suppress tone_mapping_param deprecation warning
It is not going anywhere soon.

Fixes: #14696
2024-10-12 01:08:36 +02:00
Kacper Michajłow fa77ad46cb win32: always fit to the screen on initial positioning
VO_WIN_FORCE_POS is set even if the position is not provided by the
user, so we have no choice but to always fit. We should do this
regardless, and if any issues occur in multi-monitor configurations,
they should be addressed separately.

Fixes: #15049
Fixes: e5159de811
2024-10-11 13:26:31 +02:00
Kacper Michajłow e5159de811 win32: center geometry, but only at start
I must have misunderstood the intent of the previous commit. Adjusted to
always center on window initialization.

Fixes: #15043
Fixes: e01eab4385
2024-10-10 18:50:08 +02:00
Kacper Michajłow ac7e9247b2 vulkan/context: make use of VK_EXT_shader_object only if available
VK_EXT_shader_object was added in 1.3.246, mpv currently requires
1.3.238. Debian stable is at 1.3.239.

Fixes build on Debian stable (Bookworm).

Fixes: #15041
Fixes: 2ac1d6db32
2024-10-10 18:37:22 +02:00
Dudemanguy 48963aef4b vo_gpu_next: force a reset when --image-lut is updated
Bit of an edge case since image-lut requires the frames to be remapped
again so the normal redraw when paused doesn't work. Also we use
update_options in the VOCTRL here.
2024-10-09 13:39:06 +00:00
Kacper Michajłow 6da3a15ca8 win32: keep prev_windowrc consistent also for maximized state 2024-10-09 04:09:13 +02:00