Commit Graph

49599 Commits

Author SHA1 Message Date
Dudemanguy 2606d4cc51 x11: replace strcasestr usage with bstr
strcasestr is a GNU extension, but we can just use bstr instead to do
the same thing.
2022-06-19 16:21:07 -05:00
Dudemanguy 7e921e9939 github/workflows: install libxpresent on freebsd
This is needed for x11 which is in turn needed for vdpau.
2022-06-19 18:13:55 +00:00
Dudemanguy 3d459832a8 x11: support xorg present extension
This builds off of present_sync which was introduced in a previous
commit to support xorg's present extension in all of the X11 backends
(sans vdpau) in mpv. It turns out there is an Xpresent library that
integrates the xorg present extention with Xlib (which barely anyone
seems to use), so this can be added without too much trouble. The
workflow is to first setup the event by telling Xorg we would like to
receive PresentCompleteNotify (there are others in the extension but
this is the only one we really care about). After that, just call
XPresentNotifyMSC after every buffer swap with a target_msc of 0. Xorg
then returns the last presentation through its usual event loop and we
go ahead and use that information to update mpv's values for vsync
timing purposes. One theoretical weakness of this approach is that the
present event is put on the same queue as the rest of the XEvents. It
would be nicer for it be placed somewhere else so we could just wait
on that queue without having to deal with other possible events in
there. In theory, xcb could do that with special events, but it doesn't
really matter in practice.

Unsurprisingly, this doesn't work on NVIDIA. Well NVIDIA does actually
receive presentation events, but for whatever the calculations used make
timings worse which defeats the purpose. This works perfectly fine on
Mesa however. Utilizing the previous commit that detects Xrandr
providers, we can enable this mechanism for users that have both Mesa
and not NVIDIA (to avoid messing up anyone that has a switchable
graphics system or such). Patches welcome if anyone figures out how to
fix this on NVIDIA.

Unlike the EGL/GLX sync extensions, the present extension works with any
graphics API (good for vulkan since its timing extension has been in
development hell). NVIDIA also happens to have zero support for the
EGL/GLX sync extensions, so we can just remove it with no loss. Only
Xorg ever used it and other backends already have their own present
methods. vo_vdpau VO is a special case that has its own fancying timing
code in its flip_page. This presumably works well, and I have no way of
testing it so just leave it as it is.
2022-06-19 18:13:55 +00:00
Dudemanguy ceade34930 x11: use xrandr providers for driver detection
Unfortunately there's a certain company that makes graphics drivers that
are harder to deal with. The next commit aims to implement presentation,
but some empirical testing from users show that it's actually broken.
Give up and just tap into Xrandr so we can figure what drivers (or well,
providers by the extension terminology) are driving the screen.
Basically if we find intel, amd, or radeon, assume it's a Mesa driver.
If we find nvidia, then it must be nvidia. This detection requires randr
1.4 (which means using presentation in mpv secretly depends on randr
1.4), but this protocol version is nearly a decade old anyway so
probably 99.9% of users are fine. Do the version query check and all
that anyway just to be on the safe side.
2022-06-19 18:13:55 +00:00
Dudemanguy 7ce26dd324 vo: move wayland presentation to separate files
Wayland had some specific code that it used for implementing the
presentation time protocol. It turns out that xorg's present extension
is extremely similar, so it would be silly to duplicate this whole mess
again. Factor this out to separate, independent code and introduce the
mp_present struct which is used for handling the ust/msc values and some
other associated values. Also, add in some helper functions so all the
dirty details live specifically in present_sync. The only
wayland-specific part is actually obtaining ust/msc values. Since only
wayland or xorg are expected to use this, add a conditional to the build
that only adds this file when either one of those are present.

You may observe that sbc is completely omitted. This field existed in
wayland, but was completely unused (presentation time doesn't return
this). Xorg's present extension also doesn't use this so just get rid of
it all together. The actual calculation is slightly altered so it is
correct for our purposes. We want to get the presentation event of the
last frame that was just occured (this function executes right after the
buffer swap). The adjustment is to just remove the vsync_duration
subtraction. Also, The overly-complicated queue approach is removed.
This has no actual use in practice (on wayland or xorg). Presentation
statistics are only ever used after the immediate preceding swap to
update vsync timings or thrown away.
2022-06-19 18:13:55 +00:00
Dudemanguy 44ecf83a1b meson: use require when checking for vdpau
Technically this was wrong. If you passed -Dvdpau=enabled but did not
have x11 (a requirement for this), the build would silently just not
build the vdpau VO. The correct behavior is for it to be a hard error.
Accomplish this by using the require function and making sure that x11
is indeed being used before attempting to find the library.
2022-06-19 02:24:31 +00:00
Mia Herkt 07d78f8c8b
ci/build: Do not manually install Meson in openSUSE container
Newer image builds already include Meson.
2022-06-19 02:56:28 +02:00
Crend King c1a46ecfaf meson: rearrange library dependency order to avoid crash with fontconfig
In win32 build, if libass and libfontconfig appear after libmingwex
during linking, crash happens whenever fontconfig calls to opendir().

Moving them before ffmpeg makes sure they always appear first.

More info on https://github.com/shinchiro/mpv-winbuild-cmake/issues/217.
2022-06-18 15:17:46 +00:00
Aaron Boxer c961f4d0db vo_vaapi_wayland: only attach solid buffer once to main surface, on creation
There's no need to attach it with each frame.
2022-06-15 20:54:34 +00:00
Aaron Boxer ccce813a92 vo_vaapi_wayland: remove unnecessary subsurface sync/desync in resize
resize only changes subsurface position, which is always synchronized
with the parent surface.

For reference, see :
https://wayland-book.com/surfaces-in-depth/subsurfaces.html
2022-06-15 20:54:34 +00:00
Jan Ekström 1e1956e15b ci/build-mingw64: enable test building
Not currently run, but adds coverage for compiled code.
2022-06-15 21:19:10 +03:00
Jan Ekström 5d9af3a9dd ci/build-mingw64: bump dependencies 2022-06-15 21:19:10 +03:00
Jan Ekström 05a3affc58 ci/build-mingw64: switch to fossils directory for zlib
This contains current as well as previous versions, while the root
directory only contains the latest version.
2022-06-15 21:19:10 +03:00
Jan Ekström 312a555053 ci/build-tumbleweed: attempt to enable unit tests in CI 2022-06-15 21:19:10 +03:00
Jan Ekström 8f274da066 test/chmap: start adding AVChannelLayout unit tests
The first set iterates through all standard FFmpeg layouts and
checks that those which fit MP_NUM_CHANNELS succeed.

The second set iterates through built-in named channel layouts,
and attempts to convert them to AVChannelLayouts.
2022-06-15 21:19:10 +03:00
Jan Ekström 8123adadbd audio/chmap: add mp_iterate_builtin_layouts
Mostly useful for unit tests in order to access the channel
layouts from chmap which have mapped channels.
2022-06-15 21:19:10 +03:00
Jan Ekström 0411acf5f6 f_lavfi: switch to AVChannelLayout when available 2022-06-15 21:19:10 +03:00
Jan Ekström edfd17ab18 ad_lavc: switch to AVChannelLayout when available 2022-06-15 21:19:10 +03:00
Jan Ekström e7483ced5d af_lavcac3enc: switch to AVChannelLayout when available 2022-06-14 22:41:20 +03:00
Jan Ekström 42b58c5698 af_lavcac3enc: refactor chmap adding into its own function
This simplifies ifdeffery with AVChannelLayouts.
2022-06-14 22:19:45 +03:00
Jan Ekström 7a3f9af67f ao_lavc: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström cfc39bec00 demux_lavf: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström 46b19aedc6 common/av_common: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström 302acb27c8 audio/aframe: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström 1d15a5a059 audio: add AVChannelLayout helpers to convert from/to mp_chmap
This is the new FFmpeg channel layout structure, which now
combines channel count and layout into a single location.

Only unspecified (channel count only) and native (channel layout
mask based) layouts are currently supported for the initial move
towards non-deprecated APIs.
2022-06-12 21:05:59 +03:00
Dudemanguy 602995fd40 wayland: set appid before initial surface commit
This shouldn't have mattered but apparently qtile is unable to get the
app id if you set it after the initial surface commit. Wayland is a mess
anyway so just shuffle this around so that the frame callback and
surface commit are the last things registered in vo_wayland_init. This
works around qtile and, in theory, doesn't appear to break anything
else. Fixes #10280.
2022-06-11 10:20:06 -05:00
Dudemanguy b3ef506932 wayland_gl: fix a typo
Somehow in commit 661b5542de, my editor
snuck in a ¥ sign in here. Oops.
2022-06-11 10:07:11 -05:00
Dudemanguy 661b5542de wayland_gl: wait until resize to create egl_window
Some wayland compositors (i.e. weston) get extremely picky about
committed buffer sizes not matching the configured state. In particular,
weston throws an error on you if you attempt to launch with
--window-maximized and use opengl (vo_vaapi_wayland actually errors as
well in this case, but that's a different issue). The culprit here is
actually wl_egl_window_create. This creates an initial buffer at the
sizes passed in the arguments which is what weston doesn't like.
Instead, move the egl_window creation call to the resize function. This
ensures that mpv is using the size obtained via the toplevel event, and
it should always be the buffer size we want.
2022-06-10 13:55:22 +00:00
Sagnac aab9ab97f0 DOCS/options: fix incorrect labelling of hr-seek default
The `absolute` value was incorrectly labelled as the default instead of
the value named `default`, which was somewhat confusing. When the newer
default option was added in 679e410 it seems like wm4 forgot to remove
the label in the manual on the previous default.
2022-06-10 13:42:10 +00:00
Avi Halachmi (:avih) 7ff4a27eb6 sub: jsre filter: abort init early on empty filter list
TL;DR: previously a JavaScript VM was created + destroyed whenever
       a sub track was initialized, even if no jsre filter was set.
       Now a JS VM is created only if jsre filters were set.

Sub filters are initialized once when a subtitle track is chosen, and
then whenever the sub track changes or when some sub options change.

Sub filters init is synchronous - playback is suspended till it ends.

A filter can abort init early (get disabled) depending on conditions
specific to each filter. The regex and jsre filters aborted early
if the filter is disabled (default is enabled) or if the track is not
ass (relativey rare, e.g. bitmap subs).

The init then iterates over the filter strings, and if the result is
empty (common - no filter was added, but also if all strings failed
regex init) then it's also aborted during init.

While this iteration step is cheap with filter regex, with jsre it
requires instanciating the JS VM (mujs) in advance in order to parse
the filter strings at the list, and the VM is then destroyed if the
list ends up empty.

This VM create+destroy is fast but measurable (0.2 - 0.7 ms, slowest
measured on 2010 MacBook Air), but can be avoided altogether if we
check that the filter list is not empty before we create the VM.

So now we do just that.
2022-06-09 14:38:24 +03:00
Jan Ekström 3a52159286 ci/mingw64: add git libplacebo for gpu-next
This way mingw-w64 becomes the first CI workflow to build gpu-next.

Unfortunately, currently neither wscript or meson has gpu-next or
libplacebo-next as an option that one can require.
2022-06-07 21:04:00 +03:00
Jan Ekström f7164fcfac github/workflows: move mingw CI to ubuntu 22.04
Updates mingw-w64 to 8.0 as well as generally bumps the toolchain
to gcc 10.x.
2022-06-07 21:02:37 +03:00
Jan Ekström a10e3ab230 ci/mingw64: make meson crossfile global
This enables it to be utilized for dependencies such as libplacebo.
2022-06-07 21:02:22 +03:00
Dudemanguy 7684ebc68b wayland_gl: use wl->scaling when creating egl_window
This was actually always bugged, but we just got lucky that compositors
ignored it. The egl window was created only using wl->geometry's
coordinates but those do not include the scale factor. So technically,
the initial window creation always had the wrong size (off by whatever
the scaling factor is). The resize call later fixes it because that
correctly uses wl->scaling so in practice nothing bad was seen.
wlroots's master branch has started sending an error in this case
however and this is what trips it. Fix it correctly by using the scale
factor. This is what cd3b4edea0 tried to
fix (but was incorrect).
2022-06-07 17:13:45 +00:00
Dudemanguy a18b614a4a wayland: rearrange initialization logic
cd3b4edea0 is not correct and had some
unexpected breakage with geometry/resizing. Rather than completely
revert it, this commit restores the set_surface_scaling call as well as
rearranges some other things in the wayland init/reconfig process to
make it simplier. The next commit properly fixes what
cd3b4edea0 tried to fix.
2022-06-07 17:13:45 +00:00
AtticFinder65536 a4f0db051a player: add tiff/tif (TIFF) to list of image extensions 2022-06-07 06:28:34 -04:00
AtticFinder65536 bd46f050fe player: add jxl (JPEG XL) to list of image extensions 2022-06-07 06:28:34 -04:00
Dudemanguy cd3b4edea0 wayland: remove some unneeded lines from reconfig
Just a couple of small changes. First, the obvious one is to remove the
bogus wl->window_size = wl->vdparams; line in the configure conditional.
The reconfig always unconditionally sets the window_size here so there's
no need to duplicate it. The more important change is to remove the
usage of set_surface_scaling. This function is just to handle when
scaling changes and for setting the initial scale, it was called in the
reconfig. This, however, causes some weird issues in the latest
sway/wlroots where it can try to divide a buffer by an inappropriate
scale factor. This is possibly due to some weird ordering of events and
only occured in opengl for some reason.

Luckily, it turns it out it's not neccessary to set the scaling here at
all. The surface enter event is already setup to handle scale changes.
On an HIDPI display, mpv will initially assume a scale of 1 but the
surface actually enters the wl_output, it will automatically readjust
and resize itself to the appropriate scale value. This works on the
initial launch of the mpv window as well, so there's no need to special
case this in the reconfig event. This has the nice bonus of avoiding
that sway/wlroots issue as well since the buffer_scale is set much
later. Fixes #10263.
2022-06-06 15:13:07 -05:00
Niklas Haas 969bdf5f41 vo_gpu_next: fix OSD rendering of screenshots
One downside of this approach is that it bypasses the mixer cache, but
while this is not ideal for performance reasons, the status quo is also
simply broken so I'd rather have a slower implementation that works than
a faster implementation that does not.

And as it turns out, updating the OSD state and invalidating the mixer
cache correctly is sufficiently nontrivial to do in a clean way, so I'd
rather have this code that I can be reasonably certain does the right
thing.

Fixes #9923 as discussed. Also fixes #9928.
2022-06-06 17:04:08 +02:00
Simon Ser c4c7b07acf meson: add internal arg to wayland-protocols' get_variable()
This allows developers to build mpv with a wayland-protocols
subproject.
2022-06-05 13:46:29 -05:00
Dudemanguy ec236f7a99 osc.lua: add idlescreen and osc-idlescreen
This is mainly for other user scripts that may conflict with the osc
logo in some way. Although it is possible to listen for
shared-script-properties, this has many edge cases that could easily pop
up. A user could want other OSC things to happen at the same time (say
osc-message). They just don't want the logo. The idlescreen option
disables all idlescreen related things (including the santa hat) if it
is set to "no". A new script message (osc-idlescreen) is also added so
users can easily toggle the value (passing "cycle" or just explictly
setting "yes" or "no"). Some more discussion on this is found in the
below github issues.
https://github.com/mpv-player/mpv/issues/10201
https://github.com/CogentRedTester/mpv-file-browser/issues/55
2022-06-04 14:48:32 +00:00
Wessel Dankers 5c4b0c2afd video/out/dither: remove custom index_t typedef
Apparently _t names are reserved, and in this case it wasn't very
useful anymore (it was useful while developing it, but this code is
almost 10 years old now).

Fixes a compilation error on Solaris.
2022-06-04 01:23:03 +02:00
Dudemanguy f235bfbf36 wayland: force vo_vaapi_wayland scaling to 1
The wayland stuff is designed to update/rescale itself whenever the
wl_output scale changes. This is great, but vo_vaapi_wayland should not
actually attempt to handle any hidpi stuff. The point of this VO is to
hand off as much to the compositor as possible, so we do want the
compositor to do the scaling here (enjoy your bilinear). This fixes some
incorrect rendering that could occur with scaling values not equal 1 due
to mismatches between buffer coordinates and the surface local
coordinates. It also eliminates the need to specify
--no-hidpi-window-scale on hidpi displays (has the same practical
effect).
2022-05-30 20:28:16 -05:00
Dudemanguy 1ff2153245 DOCS/interface-changes: mention vaapi-wayland vo 2022-05-30 19:51:46 +00:00
Aaron Boxer 3536b53ed1 vo: move allocate_memfd method to wayland_common 2022-05-30 19:51:46 +00:00
Dudemanguy 38eda3804f vo_vaapi_wayland/wayland_common: code style fixes
A bad person (AKA me) merged this stuff without paying close enough
attention to the code style. Reformat this to be in-line with the rest
of the wayland code and general mpv style (braces for functions on the
next line, horizontally aligning arguments, some cosmetic cleanups for
wayland_common.h, etc.).
2022-05-30 19:51:46 +00:00
Dudemanguy 0ec3bd6ba9 wayland: use mp_tag_str not drm_format_string
So it turns out that mpv already has an mp_tag_str which makes a
readable string out of fourccs (drm formats are these).
drm_format_string, on the other hand, has a ton of baggage with having
to check different libdrm versions for certain headers, adding
compile-time defines (because there are no version defines in the libdrm
headers), etc. It's a lot simpler to just use what mpv already has and
it returns what you actually care about: i.e. is this format supported
or not. Fixes https://github.com/mpv-player/mpv-build/issues/184
2022-05-30 19:51:46 +00:00
Aaron Boxer b1639ee561 vo: allow vaapi_wayland and vaapi_x11 to coexist 2022-05-30 19:51:46 +00:00
Julian Orth afe29026ed wayland: don't depend on the order of global announcements
E.g. wl_subcompositor could be announced before wl_compositor.
2022-05-28 21:26:04 +00:00
Aaron Boxer defb02daa4 vo: add new vaapi-wayland driver
This driver makes use of dmabuffer and viewporter interfaces
to enable efficient display of vaapi surfaces, avoiding
any unnecessary colour space conversion, and avoiding scaling
or colour conversion using GPU shader resources.
2022-05-24 21:39:34 +00:00