1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 12:17:12 +00:00
Commit Graph

6309 Commits

Author SHA1 Message Date
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
Lynne
2ac1d6db32 vulkan/context: use VK_EXT_shader_object if available
FFmpeg has patches which add support for it.
2024-10-08 11:48:22 -07:00
llyyr
6871304029 wayland: replace old keymap if we receive a new keymap event
Fixes: 2274311b25
Fixes: #15022
2024-10-08 20:06:41 +02:00
Kacper Michajłow
fb9ac9b570 win32: don't change window size on video reconfig when maximized
Fixes: #7265
2024-10-07 09:41:40 +02:00
Kacper Michajłow
6667b9723e win32: fix window size restore after maximize state
This remembers and sets window-scale when exiting maximized state. Also
fixes not staying in maximized state when exiting fullscreen mode.

Fixes: #14126
2024-10-07 00:45:11 +02:00
nanahi
f46975c2d2 mp_image: restore dovi metadata before converting to AVFrame
They should be passed as side data instead.
2024-10-06 22:01:37 +02:00
nanahi
e2365bfece vf_format: set original params when converting format
Otherwise it will restore to a format before vf_format conversion when
restoring params. Only do this when the out format isn't dolbyvision.
2024-10-06 22:01:37 +02:00
nanahi
e35a559ce1 mp_image: only restore params when image is dolbyvision
Should be no need to do so otherwise.
2024-10-06 22:01:37 +02:00
nanahi
9b571a7aa7 mp_image: copy params before dovi mapping for mp_image_copy_attributes
It currently doesn't copy original params before mapping, resulting in
wrong colors when some video filters are used, e.g. d3d11vpp=scale.
2024-10-06 22:01:37 +02:00
der richter
7bd612ee66 mac: remove unnecessary window size change check
this is already done in the updateSize method of the window.

also fixes an issue where the size wasn't properly changed, even though
the new and old size were different. the unfsContentFrame should have
been checked instead of the pixel representation of the same frame.
2024-10-06 21:53:08 +02:00
Kacper Michajłow
3e74b1176e d3d11_helpers: remove leftover variables 2024-10-06 18:24:33 +02:00
der richter
9791c6d178 mac/common: don't unconditionally move the window on geometry changes 2024-10-05 18:40:11 +00:00
Dudemanguy
2fa87117e0 x11: don't unconditionally move the window on geometry changes
With the pieces set in place with the previous changes, we can implement
the desired behavior. The trick here is that we do want to force
centering the window when mpv first initially starts and the window size
is not known yet. This can be done by simply checking
x11->pseudo_mapped. The other change is to just look if we have the
VO_WIN_FORCE_POS flag and feed that to highlevel resize.
2024-10-05 18:40:11 +00:00
Dudemanguy
e01eab4385 win_state: move window centering to vo_calc_window_geometry
c4e8c36071 made any usage of --geometry
implicitly center the window on the screen after a resize even if the
user did not pass any x/y arguments to the option. At the time, this was
probably wanted since --geometry was primarily a startup option and
likely the window wouldn't be centered on x11 without moving
coordinates. Times have changed since then and we support full runtime
--geometry changes on all the relevant platforms but it comes with this
automatic window centering behavior (except on wayland of course hah).

It's better to make such window centering optional and user controllable
since it is entirely reasonable that someone wants --geometry=50% to
just resize and not move anything. It's already trivial for a person
that does want to move the window to just add their coordinates to the
--geometry command so there's no reason to continue to force this
behavior since it is less flexible.

Instead, move the window centering stuff out of m_geometry_apply into
vo_calc_window_geometry. We give the power to the caller to whether or
not to force centering the window here and all usage of the function is
updated to simply call it with false for now. Additionally,
--force-window-position being set will also center the window like
before. All that is left is for the windowing code to take advantage of
this. See subsequent commits.
2024-10-05 18:40:11 +00:00
Dudemanguy
8b30a2386f win_state: remove redundant vo_calc_window_geometry functions
There's really no reason to have all these extra variants. It's not like
this is public API. Collapse it all into one vo_calc_window_geometry
function and callers can simply just pass the appropriate parameters to
get the same behavior as before. I'm about to edit this function again
in a future commit and I really don't want to make a
vo_calc_window_geometry4 for this so let's clean it up.
2024-10-05 18:40:11 +00:00
Kacper Michajłow
822daeb89f f_hwtransfer: ensure that we convert to full range rgb with scale_vaapi
Limited range rgb is evil and not supported by FFmpeg, this ensures
parity of hardware conversion with software conversion.
2024-10-04 00:06:58 +02:00
Dudemanguy
0d7b4d64a5 wayland: support multiple devices and tranches when querying formats
The multi device part is mostly theoretical, but it turns out that
plasma does send multiple tranches to the same device so we have to take
that into account. And that means taking into account multiple devices
as well. In theory, a compositor should give us tranches for any device
that will work so as long as we find a match it should be OK. This is
still technically incomplete since mpv's core wouldn't react to a device
being hotplugged.
2024-10-02 21:27:01 +00:00
Dudemanguy
f1865f312c vo_{dmabuf_wayland,wlshm}: use proper values with MP_ALIGN_{UP,DOWN}
Both of these VOs draw buffers in software via wl_shm to an mp_image, so
they are affected by the internals of whatever mpv does for alignment.
When wlshm was originally written, mp_sws was aligning to 16 bytes and
thus it chose this value but it was hardcoded. vo_dmabuf_wayland later
blindly copied this value. e1157cb6e8
actually changed the internal value to 64 bytes. In theory, this doesn't
probably doesn't really matter since 16 should also work in most cases,
but we might as well stop using a magic number and be consistent.

Additionally, wl_shm did some funny alignments that no other software
output did. The reasoning was apparently due to warning messages from
ffmpeg while cropping*. This was left in at the time, but I'm not able
to reproduce any such warning messages on my end when I make this match
other software VOs. Go ahead and remove the MP_MAX business and align to
the fmt x/y like the other VOs do.

*: https://github.com/mpv-player/mpv/pull/6240#discussion_r227930233
2024-10-02 02:32:49 +00:00
Kacper Michajłow
7202406fe8 various: remove global.h inclusion where not needed 2024-10-01 12:23:44 +02:00
sfan5
c11239be8c options: enable handling --no-hwdec as --hwdec=no
Reusing M_OPT_ALLOW_NO has the side-effect of applying to --ab-loop-[ab],
which makes sense.
2024-09-30 11:26:13 +02:00
Dudemanguy
344ce9200d ra_wldambuf: don't unconditionally filter out non-planar formats
4d09cde8f9 added this behavior and made
the format filtering more aggressive, but it's over correcting. The
misunderstanding on my part is that the problem was with modifiers not
with formats. There is hardware that do not have any valid modifiers
which means certain formats cannot possibly work correctly with
vo_dmabuf_wayland (broken colors etc.). Formats on the primary plane do
not require modifiers so if it happens to be a planar format, we can
accept it and possibly use mpv's autoconverter. If we do get a valid
format + modifier pair from the compositor, then we should always accept
it regardless if it is planar or not.
2024-09-30 03:12:59 +00:00
Dudemanguy
99d4dec38f wayland: rename gpu_formats to planar_formats
The old name is misleading. We do want these formats, but it is not
accurate to call them "gpu formats". Call it "planar" instead so it's
more obvious these come from drm primary planes.
2024-09-30 03:12:59 +00:00
Dudemanguy
c5aa7d83ac wayland_common: fix some stray tabs
quite unfortunate
2024-09-30 03:12:59 +00:00
Kacper Michajłow
6ca3752f75 vf_d3d11vpp: add NVIDIA RTX Video HDR support
Fixes: #13352
2024-09-30 02:51:21 +02:00
nanahi
ffb40ab958 video/decode/vd_lavc: fix null deref when hwdec is empty
This can happen when using --hwdec-clr.

Fixes: 9ff8c9e780
2024-09-29 22:56:40 +02:00
Kacper Michajłow
2c5928e518 vf_d3d11vpp: remove unnecessary compatibility defines 2024-09-24 00:21:19 +02:00
Kacper Michajłow
d650b3a5a3 d3d11_helpers: remove not needed compatibility define 2024-09-24 00:21:19 +02:00
Kacper Michajłow
e7e759cdfd opengl/context_dxinterop: remove unnecessary compatibility defines
No longer needed after 9f8b4b38c9.
2024-09-24 00:21:19 +02:00
Kacper Michajłow
1a3e3a0c98 w32_common: remove backward compatibility code
No longer needed after 9f8b4b38c9.
2024-09-24 00:21:19 +02:00
Kacper Michajłow
c6a8b6852c win32: remove dxgi debug checks
No longer needed after 9f8b4b38c9.
2024-09-24 00:21:19 +02:00
nanahi
cae3aee23b Revert "mp_image: don't restore image params if they're unknown"
This results in all image params not being restored even if only one is
unknown. In particular params->color.hdr isn't cleared, causing
overblown color for some samples.

It should be safe to restore even unknown values.
mp_image_params_guess_csp will handle that.

This reverts commit 3acd253e89.
2024-09-16 10:34:14 +02:00
Dudemanguy
6797f54378 hwdec/vaapi: additionally probe hwupload format conversions
This is probably fringe, but I encountered it on my machine. The
hwupload filter happily does conversions all on the GPU side if
possible. Makes sense. However, it turns out that there is a difference
between e.g.yuv420p -> vaapi[bgr0] and a vaapi[yuv420p] -> vaapi[bgr0].
The latter worked without any issues on my hardware, but the first
example fails. To remedy this, we need to also do hardware uploads
during probing against formats and track what actually works (i.e.
vaSurfaceExportHandle). This commit only implements it in vaapi since it
is the only known place where this edge case is relevant. But other
hardware decoding drivers could easily add support later if needed.
2024-09-16 00:07:36 +00:00