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

6272 Commits

Author SHA1 Message Date
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
Dudemanguy
7a80330be3 wayland: properly use tranche_formats when getting compositor formats
It's a bit roundabout, but we were doing this incorrectly before. The
format table alone isn't good enough because it is possible the the
compositor may advertise different formats for a specific device which
is a subset of the format table. What we need to do is add formats based
on the array in tranche_formats. Note that it is possible for the
compositor to send multiple tranches (was not able to simulate this but
it's allowed by the protocol). For mpv, we only care about the very
first one which is supposed to be the most preferred one. The compositor
can also send the entire chain of events (main device, format_table,
tranches, etc.) all over again. We handle this in the wayland code, but
handling this in mpv's core code isn't done. e.g. say a format in use
was suddenly no longer supported. We ideally should do a full reconfig
in this case, but that gets complicated and is pretty niche so save that
for another day. Multiple GPUs isn't taken into account either. We just
pick the first one. Not strictly correct, but close enough for us.
Fixes #14544.
2024-09-16 00:07:36 +00:00
Dudemanguy
4d09cde8f9 vo_dmabuf_wayland: reject formats not supported by the GPU
The linux-dmabuf protocol gives us the main device being used. Using
that along with some drm code, we can get what drm formats are supported
by the GPU. This is pretty crude as we just check against the first
primary plane we find and hope for the best. Also the protocol can
technically update formats at any time (e.g. if the device changes). We
do update what gets stored in  wl->gpu_formats but the next commit won't
make any attempt to address this hypothetical scenario. It's complicated
and this is better than nothing. In practice, this will only work
against one constant device during VO runtime. Additionally, we can add
this check to ra_compatible_format to filter out additional unsupported
formats.
2024-09-16 00:07:36 +00:00
Dudemanguy
7d4abdbd45 wayland: rename wayland_format to compositor_format
Cosmetic. This is to better indicate that these formats come from the
compositor.
2024-09-16 00:07:36 +00:00
llyyr
22a7a0af8a vo_gpu_next: allow setting antiring value for cscale
This has been possible since 11771cdd82
but nobody bothered to map it to mpv until now?
2024-09-15 18:54:23 +02:00
Kacper Michajłow
0e43eea5bb meson: require Vulkan loader/headers >= 1.3.238
Even Debian stable has them, so no need to keep compatible with ancient
versions.

Note that this does not change runtime version requirement for Vulkan.

Fixes: https://github.com/mpv-player/mpv-build/issues/234
2024-09-14 17:20:16 +02:00
Kacper Michajłow
2aab3fc381 vd_lavc: add Vulkan hardware decoding to autoprobe
On platforms where it is unstable/experimental, it is disabled behind
environmental variable, so safe to probe it there too.

Fixes usage of hwdec=yes with gpu-api=vulkan, where hwdec would be not
enabled. Position it after older and more stable variants. That means
the -copy variant of the other API will likely be prefered.
2024-09-14 17:20:16 +02:00
Guido Cella
dd77d0a7da vo_gpu{,_next}: convert scale options to type choice
This allows Tab completing them in the console and zsh, and using cycle
scale.

jinc is also added to --tscale=help's output, while before it was
missing because validate_scaler_opt() skipped filter windows with the
same name as a filter kernel, but the jinc kernel was skipped with
--tscale because it is polar.
2024-09-14 17:06:07 +02:00
llyyr
d2f3b66439 vulkan: don't tolerate suboptimal swapchain configurations
The comment was probably only ever true for x11, and it currently isn't
true anymore. X11 WSI used to return VK_SUBOPTIMAL_KHR in
vkQueuePresentKHR and vkAcquireNextImageKHR before, but as of
2b885b233f
it only returns VK_SUBOPTIMAL_KHR in vkAcquireNextImageKHR for
performance reasons. This makes it so that we don't have to tolerate
suboptimal swapchain configurations for the sake of smoother resizing.

On top of that, not recreating swapchain when it was suboptimal, it
also prevented mpv from being directly scanned out when fullscreened on
Wayland compositors. On Wayland, the preferred modifier from the wsi
may change depending on whether the window is fullscreened or not for
direct scan out. If mpv is fullscreened but not using modifiers that
can be directly scanned out, mpv will be receive VK_SUBOPTIMAL_KHR from
WSI and should recreate swapchain to use the right modifier with the
format mpv picked. mpv will always get the format it picks, WSI can't
give us a different format. This allows for recreating the swapchain
with modifiers that will allow mpv to be directly scanned out when the
window is fullscreened spanning an output on Wayland.

I checked X11 and Wayland myself to have no regressions when resizing,
and others have checked Windows and Mac to have no regressions.

With this, direct scanout with Vulkan on Wayland should just work.
You might also need https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31122
if your compositor enables explicit syncronization via
linux-drm-syncobj-v1.
2024-09-14 16:16:35 +02:00
Kacper Michajłow
f6d931301b vf_d3d11vpp: adjust options for userdeint filter
Fixes: #14816
2024-09-08 21:44:51 +02:00
Dudemanguy
e6c536ae45 wayland: fix vertical resizing
Resizing in strictly the vertical direction has been broken forever on
wayland. It's because of how the keepaspect calculation always resized
with respect to the width. So if you moved the mouse strictly
vertically with no change left/right, the mpv window would never change
size since it just calculates with respect to the width that doesn't
change.

Fixing this is kind of weird and maybe someone should think of a better
algorithm for preserving aspect ratio (we just multiply by the gcd
basically), but whatever. You might naively try something like "resize
with respect to what direction changes the most" at first, but this
leads to very cludgy resizing since during a typical mouse dragging
motion, it will flip constantly from "resize w/ respect to the width"
and "resize w/ respect to the height". It "works" but it's really ugly
and not worth it.

The trick is to realize that we need to consider the resizing state as
one continuous motion, choose a direction initially, stick to it
throughout the entirety of the resize, and reset the relevant parameters
after we finish the resize. This ensures the direction never
unintuitively flips during a motion, but also allows for the strictly
vertical case to still work.

Might as well note it here in the commit, but mpv's resizing behavior
technically violates xdg-shell. For the resizing event, "[t]he window
geometry specified in the configure event is a maximum; the client
cannot resize beyond it." Well, we do obviously go beyond the maximum in
certain cases. For example consider resizing strictly horizontally. The
width value increases from the compositor but not the height. Since mpv
preserves aspect ratio by default, the height obviously must increase
which will go over the prescribed bounds by the compositor. This happens
before and after this commit, and I think everyone agrees is the desired
behavior. With this commit, now vertical resizing works which violates
xdg-shell in the same way. Before, it incidentally obeyed the protocol
since it did not resize at all, but let's presume users expect the
window to actually get bigger when they do a drag resize.

*: https://wayland.app/protocols/xdg-shell#xdg_toplevel:enum:state:entry:resizing
2024-09-08 18:36:17 +00:00
Kacper Michajłow
5edc8973eb various: use talloc_replace 2024-09-08 17:33:27 +02:00
nanahi
e169302e2d video/out/wayland_common: set key state only on keyboard_enter keys
These keys should be considered "being pressed" instead of an action of
press. This way, the keypress action won't be triggered; it now triggers
only when the key binding is repeatable and after the initial ar delay.
2024-09-07 18:14:56 +00:00
llyyr
c02aa154ab vo_gpu: restore dovi mapping directly on image_params after init 2024-09-03 17:08:28 +02:00
llyyr
3acd253e89 mp_image: don't restore image params if they're unknown 2024-09-03 17:08:28 +02:00
Kacper Michajłow
1f33889c03 vo_libmpv: use fallback colorspace for Dolby Vision
Same as 2a72e6cb20 for libmpv.
2024-09-02 04:14:56 +02:00
Kacper Michajłow
c2997aa7de vf_d3d11vpp: add output format selection 2024-09-01 19:41:41 +02:00
nanahi
c4d85fc0c4 vf_format: restore image params before dovi mapping 2024-09-01 19:41:25 +02:00
nanahi
2a72e6cb20 vo_gpu: use fallback colorspace for Dolby Vision 2024-09-01 19:41:25 +02:00
nanahi
14d3a8ed28 mp_image: save fallback colorspace when dovi metadata is present
Since d9c1e9bc5c dovi metadata is
unconditionally mapped to colorspace in mp_image.

However, Dolby Vision videos can have backwards compatibility present for
players without the ability to interpret dovi metadata, like all current
VOs other than gpu-next. In this case, the original video colorspace should
be used to make sure backwards compatibility work properly.

Save the fallback colorspace for VOs which don't interpret dovi metadata.

Fixes: d9c1e9bc5c
2024-09-01 19:41:25 +02:00
nanahi
c890635634 video/out/gpu/video: use video rectangle for video-target-params
This makes the reported sizes the same as how stats.lua calculates
sizes for VOs witout video-target-params while in dumb mode.
2024-08-30 00:34:05 +02:00
nanahi
e8d14cd314 video/out/wayland_common: don't pass mouse inputs on resizing edges
Since a6683ea3c9 it is possible to bind
MBTN_LEFT to something useful without conflicting with VO dragging.
However, currently wayland edge resizing is an exception and trying to
resize still triggers MBTN_LEFT. This is not a problem on win32 which
does not pass these inputs to the input system.

Fix this on wayland to do the same.
2024-08-28 03:30:46 +02:00
Kacper Michajłow
bb0a852f56 vf_d3d11vpp: skip conversion mode selection if not requested 2024-08-27 01:27:48 +02:00
Kacper Michajłow
1c34b72aeb vf_d3d11vpp: don't force nv12 output 2024-08-27 01:27:48 +02:00
Kacper Michajłow
a341b128de vf_d3d11vpp: alloc output frames through AVHWFramesContext
This fixes d3d11 frame download further in filtering chain.

Fixes: #14732
2024-08-27 01:27:48 +02:00
Kacper Michajłow
421df7564a vulkan/context_display: don't fake avalibity of callbacks
There are generic fallback paths for those and it shouldn't be replaced
by noop.
2024-08-27 01:27:39 +02:00
llyyr
cb4fdb530a video/csputils: remove space from choice option for chroma loc
Also document the field
2024-08-24 17:11:39 +02:00
Kacper Michajłow
f44c29b223 vf_d3d11vpp: ensure width and height is even
Fixes: bbb3d5ba78
2024-08-20 20:27:03 +02:00
Kacper Michajłow
2848af5618 vf_d3d11vpp: add support for Intel VSR and NVIDIA RTX scaling modes
Adds `--vf=d3d11vpp=scaling-mode` to control which extensions should be
enabled.

Fixes: #11390
Co-authored-by: xc <wxc9312@gmail.com>
2024-08-20 03:34:08 +02:00
Kacper Michajłow
bbb3d5ba78 vf_d3d11vpp: add support for scaling
Adds `--vf=d3d11vpp=scale` to scale video using d3d11 video processor.

Co-authored-by: xc <wxc9312@gmail.com>
2024-08-20 03:34:08 +02:00
Lynne
a3baf94ab9 hwdec_vulkan: allow using multiple decoding family queues
Some devices may only support a single codec type on a single
queue family. The new libavutil API allows this.
2024-08-17 02:01:05 +02:00
Lynne
678ad90bf4 hwdec_vulkan: update to new libavutil queue family API
The new API allows duplicates to easily port any old API users.
It does require users to check and fill in video decode capabilities.
2024-08-17 02:01:05 +02:00
Mike Will
acc69e082f img_format: prevent an offset >= MP_MAX_PLANES into bpp
Addresses the warning: "writing 1 byte into a region of size 0"
2024-08-13 12:35:27 +02:00
Jonas Karlman
ea01b042c2 context_drm_egl: always use drmModeAddFB2WithModifiers
Change to always use drmModeAddFB2WithModifiers for all formats and fall
back on using drmModeAddFB2 if drmModeAddFB2WithModifiers fail.

With the DRM_MODE_FB_MODIFIERS-flag now only being used for formats with
modifiers all formats without modifiers should also work.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2024-08-11 08:22:59 -07:00
Jonas Karlman
84c18f6b96 drm_prime: fix use of formats with modifiers
Similar to handles the modifiers must be supplied for each plane of the
format or a framebuffer cannot be created.

Use the format_modifier tied to the object used for the plane to fix use
of formats with modifiers.

Also fix the improper use of the DRM_MODE_FB_MODIFIERS-flag for formats
without modifiers.

This fixes playback of videos decoded by e.g. rpivid into a NV12 format
using SAND128 modifer on RPi using the drmprime-overlay interop.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2024-08-11 08:22:59 -07:00
nanahi
f3a00ea131 various: handle numpad add/subtract/multiply/divide keycodes 2024-08-11 15:08:42 +02:00
Philip Langdale
4b97c23dac video: hwdec: extend look up of hwdecs to consider device type as well
Now that we have identified the device types associated with each hwdec, we
can take advantage of this to ensure that get the right hwdec is chosen when
decoding frames and there are multiple choices available with different device
types.

This is also plumbed into the filter initialisation logic, although in practice
the decision on the hwdec has already been made at this point - still it's
easier than retaining the ambiguous look up logic and worrying that it might
lead to an inconsistent result.
2024-08-10 14:24:36 -07:00
Philip Langdale
7bbf132e20 vo: hwdec: add AVHWDeviceType property to hwdecs
As the first step towards handling scenarios where the are multiple hwdecs for
a given image format but backed by different AVHWDeviceTypes, let us annotate
the hwdecs with their corresponding device types.

From this, we can also see how all the existing hwdecs which match the same
image format also match the same device type.
2024-08-10 14:24:36 -07:00