Commit Graph

49793 Commits

Author SHA1 Message Date
Dudemanguy adb556bf15 vo_dmabuf_wayland: use special ra_ctx_create_by_name
vo_dmabuf_wayland has its own ra and context so it can handle all the
different hwdec correctly. Unfortunately, this API was pretty clearly
designed with vo_gpu/vo_gpu_next in mind and has a lot of concepts that
don't make sense for vo_dmabuf_wayland. We still want to bolt on a
ra_ctx, but instead let's rework the ra_ctx logic a little bit. First,
this introduces a hidden bool within the ra_ctx_fns that is used to hide
the wldmabuf context from users as an option (unlike the other usual
contexts). We also want to make sure that hidden contexts wouldn't be
autoprobed in the usual ra_ctx_create, so we be sure to skip those in
that function. Additionally, let's create a new ra_ctx_create_by_name
function which does exactly what says. It specifically selects a context
based on a passed string. This function has no probing or option logic
is simplified just for what vo_dmabuf_wayland needs. The api/context
validations functions are modified just a little bit to make sure hidden
contexts are skipped and the documentation is updated to remove this
entries. Fixes #10793.
2022-10-28 02:36:46 +00:00
Dudemanguy 31af37f877 vo_dmabuf_wayland: load all hwdecs in preinit
vo_gpu and vo_gpu_next typically load hwdec interops on demand and
vo_dmabuf_wayland naively copied this logic. This is actually wrong
however since draw_frame in the VO always inherently relies on hwdec
being fully loaded. This can lead to a race condition during startup
which happens with --force-window=immediate. Avoid this by simply always
loading all the interops. In the case of vo_dmabuf_wayland, this is not
really a big deal since there's only vaapi and drmprime to load. Also
fixes #10791 (the other half).
2022-10-28 02:36:46 +00:00
Dudemanguy 99699cd7ba wayland: always do a display_roundtrip at the end of init
We really need two roundtrips in the init function. The first one is for
running the registry and then second one is for ensuring the xdg_surface
and other potential wayland objects are configured at least once before
mpv does anything. We've been getting away with only doing the first for
a while via luck, but really we should do at least one more wait on the
compositor. Fixes #10791 (half of it).
2022-10-28 02:36:46 +00:00
Dudemanguy 0f1ae8896e github/workflows: print error logs on freebsd
Despite being run in a VM, the workflow actually copies the files back
to the host. We can then explictly print the error logs on failure in
their own separate section for visibility instead of it being hidden
within all the vm output.
2022-10-27 18:42:12 +00:00
Dudemanguy c3c1978330 ci/build-freebsd.sh: remove nonexistent option
Mistakenly added in aeb4792cb6.
2022-10-27 18:42:12 +00:00
Dave Craig 6e274dc8d8 vo_dmabuf_wayland: fix DRM builds with no VAAPI
Building on DRM platform without VAAPI broke because of misuse of
HAVE_VAAPI with #ifdef in place of #if. Also, the hwcontext_drm.h
header is not required for VAAPI builds, only DRM builds.
2022-10-27 18:41:37 +00:00
Jan Ekström bc3e96098d video/out/wayland_common: adjust decoration disagreement log level
Originally, I considered warning once to be useful for figuring
out whether the change in logic regarding resetting requested
mode actually fixed the reported issue or not, but alas not everyone
was happy with that decision. Thus the log level will always be
debug. This enables us to lose one level of indent as well as a
variable, which is always positive.

Additionally, make the message more explicit regarding what could
possibly be implied by the mismatch, as it seems like this was
not always clear.
2022-10-27 19:07:05 +03:00
Jan Ekström e0c4193ee5 video/out/wayland_common: clear decoration request even if compositor disagrees
Otherwise mpv and the compositor can end up in an eternal loop where
mpv requests one mode, and compositor tells that the mode is not
that (and will most likely not change).

Additionally, log these mismatches - first time as a warning, and
later as debug logging.
2022-10-26 22:20:31 +03:00
Jan Ekström f39e56bf5e video/out/wayland_common: don't pass a negative of border flag into ternary
Make it clear that we are passing the original requested border mode
on.
2022-10-26 22:20:31 +03:00
Jan Ekström 2c58ab481b video/out/wayland_common: make decoration state usage explicit
It is verbose, but makes it more explicit that requested_decoration
takes in three values:

* 0: no specific mode requested by mpv
* ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: (!border)
* ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE: (border)
2022-10-26 22:20:31 +03:00
Thomas Weißschuh c9af75e888 ao_pipewire: compatibility for libpipewire 0.3.19 2022-10-26 21:56:33 +03:00
Jan Ekström 8b81f45e1b ci: require pipewire to be enabled for Tumbleweed Linux builds 2022-10-26 21:56:33 +03:00
Emmanuel Gil Peyrot 666cb91cf1 wayland: bump dmabuf protocol to version 4
Pulled from https://github.com/mpv-player/mpv/pull/10382

The zwp_linux_dmabuf_v1 protocol version 4 provides a file descriptor
containing both formats and modifiers, which makes it possible for the
compositor to import the buffers onto planes using explicit modifiers.

This is an extremely important efficiency improvement, as the 3D
hardware can be left powered off altogether, the vaapi buffer being sent
directly from the video hardware to the display controller.

It could be possible to support zwp_linux_dmabuf_v1 version 3 as well,
but there is no reason beyond compatibility with old stacks.  I would
recommend to ditch version 2 as well, as modifier-less formats aren’t
very useful nowadays.
2022-10-26 18:41:47 +00:00
Aaron Boxer aeb4792cb6 vo_vaapi_wayland: remove, as it is superceded by vo_dmabuf_wayland 2022-10-26 18:41:47 +00:00
Aaron Boxer 7358b9d371 vo_dmabuf_wayland: wayland VO displaying dmabuf buffers
Wayland VO that can display images from either vaapi or drm hwdec

The PR adds the following changes:

1. a context_wldmabuf context with no gl dependencies
2. no-op ra_wldmabuf and dmabuf_interop_wldmabuf objects
   no-op because there is no need to map/unmap the drmprime buffer,
    and there is no need to manage any textures.

Tested on both x86_64 and rk3399 AArch64
2022-10-26 18:41:47 +00:00
Aaron Boxer 964692ad4c wayland: clean wp_presentation_feedback in discard callback to avoid leak 2022-10-26 18:41:47 +00:00
Aaron Boxer 8314c907ab build_image_converter - use full image format list to create hw_upload
currently we only try for the first format in the list
2022-10-26 18:41:47 +00:00
Aaron Boxer fbcd9c140f mp_imgfmt: move DRMPRIME format to end of enum
dmabuf-wayland vo supports both DRMPRIME and VAAPI formats.
If upload filter is needed, we want to try VAAPI hwdec first
since most users will be using VAAPI, and there is a several second
delay when DRMPRIME hwdec is tried and fails.
2022-10-26 18:41:47 +00:00
Leo Izen 050f5e7915 DOCS: document E to cycle through Editions
Pushing E (aka Shift+e) cycles through Editions for containers
that support editions, such as Matroska, although this feature was not
documented before this commit.
2022-10-24 15:23:41 -04:00
Thomas Weißschuh c3be7e2585 ao: promote ao_pipewire
The AO is feature-complete now.
As PipeWire also provides compatibility with PulseAudio, ALSA and Jack
we should put it before those for the autodetection to work.
2022-10-24 11:09:34 -07:00
Thomas Weißschuh b9a9e0a6f1 ao_pipewire: test for session to contain audio sinks
The pure presence of PipeWire does not mean that it is actually driving
the audio session. For example it could only be meant for video.

Currently there is no proper API to detect this (see [0]), so we check
for the presence of audio sinks.

As soon as a proper API exists, we should use that.

[0] https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1835
2022-10-24 11:09:34 -07:00
Thomas Weißschuh e4505ce744 ao_pipewire: init_boilerplate(): simplify errorhandling 2022-10-24 11:09:34 -07:00
dyphire 4bc6686b6a
TOOLS/lua/autoload: fix incorrect duplicate file loading behavior
This will correctly avoid the duplicate file loading when the playlist
changes due to shuffle playback or append new files.

Fixes https://github.com/mpv-player/mpv/issues/8575
2022-10-24 01:34:39 -04:00
Cœur 67260f8aac audio/format: fix Type 'struct entry' has incompatible definitions in different translation units
`struct entry` already exists from <search.h>, so the one we declare in audio/format.c needs to be named differently
2022-10-23 14:57:24 +02:00
Philip Langdale 395b37b005 vo_gpu/hwdec: add NULL check for legacy_name 2022-10-22 12:56:18 -07:00
sfan5 42cfed002f hwdec_aimagereader: fix incorrect return values 2022-10-22 15:34:37 +02:00
Nicolas F 375076578f demux_mkv: add AVS2 and AVS3 to tag list
Add support for playing back AVS2 and AVS3 video streams inside
mkv containers if ffmpeg was compiled with avs2/avs3 support.

Fixes: #10695
2022-10-21 18:12:08 +03:00
Dudemanguy 48ad2278c7 wscript: remove some bogus configure options
It turns out that wayland-scanner and wayland-protocols are both exposed
as configure options in waf meaning you can --enable/--disable them at
configure time. This is pretty nonsensical. If you want to control
wayland in the build, you should just use --enable-/--disable-wayland.
wayland-scanner and wayland-protocols should just be typical checks like
in the meson build.
2022-10-17 14:57:42 +00:00
Paul B Mahol cdcbd7372d demux_mf: add support for QOI, PHM and HDR images 2022-10-15 21:31:43 +03:00
Philip Langdale 2852691587 f_hwtransfer: allow hw uploads to implicitly convert formats
vaapi allows for implicit conversion on upload, which has some
relevance as the set of supported source formats is larger than the
set of displayable formats. In theory, this allows for offloading the
conversion to the GPU - if you have any confidence in the hardware
and/or driver's ability to do the conversion.

Today, we actually track the 'input' and 'output' upload formats
separately all the way up until the point we do a check as to whether
the original source format is an accepted 'output' format and then
reject it if it is not.

This means that we're essentially ignoring all the work we did to track
those 'input' formats in the first place. But it also means that it's a
simple change to compare against the 'input' format instead. The logic
is already in place to do best format selection on both sides.

I imagine that if I read through the history here, wm4 tried to
implement all of this properly and then gave up in disgust after seeing
vaapi mangle various conversions.

This is particularly interesting for vo-dmabuf-wayland where it is only
possible to display the subset of valid vaapi formats that are
supported by the compositor, yet all playback has to go through vaapi.
Users will then be able to take advantage of all possible vaapi formats
to avoid having to do software format conversion.
2022-10-15 09:57:09 -07:00
Philip Langdale 1bca62e58b f_hwtransfer: accept non-power-of-2 hw uploads
This works fine for me on vaapi, cuda and vulkan. Why did we have this
restriction in there? Worst case, the hwdec_interop will reject it.
2022-10-15 09:57:09 -07:00
Philip Langdale 345342f50a hwdec/dmabuf_interop_gl: work-around implicit rgba swizzling
This has been a long standing problem that I think was the root cause
for wm4's vaapi shitlist. As DRM explicit supports all possible rgba
orderings, but OpenGL only guarantees support for 'rgba8', something
has to happen to support import of dmabufs with non-native ordering.

Although undocumented, it appears that somewhere in the import on the
GL side, the ordering is swizzled to rgba - which makes sense as that's
the only way to be able to support importing all the different formats.

But we didn't know this, and we do our own swizzling based on the
original imgfmt - which matches the drm format. So we get double
swizzling and messed up colours.

As there is no way for us to express that the GL swizzle happened to
the rest of mpv, the easiest thing to do is fudge the format to the
natural ordering so the GL doesn't change anything, then our swizzling
will do the right thing in the end.

Note that this change doesn't handle 0rgb and 0bgr because they seem to
be affected by some additional feature/bug that is mangling the
ordering somewhere that equally affects Vulkan interop. That could be a
vaapi driver bug or something going on in ffmpeg.
2022-10-15 09:30:46 -07:00
Philip Langdale 6f7506b660 f_hwtransfer: get rid of the shit list
A few years ago, wm4 got sufficiently annoyed with how vaapi image
format support was being discovered that he flipped the table and
introduced the shit list (which just included vaapi) to hard-code the
set of supported formats.

While that might have been necessary at the time, I haven't been able
to find a situation where the true list of supported formats was unsafe
to use. We filter down the list based on what the vo reports - and the
vo is already doing a thorough testing of formats, and if a format
makes it through that gauntlet, it does actually work.

Interestingly, as far as I can tell, the hwdec_vaapi probing code was
already good enough at the time (also written by wm4), so perhaps the
key difference here is that the driver side of things has improved.

I dug into this because of the support for the 422/444 high bit depth
vaapi formats I added to ffmpeg. These are obviously not in the hard
coded list today, but they work fine.

Finally, although it's positioned as a vaapi thing, it's really just
Intel specific, as the AMD vaapi driver has never exposed support for
anything except the formats used by the decoder/encoder profiles.
2022-10-15 09:30:46 -07:00
Philip Langdale 66e30e7f2f hwdec/vaapi: improve probing of supported sw formats
The logic around trying to establish what formats are supported by
vaapi is confusing, and it turns out that we've been doing it wrong.

Up until now, we've been going through the list of decoding profile
endpoints and checking the formats declared in those profiles to build
our list.

However, the set of formats that the vaapi driver can actually support
is potentially a superset of those supported by any given profile
endpoint. This master list is exposed by libavutil via the
av_hwframe_transfer_get_formats() function, and so we should use that
list as our starting point.

Perhaps surprisingly, this change actually removes no code, because we
still want the logic that enumerates endpoints and finds supported
formats for endpoints. We need this because we must have at least one
known sw format to initialise the hwframe_ctx with.

Additionally, while in the general case,
av_hwframe_transfer_get_formats can return different formats depending
on what format you initialise the hwframe_ctx with, I happen to have
read the libavutil code, and it doesn't care, so we just need to call
it once, we know we'll get back all known formats.

In practice, with an Intel vaapi driver, this will result in us
supporting a handful of extra formats for hwuploads - particularly
yuv420p (so no need to convert to nv12 first) and various orderings
of rgb(a).
2022-10-15 09:30:46 -07:00
rcombs dfb5b0c55f vo_gpu_next: fix crash on uninit after startup failure 2022-10-14 15:37:49 +02:00
VincentVerdynanta 59fc8eecbc sd_ass: improve handling of subtitles with unknown duration
Commit 740b701 introduced handling for subtitles with unknown duration,
but it came with a minor flaw where a track event that shares identical
start time with following track event will has its Duration value set
to 0, we don't want this to happen since it will prevent simultaneous
rendering of multiple track events.
This commit aims to address this issue.
2022-10-12 19:57:44 -04:00
Leo Izen b3d77397eb
DOCS: fix minor typo with keep-open description
Fix a minor typo in the description of --keep-open
in DOCS/man/options.rst
2022-10-12 10:19:09 -04:00
Shreesh Adiga e97819f88e draw_bmp: fix out of bounds access in mark_rect
When the width is exactly a multiple of SLICE_W (currently 256),
heap buffer overflow is reported by Address Sanitizer. So adjust
the maximum index for the line array accordingly.
2022-10-11 17:11:07 +00:00
Philip Langdale 064059e6c3 vo_gpu/hwdec: rename and introduce legacy names for some interops
We've had some annoying names for interops, which we can't simply
rename because that would break config files and command lines. So we
need to put a little more effort in and add a concept of legacy names
that allow us to continue loading them, but with a warning.

The two I'm renaming here are:
* vaapi-egl -> vaapi (vaapi works with Vulkan too)
* drmprime-drm -> drmprime-overlay (actually describes what it does)
* cuda-nvdec -> cuda (cuda interop is not nvdec specific)
2022-10-11 10:07:48 -07:00
odnar-dev d050e350fe x11: fix --on-all-workspaces option
mpv set _NET_WM_DESKTOP to 0xFFFFFFFF, which behaves differently with each window manager.
Instead, set the window property to STICKY, and let the window managers deal with it.
2022-10-11 09:25:26 +02:00
Niklas Haas c96cee2940 vo_gpu_next: vulkan: libplacebo: unify log prefix
The new status quo is simple: all messages coming from libplacebo are
marked "vo/gpu{-next}/libplacebo", regardless of the backend API (vulkan
vs opengl/d3d11).

Messages coming from mpv's internal vulkan code will continue to come
from "vo/gpu{-next}/vulkan", and messages coming from the vo module
itself will be marked "vo/gpu{-next}".

This is significantly better than the old status quo of vulkan messages
coming from "vo/gpu{-next}/vulkan/libplacebo" whereas opengl/d3d11
messages simply came from "vo/gpu{-next}", even when those messages
originated from libplacebo.

(It's worth noting that the the destructor for the log is redundant
because it's attached to the ctx which is freed on uninit anyway)
2022-10-09 21:47:35 +02:00
Jan Ekström 3f32dfe981 github/workflows: explicitly install Xinerama on FreeBSD
Apparently an implicit dependency on it through one of the
otherwise installed packages is no longer there.
2022-10-09 17:09:06 +03:00
Dudemanguy bb56554a62 x11: fix a couple of memory leaks
Managed to go completely unnoticed for months (who was the bad person
that introduced these*). Fairly self-explanatory. After getting
ProviderInfo from randr, we need to free it. The other one is pretty bad
because it leaked every frame (ouch). It turns out that you're supposed
to free any event data after you cast a generic event to an
XGenericEventCookie. Free that as well.

*: It was me.
2022-10-08 23:50:55 -05:00
Thomas Weißschuh 161bdd9359 ao_pipewire: allow specification of remote name 2022-10-06 13:16:35 -07:00
Thomas Weißschuh a1e29f1555 ao_pipewire: small cleanups and restructring
* Remove unneeded braces.
* Don't use non-standard %m in printf.
* Organize struct priv a bit.
2022-10-06 13:16:35 -07:00
Christoph Heinrich cc65b3892d osc: scale rendered aspect ratio with window aspect ratio
The logo stays centered better and it doesn't distort anymore due to a
recent change in libass https://github.com/libass/libass/pull/645
2022-10-06 14:34:56 -04:00
Dudemanguy d2a0791fe8 wayland: correctly handle non-CLOCK_MONOTONIC clocks
The wayland presentation time code currently always assumes that only
CLOCK_MONOTONIC can be used. There is a naive attempt to ignore clocks
other than CLOCK_MONOTONIC, but the logic is actually totally wrong and
the timestamps would be used anyway. Fix this by checking a use_present
bool (similar to use_present in xorg) which is set to true if we receive
a valid clock in the clockid event. Additionally, allow
CLOCK_MONOTONIC_RAW as a valid clockid. In practice, it should be the
same as CLOCK_MONOTONIC for us (ntp/adjustime difference wouldn't
matter). Since this is a linux-specific clock, add a define for it if it
is not found.
2022-10-06 18:08:51 +00:00
Niklas Haas 7f5541fc3c vulkan: remove --vulkan-disable-events
This has had no effect since libplacebo v4.192.0, and was deprecated
upstream a year ago. No deprecation period in mpv is justified by this
being a debug / work-around option.
2022-10-05 16:35:14 +02:00
sfan5 a2de6524ff vo: hwdec_aimagereader: add missing image format specifier
This is required since e50db42927, but was missed during the merge.
2022-10-03 20:34:25 +02:00
sfan5 5463d3eeff vo_gpu: hwdec: add Android hwdec utilizing AImageReader 2022-10-02 14:12:26 +02:00