0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

4391 Commits

Author SHA1 Message Date
Niklas Haas
f97584cadc vo_gpu_next: drop redundant PL_HAVE_LCMS check
This header is installed unconditionally starting with libplacebo
v4.208.0, so we are safe to remove the check.
2023-08-18 16:40:44 +02:00
Kacper Michajłow
f274ff2f2b vo_gpu_next: use pl_dispatch_info_move to avoid useless data copy
Instead copy the data on-demand when VOCTRL_PERFORMANCE_DATA is
requested.
2023-08-18 16:39:57 +02:00
Niklas Haas
6a28e0fa3b libplacebo: drop PL_API_VER compatibility paths 2023-08-18 16:39:57 +02:00
Niklas Haas
b8e6b03d3b ra_pl: drop PL_API_VER compatibility paths 2023-08-18 16:39:57 +02:00
Niklas Haas
442adb0553 vo_gpu_next: drop PL_API_VER compatibility paths
v6.292 implied by minimum dependency.
2023-08-18 16:39:57 +02:00
Niklas Haas
24dca265b4 meson: remove redundant libplacebo-next check
Now implied by the minimum libplacebo version.
2023-08-18 16:39:57 +02:00
Niklas Haas
e3ae072414 hwdec_cuda: drop old PL_API_VER compatibility path
LIBPLACEBO_NEXT is now implied by libplacebo being available
2023-08-18 16:39:57 +02:00
Niklas Haas
36972aec53 vo_gpu: allow --hdr-peak-decay-rate=0.0
This completely disables all smoothing. Despite what the manual claims,
a decay rate of 1.0 does *not*.

It's worth pointing out that this depends on the following commit to
work properly in --vo=gpu-next, but I don't think working around such a
minor detail is worth the trouble, considering people building nightly
mpv are probably also building nightly libplacebo it should just work
(tm).

See-Also: 1c464baaf4
See-Also: 83af2d4ebd
2023-08-18 15:00:25 +02:00
Dudemanguy
640c07fb19 vo: clear vsync_offset if drawing while paused
libplacebo doesn't like it when the queue_params PTS is less than the
actual PTS of the frame for the first frame and skips mixing it during
interpolation. This can happen if you seek while paused because mpv will
always keep the vsync_offset value as if it was still playing. So in
some cases, this can be a negative value and thus the PTS will end up
decreasing and libplacebo interprets this frame as a first frame. This
skips mixing the frame and thus you get a black screen. To fix this
this, just realize that vsync timings are completely meaninglessly in
while paused. If you are not actively pushing frames, there's no reason
to care about vsync_offset. So just clear it and make it zero when the
VO's internal state is paused and we're trying to render a frame. Makes
libplacebo happy and fixes #11958.
2023-08-16 14:13:43 +02:00
Dudemanguy
455487bdc9 win32: fix display resolution calculation on mulitple monitors
It was actually always wrong, and no one ever noticed. This currently
returns the size of the entire display area and not one actual monitor.
Fix this by calling get_monitor_info and then doing the appropriate
subtractions. Checked by @CrendKing and fixes #12172.
2023-08-15 21:01:13 +00:00
Dudemanguy
9d7638a6f2 wayland: clear all keys on keyboard_handle_leave
There was no known problem with this, but according to the wayland
spec*, "After this event client must assume that no keys are
pressed...", so go ahead and do that.

*: 72da004b3e/protocol/wayland.xml (L2449)
2023-08-14 21:55:20 +00:00
Dudemanguy
221a574a50 wayland: clear saved mpkey more aggressively
Introduced by 1f8013ff3f. We try to save
the mpkey so it can be used in the modifier event that comes next if
appropriate and also clear it when needed. The problem is that the
condition for clearing is too strict and things like mismatched cases
and so on can make mpkey on the corresponding key release event not
match the saved mpkey even though in reality they were the same key.
Loosen the check by simply always clearing the saved mpkey as long as
there was some key found and the state is up. We don't handle multiple
keys at the same time anyways (they're interpreted in a sequence), so it
should be hopefully OK.
2023-08-14 21:55:20 +00:00
Dudemanguy
64db68639d wayland: use fallback for display-fps/width/height
During initialization, the mpv window was not available and wayland
simply just reported nothing. But this can be a nuisance and there are
cases where having a values is better than nothing (vapoursynth). So if
current->output isn't available yet, fallback to find_output instead.
This is influenced by what is set by options like --screen and
--screen-name, but we'll consider that a feature not a bug.
2023-08-13 19:58:20 +00:00
Dudemanguy
4a6abff812 x11: add --x11-wid-title option
This deliberately wasn't being done when mpv was embedded
(fbccddb48b). There are some applications
that would benefit from mpv setting a title since they don't do so
themselves (such as tabbed), but at the same time some others would
probably rather not have this behavior (like smplayer). Add an option
that allows an embedded mpv to set the title if the user wishes.
Fixes #11528.
2023-08-13 19:58:20 +00:00
NRK
331832f55d x11_common: drop unnecessary NULL check
similar to free(), XFree() is a no-op if argument is NULL
2023-08-13 19:57:55 +00:00
NRK
5d2d7cde8e x11_common: avoid unnecessary XUnmapWindow() call
XDestroyWindow() is called immediately after, which also unmaps window
if needed. according to the manpage:

> If the window specified by the w argument is mapped, it is unmapped
> automatically.
2023-08-13 19:57:55 +00:00
Dudemanguy
efefe3a6dc vo_gpu_next: actually fix screenshots with PAR
983e8f0100 resulted in the correct
dimensions, but it was not actually right because vo_gpu_next still had
the src and dst rects the same. This just needs to work like how vo_gpu
does where the src is the image params and the dst is desired output. So
basically, just copy that code over here. Fixes #12108 and as a bonus,
overriding the aspect ratio now results in correct screenshots
(previously didn't work at now and then with the above commit it had
correct dimensions but still incorrect output).
2023-08-08 21:28:10 -05:00
Dudemanguy
983e8f0100 vo_gpu_next: take into account PAR when taking screenshots
Using the width and height params directly doesn't actually work if PAR
is something other than 1. Instead, use mp_image_params_get_dsize and
calculate the correct dimensions which matches the vo_gpu behavior.
2023-08-07 21:09:30 -05:00
Niklas Haas
cf01646c39 vo_gpu_next: add ability to use named hook params
Closes: https://github.com/mpv-player/mpv/issues/12093
2023-08-07 19:34:44 +02:00
Niklas Haas
35a6b26b78 vo_gpu_next: increase non-interpolation queue size
1 is not enough to prevent PL_QUEUE_MORE, because the pl_queue is
designed to always know the next frame (in addition to the current).
Before haasn/libplacebo@112bb886, this was was (wrongly) silently
omitted by the pl_queue code, but that fix exposed this.

While it's technically API misuse on mpv side, due to the mpv vo code
having its own internal queueing and timing control, it shouldn't
actually make any difference in practice (and likely, the error message
showing up is the only meaningful bug here - the issue is entirely
cosmetic).

Fixes: https://github.com/mpv-player/mpv/issues/12101
2023-08-07 10:42:08 +02:00
Niklas Haas
f6de44dd6a vo_gpu_next: update for new pl_filter configuration API
Configuration of filter parameters was moved from pl_filter_function (of
which the user had to make a copy) to pl_filter_config, with the
pl_filter_function remaining immutable.

Implement this new logic in a way that can reasonably exist side-by-side
with the old configuration API. Once we drop support for PL_API_VER
below 303, we can drastically simplify this code.
2023-08-06 22:44:54 +02:00
Dudemanguy
8417804224 win32: signal VO_EVENT_DPI on dpi changes
The win32 code already updates itself on dpi changes. However, it never
signalled mpv's core when this happened which meant that the
display-hidpi-scale property never changed. Simply send the
VO_EVENT_DPI event when appropriate. Fixes #12081.
2023-08-06 19:09:44 +00:00
Dudemanguy
59ac302dff vo_gpu/vo_gpu_next: fix setting an empty dscale
The manual currently says that if dscale is unset, --scale will be
applied. However, this only works at init time. If you change the dscale
filter to be empty later, vo_gpu will segfault and vo_gpu_next will
throw an error and refuse the changes. That's because when the option is
unset at runtime, the value becomes "" not NULL and the vo's never
accounted for this. Fixes #12031.
2023-08-05 14:01:02 +00:00
Niklas Haas
45e95311b8 vo_gpu_next: add --hdr-peak-percentile 2023-08-04 16:58:44 +02:00
billdoor1
30bf811a8f vo_vdpau: set hwdec image format 2023-08-02 18:51:02 +00:00
LaserEyess
3b19866882 drm: bump minimum version to 2.4.105
Debian 12 is out, with 2.4.114, and Ubuntu 22.04 has 2.4.110, this
 #ifdef is no longer needed
2023-07-31 21:40:10 +02:00
Dudemanguy
0bed2a2263 build: remove outdated generated directory
This only existed as essentially a workaround for meson's behavior and
to maintain compatibility with the waf build. Since waf put everything
in a generated subdirectory, we had to put make a subdirectory called
"generated" in the source for meson so stuff could go to the right
place. Well now we don't need to do that anymore. Move the meson.build
files around so they go in the appropriate place in the subdirectory of
the source tree and change the paths of the headers accordingly. A
couple of important things to note.

1. mpv.com now gets made in build/player/mpv.com (necessary because of
   a meson limitation)
2. The macos icon generation path is shortened to
   TOOLS/osxbundle/icon.icns.inc.
2023-07-31 19:00:06 +00:00
Dudemanguy
b7bf5e619f draw_bmp: fix overflowing coordinates in mark_rcs
This is yet another unfortunate side effect of the width % SLICE_W == 0
special case. While looping through these rectangles, the rc->x1 value
on the final loop can be greater than the actual total width. This will
cause a buffer overflow if using the mp_draw_sub_overlay API. 2 of the
current VOs that use that work around it by adjusting the values
returned, but the better fix is to correct what's actually given in the
rectangles so you can safely use the values. As for the fix, it's simply
ensuring that rc->x1 doesn't extend beyond p->w with a MPCLAMP.
Previously, the code would always naively add SLICE_W (256) to rc->x0
which would easily extend past the actual width in many cases. The
adjustments in vo_vaapi and vo_dmabuf_wayland are dropped and in theory
vo_direct3d should work now since we can just trust the values given to
us in the rectangles. How nice.
2023-07-30 20:06:20 +02:00
Niklas Haas
3bf1d22879 vo_gpu_next: fix assertion on wayland
This code failed to handle the case of the swapchain submission being
skipped because the window was invisible.

Fixes: f9dc695b58
2023-07-29 19:09:45 +02:00
Niklas Haas
f9dc695b58 vo_gpu_next: delay swapchain submit until flip_frame()
Presents frames at the correct time when DS is disabled.
2023-07-29 17:09:59 +02:00
Dudemanguy
48eb77207b wayland: restore xkb_keysym_to_utf8 handling
In 1f8013ff3f, I mistakenly thought this
was only used for modifier presses way back in the commit it was
introduced in, but it actually also handles non-english keys/letters.
Instead of returning early, we should try xkb_keysym_to_utf8 first and
then return if that doesn't do anything so the modifier can then be
handled in the appropriate event. Fixes #12009.
2023-07-24 17:07:27 +00:00
Dudemanguy
9e449cc685 build: internally rename gl-wayland to egl-wayland
This has always been a pet peeve of mine and in fact I named the option
in meson "egl-wayland" with the intention of finally doing this. We call
everything that's egl "egl-foo" internally except for wayland.
2023-07-23 22:00:08 +00:00
sfan5
5236003db5 Revert "vo_gpu_next: use pl_dispatch_info_move to avoid useless data copy"
We wanted to preserve the libplacebo v5.264.0 requirement for gpu_next
for this release, since this is the what most Linux distributions are shipping.
The VLC 3 <-> libplacebo v6 situation is an additional reason distros are not
likely to ship the newest libplacebo release soon.
This reverts commit b73d96776c.
2023-07-23 15:40:41 +02:00
Dudemanguy
783e2bf138 vo_dmabuf_wayland: correctly handle force-window
Since this works by mpctx giving us a dummy image, we can be reasonably
be confident that when we receive a matching imgfmt with no underlying
hw_subfmt that this is simply force window from the player. Just allow
this to go through the usual wayland logic and skip the hwdec checking.
When we get the real image later, it will still error out on the
compositors that don't have proper support.
2023-07-23 04:55:26 +00:00
Gusar321
bddf0efade vo_vaapi: restore hardware video decoding
Commit e50db42 changed how hwdec interop works. Adjust vo_vaapi accordingly by setting the appropriate image format.
2023-07-22 12:16:29 +02:00
Gusar321
800d9eaa42 vo_vaapi: fix segfault in draw_osd
When video width is not a multiple of slice size, the last slice will overflow. Fix this by adjusting the width of the last slice to fit within the video.

Fixes issue #10436
2023-07-22 12:16:29 +02:00
Dudemanguy
9a95cb9fd1 vo_drm: remove VOCTRL_SCREENSHOT_WIN
With the generic screenshot window implemented, this is no longer
needed since vo_drm already uses software scaling.
2023-07-21 20:23:11 +02:00
sfan5
d46a31317f wayland_common: remove questionable gcd impl and global state 2023-07-19 13:01:08 +02:00
Dudemanguy
e399266400 wayland: don't treat tiled and maximized windows the same
mpv has historically always treated the various tiled states in
xdg-shell as maximized (probably because it was easier). Well it turns
out that there are some tiling compositors (hyprland) that allow tiled
windows to maximize themselves. This can lead to some scenarios where
mpv ends up doing a maximize on hyprland which actually works since it's
not a no-op like on sway. Fix this by separating out the tiled state
from maximize. It works mostly the same, but the main difference is that
there's no request to tile yourself like there is with maximize. Should
fix #11954.
2023-07-19 01:14:32 +00:00
Dudemanguy
949e1f0dcc wayland: add locked_size convenience shorthand
There's a lot of checks that are along the lines of !maximized &&
!minimized or vice versa. Make a locked_size boolean and store the
value of this in here to avoid writing long lines since the next commit
will add yet another condition to this.
2023-07-19 01:14:32 +00:00
Niklas Haas
02595011eb vo_gpu_next: add --hdr-contrast-recovery/smoothness
New upstream feature. Disabled by default.
2023-07-18 15:22:18 +02:00
Dudemanguy
1f8013ff3f wayland: handle modifier keys correctly
I don't know why we've been doing this wrong for so long or how I didn't
notice until now. Wayland specifically has an event for handling
modifiers. We even named it "keyboard_handle_modifiers" in the code.
What we should do is just get the modifier and save it after the xkb
state is updated. Then later if the user does something else (press
another key or clicks the mouse button), the saved modifier key is
applied. If you let go of the modifier at any point, the xkb will just
update its state again and we save a 0 again here (i.e. no modifier).

There is one bit of an edge case however. If a key is pressed BEFORE the
modifier, then we have to handle the mp_input_put_key in the modifier
event instead since the ordering is not guarenteed. What we do here is
keep track of the mpkey as well as the mpmod. However if we are unable
to find a matching mpkey and the key state is pressed down, assume it's
a modifery key that was pressed and don't update mpkey. That way
whenever the modifier event does happen, it can correctly handle this
and we know that the keys must be pressed down if we end up there in the
code path.

As another fun historical note, the xkb_keysym_to_utf8 line was actually
written by wm4 himself in 460ef9c7a4
nearly 10 years ago. As the commit shows, it was clearly intended to
handle modifiers (if lookupkey finds nothing, then try to find a mod
instead). Of course, this is extremely dated and wayland hasn't worked
like that in ages. This branch never actually did anything, and thus
we'll remove it here along with modifier lookup changes.

This solves bizarre issues with modifiers not working with random keys
while working fine with others (don't ask me why). Fixes #10286 and
fixes #11945.
2023-07-17 18:53:50 +00:00
Kacper Michajłow
347fbd6fa3 vo_gpu_next: add --target-contrast option
For better control over target display levels.
2023-07-17 18:50:34 +02:00
Dudemanguy
9e9abb1a0f wayland: wrap resize requests in prepare_resize
828dd65ef8 started this and put it in the
most common place, but any resize mpv is doing should be accompanied by
that function call to correctly inform the compositor of the window
bounds. Since we also have to set VO_EVENT_RESIZE at the same time, it
makes sense to just put these in the same function. A slight thing to
note is that xdg_surface_set_window_geometry uses surface local
coordinates which means they are divided by the wl->scaling factor. If
possible, we should use surface local coordinates directly if available
(like in the toplevel config) to avoid potential rounding errors.
Otherwise, just calculate it out. The linked commit actually broke
some weston resizes in weird ways (window disappearing or completely
freezing). Don't ask me why and I didn't attempt to find out why either,
but with this it all appears to work normally again (the other
compositors don't appear to be any different, and they shouldn't be), so
we'll go with this since it fixes soemthing and it also is more
conceptually correct.
2023-07-16 21:20:50 -05:00
Dudemanguy
1f683401aa vo_dmabuf_wayland: error out if compositor doesn't support the format
This was never implemented so in cases where the compositor didn't have
support for the underlying format, the window would just be black and
quite unhelpful. Well it turns out that fixing this is actually really
easy because mpv has reconfig2 which returns the entire mp_image on
every reconfig. We can just use that mp_image to try and obtain the
format and modifier pair and then use that to check against what we know
the compositor supports. If there are any problems, error out
gracefully. Some code duplication with the vaapi/drmprime importers, but
it's probably better to keep these separate. Fixes #11198 and fixes #11664
2023-07-14 14:24:45 +00:00
Dudemanguy
2616b2b11e build: make dmabuf-wayland a build option and require drm
It makes more sense as an option at this point. Also libdrm is not
optional at all. You have to get a drm format and modifier for this to
even work (the VO will just fail without DRM). Just hard require it and
remove the guards. vaapi can remain optional.
2023-07-14 14:24:45 +00:00
Dudemanguy
828dd65ef8 wayland: use xdg_surface_set_window_geometry
mpv has never used this because we never really seemed to need it, but
it actually has a purpose. This informs the compositor of the actual
dimensions of the mpv window and avoids errors with sizes not matching
(particularly with weston). It's a better way to fix the "maximizing
causing an error on weston" issue since it also works for dmabuf-wayland
(which always had this problem).
2023-07-13 12:12:37 +00:00
Dudemanguy
4ff27d5220 Revert "wayland_gl: wait until resize to create egl_window"
The original reason for this commit was to prevent a compositor error on
weston when going into the maximized state. The configured dimensions of
mpv didn't match its actual size and Weston is super strict about this
so it threw a compositor error which is fatal. It only happened in
opengl and this seemed like an OK workaround, so I went with this.
However, there's actually a far easier way to solve this problem and we
don't need this anymore. This has the benefit of avoiding a harmless
warning message that appears with gpu-next on opengl. The next commit is
the proper solution. Closes #10324.

This reverts commit 661b5542de.
2023-07-13 12:12:37 +00:00
Dudemanguy
33130741f4 vo_dmabuf_wayland: guard in destroy_osd_buffers
*sigh*
2023-07-12 22:20:20 -05:00
Dudemanguy
7409f4a6c9 vo_dmabuf_wayland: stop lazy loading hwdec
The implementation was copied from vo_gpu/vo_gpu_next but fundamentally
it doesn't make sense for this VO. Hardware decoding is not optional in
vo_dmabuf_wayland. We should be sure to request and load all supported
formats in the preinit and fail if there are any problems. There should
be no functional change from before, but it's more conceptually correct
this way.
2023-07-12 16:59:59 -05:00
Dudemanguy
b57cf110c9 vo_dmabuf_wayland: don't try to get pts without frame->current
Fixes a segfault with --force-window=immediate.
2023-07-12 16:59:47 -05:00
Dudemanguy
c958990833 vo_dmabuf_wayland: add osd support
This adds osd support via shm buffers using a similar approach that the
normal buffers do, but it differs in a few key areas. One thing to note
is that sway and weston actually handle this extremely differently which
required all the abstractions here. In particular, weston does not cope
well with destroying the wl_buffer from shm outside of the release
handler at all (i.e. it segfaults). The workaround here is to simply
attach a NULL to the osd surface and do a surface commit before we
destroy the buffers. This is reasonable enough and seems to work well
although it's pretty weird. Sway is more straightforward although it
actually releases the osd buffer when the window goes out of sight.
Also, I found that it doesn't always release every buffer before you
close it unlike weston seems to do which is part of the reason all this
bookkeeping is required. I don't know if there's any other compositor
out there that can possibly handle vo_dmabuf_wayland right now, but
suffering through these two is good enough for now I think.
2023-07-12 19:19:54 +00:00
Dudemanguy
180a3df1f1 vo_dmabuf_wayland: init wl_list at the top of preinit
Otherwise, we could fail and skip to uninit without initalizing this
which then will segfault because the list is null and accessed while
trying to destroy buffers.
2023-07-12 19:19:54 +00:00
Dudemanguy
a890d7be2a vo_dmabuf_wayland: stop guarding viewport interfaces
It's entirely pointless. Not having viewport is already a fatal error
for this VO as it cannot possibly work without that protocol. Just drop
all these redundant if's.
2023-07-12 19:19:54 +00:00
llyyr
a0f1bbddff wayland: add xdg_toplevel.wm_capabilities handler
Fixes crash when compositors advertise xdg_toplevel version >= 5
2023-07-10 13:37:23 +00:00
Dudemanguy
7beae9ac86 wayland: add support for suspended toplevel state
mpv already guesses when the window is hidden so plugging in a proper
event that actually tells us this is really trivial. Note that there's
some redundancy with setting wl->hidden in a few spots, but nothing can
really be done about that as long as the crappy hack is still in place.
2023-07-09 19:22:53 +00:00
Dudemanguy
589da09e5a wayland: add cursor-shape-v1 support
This protocol no longer requires us to draw a separate cursor surface
and all of that horrible stuff. We can just ask the compositor for the
default cursor instead since that's literally all mpv cares about.
2023-07-09 18:10:19 +00:00
Dudemanguy
ab3002851e vo_wlshm: bail out of resize if width/height is 0
It can happen during initialization and of course nothing good will
happen if we let this go through (i.e. segfault). Return and wait for
geometry to finish setting up in the wayland stuff before doing the
initial resize.
2023-07-08 20:47:35 -05:00
Dudemanguy
0242055564 wayland: fix memory leak with multiple monitors
Very dumb. I can't remember if it was always like this or if I broke it
at some point, but clearly each wl_output should just be freed in
remove_output. Freeing it if it happens to be wl->current_output only
works for that one monitor, so remove that whole line. This has to
happen before we close the wayland connection so reorder the uninit a
little bit.
2023-07-08 20:31:09 -05:00
Dudemanguy
ee69d99bd4 various: correctly ignore cache files with --no-config
--no-config should prevent loading user files of any type: configs,
cache, etc. For cache files, this case wasn't properly handled and it
was assumed they would always get something. vo_gpu's shader cache
actually already handles this, so it was left untouched. In theory,
demuxer cache should never have this issue because saving it to disk is
disabled by default (and likely that will never change), but go ahead
and change it for consistency's sake. Fixes some segfaults with
--no-config and various combinations of settings (particularly
--vo=gpu-next).
2023-07-06 13:08:23 +00:00
Dudemanguy
48e0ee9979 vo_gpu/vo_gpu_next: enable gpu shader and icc cache by default
4502522a7a changed the way mpv handled and
saved cached files. In particular, it made a separate boolean option for
actually enabling cache and left the *-dir options as purely just a path
(i.e. having a dir set didn't mean you save cache). This technically
regressed people's configs, so let's just turn the cache on by default.
Linux users already expect random stuff in ~/.cache and well everyone
else can just live with some files possibly appearing in their config
directory.
2023-07-04 22:14:43 +00:00
Dudemanguy
d6a6901090 vo_gpu: fix some cache related memory leaks
I goofed this up.
2023-07-04 22:14:43 +00:00
Dudemanguy
dbc0fcea1b player: add --input-cursor-passthrough option
Add an option for allowing pointer events to pass through the mpv
window. This could be useful in cases where a user wants to display
transparent images/video with mpv and interact with applications beneath
the window. This commit implements this functionality for x11 and
wayland. Note that whether or not this actually works likely depends on
your window manager and/or compositor. E.g. sway ignores pointer events
but the entire window becomes draggable when you float it (nothing under
the mpv window receives events). Weston behaves as expected however so
that is a compositor bug. Excuse the couple of completely unrelated
style fixes (both were originally done by me).
2023-07-04 19:16:43 +00:00
Kacper Michajłow
d2c28bc4df vo_gpu_next: remove synchronization from info_callback
VOCTRL is processed on VO thread.
2023-07-02 16:20:48 +02:00
Kacper Michajłow
b73d96776c vo_gpu_next: use pl_dispatch_info_move to avoid useless data copy
Instead copy the data on-demand when VOCTRL_PERFORMANCE_DATA is
requested.
2023-07-02 16:20:48 +02:00
NRK
b616a6cef1 vo_x11: don't rely on XFree to free calloc-ed data 2023-07-02 12:47:31 +02:00
NRK
fa7503989f vo_x11: check for calloc() failure 2023-07-02 12:47:31 +02:00
Dudemanguy
f76c441ba2 win32: add support for drag-and-drop option 2023-07-01 02:06:02 +00:00
Dudemanguy
6625a94608 options: add no to drag-and-drop
Suggested by @sfan5. Naturally, "no" disables all drag and drop
behavior.
2023-07-01 02:06:02 +00:00
NRK
7ad7609541 wayland: remove erroneous POLLERR usage
POLLERR is only returned in `.revents` and is ignored in `.events`
2023-06-29 13:17:56 +02:00
NRK
d70b859084 mp_image: abort on av_buffer_ref() failure
this changes mp_image_new_ref() to handle allocation failure itself
instead of doing it at its many call-sites (some of which never checked
for failure at all).

also remove MP_HANDLE_OOM() from the call sites since this is not
necessary anymore.

not all the call-sites have been touched, since some of the caller might
be relying on `mp_image_new_ref(NULL)` returning NULL.

Fixes: https://github.com/mpv-player/mpv/issues/11840
2023-06-28 20:56:23 -07:00
syphyr
f8cb539e6f hwdec: fix undeclared identifier in mediacodec_embed
mediacodec_embed is a `vo` and not a `hwdec`.
2023-06-28 10:29:24 -07:00
NRK
c3781b2d68 vo_drm: fix null dereference and using closed fd
when vo_drm_init() fails inside of preinit(), uninit() will be called as
part of cleanup with vo->drm being NULL and thus `drm->fd` would lead to
null dereference.

and since vo_drm_uninit() closes drm->fd, destroy_framebuffer() ends up
using a closed fd.

according to the drm-gem manpage [0]:

> If you close the DRM file-descriptor, all open dumb-buffers are
> automatically destroyed.

so remove the destroy_framebuffer() loop entirely, which fixes both the
issues.

[0]: https://www.systutorials.com/docs/linux/man/7-drm-gem/
2023-06-28 02:10:14 +00:00
Kacper Michajłow
4dfc2c50c1 hwdec: do not add hwdec device if it failed to create 2023-06-26 19:07:29 +02:00
Philip Langdale
78285e98f1 vo: hwdec: prioritise drmprime over drmprime_overlay
I originally left `drmprime_overlay` as higher priority because
`drmprime` was new, and because I didn't have any hardware where both
worked (only one or the other) so I couldn't compare relative
performance, and if only one worked, the priority didn't matter.

But with time and more usage, we've reached a point where we can say we
would recommend using `drmprime` in situations where both work, and
we've also been able to identify hardware where both do indeed work and
it seems that `drmprime` is more reliable.

So, let's flip them.
2023-06-22 12:46:21 -07:00
Niklas Haas
0af81b16d8 vo_gpu_next: add --corner-rounding option
For better or worse.
2023-06-21 23:52:35 +02:00
Niklas Haas
f1600ea9cf vo_gpu_next: add missing --gamut-mapping-mode options
Adds the missing upstream values that were exposed by the new gamut
mapping API.
2023-06-21 23:52:35 +02:00
Dudemanguy
650c53df50 vo_dmabuf_wayland: drop linux-dmabuf-v2 (again)
It was done once before but later reverted for testing reasons. This
time it's permanent though since I can test this VO on ARM and with an
up to date system.
2023-06-16 14:46:59 +00:00
Dudemanguy
ca08bf599f wayland: bump wayland-protocols to 1.25
1.27 would have been nicer but ubuntu 22.04 is on 1.25 so we'll just
compromise.
2023-06-16 14:46:59 +00:00
Dudemanguy
45e2ca5411 wayland: bump required version to 1.20
This lets us remove some ifdefs.
2023-06-16 14:46:59 +00:00
Dudemanguy
f5e828ac25 vo_dmabuf_wayland: update the image of pending buffers
When using a display-* video-sync mode, it is possible for buffers with
a matching id to already have an image associated with them (i.e. the
compositor hasn't released it yet). Previously, it was thought that we
could just unref, return null, and make a new buffer but this eventually
leads to a fatal error that originates from libwayland itself which
stops playback. Admittedly, the reason for the error is a bit nebulous
but likely it seems to be some kind of mismatch between dmabuf params
and the associated image with the buffer.

However, we can simplify this process greatly. Instead when the
previously mentioned edge case happens, the old image can simply be
freed and we give the buffer the new image. This saves creating a new
buffer and also avoids that nasty libwayland error. A nice win-win all
around. Fixes #11773.
2023-06-14 12:21:10 -05:00
Dudemanguy
4d4837b84e vo_dmabuf_wayland: use a minimum of 15 buffers
vo_dmabuf_wayland has a pool of wl_buffers that it cycles through when
drawing frame. There needs to be at least some minimum number otherwise
a flickering artifact occurs where old frames are mistakenly repeated.
When using display-resample and other similar modes, it seems more
buffers are required (more drawing happens so it makes sense) and the
current minimum of 8 isn't good enough. Let's just bump this to 15. It's
also a random ad hoc number, but as far as I know there's not really a
way to predict how many buffers a random video may need. From testing,
it works fine and overall 15 is still a tiny amount of objects to create
considering the lifetime of a video, so we'll just go with this.
2023-06-14 12:00:23 -05:00
Dudemanguy
8ecf2d37eb player: add drag-and-drop option
Some platforms (wayland) apparently have a lot of trouble with drag and
drop. The default behavior is still the same which is basically obeying
what we get from the window manager/compositor, but the --drag-and-drop
option allows forcibly overriding the drag and drop behavior. i.e. you
can force it to always replace the playlist or append at the end. This
only implements this in X11 and Wayland but in theory windows and macos
could find this option useful (both hardcode the shift key for
appending). Patches welcome.
2023-06-12 20:50:08 +00:00
Dudemanguy
2f8d9322fd wayland: avoid misleading log messages on drag/drop
In data_offer_actions, it's possible to get the
WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE action which would set
wl->dnd_action to DND_APPEND (did nothing in practice) but also log a
message which is confusing and misleading. Instead, just ignore and
don't do anything when we get this case.
2023-06-12 20:50:08 +00:00
Philip Langdale
3a6738ed8c hwdec_cuda: clear vulkan semaphore fd after passing ownership to cuda
This is not technically necessary, because we never touch the fd again
after passing to cuda, but having it there could lead to future code
accidentally using it.
2023-06-04 13:24:52 -07:00
Philip Langdale
7918545caf hwdec_vulkan: respect probing flag when logging during init
All hwdecs should respect the probing flag and demote their lgoging to
verbose level, so that initialisation failures during probing do not
spam the user. I forgot to do this for the Vulkan hwdec.
2023-06-03 18:37:43 -07:00
Philip Langdale
ba6af0fb15 vulkan: don't assume all ra_ctx implementations have a swapchain
The dmabuf-wayland vo has a stub ra implementation that doesn't
have a swapchain. That means that it's currently not safe to call
ra_vk_ctx_get on that ra_ctx, but it must be safe to call on all ra
implementations as this is how we discover if it is a vulkan ra.

This hasn't been an issue before because no Vulkan code paths would be
triggered when using dmabuf-wayland, but with the new vulkan hwdec, it
becomes possible to trigger when hwdecs are probed.
2023-06-03 18:37:43 -07:00
Philip Langdale
c8790a9173 hwdec_cuda: remove usage of deprecated libplacebo sync API
The libplacebo sync abstraction is deprecated and we should be using
the more explicit Vulkan semaphore helpers instead. This means that
more of the book keeping moves to our side, but it's not too bad.

There are two main things going on here:

1. After a lot of back and forth, I decided to write the new code with
   timeline semaphores to streamline things, and that also means all
   the variables are separate - which makes the #ifdefs easier to read.
   Which is important because:

2. While pl_sync owned the exported fd/handle, pl_vulkan_sem does not,
   so we are responsible for managing them. That means reversing the
   previous logic - we now can pass an original fd to CUDA and never
   think about it again, while we have to clean up a Win32 Handle
   because CUDA will not take ownership.
2023-06-03 18:15:20 -07:00
sfan5
e18cf0b92a video/out/android: assert WinID value before use 2023-06-03 17:07:43 +02:00
Philip Langdale
bc28dce303 hwdec_vulkan: enable AV1 support if available
AV1 support in Vulkan is extremely bleeding edge - to the point that
the extension is not present in official Khronos releases, but it has
a reserved identifier and we can look it up with a string literal for
now.

This will be skipped and ignored if the driver doesn't support it, so
it's safe if/when the name changes later (it'll just never be activated
in that case).
2023-05-29 14:46:42 -07:00
sfan5
0d1b96c233 vo: hwdec_aimagereader: fix compile
forgotten in 085f3e31a0
2023-05-29 22:50:35 +02:00
Philip Langdale
0131ae4133 hwdec_vulkan: simplify requirement checks for Vulkan interop
I originally wrote this trying to avoid doing an explicit version check
on the headers, but it just makes things more confusing, and the
requirements harder to understand.

So, Vulkan interop now takes a dependency on the header release where
they finalised the video decode headers. VK_EXT_descriptor_buffer was
added in 1.3.235, so that's covered as well.

Along the way I fixed a bug in the waf build where it was depending
on libplacebo-next instead of libplacebo-decode.
2023-05-29 13:26:29 -07:00
Kacper Michajłow
ba5370e82a vo/vulkan: do not define zero sized array
It is not needed at all.
2023-05-29 12:33:43 -07:00
Philip Langdale
c40bd88872 hwdec_vulkan: account for vulkan frames now using presentation size
ffmpeg was previously allocating images for frames as the code size,
rather than the presentation one (1088 vs 1080 in the most common
example). Using the coded size when wrapping images for libplacebo
resulted in incorrect scaling from 1088 -> 1080, but even using the
presentation size wasn't perfect, as discussed in the original
commit.

However, ffmpeg has now been updated to use the presentation size for
the frame images, after discussions that concluded this must be done
because there is no way for a frame consumer to fix the dimensions
without copying the frame.

With that ffmpeg change, we can just use the normal layout information
like all the other hwdecs.
2023-05-29 10:16:29 -07:00
Philip Langdale
45a2d8c670 vo: vulkan: request additional extensions and features for ffmpeg
Vulkan hwdec interop with the ffmpeg 6.1 vulkan code will require
additional features beyond those activated by libplacebo by default.

Enabling these features requires both requesting the features'
extensions and then explicitly turning on the features. libplacebo
handles detecting unsupported features and dropping them, to avoid
failing to create the vulkan device.

We then leave it to ffmpeg to decide if any missing features are
required for functionality, and error out if necessary.

As ffmpeg requires at least one bleeding edge extension (descriptor
buffers), all of this logic is gated on the presence of sufficiently
new Vulkan headers.
2023-05-28 15:46:05 -07:00
Philip Langdale
61e685594d hwdec_vulkan: add Vulkan HW Interop
Vulkan Video Decoding has finally become a reality, as it's now
showing up in shipping drivers, and the ffmpeg support has been
merged.

With that in mind, this change introduces HW interop support for
ffmpeg Vulkan frames. The implementation is functionally complete - it
can display frames produced by hardware decoding, and it can work with
ffmpeg vulkan filters. There are still various caveats due to gaps and
bugs in drivers, so YMMV, as always.

Primary testing has been done on Intel, AMD, and nvidia hardware on
Linux with basic Windows testing on nvidia.

Notable caveats:
* Due to driver bugs, video decoding on nvidia does not work right now,
  unless you use the Vulkan Beta driver. It can be worked around, but
  requires ffmpeg changes that are not considered acceptable to merge.
* Even if those work-arounds are applied, Vulkan filters will not work
  on video that was decoded by Vulkan, due to additional bugs in the
  nvidia drivers. The filters do work correctly on content decoded some
  other way, and then uploaded to Vulkan (eg: Decode with nvdec, upload
  with --vf=format=vulkan)
* Vulkan filters can only be used with drivers that support
  VK_EXT_descriptor_buffer which doesn't include Intel ANV as yet.
  There is an MR outstanding for this.
* When dealing with 1080p content, there may be some visual distortion
  in the bottom lines of frames due to chroma scaling incorporating the
  extra hidden lines at the bottom of the frame (1080p content is
  actually stored as 1088 lines), depending on the hardware/driver
  combination and the scaling algorithm. This cannot be easily
  addressed as the mechanical fix for it violates the Vulkan spec, and
  probably requires a spec change to resolve properly.

All of these caveats will be fixed in either drivers or ffmpeg, and so
will not require mpv changes (unless something unexpected happens)

If you want to run on nvidia with the non-beta drivers, you can this
ffmpeg tree with the work-around patches:

* https://github.com/philipl/FFmpeg/tree/vulkan-nvidia-workarounds
2023-05-28 15:46:05 -07:00
Philip Langdale
085f3e31a0 vo: hwdec: Pass the ra_ctx to hwdecs instead of just the ra
We will need the full ra_ctx to be able to look up all the state
required to initialise an ffmpeg vulkan hwcontext, so pass let's
pass the ra_ctx instead of just the ra.
2023-05-28 15:46:05 -07:00
Kacper Michajłow
959ef843d2 vo_gpu_next: fix to allow using dllimport
Address of variables can't be used for constant initialization in C
language modes.
2023-05-27 14:54:59 +02:00
Niklas Haas
7595ea7c7c vo_gpu_next: respect gl->flipped
This fixes flipped rendering on angle/dxinterop instances.
2023-05-27 11:37:48 +02:00
Niklas Haas
b216c09ade opengl: move ra_gl_ctx_params.flipped to struct GL
This is motivated by a need to access it from vo_gpu_next's opengl
wrapping code, and justified by it being an inherent property of the GL
context itself,
2023-05-27 11:37:48 +02:00
Kacper Michajłow
9fd4ae9529 vo: make mp_frame_perf thread safe
It was unsafe to return pointer to memory that was freed on another
thread, just copy the string to caller owned sturcture.

Fixes crashes when displaying passes stats with gpu-next.
2023-05-25 16:25:33 +02:00
Kacper Michajłow
19c5cd92b2 vo_gpu_next: add size guard for pass->num_samples
This shouldn't happen as the array sizes are the same, but guard against
it in case libplacebo do something naughty.
2023-05-25 16:25:33 +02:00
Kacper Michajłow
3b89a58af7 vo_gpu_next: synchronize voctrl_performance_data access
info_callback is fired quite often and from different thread than any
accesses to this structure.
2023-05-25 16:25:33 +02:00
Kacper Michajłow
695b3c51d1 vo_gpu_next: fix off by one in info_callback
Fixes invalid memory writes.
2023-05-25 16:25:33 +02:00
Dudemanguy
c1de4bb745 vo_dmabuf_wayland: rewrite around wl_list
vo_dmabuf_wayland worked by allocating entries to a pool and then having
a lot of complex logic dealing with releasing buffers, pending entries,
etc. along with some other not so nice things. Instead, we can rewrite
this logic so that the wl_buffers created by the imported dmabuf is
instead stored in a linked list, wl_list. We can simply append our
buffers to the list when needed and destroy everything at the end. On
every frame, we can check the ids of our surfaces and reuse existing
buffers, so in practice there will only ever be a handful at a time.
Some other small changes were made in an attempt to organize the
vaapi/drmprime code a little better as well.

An important change is to always enforce at least a minimum number of
buffers. Certain formats would not make enough unique buffers, and this
results in flickering/artifacts occuring. The old way to attempt to deal
with this was to clear out all the existing buffers and remake them, but
this gets complicated and also didn't always work. An easy solution to
this is just create more buffers which appears to solve this problem.
The actual number needed is not really based on anything solid, but 8
is a reasonable number to create for the lifetime of a file and it seems
to do the trick.

Additionally, seeking/loading new files can result in flicker artificts
due to buffers being reused when they shouldn't. When that happens, we
flip a bool so all the buffers get destroyed in draw_frame to avoid any
visual glitches.
2023-05-24 21:53:17 +00:00
Niklas Haas
b9a5583f17 vo_gpu_next: fix build on older libplacebo
Introduced by, of all things, a rebase...

Fixes: a5da8b2c87
2023-05-24 22:06:03 +02:00
Niklas Haas
a5da8b2c87 vo_gpu_next: update to new libplacebo gamut mapping API
This just replaces the API calls to get rid of deprecation warnings, it
doesn't yet expand the enum, nor replace them by the proper options.

The translation from tone map modes to hybrid mix parameters is taken
from the libplacebo source code.
2023-05-24 21:32:23 +02:00
Niklas Haas
dc13d47c73 vo_gpu_next: remove --tone-mapping-crosstalk
Removed upstream, to be replaced by constant 0.04.
2023-05-24 21:32:00 +02:00
Matthew Lindner
a1a2e27f84 context_drm_egl: check for non-existant drm in uninit
Previously, if vo_drm_init failed at the start of drm_egl_init it
caused a use-after-free in drm_egl_uninit when it tried to access the
non-existant drm context. At that point vo_drm_uninit had already been
called resulting in two different null pointer dereference. In this
situation the DRM private context had also not been allocated.
2023-05-22 21:47:24 -05:00
Kacper Michajłow
ec58670a0d ra_d3d11: change how messages are ignored during texture size lookup
Filtering globally D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS is
suboptimal, because can also hide other invalid usages. In the same time
it is not enough, because not only this message is emitted, but also one
about E_INVALIDARG. Just flush queue before and clear messages after to
ignore this part of code.

As a side note, I don't believe this texture size lookup is in fact
useful, but since it is there and is relatively harmless, let's leave
it as is.
2023-05-18 21:56:54 +02:00
Dudemanguy
f677f8a5a7 wayland: improve guessing when mpv is focused
The current implementation is order dependent and assumes that getting
keyboard input happens before the toplevel is activated. This isn't
necessarily the case and indeed mutter activates the toplevel first.
Improve this by simply spinning off the check to a function and calling
it in the three places where it would be needed: the toplevel
configuration event, keyboard entering, and keyboard leaving. This
fixes #11694.
2023-05-17 16:13:04 -05:00
Kacper Michajłow
9e716d6303 vo_gpu_next: allow to use ICC profile luminance value
Also while at it respect target-peak option when ICC profile is used.

Fixes #11449
2023-05-13 17:08:37 +02:00
Dudemanguy
4502522a7a player: use XDG_CACHE_HOME by default
This adds cache as a possible path for mpv to internally pick
(~/.cache/mpv for non-darwin unix-like systems, the usual config
directory for everyone else). For gpu shader cache and icc cache,
controlling whether or not to write such files is done with the new
--gpu-shader-cache and --icc-cache options respectively. Additionally,
--cache-on-disk no longer requires explicitly setting the --cache-dir
option. The old options, --cache-dir, --gpu-shader-cache-dir, and
--icc-cache-dir simply set an override for the directory to save cache
files. If unset, then the cache is saved in XDG_CACHE_HOME.
2023-05-09 20:37:17 +00:00
Simon Ser
6234a70920 wayland: add support for wl_surface.preferred_buffer_scale
See [1] for the motivation. Very similar to the fractional scale,
except it's in core and integer-only.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-30 21:20:18 +00:00
Kacper Michajłow
4fd0a39fc8 vo_gpu_next: fixes to allow using dllimport
Address of variables can't be used for constant initialization in C
language modes.

See 0c43d8077e
2023-04-24 13:16:55 +02:00
EmperorPenguin18
c7a8e71578 hwdec_drmprime: support rpi4_8 and rpi4_10 formats
HEVC hardware decode with drm wasn't working on the RPi 4. Mpv would
report the image format (rpi4_8 for 8-bit and rpi4_10 for 10-bit) wasn't
supported. The change to hwdec_drmprime.c identifies these two formats
as NV12 because it functions exactly the same. The change to
dmabuf_interop_gl.c adds support for P030 which rpi4_10 uses. These
changes were tested on a Pi 4 with this fork of ffmpeg:
https://github.com/jc-kynesim/rpi-ffmpeg.

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
2023-04-20 14:37:15 -07:00
iczero
d65e56216d wayland: correctly scale configure_bounds 2023-04-11 20:05:17 +00:00
Mika Kuoppala
95d7b05e71 video/out/gpu: Fix compilation warning of out of bound access
Make the index into the arrays in copy_image()
unsigned to make compiler trust that we dont access
out of bounds.
2023-04-10 10:48:16 -04:00
Kacper Michajłow
9feeb324ed win32: follow Windows settings and update dark mode state
Microsoft documented how to enable dark mode for title bar:

https://learn.microsoft.com/windows/apps/desktop/modernize/apply-windows-themes
https://learn.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute

Documentation says to set the DWMWA_USE_IMMERSIVE_DARK_MODE attribute to
TRUE to honor dark mode for the window, FALSE to always use light mode.
While in fact setting it to TRUE causes dark mode to be always enabled,
regardless of the settings. Since it is quite unlikely that it will be
fixed, just use UxTheme API to check if dark mode should be applied and
while at it enable it fully. Ideally this function should only call the
DwmSetWindowAttribute(), but it just doesn't work as documented.

Fixes: #6901
2023-04-04 20:04:57 +02:00
Kacper Michajłow
68b3239b52 d3d11: retry device creation without debug, if SDK is not available
Fixes #11512
2023-04-02 21:43:53 +03:00
Kacper Michajłow
911d742817 context_angle: include eglext_angle.h explicitly
Recent MSYS update switched to using vanilla EGL headers, which doesn't
include eglext_angle.h implicitly.
2023-03-30 22:00:38 +03:00
Alexander Seiler
bdf7b5c3b8 various: fix various typos in the code base
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-03-28 19:29:44 +00:00
Harri Nieminen
292a5868cb various: fix typos
Found by codespell
2023-03-28 19:29:44 +00:00
llyyr
685d9cbe5b vo_gpu_next: drop various PL_API_VER checks
We don't need these anymore now that we require PL_API_VER>=264 for
building libplacebo-next
2023-03-26 20:55:58 -07:00
llyyr
3a2f8d42ab vo_gpu_next: compatibility with libplacebo v6.265
libplacebo v6.265.0 removed v4 deprecations. We already require
PL_API_VER >= 202, so we don't need to wrap
pl_tex_transfer_params.row_pitch around a conditional, which exists
since PL_API_VER >= 168. However, pl_source_frame.duration does not exist until
PL_API_VER >= 219, so we should use a conditional directive.
2023-03-13 20:09:06 +01:00
Dudemanguy
9880b06a37 wayland: make wayland-edge-pixels-pointer default to 16
10 is ludicrously small. How did no one on an CSD compositor complain
about this?
2023-03-08 14:06:22 +00:00
Dudemanguy
b313a242c2 wayland: use correct x/y coordinates for the cursor
While adding fractional scale support, the coordinates for wayland
changed to always include the scaling parameter. The pointer stuff
actually did too. However, the check_for_resize function used the
unscaled, local surface coordinates. Likely, it was neccesary at the
time since wl->geometry used to report unscaled coordinates. In light of
that, we can just simply use mouse_x/y instead for this function to make
it work correctly with the right/bottom edges. mouse_unscaled becomes
completely unneccesary, so just drop it.

Some minor style changes included just because.
2023-03-08 14:06:22 +00:00
Christoph Heinrich
31160ff941 wayland: fix client side resize
`xdg_toplevel_decoration` exists on SSD compositors independent of if
there is a border or not, so resizing didn't work on those.
Checking the border option makes more sense and also works on such
compositors.
2023-03-07 00:16:18 +00:00
Niklas Haas
dcc9bc5dea vo_gpu_next: compatibility with PL_API_VER >= 254
This field was renamed/moved to a different params struct.
2023-03-06 21:35:10 +01:00
Leo Izen
4defd8bb27 vo_gpu_next: use inverse mapping functions to tag screenshots
Screenshots using the hardware renderer should now include color tags
that map directly from the libplacebo tags, so the if/else logic only
needs to be included once.
2023-03-05 22:37:05 -05:00
Leo Izen
8217b186f6 video/out/placebo/utils: add mappings from pl enums to mpv enums
mp_trc_to_pl, mp_prim_to_pl, and mp_levels_to_pl have forward but not
inverse mappings. This commit adds mp_trc_from_pl, mp_prim_from_pl, and
mp_levels_from_pl inverse mapping functions, which just map the enums
in the other direction.
2023-03-05 22:37:05 -05:00
Leo Izen
34ed2ac225 video: add missing libplacebo colorspace enums
Add some missing libplacebo primaries and transfer enums to mpv's enum
constant tables, and update the functions that convert between the two.
2023-03-05 22:37:05 -05:00
Dudemanguy
296d40dc6f vo: fix race condition with redraw requests
There is a very subtle race in vo that can manifest itself on pause
events. In the renderloop, render_frame, unsurprisingly, does the heavy
lifting of actually queuing up and flipping the frames. This is called
during normal playback. Sometimes various parts of the player can make a
redraw request which will latter trigger another render of the frame
later down in the loop (do_redraw). Because these requests can happen at
essentially anytime, sometimes the redraw request will happen *before*
do_redraw and it'll be caught in render_frame. When this happens,
the existing render_frame run works perfectly fine as a redraw so it
clears out the request which is sensible. Normally this is all locked of
course, but there's one catch. render_frame has to unlock itself when
propagating down into specific VOs/backends. That's what causes this
bug.

While render_frame is unlocked, other parts of the player can send
redraw requests which will cause in->request_redraw to become true. The
logic in the code always clears out this parameter after a successful
render, but this isn't correct. When in->request_become becomes true in
the middle of render_frame, there needs to be one more draw afterwards
to reflect whatever actually changed (usually the OSD). Instead, this
gets simply discarded. If you rapidly spam pause while rendering things
to the OSD at the same time, it's possible to for the last render to
be behind a frame and appear as if your osd event was ignored.

Once you realize what is happening, the fix is quite simple. Just store
the initial value of in->request_redraw before the unlock step. After we
do the render step and unlock again, only set in->request_redraw to
false if there was an initial redraw request. We just finished doing a
redraw, so it is safe to clear. Otherwise, leave in->request_redraw
alone. If it is initially false, then it will still be false and nothing
changes. However if it updated to true in the middle of the rendering,
this value is now preserved so we can go and call do_redraw later and
show what that last frame was meant to be when you pause. One
unfortunate thing about this design is that it is technically possible
for other internal things in vo to update during that unlocked period.
Hopefully, that doesn't actually happen and only redraw requests work
like this.

Fixes #8172 and #8350.
2023-03-02 22:09:10 +00:00
Dudemanguy
9db818279a test: integrate unittests with meson
This reworks all of mpv's unit tests so they are compiled as separate
executables (optional) and run via meson test. Because most of the tests
are dependant on mpv's internals, existing compiled objects are
leveraged to create static libs and used when necessary. As an aside, a
function was moved into video/out/gpu/utils for sanity's sake (otherwise
most of vo would have been needed). As a plus, meson multithreads
running tests automatically and also the output no longer pollutes the
source directory. There are tests that can break due to ffmpeg changes,
so they require a specific minimum libavutil version to be built.
2023-03-02 15:45:27 +00:00
Kacper Michajłow
9dc4154fec vo_gpu: improve XYZ conversion
Fixes #4925
2023-03-02 09:37:06 -05:00
Kacper Michajłow
cb9ba6cb26 csputils: add MP_CSP_TRC_ST428 as defined in ST 428-1 2023-03-02 09:37:06 -05:00
Dudemanguy
c993d5c0ce player: add --auto-window-resize option
mpv's window resizing logic always automatically resized the window
whenever the video resolution changed (i.e. advancing forward in a
playlist). This simply introduces the option to make this behavior
configurable. Every windowing backend would need to implement this
behavior in their code since a reconfigure event must always be a
resize. The params of the frame changed so you either have to resize the
window to the new size of the params or make the params the same size as
the window. This commit implements it for wayland, win32, and x11.
2023-03-02 02:55:36 +00:00
Dudemanguy
cd02b5ccf6 ra: assert when using params with dimensions
This came up in #9828. According to the header comments, creating a 1D
ra_tex requires height and depth to be set to 1. For a 2D texture, it
requires depth be set to 1. There were a couple of spots in mpv's code
where this wasn't being followed. Although there was no known bug from
this, the rest of the code works like this so it was a good idea to go
ahead and sync it up. As a followup, let's just add some simple asserts
to ra.c to enforce this so it doesn't go unnoticed in the future.
2023-03-02 02:08:39 +00:00
Daniel van Vugt
022790a2b4 wayland: request frame callbacks on the topmost surface
Which is wl->video_surface for vo_dmabuf_wayland.

Listening on wl->surface results in freezes if it is occluded and
culled by the compositor. Which mutter does, and the wl_surface::frame
spec warns about:

> A server should avoid signaling the frame callbacks if the
> surface is not visible in any way, e.g. the surface is off-screen,
> or completely obscured by other opaque surfaces.
2023-02-28 15:07:14 +00:00
Daniel van Vugt
1f493b7671 wayland: deduplicate and cache detection of dmabuf-wayland 2023-02-28 15:07:14 +00:00
Ray Smith
8a43fc0e9a wayland: use bool type for alpha framebuffer tracking
ra_ctx_opts.want_alpha and vo_wayland_set_opaque_region's alpha
argument are only used as bool but both are ints. Particularly for the
function argument, passing a 0 or 1 is confusing - at first glance it
looks like you're specifying an alpha value of 0 or 1.

Since they're only used as bools, make them bools.
2023-02-28 14:53:32 +00:00
msoxzw
8006ff6cf6 vo_gpu: d3d11_helpers: prefer DXGI_SWAP_EFFECT_FLIP_DISCARD if possible
Similar to libplacebo[1], DXGI_SWAP_EFFECT_FLIP_DISCARD is used instead
of DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL starting with Windows 10.

[1]: https://github.com/haasn/libplacebo/blob/master/src/d3d11/swapchain.c
2023-02-28 14:41:33 +00:00
averne
4fbc3ad399 video: initialize depth=1 on screenshot textures
According to internal documentation, 2D textures should have d=1.
This fixes the correctness of the API usage, not any bug.
2023-02-28 14:13:55 +00:00
Thomas Weißschuh
ed5426c351 various: fix warning -Wimplicit-const-int-float-conversion 2023-02-26 16:45:07 +01:00
Thomas Weißschuh
8d67e891ab vo_gpu_next: fix warning -Wunused-function 2023-02-26 16:45:07 +01:00
Thomas Weißschuh
b4ae1551e4 vo_wayland: fix warning -Wvoid-pointer-to-enum-cast 2023-02-26 16:45:07 +01:00
sfan5
0d991eba72 vo_gpu: fix newline in log message 2023-02-24 13:33:45 +01:00
Kacper Michajłow
84f6d7a97e vo_gpu_next: fix color space hint with target peak override
Fixes: #11339
2023-02-23 10:14:53 +01:00
Christoph Heinrich
c0807e98fb options: remove explicit initialization of integers to 0 2023-02-21 17:15:17 +00:00
Christoph Heinrich
4ebfe9851c options: transition commands from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
Christoph Heinrich
91cc0d8cf6 options: transition options from OPT_FLAG to OPT_BOOL
c784820454 introduced a bool option type
as a replacement for the flag type, but didn't actually transition and
remove the flag type because it would have been too much mundane work.
2023-02-21 17:15:17 +00:00
Thomas Weißschuh
9efce6d4ae various: drop unused #include "config.h"
Most sources don't need config.h.
The inclusion only leads to lots of unneeded recompilation if the
configuration is changed.
2023-02-20 14:21:18 +00:00
rcombs
d1cf89b655 Vulkan: add configure check for VK_KHR_display extension
This allows building directly against ICDs that don't implement this extension.
2023-02-20 00:05:26 -06:00
Niklas Haas
9a752e8b26 vo_gpu_next: add --tone-mapping-visualize 2023-02-19 21:01:40 +01:00
quietvoid
41ad51bda2 vo_gpu_next: parse Dolby Vision metadata for dynamic scene brightness
Improves playback for Dolby Vision video files as the metadata can be
used instead of requiring `hdr-compute-peak=yes`.
2023-02-19 20:50:37 +01:00
Dudemanguy
e2cdc23af0 Revert "vo_dmabuf_wayland: drop support for linux-dmabuf-v2"
This was originally dropped because it was thought to be unneeded at the
time, but at least some devices (rockchip) apparently are still on old
compositors that use linux-dmabuf v2. It's not much code, and for
testing purposes it's good to have around since it's hard to test
drmprime otherwise. Some minor additions are here to support the newly
added vaapi-format mapping in v2 of the protocol.

This reverts commit a5b9d529ee.
2023-02-18 02:21:54 +00:00
Niklas Haas
16ef237da5 vo_gpu_next: allow native CSP screenshots
Useful for getting native screenshots of non-sRGB content, such as HDR
etc.
2023-02-13 21:53:41 +01:00
Niklas Haas
c975888584 player/screenshot: pass on ability to output native CSP
Fixes: #10988
2023-02-13 21:53:41 +01:00
Niklas Haas
862be6c237 vo_gpu_next: tag screenshots with correct colorspace
When taking window screenshots with a colorspace override, tag them
appropriately, based on the best-known colorspace info. Note that this
is imperfect, we should ideally also attach the output ICC profile if
one exists. But this is better than nothing.

Also force 1:1 PAR in this case. In all other cases, default to sRGB.
2023-02-13 21:53:41 +01:00
Niklas Haas
5078132b28 vo_gpu_next: only apply target options in window screenshot mode
When taking an unscaled screenshot, always render to an unspecified
SDR-like space. (Subject to change) Apply output-specific options (ICC
profile, color space overrides, custom LUT) only in window screenshot
mode.

I decided to split this off from subsequent refactors because it is IMO
a bug fix deserving of its own commit.
2023-02-13 21:53:41 +01:00
Niklas Haas
4f84d91df2 vo_gpu_next: be explicit about screenshot repr
Screenshots are currently always RGB. Subject to change, but needs to be
communicated clearly if changed. This commit is not a functional change,
it's merely for code clarity.
2023-02-13 21:53:41 +01:00
Niklas Haas
2d4a243810 vo_gpu_next: expose --tone-mapping=st2094-40 and st2094-10 2023-02-13 17:52:35 +01:00
Niklas Haas
79b093f210 vo_gpu_next: support mapping HDR10+ dynamic metadata
Based on the new upstream helper function `pl_map_hdr_metadata` and the
existing AV_FRAME_DATA_DYNAMIC_HDR_PLUS. This allows us to use SMPTE
2094-40 dynamic HDR tonemapping in mpv, albeit with the limitation of
requiring `--tone-mapping=auto` in order to pick this curve upstream.
2023-02-13 17:52:35 +01:00
Aaron Boxer
49fd6caa43 vo_dmabuf_wayland: reject hw formats not supported by compositor 2023-02-11 00:46:46 +00:00
Aaron Boxer
a3340645be vo_dmabuf_wayland: add purgatory list to buffer pool to avoid memory leaks 2023-02-05 23:27:08 +00:00
Aaron Boxer
6803903e0c vo_dmabuf_wayland: ensure buffer pool is cleaned at start of uninit 2023-02-05 23:27:08 +00:00
Aaron Boxer
ce6efc782f vo_dmabuf_wayland: simplify buffer pool reset 2023-02-05 23:27:08 +00:00
Aaron Boxer
f1f6eaa3de vo_dmabuf_wayland: only resize when a new frame is about to be drawn 2023-02-05 23:27:08 +00:00
Kacper Michajłow
87fb254deb vo_gpu_next: add check for PL_HAVE_LCMS 2023-02-02 14:23:02 +00:00
Kacper Michajłow
a97dd423c8 hwdec_cuda: fix enum type for semaphore 2023-02-02 14:23:02 +00:00
Kacper Michajłow
68c1338d56 vo_d3d11: do not call MAKEINTRESOURCEW twice 2023-02-02 14:23:02 +00:00
Kacper Michajłow
0a4b139ddf osdep: add MP_FALLTHROUGH 2023-02-02 14:23:02 +00:00
Kacper Michajłow
08cd7c1e29 libplacebo: fix enum type cast 2023-02-02 14:23:02 +00:00
Dudemanguy
9659555d45 hwdec/vaapi: zero-initialize VADRMPRIMESurfaceDescriptor
Otherwise, desc can contain garbage values and segfault trying to close
file descriptors that aren't actually there. Fixes #11239.
2023-01-30 10:41:32 -06:00
rcombs
4bcefa5be3 vo_lavc: set frame rate on encoder; fixes #11215
ffmpeg was internally defaulting to 24000fps, which resulted in encoders selecting inappropriate levels and making poor ratecontrol decisions.
2023-01-29 22:14:27 -06:00
Dudemanguy
da81a6d532 wayland: add auto choice to wayland-configure-bounds
Previously, this defaulted to yes and configure-bounds from the
compositor would always apply. In the case where the user explicitly set
autofit or geometry, this could be confusing because configure-bounds
would take precedence over it. Instead, let's add an auto choice and
make that the default. If we detect that the option is on auto and that
there is autofit/geometry being set, then ignore the event. This should
be more intuitive since someone who bothers to explicitly set mpv's
geometry would naturally expect that geometry to actually apply.
2023-01-30 03:59:40 +00:00
Dudemanguy
adc04dbba0 wayland: handle runtime hidpi-window-scale changes correctly
Semi-regression although this option never really did what the manual
said until recently. In the past, this option also controlled whether or
not mpv set the wayland buffer_scale to the value of the wl_output or
force it 1. This had varying effects depending on the exact compositor
configuration. That logic has now all been removed and this option now
only controls whether or not to scale the window with the hidpi scale
factor we get from the compositor. i.e. it actually does what the
manual says now.
2023-01-30 03:59:40 +00:00
Dudemanguy
e6a42f7afc wayland: unbreak runtime geometry/autofit changes
Regressed from 879824a47f. The geometry
needs to be explictly recalculated now. Change up this function a little
bit also give it the ability to directly perform a resize after the
fact. This is a common workflow and we'll be using it in the next
commit.
2023-01-30 03:59:40 +00:00
Aaron Boxer
588d66fb25 hwdec_vaapi: close file descriptors even if surface export fails
otherwise they can leak
2023-01-28 16:54:48 +01:00
Aaron Boxer
881f820fdf vo_dmabuf_wayland: close file handles when surface export fails
file handles may still be opened despite failure
2023-01-28 16:54:48 +01:00
Aaron Boxer
e3618002e3 vo_dmabuf_wayland: plug leaking file descriptor from solid buffer pool 2023-01-28 16:54:48 +01:00
Kacper Michajłow
af537eff06 vo_opengl/angle_dynamic: simplify symbol renaming to make it more straightforward 2023-01-28 01:03:12 +00:00
Sultan Alsawaf
0d44ae319d x11: remove PresentNotifyMSC from egl/glx/vulkan to fix xpresent timing
PresentNotifyMSC turns out to be not only redundant, but also harmful with
mesa-backed egl/glx/vulkan VOs because for all of them, mesa uses
PresentPixmap behind the scenes when DRI3 is available, which already
spawns a PresentCompleteNotify event when the buffer swap actually
finishes. This is important because without using the timing information
from these PresentCompleteKindPixmap events, there's no way for mpv to know
exactly when a frame becomes visible on the display.

By using PresentNotifyMSC in conjunction with DRI3-enabled mesa, two
problems are created:
1. mpv assumes that a vblank won't elapse (i.e., it assumes the current MSC
   won't change) between the time when mesa enqueues the buffer swap and
   the time when mpv calls PresentNotifyMSC to ask xorg for a notification
   at the next MSC, relative to the current MSC at the time that xorg reads
   it for the PresentNotifyMSC call. This means that mpv could get a
   notification one or more vblanks later than it expects, since the
   intention here is for mpv to get a notification at the MSC that the
   buffer swap completes.
2. mpv assumes that a buffer swap always takes one vblank to complete,
   which isn't always true. A buffer swap (i.e., a page flip) could take
   longer than that depending on hardware conditions (if the GPU is running
   slowly or needs to exit a low-power state), scheduling delays (under
   heavy system or GPU load), or unfortunate timing (if the raster scan
   line happens to be at one of the last few rows of pixels and a vblank
   elapses just before the buffer swap is enqueued).

This causes mpv to have a faulty assumption of when frames become visible.

Since mpv already receives the PresentCompleteNotify events generated by
mesa's buffer swaps under the hood, the PresentNotifyMSC usage is unneeded
and just throws a wrench in mpv's vsync timing when xpresent is enabled.

Simply removing the PresentNotifyMSC usage from the egl, glx, and vulkan
VOs fixes the xpresent vsync timing.
2023-01-25 03:13:23 +00:00
Dudemanguy
879824a47f wayland: add wp-fractional-scale-v1 support
This protocol is pretty important since it finally lets us solve the
longstanding issue of fractional scaling in wayland (no more mpv doing
rendering over the target resolution and then being scaled down). This
protocol also can completely replace the buffer_scale usage that we are
currently using for integer scaling so hopefully this can be removed
sometime in the future. Note that vo_dmabuf_wayland is omitted from the
fractional scale handling because we want the compositor to handle all
the scaling for that VO.

Fixes #9443.
2023-01-24 00:04:39 +00:00
Dudemanguy
006ec9ce43 wayland: rewrite geometry and scaling handling
This is in preparation for fractional scaling support. Basically, redo
all the coordinates in wayland so that wl->geometry is equal exactly to
what is being put out to the screen (no extra wl->scaling multiplication
required). The wl->vdparams variable is also eliminated for simplicity.
This changes mpv's behavior on wayland with hidpi scaling but that will
be addressed in more detail with the next commit.
2023-01-24 00:04:39 +00:00
sfan5
9b59d39a3a vo_gpu: implement VO_DR_FLAG_HOST_CACHED
For OpenGL, this is based on simply comparing GL_VENDOR strings against
a list of allowed vendors.

Co-authored-by: Nicolas F. <ovdev@fratti.ch>
Co-authored-by: Niklas Haas <git@haasn.dev>
2023-01-23 14:13:34 +01:00
Niklas Haas
2531a89fcb vo_gpu_next: implement VO_DR_FLAG_HOST_CACHED
For sufficiently new versions of libplacebo.
2023-01-23 14:13:34 +01:00
sfan5
c7ea0cd68f vd_lavc: add "auto" choice for vd-lavc-dr
--vd-lavc-dr defaulted to "yes", which caused issues on certain
hardware. Instead of disabling it, add a new "auto" value and
make it the default.

The "auto" choice will enable DR only when we can request host-cached
buffers (as signalled by the new VO_DR_FLAG_HOST_CACHED).

Co-authored-by: Nicolas F. <ovdev@fratti.ch>
Co-authored-by: Niklas Haas <git@haasn.dev>
2023-01-23 14:13:34 +01:00
Niklas Haas
f8c17f55f9 vo: add int flags to the get_image signature
This is a huge disgusting mess to thread through everywhere. Maybe I'm
stupid for attempting to solve the problem this way.
2023-01-23 14:13:34 +01:00
Dudemanguy
92a6f2d687 drm: rewrite based around vo_drm_state
A longstanding pain point of the drm VOs is the relative lack of state
sharing. While drm_common does provide some sharing, it's far less than
other platforms like x11 or wayland. What we do here is essentially copy
them by creating a new vo_drm_state struct and using it in vo_drm and
context_drm_egl. Much of the functionality that was essentially
duplicated in both VOs/contexts is now reduced simple functions in
drm_common. The usage of the term 'kms' was also mostly eliminated since
this is libdrm nowadays from a userspace perspective.
2023-01-21 17:08:29 +00:00
Niklas Haas
b091dfda71 hwdec_cuda: drop support for PL_HANDLE_WIN32_KMT
This handle type was only needed for backwards compatibility with
windows 7. Dropping it allows us to simplify the code: there is no
longer a need for runtime checks, as the handle type can now be
statically assigned based on the platform.

The motivating usecase here, apart from code simplification, is a
desired switch to timeline semaphores, which (in the CUDA API) only
supports the non-KMT win32 handles.

It's worth pointing out that we need no runtime check for
IsWindows8OrGreater(), because the `export_caps.sync` check will already
fail on versions of windows not supporting PL_HANDLE_WIN32.
2023-01-17 11:38:46 +01:00
Thomas Weißschuh
f52cfdabca wayland: only warn when actually missing idle inhibit support 2023-01-16 19:26:09 +00:00
Thomas Weißschuh
2bbf880d96 vo: make driver list static 2023-01-16 19:25:54 +00:00
Thomas Weißschuh
f66c5404f4 vo: remove trailing NULL element from driver array 2023-01-16 19:25:54 +00:00
Dudemanguy
6cdce9e18e wayland: store presentation feedbacks in a pool
Officially, the most cursed part of the wayland code in mpv (third or
fourth try now?) This time, let's allocate a pool during init
(arbitrarily set to the maximum swapchain length mpv allows, 8; don't
even know if this actually works in wayland). Then we add/remove
feedbacks from the pool during the lifecycle of the VO, and clean it up
all at the end. Hopefully, this does the trick for good this time.
2023-01-13 22:24:11 -06:00
Dudemanguy
f32c5586d6 Revert "wayland: dispatch and wait for compositor events in uninit"
This ended up being a bad idea. The problem is that it introduces
ordering when destroying events (something we weren't worried about
before) and Lynne pointed out a problem with the callback not also being
destroyed before the surface in IRC. Just undo this and go with a
different approach (next commit). P.S. the wayland_dispatch_events name
change is kept though because I like that better.

This reverts commit aa8ddfcdf3.
2023-01-13 22:23:49 -06:00
sfan5
1201d59f0b various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriate
In debug mode the macro causes an assertion failure.
In release mode it works differently and tells the compiler that it can
assume the codepath will never execute. For this reason I was conversative
in replacing it, e.g. in mpv-internal code that exhausts all valid values
of an enum or when a condition is clear from directly preceding code.
2023-01-12 22:02:07 +01:00
sfan5
7b03cd367d various: replace if + abort() with MP_HANDLE_OOM()
MP_HANDLE_OOM also aborts but calls assert() first, which
will result in an useful message if compiled in debug mode.
2023-01-12 22:02:07 +01:00
sfan5
833bff8738 {video,audio}: adjust unsafe strncpy usages 2023-01-12 22:02:07 +01:00
sfan5
f4280e5238 video/x11: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5
2703a2c8ff video: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5
356096b954 ra_d3d11: fix incorrect type
As it happens, `SIZE_T` and `size_t` are not the same length on 32-bit Windows
2023-01-12 22:02:07 +01:00
Dudemanguy
a5b9d529ee vo_dmabuf_wayland: drop support for linux-dmabuf-v2
The only real reason this was ever supported is because it was
dramatically simpler than v4, so it was put in as an initial
implementation. Later, v4 support was added and we left v2 for
compatibility, but let's just drop it. Compositors all use v4 nowadays,
and v2 is significantly limited (no modifier support for example). It's
better to just remove this dead code for simplicity.
2023-01-12 17:42:35 +00:00
Aaron Boxer
865a159244 vo_dmabuf_wayland: support panscan and panning 2023-01-11 18:10:40 +00:00
Dudemanguy
4beb1bcae7 vo_wlshm: properly support video panscan
Turns out it was already doing this under the hood the entire time. The
only catch is that the vo just needed a resize.
2023-01-09 19:30:26 -06:00
Dudemanguy
8439c084e1 wayland: make vo_wayland_reconfig a bool
This was already returning true/false but the type was int. Also
simplify a few places in the wayland contexts where we can just return
the value of this function instead of doing redundant checks.
2023-01-08 20:42:42 +00:00
Dudemanguy
d73fc7912a wayland: cleanup on vo_wayland_init error
Instead of just returning true/false, it's better to have this function
cleanup itself. We can eliminate some redundant uninit calls elsewhere
in the code as well.
2023-01-08 20:42:42 +00:00
Dudemanguy
e4e0e7dfcf vo: change vo_platform_init to bool
There's several functions that are used for initializing mpv on a
certain platform (x11, wayland, etc.). These currently are all int, but
they actually return 1 and 0 like a boolean. This gets a bit confusing
because actual vo preinit functions return 0 and -1 instead. Just make
these all bool instead and return true/false to make it clearer.
2023-01-08 20:42:42 +00:00
Dudemanguy
e43393c4da vo_wlshm: cleanup on failure
If failure occurs during preinit, vo_wlshm should goto an error and
cleaup itself like the other VOs.
2023-01-08 12:39:50 -06:00
Dudemanguy
c5af54eb35 vo_dmabuf_wayland: goto err instead of returning
Returning early is clearly wrong. It should use to goto to cleanup after
itself. Also renamed from error_out to err for purely comestic reasons.
2023-01-08 12:19:14 -06:00
Christoph Reiter
96773f39e1 vulkan: fix build error for 32bit builds with clang
vk->surface is a handle and not a pointer, so assign VK_NULL_HANDLE.
This fixes the following build error on 32bit Windows when using clang for example,
which errors out when assigning a 32bit pointer to a 64bit integer:

  ../mpv-0.35.0/video/out/vulkan/utils.c:37:21:
    error: incompatible pointer to integer conversion assigning to 'VkSurfaceKHR' (aka 'unsigned long long') from 'void *' [-Wint-conversion]
          vk->surface = NULL;
                      ^ ~~~~
2023-01-08 16:09:01 +01:00
Dudemanguy
aa8ddfcdf3 wayland: dispatch and wait for compositor events in uninit
Similar to some other issues we've had with unprocessed compositor
events. When quitting mpv, there's two things we should be doing:
dispatching any last minute wayland events and then waiting for a
compositor reply. Luckily, there's already an internal helper for this
(renamed to wayland_dispatch_events for consistency) that we can use.
All of the special casing of wl->feedback becomes unneccesary and we can
remove this from vo_wayland_state with this method. Fixes #110022.
2023-01-03 20:45:39 +00:00
Dudemanguy
4bbb1ccfd7 wayland: initalize display_fd as -1
In the event of a failed wayland initalization, the display_fd is
actually 0 instead of -1 which would correctly indicate it doesn't
exist. Also move the fd check inside vo_wayland_dispatch_events since
that function shouldn't ever do anything if we don't actually have a
display fd.
2023-01-03 20:45:39 +00:00
Dudemanguy
24e2251b73 wayland: consistently employ use_present
We have a use_present bool that keeps track of whether or not to use
presentation time. However, the creation of the feedback listener
actually wasn't checking this and was instead checking for the existence
of wl->presentation. There's no point in always creating the
listener and feedback if mpv isn't actually going to use it. Just change
it to use_present instead.
2023-01-03 20:45:39 +00:00
repojohnray
fee6847aa7 vo: hwdec: fix drmGetDeviceNameFromFd2() related memory leak
This commit fixes a minor memory leak related to drmGetDeviceNameFromFd2().
This function returns a string allocated with strdup().
2023-01-02 16:48:24 -08:00
repojohnray
2e9c43f931 hwdec_drmprime: fix memory leak 2023-01-02 19:46:07 +01:00
Kacper Michajłow
ad65c8855b vo_opengl: do not blindly reject all Microsoft's OpenGL implementations
This change enables mpv to work in the WSL2 (WSLg) environment where
OpenGL is implemented on top of D3D12.

This reverts commit 149d98d244.

Mentioned OpenGL implementation (GDI Generic) in the original change
will be rejected by version check, so there is no need to handle it
manually.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2022-12-30 11:02:52 -05:00
Sultan Alsawaf
4a2aa36674 x11: add modesetting to the xpresent whitelist
Since the modesetting driver now has TearFree support with integration into
xpresent, it's important that xpresent is used with the modesetting driver
to get the correct vsync timing when a frame is delayed by one vblank
interval due to a pending page-flip enqueued by a different entity. The
modesetting driver ensures that the xpresent extension reports the correct
presentation timing when TearFree is used; mpv just needs to listen to it.

Add the modesetting driver to the xpresent whitelist so mpv can get the
correct presentation completion timing when modesetting TearFree is used.

This is also helpful for when xpresent performs page flips directly in the
modesetting driver and a natural delay in the display pipeline causes a
page flip to be delayed by one vblank interval or more.
2022-12-27 13:07:33 +01:00
sfan5
d8ae14653a build: add configure test for POSIX shm for the sake of vo_kitty
Android's POSIX coverage is pretty sketchy but not like we have a choice.
2022-12-26 15:08:07 +01:00
Mia Herkt
874e28f4a4
vo_kitty: Introduce modern sixel alternative
See https://sw.kovidgoyal.net/kitty/graphics-protocol/

This makes no attempt at querying terminal features or handling
terminal errors, as it would require mpv to pass the response codes
from the terminal to the vo instead of interpreting them as
keystrokes made by the user and acting very unpredictably.

Tested with kitty and konsole.

Fixes #9605
2022-12-21 19:39:30 +01:00
chen70
3447463008 hwdec/d3d11va: fix a possible memory leak 2022-12-21 19:03:38 +01:00
garamond13
27dab30209 filter_kernels: fix kaiser
Seems to me that params[1] is set to NAN and here should be the same value as in params[0].
2022-12-20 13:53:25 +01:00
Mia Herkt
56f0ba22f1
vo_sixel: Implement write() loop
Not all systems are Linux. Also update the comment to better reflect
POSIX documentation.
2022-12-20 10:45:36 +01:00
Mia Herkt
125fd4c2f9
vo_sixel: Rename draw-clear -> config-clear 2022-12-20 10:29:49 +01:00
Mia Herkt
08747c4965
osdep/terminal.h: Rename screen buffer controls
SAVE/RESTORE were a bit misleading.
2022-12-20 10:26:53 +01:00
Mia Herkt
a4cac2ddc6
vo_sixel: Alias/deprecate exit-clear -> alt-screen
Also update documentation to reflect actual behavior.
2022-12-20 10:22:51 +01:00
Mia Herkt
12c3203e98
vo_sixel: Make buffering optional
It can be slower than unbuffered.
2022-12-20 10:06:49 +01:00
Mia Herkt
fe21553637 vo_sixel: Buffer full output sequence
This allows the VO to write its output without interference from other
processes or threads.
2022-12-19 13:48:49 +01:00
Mia Herkt
3ca31b6cf4 vo_sixel: Use write(2) on POSIX platforms 2022-12-19 13:48:49 +01:00
Mia Herkt
0f721ab51c vo_tct: Use newer options API 2022-12-19 13:48:49 +01:00
Mia Herkt
85f1fa0715 vo_sixel: Move user options to struct 2022-12-19 13:48:49 +01:00
Mia Herkt
68ae603e75 vo_sixel: Add option to skip clear while drawing 2022-12-19 13:48:49 +01:00
Mia Herkt
f1957ce911 osdep/terminal: Move common esc codes to terminal.h 2022-12-19 13:48:49 +01:00
Mia Herkt
4e1626a21c vo_sixel: Use the alternate buffer to restore term 2022-12-19 13:48:49 +01:00
Mia Herkt
1564e4f29f vo_tct: Use the alternate buffer to restore term 2022-12-19 13:48:49 +01:00
EmperorPenguin18
cf349d68e3 hwdec_drmprime: support yuv420p format
H264 hardware decode with v4l2m2m wasn't working on the RPi 4. Mpv would
report the image format (yuv420p) wasn't supported. The change to
hwdec_drmprime.c is to explicitly say that the format now is supported.
The change to dmabuf_interop_gl.c is to specify the colour format of the
planes before generating egl images. These changes were tested on a Pi 4
with this fork of ffmpeg: https://github.com/jc-kynesim/rpi-ffmpeg.

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
2022-12-10 15:57:09 -08:00
NRK
25b66256d7 player: add window-id property
currently only supported on x11.

one practical use-case of this is wanting to embed something (such as
dmenu) into the mpv window to use as a menu/selection. there might be
other use-cases as well (e.g doing some shenanigans with `xdotool` or
whatnot).

it's currently possible to:

* listen for 'current-window-scale' change (to check if the
  window has been created or not)
* call an external tool like `xdo` or `xdotool` and grab the xid
  from mpv's pid.

however it adds unnecessary dependency on external tools when mpv is
fully capable of easily providing this information.

closes: #10918
2022-12-05 02:03:25 +00:00
Dudemanguy
11229e7f71 wayland: check for resize/move in touch event first
8300830951 rearranged/simplified some of
the wayland touch code mainly because what was there before was
completely broken on my machine in those days (dragging was unreliable,
resizing was really buggy, etc.). However, one user said that touch
input no longer worked for him after that change. I could not ever
reproduce it, but it seems the issue was putting down the key before
testing for resize/move in the code. Now who knows why this actually
matters, but apparently it works for the user in question and I don't
observe any unexpected behavior on my end when swapping the order. Like
the mouse/pointer code, we also now do a test for dragging before
actually trying a resize/move which is a little more consistent than
before. Fixes #9771.
2022-12-01 11:14:03 -06:00
Niklas Haas
e97e0e4d92 vo_gpu_next: don't flush cache on OSD update
Flushing the cache is a hammer-for-a-screw operation, because it nukes
*all* renderer state, including the HDR peak detection state. When
enabling e.g. --hdr-compute-peak, or any other future methods of dynamic
tone mapping, this would lead to bad results (e.g. brightness
fluctuations) whenever the OSD state is updated.

Instead of flushing the cache to force an OSD re-render, instead just
update the frame signature directly whenever its osd_sync value changes.
This accomplishes effectively the same thing but without touching the
HDR state.

This is slightly violating the libplacebo abstraction in a way that
isn't publicly documented. To be on the safe side we could make a carbon
copy of the array before modifying it, but given that this is unlikely
to change upstream I'll probably just end up explicitly documenting it
instead of forcing the copy in mpv.
2022-11-25 02:15:05 +01:00
Niklas Haas
e1a04cd8ac lcms: fix validate_3dlut_size_opt
Not only was this function needlessly convoluted, it was also broken -
since it returned a bool value where an error code was expected.
2022-11-21 17:39:37 +01:00
Niklas Haas
b9b3342369 lcms: always parse lcms2-related options
Currently, the lcms-related options are only defined when lcms2 is
enabled at build time. However, this causes issues (e.g. segfault) for
vo_gpu_next, which relies on the presence of these options (to forward
them to libplacebo).

(That libplacebo internally depends on lcms2 as well is an
implementation detail - compiling mpv *without* lcms against libplacebo
*with* lcms should be possible in principle)

Fixes: #10891
Closes: #10856
2022-11-21 17:39:37 +01:00
LaserEyess
a62f71bfbe vo_dmabuf_wayland: use single-pixel-buffer-v1
The new single-pixel-buffer protocol is designed to optimize the case
for using a solid color as an underlay wl_surface. It works the same as
the wl_shm 1x1 pixel trick currently used, but it allows the compositor
to make optimizations with more certainty than the wl_shm trick.
2022-11-20 19:13:59 +00:00
LaserEyess
303178e645 wlbuf_pool.h: add headers for forward declarations
This was previously implicitly included by the order of headers in
vo_dmabuf_wayland.c, but it is better to make it an explicit and reorder
the headers properly.
2022-11-20 19:13:59 +00:00
Niklas Haas
8327ac3e6d vo_gpu_next: fix undefined behavior on alpha-first formats
When the alpha channel is the first component, this code block gets
skipped by the continue, meaning the check for c==0 never passes.

Fix it by explicitly keeping track of whether bits have been set.
2022-11-19 14:12:24 +01:00
Dudemanguy
d3a61cfe98 wayland: also log refresh rate on surface entrance
Never bothered to log this for some reason, but it's pretty convenient
when debugging.
2022-11-18 16:36:21 -06:00
LaserEyess
ba20f60add drm: remove legacy API
The legacy DRM API adds some complexity to the DRM code. There
are only 4 drivers that do not support the DRM Atomic API:

1. radeon (early GCN amd cards)
2. gma500 (ancient intel GPUs)
3. ast (ASPEED SoCs)
4. nouveau

Going forward, new DRM drivers will be guaranteed to support the atomic
API so this is a safe removal.
2022-11-16 09:32:55 +01:00
Dudemanguy
6623efb142 wayland: add support for content-type protocol
The content-type protocol allows mpv to send compositor a hint about the
type of content being displayed on its surface so it could potentially
make some sort of optimization. Fundamentally, this is pretty simple but
since this requires a very new wayland-protocols version (1.27), we have
to mess with the build to add a new define and add a bunch of if's in
here. The protocol itself exposes 4 different types of content: none,
photo, video, and game.

To do that, let's add a new option (wayland-content-type) that lets
users control what hint to send to the compossitor. Since the previous
commit adds a VOCTRL that notifies us about the content being displayed,
we can also add an auto value to this option. As you'd expect, the
compositor hint would be set to photo if mpv's core detects an image,
video for other things, and it is set to none for the special case of
forcing a window when there is not a video track. For completion's sake,
game is also allowed as a value for this option, but in practice there
shouldn't be a reason to use that.
2022-11-15 23:18:55 +00:00
Dudemanguy
bab85944df player/video: add VOCTRL_CONTENT_TYPE
mpv's core already keeps track of whether or not it thinks a track is an
image. Some VOs (i.e. wayland) would benefit from knowing if what is
currently being displayed is an image or not so add a new VOCTRL that
signals this anytime we load a new file with a VO. Additionally, let's
add a helper enum for signaling the kind of content that is being
displayed. There is now MP_CONTENT_NONE (strictly for force window being
used on a track with no image/video), MP_CONTENT_IMAGE, and
MP_CONTENT_VIDEO. See the next commit for the actual usage of this (with
wayland).
2022-11-15 23:18:55 +00:00
Philip Langdale
25fa52d237 vo: hwdec: remove legacy_names
These were introduced for configuration compatibility in 0.35 but we
don't want to retain them past that point.
2022-11-15 16:33:12 +01:00
Dudemanguy
38a626650a player: add --force-render option
mpv has an internal optimization on a couple of platforms where it will
not render any frames if the window is minimized or hidden. There's at
least once possible use case for wanting to force a render anyway
(screensharing with pipeware) so let's just add a simple switch for
this that always forces mpv to render. Closes #10846.
2022-11-15 15:31:21 +00:00