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

4545 Commits

Author SHA1 Message Date
Kacper Michajłow
ed8b3cef5f vo: change spammy log to trace 2023-10-23 00:10:49 +00:00
Kacper Michajłow
8c7c878255 vo: average more vsync samples
Improves averaging on high refresh rate displays.
2023-10-23 00:10:49 +00:00
Kacper Michajłow
f27767f59e d3d11: calc vsync interval on real stats, not just last interval 2023-10-23 00:10:49 +00:00
NRK
a1f465b582 aspect: remove unused multiplication
the variable `w` is unused as a whole.
2023-10-23 00:10:42 +00:00
NRK
d05ef7fdc4 various: sort some standard headers
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
2023-10-20 21:31:09 +02:00
NRK
450a69b1d6 various: remove ATOMIC_VAR_INIT
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then made obsolete in C17 and removed in C23.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
2023-10-20 21:31:09 +02:00
NRK
2070331f64 osdep: remove atomic.h
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
2023-10-20 21:31:09 +02:00
Niklas Haas
bd1ba99ab2 vo_gpu_next: optimally align DR buffers
May increase performance, especially when using DR with a dedicated
transfer queue.
2023-10-19 18:26:05 +02:00
Niklas Haas
f369e65261 vd_lavc: align buffers to multiple of image size
Fixes: https://github.com/mpv-player/mpv/issues/12672
2023-10-19 18:26:05 +02:00
Kacper Michajłow
1ea1359a82 win32: suppress pointer cast warning 2023-10-19 14:03:23 +00:00
Kacper Michajłow
cb48b40bb3 vo_gpu_next: cast const away to suppress warning 2023-10-19 14:03:23 +00:00
Kacper Michajłow
7e18a46ec2 d3d11: don't skip last char in buffer
Both buffers have the same size (32) and if the source is not null
terminated it should be fixed there. Copy whole buffer.
2023-10-19 14:03:23 +00:00
Kacper Michajłow
94b7584972 win32: clear background only on first paint
Some users report visible black frames during window resize, this should
not happen in most cases. Let's just keep stale content as it is less
distracting. While still clearing on first window paint to avoid white
background.

Fixes: #12642
2023-10-18 15:22:22 +00:00
Dudemanguy
11bbb49bdf wayland: use ppoll if possible
Since the previous commit unbreaks the timeout, this now actually works.
Imagine that.
2023-10-17 15:05:33 +00:00
Dudemanguy
917bdf1b5c dither: removed some unused code
Added in 58a7d81dc5. Nobody touched it
since then, so it's probably useless. libplacebo has its own dithering
stuff anyways.
2023-10-16 15:38:59 +00:00
Dudemanguy
39b9635305 vo: convert some final low-hanging things to nanoseconds 2023-10-16 15:38:59 +00:00
Dudemanguy
de9b800879 timer: add convenience time unit conversion macros
There's a lot of wild 1e6, 1000, etc. lying around in the code. A macro
is much easier to read and understand at a glance. Add some helpers for
this. We don't need to convert everything now but there's some simple
things that can be done so they are included in this commit.
2023-10-16 15:38:59 +00:00
der richter
78d43740f5 vo_gpu/vo_gpu_next: add vulkan support for macOS
add support for vulkan through metal and a translation layer like
MoltenVK. also add the possibility to use different render timing modes
for testing.

i still consider this experimental atm.
2023-10-14 18:39:56 +02:00
der richter
bc66de2834 mac: add a window animation lock to wait for animations to finish
add an animation lock to the window to prevent the window from closing
while animating. if this is done while the fs animation is running the
dock will stay hidden. this is not used yet, because it's unnecessary
for cocoa-cb but will be for new vo backends.
2023-10-14 18:39:56 +02:00
Kacper Michajłow
fd46070490 hwdec_dxva2egl: fix log value type
Fixes type mismatch after recent changes.

Fixes: 59dd7d94af
2023-10-14 14:02:54 +00:00
Dudemanguy
273906490d vo_gpu_next: only increment osd_sync in update_overlays if paused
While the video playing, it's not actually needed and can cause
unnecessary redraws. Fixes #12623.
2023-10-13 14:00:22 +00:00
NRK
e41add29d4 drm_common: don't spoil errno in signal handler
same rationale as last commit
2023-10-13 11:36:01 +02:00
sunpenghao
1dd71a6093 win32: improve window snapping behavior
Several window resizing operations (i.e., --auto-window-resize,
border dragging with --keep-aspect-window, Alt+0/1/2) cause the
window to detach from the snapped borders. This patch resolves
this by recording to which borders the window is snapped, and
using this info to determine how the window should be placed after
resizing.

Closes https://github.com/mpv-player/mpv/issues/6588
2023-10-10 19:41:08 +00:00
Dudemanguy
59dd7d94af timer: change mp_sleep_us to mp_sleep_ns
Linux and macOS already use nanosecond resolution for their sleep
functions. It was just being converted from microseconds before. Since
we have mp_time_ns now, go ahead and bump the precision here. The timer
for windows uses some timeBeginPeriod thing which I'm not sure what it
does really but whatever just convert the units to ms like they were
doing before. There's really no reason to keep the mp_sleep_us helper
around. A multiplication by 1000 is trivial and underlying OS clocks
have nanosecond precision.
2023-10-10 19:10:55 +00:00
Dudemanguy
5d44cf93df vo: use mp_poll wrapper in wait_events when applicable
On linux, several platforms poll for events over a fd. This has ms
accuracy, but mpv's timer is in ns now so lots of precision is lost. We
can use an mp_poll wrapper to use ppoll instead which takes a timespec
directly with nanosecond precision. On systems without ppoll this falls
back to old poll behavior. On wayland, we don't actually use this
because ppoll completely messes up the event loop for some unknown
reason.
2023-10-10 19:10:55 +00:00
Dudemanguy
a899e14bcc vo: change vo->driver->wait_events to nanoseconds
In many cases, this is purely cosmetic because poll still only accepts
microseconds. There's still a gain here however since
pthread_cond_timedwait can take a realtime ts now.

Additionally, 37d6604d70 changed the value
added to timeout_ms in X11 and Wayland to ensure that it would never be
0 and rounded up. This was both incomplete, several other parts of the
player have this same problem like drm, and not really needed. Instead
the MPCLAMP is just adjusted to have a min of 1.
2023-10-10 19:10:55 +00:00
Dudemanguy
c82c55b4b9 vo: use nanoseconds for frame duration and pts 2023-10-10 19:10:55 +00:00
Dudemanguy
ae335ef155 vo: remove vo_get_estimated_vsync_interval conversion to seconds
This is weird. The caller should be responsible for converting the value
if desired. Move the conversion to player/command.c instead.
2023-10-10 19:10:55 +00:00
Kacper Michajłow
ef11d31c3a vo: remove frame timing check from vo_still_displaying()
This timing dependency does not guarantee that we will wake up in the
future, depending on processing times.
2023-10-07 17:50:50 +00:00
Kacper Michajłow
44c398c3e1 Revert "video: remove another redundant wakeup"
vo_still_displaying() is racey with vo_request_wakeup_on_done() and above
that it doesn't work as expected. VO can run out of work and go to sleep
for 1000s, while the play thread still returns on vo_still_displaying()
check, because of a check `now < frame_end` so it never advances and go
to sleep itself.

This fixes dead lock that we have when image parameters changes during
playback.

This reverts commit 0c9ac5835b.

Fixes: #12575
2023-10-07 17:50:50 +00:00
Dudemanguy
07995f5d5f vo_gpu_next: improve updating overlays
fbe154831a added a new VOCTRL to signal
when the OSD changed for gpu-next's handling of subtitles, but this is
both not necessary and actually incomplete. The VOCTRL would signal OSD
changes, but not all subtitle changes (like selecting another
non-external sub track for example). VOCTRL_OSD_CHANGED was used to
increment p->osd_sync which would then redraw the blended subtitles if
the player was paused.

But there's already a VOCTRL_PAUSE and VOCTRL_RESUME. Plus, the
sub_bitmap_list object will have items in it if it changed in any way,
so we don't need the VOCTRL_OSD_CHANGED method at all. That can be
removed.

The check that fp->osd_sync < p->osd_sync stays in place since that's an
optimization while the video is playing, but we also check the pause
state as well since the VO can know this. If we're paused, then always
do update_overlays since core must be signalling a redraw to us if we
get a draw_frame call here. Additionally in update_overlays itself, the
p->osd_sync counter is incremented if we have any items since the frame
signature will need that. As for the actual bug that is fixed, changing
subtitle tracks while paused with blended subtitles now correctly works.
Previously, it was never updated so the old subtitle stayed there
forever until you deselected it (since VOCTRL_OSD_CHANGED triggered
there).

Also include some cosmetic code fixes that were noticed.
2023-10-05 22:32:06 +00:00
Dudemanguy
61aecfabfd vo_dmabuf_wayland: correct full window size calculation
The current calculation makes the implicit assumption that the margins
on both sides are always equal (the 2 times multiplication). This isn't
true though. For example, a 720p video fullscreened on a 1680x1050
display will have a top margin of 52 but a bottom margin of 53. The
current calculation just multiplies 52 by 2, so it's off by one. Fix
this by adding together all the margins together (left + right or top +
bottom) then adding that to the dst window size (width or height). This
way, we get the full size of the window for the viewport. Fixes #12554.
2023-10-05 22:28:37 +00:00
Kacper Michajłow
d17db1367a win32: clear client area to black early
This fixes white background appearing for short period of time before
first frame is drawn. Clear to black as this is way less distracting
than bright white flash.

Borderless window and fullscreen seems to be initially not
drawn/transparent, so no need to clear it to black. Only when
decorations are enabled (--border) the issue happens.

Fixes: #12549
2023-10-05 17:10:23 +02:00
Dudemanguy
8641cbaab6 vo_dmabuf_wayland: free frame if the visibility check fails
Forgotten in 7b8a30fc81. Every other case
either is either a dummy frame (no allocated memory) or we manage it as
part of the usual wayland buffer release.
2023-10-04 16:21:47 -05:00
Dudemanguy
7b8a30fc81 vo_dmabuf_wayland: eliminate an extra frame copy
When implementing vo_dmabuf_wayland, it always did a copy of the image
from the current frame and worked with that. The reason was because
mpv's core held onto the frame and caused some timing issues and
rendering glitches depending on when it freed the image. This is pretty
easy to fix: just make vo_dmabuf_wayland manage the the frames. In vo.h,
we add a boolean that a VO can set to make them manage freeing frames
directly. After doing this, change the buffers in vo_dmabuf_wayland to
store the whole vo_frame instead of just the image. Then, just modify
some things a bit so frame is freed instead of the image. Now, we should
truly have zero-copy playback. Well as long as you don't use libass to
render anything (that's still a copy from system memory).
2023-10-03 23:45:20 +00:00
Kacper Michajłow
01c5346d1a win32: adjust WM_NCACTIVATE for better compatibility with window state
We have to support all changing states, not only borderless.
2023-10-02 21:51:47 +00:00
Dudemanguy
47dec1c7c2 vo_dmabuf_wayland: attach solid buffer when using force window
e125da2096 changed the z order of the
surfaces a bit, but it turns out this has a side effect. If the aspect
ratio of the actual video doesn't match your display, the osd surface
doesn't scale properly and gets clipped. Put the z ordering back where
it used to be. Instead when we have the force window case, simply attach
the already existing solid buffer to the video surface. This allows the
osd surface to actually draw over it instead of always being obscured so
it satisfies the case of not having any real video frames but still
wanting to draw the osd. Also don't mess with any of the viewport source
setting stuff with force window. Weston complains about it, and it's
nonsensical anyway. Fixes #12547.
2023-10-02 15:58:03 -05:00
Kacper Michajłow
a98641cf45 win32: add WS_THICKFRAME style in borderless mode
Fixes window resizing in borderless mode after adding WS_SYSMENU.

Fixes: 172d9be300
2023-10-01 15:57:31 +00:00
Dudemanguy
0b70598358 vo: fully replace draw_image with draw_frame
0739cfc209 added the draw_frame API
deprecated draw_image internally. VOs that still used draw_image were
around, but really there's no reason to not just "upgrade" them anyway.
draw_frame is what the "real" VOs that people care about (gpu/gpu-next)
use. So we can just simplfy the code a bit now. VOCTRL_REDRAW_FRAME is
also no longer needed so that can be completely deleted as well. Note
that several of these VOs are legacy crap anyway (e.g. vaapi) and maybe
should just be deleted but whatever. vo_direct3d was also completely
untested (not that anyone should ever use it).
2023-10-01 14:48:38 +00:00
Kacper Michajłow
172d9be300 win32: set WS_SYSMENU style always
Fixes missing icon when initial window is created without caption.

Fixes: #12472
2023-10-01 14:05:10 +00:00
Kacper Michajłow
0ba6ca6f76 vo: don't invoke wait, when not needed
This causes only problems, because we convert mp_time to realtime, which
is not atomic, so we introduce error. And even though on sane platforms
it should work fine, after all the sleep time is in the past.
winpthreads like to sleep for like over 10ms when the time is less than
current time, but not more than 1s.
2023-09-29 20:48:58 +00:00
Kacper Michajłow
7035debddf vo: increase display refresh rate estimation limit from 99 Hz to 400 Hz
High refresh rate displays exists...
2023-09-29 20:48:58 +00:00
Kacper Michajłow
df764bc0c3 vo: change vsync base to nanoseconds
There is no reason to use microseconds precision. We have precise timers
all all relevant platforms.
2023-09-29 20:48:58 +00:00
Kacper Michajłow
40e0fea6eb timer: rename mp_add_timeout to reflect what it actually does 2023-09-29 20:48:58 +00:00
Kacper Michajłow
da4c4d2ebd timer: rename mp_time_us_to_timespec to reflect what it actually does 2023-09-29 20:48:58 +00:00
Dudemanguy
27ef1725e7 vo_dmabuf_wayland: assume counter-clockwise rotations
In practice, most compositors implement the rotation clockwise which
matches mpv's option, but amusingly this is actually incorrect.
According to the spec*, wayland buffer rotations are counter-clockwise.
So with this assumption in mind, in order for the rotation to match
mpv's usual semantics, the 90 degree and 270 degree positions need to be
flipped. Of course, this will make the VO rotate the wrong way on most
compositors, but this is what the spec says (sway master is known to
currently be correct). Fixes #12508 (sort of but will break the rotation
direction on other compositors. Oh well).

*: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
2023-09-29 17:00:05 +02:00
hbiyik
c19115c8da hwdec_drmprime: add nv16 support
NV16 is the half subsampled version of NV12 format. Decoders which
support High 4:2:2 of h264 provide the frame in NV16 format to establish
richer colorspace. Similar profiles are also available in HEVC and other
popular codecs. This commit allows NV16 frames to be displayed over
drmprime layers.

Signed-off-by: hbiyik <boogiepop@gmx.com>
2023-09-29 12:10:59 +02:00
Jack Mitchell
1b4627f647 wayland: don't double close display fd
Calling wl_display_disconnect closes the file descriptor, no need to
manually do it ourselves beforehand which causes a double close on the
fd.

Signed-off-by: Jack Mitchell <jack.mitchell@tuxable.co.uk>
2023-09-27 16:17:31 +00:00
DeadSix
f19ada7b58 win32: add option to change backdrop style 2023-09-27 14:02:08 +00:00
DeadSix27
3665b8d1d8 win32: pass window handle to the window-id property
uses the same mechanic as for x11
2023-09-25 15:35:25 +00:00
Niklas Haas
44cf6288c7 vo_gpu: remove --scaler-lut-size
Pointless bloat option, hard-coded as 256 now in libplacebo and no
reason not to also hard-code in mpv.

See-Also: haasn/libplacebo@64d7c5aab0
2023-09-25 12:45:17 +02:00
Niklas Haas
57fad2d5f9 vo_gpu: remove --scale-cutoff etc
Pointless bloat option, hard-coded as 1e-3 now in libplacebo and no
reason not to also hard-code in mpv.

See-Also: haasn/libplacebo@64d7c5aab0
2023-09-25 12:45:17 +02:00
Dudemanguy
de61e6b67c wayland: remove gnome-specific idle-inhibit warning
Unbelievably, mutter actually supports the idle inhibit protocol now
after many years of pain*. Let's remove this hacky warning.

*: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3145
2023-09-24 01:59:07 +00:00
Dudemanguy
db12a2f224 cuda: move --cuda-device to cuda_opts group
Also change a ta_free to talloc_free for consistency reasons.
2023-09-22 14:20:38 +00:00
Dudemanguy
73ad9eef28 opengl/context_win: move opengl-dwmflush to wingl_opts group
Gets rid of yet another mp_read_option_raw call.
2023-09-22 14:20:38 +00:00
Dudemanguy
58ac0dd6db libmpv_gl: replace mp_read_option_raw call 2023-09-22 14:20:38 +00:00
Dudemanguy
a9177201d4 video/out/gpu: replace mp_read_option_raw call 2023-09-22 14:20:38 +00:00
Kacper Michajłow
6eb35f6f64 win32: don't remove WS_CAPTION from style
Apparently removing WS_CAPTION disables some window animations. Instead
adjust non-client area to not draw title bar.

Note that we do not account for difference in real border size and
invisible one, but seems to work correctly.
2023-09-21 23:13:19 +00:00
Kacper Michajłow
18deac3e81 win32: enable custom WM_NCHITTEST also when title bar is hidden 2023-09-21 23:13:19 +00:00
Kacper Michajłow
4defeddbfc win32: set window_corners to default for fullscreen
I don't think in fullscreen mode it makes sense to enable rounded corners.
We can add another option if someone needs it, but for now `window_corners`
affects only the window as one would expect.
2023-09-21 23:13:19 +00:00
Kacper Michajłow
804eb80e78 win32: add --window-corners
Allows to set preference for window corners rounding for DWM.
2023-09-21 23:13:19 +00:00
Kacper Michajłow
0d457ffc40 win32: fix fit_window_on_screen to account for invisible borders
Fixes too small initial window size.
2023-09-21 23:13:19 +00:00
Kacper Michajłow
fac2b31df7 win32: reduce top border thickness to imitate DWM invisible borders
DWM makes part of left, right and bottom border invisible.
2023-09-21 23:13:19 +00:00
Kacper Michajłow
ee24dd0419 win32: add an option to control window title bar state
Fixes: #11432
2023-09-21 23:13:19 +00:00
DeadSix
2c738ca54b win32: add an option to change window affinity 2023-09-21 22:14:28 +00:00
Dudemanguy
4c39e79169 wayland: ensure at least a scale factor of 1 when drawing cursor
With the addition of fractional scaling support, wl->scaling was
converted to a double. Some compositors (Plasma) can report values under
1 for fractional scaling, so this meant wl->scaling could be some
small fractional value. This is fine except that when using the legacy
code for drawing the mouse cursor (i.e. not the cursor-shape protocol),
it still uses the old integer scaling method in core wayland. The reason
for this is simply because fractionally scaling the mouse cursor surface
is nonsense and nobody even has cursor images for anything besides a
select few sizes anyways (32x32, 48x48, etc.). The existing integer
scaling sort of works but it's pretty bad too and you can get some weird
sizes anyway. This is why cursor-shape is preferred since it fixes this.
Anyways, since buffer scaling for the cursor only takes integers, there
could be truncation to 0 in the previously mentioned fractional scale
this. This naturally causes the compositor to send us an error and mpv
quits. The fix is to always make sure that the scale value used for the
cursor is at least 1. Anything less makes no sense. Fixes #12309.
2023-09-21 15:31:26 -05:00
Kacper Michajłow
7f6785f363 win32: explicitly guard dark mode calls by Windows version
Fixes: #11610
Fixes: 9feeb324ed
2023-09-21 19:40:40 +00:00
Kacper Michajłow
704afb8968 vo_gpu_next: use proper color for subtitles
All SUBBITMAP_LIBASS are converted to sRGB beforehand, for the rest we
need to use video color space.
2023-09-21 21:23:35 +02:00
Kacper Michajłow
e999e2b037 vo_gpu: don't override scaler options with default ones
There was assumption in the code that default settings are compatible
with dumb mode and are only one that should be used in this case.

Force bilinear if dumb mode is enabled.
2023-09-21 21:15:29 +02:00
llyyr
d48f71339e vo_gpu: allow deband-iterations to be 0
THis allows adding grain without debanding. libplacebo already supported
this, so no changes are required there.
2023-09-21 19:22:03 +02:00
Dudemanguy
be89e07229 drm: remove selecting the card number with --drm-connector
f560437594 deprecated this since the
--drm-device path option was added as a replacement. Drop the card
number selection logic.
2023-09-21 16:06:29 +00:00
Dudemanguy
1b68c5d22f vo_sixel: change exit-clear handling to OPT_REPLACED
Easier to keep track of when we do want to remove it.
2023-09-21 16:06:29 +00:00
Dudemanguy
36ea5d7b5c options: remove a few options marked with .deprecation_message
A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the
options still possibly do something but they have a deprecation
message. Most of these are old and have no real usage. The only
potentially controversial ones are the removal of --oaffset and
--ovoffset which were deprecated years ago and seemingly have no real
replacement. There's a cryptic message about --audio-delay but who
knows. The less encoding mode code we have, the better so just chuck
it.
2023-09-21 16:06:29 +00:00
Dudemanguy
969c19c9cb options: remove ancient option fallbacks/deprecation
We've got an ungodly amount of OPT_REPLACED and OPT_REMOVED sitting
around in the code. This is harmless, but the vast majority of these are
ancient. 26f4f18c06 is the last commit
that touched the majority of these and of course that only changed how
options were declared so all of this stuff was deprecated even before
that. No use in keeping these, so just delete them all. As an aside,
there was actually a cocoa_opts but it had only a single option which
was replaced by something else and empty otherwise. So that entire thing
was just simply removed. OPT_REPLACED/OPT_REMOVED declarations that were
added in 0.35 or later were kept as is.
2023-09-21 16:06:29 +00:00
Dudemanguy
e125da2096 vo_dmabuf_wayland: support osd rendering when there's no video
The osd support was originally written with the requirement that we have
actual frames getting delivered to the VO. This isn't always the case
though. If you force a window on a blank audio file for example, then
there will be no frame thus draw_frame did nothing. Since the previous
commit allows us to reliably detect this, we can rearrange the code
around a little bit to make this possible. A key change is to make the
osd_subsurface have wl->surface as the parent. This is seemingly
required otherwise the osd_surface buffers are never visible above the
empty video_surface when we have a black window. Also nuke the desync
call since it's completely pointless. Fixes #12429.
2023-09-21 14:08:52 +00:00
Kacper Michajłow
66c92dc059 vo_gpu_next: fix unscaled screenshot with --blend-subtitles
Need to use correct adjusted dst.
2023-09-21 02:26:42 +02:00
Niklas Haas
2fd5b9b4dd vo_gpu: match libplacebo debanding defaults
The defaults were awful and horribly regressed many files while also not
fixing banding on files that actually needed it, sometimes even
*increasing* banding due to the low threshold.

Fixes: 12ffce0f22
See-Also: haasn/libplacebo@e1e43376d1
2023-09-20 20:26:07 +02:00
Niklas Haas
e7bd330ed0 vo_gpu: match libplacebo peak detection defaults
This probably makes `vo_gpu` tone mapping worse, or something, but who
cares. The status quo for a while now has been to use `vo_gpu_next` if
you care about HDR rendering at all.

See-Also: haasn/libplacebo@ec60dd156b
See-Also: haasn/libplacebo@0903cbd05d
2023-09-20 20:26:07 +02:00
Niklas Haas
c172a650c4 vo_gpu: default to dscale=hermite
This new filter is slightly sharper, and significantly faster, than
mitchell. It also tends to preserve detail better. All in all, there is
no reason not to use it by default, especially from a performance PoV.
(In vo_gpu_next, hermite is implemented efficiently using hardware
accelerated bilinear interpolation)

See-Also: 75b3947b2c
2023-09-20 17:07:38 +02:00
Kacper Michajłow
703f158880 builtin.conf: modernize internal profiles
The goal is to provide simple to understand quality/performance level
profiles for the users.

Instead of default and gpu-hq profile. There main profiles were added:
    - fast: can run on any hardware
    - default: balanced profile between quality and performance
    - high-quality: out of the box high quality experience. Intended
      mostly for dGPU.

Summary of three profiles, including default one:

[fast]
scale=bilinear
cscale=bilinear (implicit)
dscale=bilinear
dither=no
correct-downscaling=no
linear-downscaling=no
sigmoid-upscaling=no
hdr-compute-peak=no

[default] (implicit mpv defaults)
scale=lanczos
cscale=lanczos
dscale=mitchell
dither-depth=auto
correct-downscaling=yes
linear-downscaling=yes
sigmoid-upscaling=yes
hdr-compute-peak=yes

[high-quality] (inherits default options)
scale=ewa_lanczossharp
cscale=ewa_lanczossharp (implicit)
hdr-peak-percentile=99.995
hdr-contrast-recovery=0.30
allow-delayed-peak-detect=no
deband=yes
scaler-lut-size=8
2023-09-19 22:26:56 +02:00
Kacper Michajłow
7e692ee490 vo: change tscale to oversample by default
Keep it sharp, let users opt-in more blurry result.
2023-09-19 22:26:56 +02:00
Kacper Michajłow
4bedcd36f6 vo: make cscale follow scale by default 2023-09-19 22:26:56 +02:00
Kacper Michajłow
8121d41245 vo: enable correct-downscaling, linear-downscaling, sigmoid-upscaling 2023-09-19 22:26:56 +02:00
Dudemanguy
27a78276eb vo: avoid unnecessary redraws when the OSD shows
296d40dc6f changed how the vo handled
redraw requests in order to fix a race condition that can occur with
pausing. However, there was a slight oversight because a redraw request
that occurred while the core was unlocked and the video was still
playing would still be kept true (previously, this was always cleared).
That redraw is essential if mpv is paused otherwise the old issue comes
back, but if the video is playing it's unnecessary since the next loop
around will simply draw whatever we needed. The extra redraw could cause
a frame drop for some people in certain instances, so the solution is to
simply always clear redraw requests if !in->paused. This eliminates the
extra redraw but still keeps it when pausing.

Fixes #12426 and fixes #11579.
2023-09-19 13:11:30 -05:00
llyyr
1c09ee44c3 filter_kernels: remove bcspline filter
After fixing the B and C params for bcspline, it ended up being the same
thing as bicubic. There's no reason to have two names for the same
filter, so remove bcspline and keep bicubic to match libplacebo.
2023-09-18 17:44:18 +02:00
llyyr
816de3f064 filter_kernels: fix bcspline params
bcspline is defined as B=1, C=0 in ImageMagick (as CubicFilter) and
libplacebo, so we should match that.
2023-09-18 17:44:18 +02:00
llyyr
faf5a4bc8d filter_kernels: add hermite filter
Matches HermiteFilter from Imagemagick (B=C=0, R=1)
2023-09-18 17:44:18 +02:00
llyyr
5efc04006b vo_gpu_next: fix blur and taper values being zero
This would always apply the config blur and taper values to the kernel,
even if it was zero because the user didn't specify any.
2023-09-18 17:42:28 +02:00
Dudemanguy
ed5c744aa9 vo_dmabuf_wayland: support 90 degree rotations
All we have to do is set VO_CAP_ROTATE90 and then use buffer transform.
Maybe ideally we would rotate with vavpp instead if possible, but this
would be a convoluted mess that I'm not really interested in dealing
with right now.
2023-09-17 19:29:59 -05:00
Kacper Michajłow
63ca12d7bc win32: remove noisy debug log
It is quite unnecessary to log every window move.
2023-09-17 17:14:34 +02:00
Niklas Haas
bc35180933 vo_gpu: remove --scale-wblur etc
No need for this since it's entirely redundant with just changing the
filter radius directly. In fact, that's the whole *point* of the filter
radius - it does not modify the filter, it modifies the scaling of the
window.

Of course, this does not work for non-resizable kernels. But, really,
who cares?
2023-09-16 14:33:45 +02:00
Niklas Haas
a24aa6b8f7 filter_kernels: add ewa_lanczos4sharpest
Mainly for vo_gpu_next.
2023-09-16 14:33:45 +02:00
Niklas Haas
93ff7554ac filter_kernels: refine ewa_lanczossharp/soft constants
Replaced by mathematically and numerically precise constants, the result
of exact computation. Also updates the description to provide more
explanation and motivation.
2023-09-16 14:33:45 +02:00
Niklas Haas
2ec79f8bb7 filter_kernels: use true jinc radius
For all filters. For consistency between vo_gpu and vo_gpu_next. Also
makes ewa_lanczossharp less special.
2023-09-16 14:33:45 +02:00
Niklas Haas
aef62063f7 filter_kernels: replace magic jinc radius by constant (cosmetic) 2023-09-16 14:33:45 +02:00
Niklas Haas
06e65778be filter_kernels: properly sharpen/blur filter radius
We currently always scaled the window to the size of the configured
radius. However, this is wrong - we should instead be scaling it to the
size of the sharpened/blurred kernel. Since the window is always
stretched to the configured size of the filter, we can accomplish this
easily by just multiplying the blur value into the filter radius
directly, and then using that adjusted radius in place of `f.radius`
everywhere.

On a side note, this gives a very minor performance boost to
ewa_lanczossharp for no downside.
2023-09-16 14:33:45 +02:00
Niklas Haas
87162f0722 vo_gpu: slight bump to hard-coded option size limits
ewa_lanczos4sharpest, for example, overflows this buffer.
2023-09-16 14:33:45 +02:00
Niklas Haas
818ef158e8 vo_gpu_next: remove ewa_lanczossharp nag
Upstream finally caved in to peer pressure and added this filter. Of
course, this also removes the fallback for people on older versions of
libplacebo, but people using mpv git master are probably using
libplacebo git master anyway. It's time to debloat this code.
2023-09-16 14:33:45 +02:00
Niklas Haas
40de03fdba vo_gpu: vo_gpu_next: support --icc-3dlut-size=auto
And make it the default. In libplacebo, this uses internal heuristics to
pick a good size based on the actual ICC characteristics. This is
significantly less wasteful than always generating a 64x64x64 3DLUT (the
old status quo).

In vo_gpu, for simplicity, just default to 65x65x65. Note that this
provides slightly better accuracy than the old default of 64x64x64 for
technical reasons, and matches what libplacebo defaults to for typical
display profiles.
2023-09-15 10:58:37 +02:00
Niklas Haas
400c12fe00 vo_gpu_next: update for new ICC profile API
Upstream has moved from passing struct pl_icc_profile to directly
attaching a managed pl_icc_object, plus providing a new function
pl_icc_update to update the ICC profile object parameters (if needed).

To facilitate this move, pull our ICC params back out of pl_options and
update the target ICC object directly.
2023-09-15 10:58:37 +02:00
Dudemanguy
8a2fbfc2b8 present_sync: allow future timestamps
The original OML sync implementation (which is where this calculation
originally comes from) made now_monotonic and ust_mp_time unsigned. This
is fine except it has the assumption that now_monotonic is always
greater than ust. This actually isn't always the case. In wayland, I
observed instances where the reported timestamp is in the future. Of
course, it's a valid question to wonder if this even makes sense but
these UST values are essentially opaque black boxes to us anyways. It's
entirely plausible that the gpu is expecting the actual presentation of
the last swap to be a bit in the future, the compositor gets this and
reports this to us. So we'll consider such stats as valid. Note that
xorg doesn't have this problem because it's roughly one swap buffer call
behind because of how the event loop works (honestly something that
should be fixed).

Of course, the problem with the unsigned type here is that it overflows
on the subtraction so make it signed and allow the appropriate negative
value to happen if it does. Note that this will simply result in a small
addition to mp_time_us() which is exactly what we want here (timestamp
slightly in the future). Some small style changes included just because.
2023-09-14 22:19:18 +00:00
Niklas Haas
c9d5b482c1 vo_gpu_next: map --scaler-resizes-only 2023-09-14 18:24:47 +02:00
Dudemanguy
bda84399ab vo: change vsync_interval to double
So strangely enough, estimated_vsync_interval is stored as a double but
nominal_vsync_interval is not and neither is the vsync_interval. Those
are stored as int64_t. This loss of precision can matter even in common
cases. For instance, take a typical 60 Hz monitor. Instead of 16666.6666
(repeating) being calculated as the vsync interval, you would get 16666
since the decimals are truncated. This is not really good at all and
affects the calculated speed values you get when using display sync. For
consistency and better precision, these should all be doubles just like
estimated_vsync_interval. Technically this means that we won't be able
to store as high of an integer value but such values would be absurdly
huge and never actually needed. Also estimated_vsync_interval already
can't handle such a case anyway.
2023-09-09 02:48:35 +00:00
Kacper Michajłow
49dfa1430b vo_gpu_next: support --blend-subtitles when taking screenshoot 2023-09-09 00:49:19 +00:00
Kacper Michajłow
b8177f7b52 vo_gpu: support crop in gl_video_screenshot 2023-09-09 00:49:19 +00:00
Kacper Michajłow
d467c0e63c vo_gpu_next: support crop in video_screenshot 2023-09-09 00:49:19 +00:00
Niklas Haas
57a6a16172 vo_gpu_next: forwards compatibility with pl_cache
Interrim solution, forwards compatible with new and backwards compatible
with old API. Eventually, we will want to discontinue the use of
deprecated pl_icc_params.save/load and pl_renderer_save/load, but that
requires minimum version bump.
2023-09-08 18:22:31 +02:00
Philip Langdale
02b49458a3 vo: vulkan: allow picking devices by UUID
We currently only allow specifying the Vulkan device to use by name. We
did this to avoid confusion around devices being enumerated in an
unpredictable order. However, there is a valid edge case where a system
may contain multiple devices of the same type - which means they will
have the same name, and so you can't control which one is used.

This change implements picking devices by UUID so that if names don't
work, you have some option available. As Vulkan 1.1 is a hard
requirement for libplacebo, we can just use UUIDs without conditional
checks.

Fixes #10898
2023-09-04 15:22:20 -07:00
Niklas Haas
67368ac5d2 vo_gpu_next: don't rotate gamut visualization
Causes bad performance with interpolation because the changing hue angle
invalidates the mixing cache, as a result of libplacebo implementations
(specifically, the fact that this graph is drawn during the color
management process, instead of as a separate overlay).

Fix it by just hard-coding a particular, relatively interesting plane
(pi/4 approximately maps onto the red-blue axis).
2023-09-02 22:22:54 +02:00
llyyr
f52056b76d Revert "aspect: change --video-pan-x/y to be relative to the destination rect"
There are way too many preexisting scripts that rely on this behavior
for video panning, like for example scripts that allow you to use mpv as
an image viewer. If this behavior is desired then it may be better to
add a new option for panning relative to the destination instead.

The restriction of video-pan-x/y being clamped to {-3, 3} also results
in the video being impossible to pan if it was zoomed in beyond a
certain degree.

This reverts commit 7d6f9e3739.
2023-09-02 16:18:31 +00:00
Niklas Haas
b4c98cb04c vo_gpu: remove --tone-mapping-mode
`--vo=gpu-next` no longer uses this option, being replaced entirely by a
luminance-based approach internally. And even for `--vo=gpu`, the values
other than 'hybrid' are universally inferior in quality.

In the interest of gradually reducing the amount of option bloat here,
remove this mostly-pointless option.
2023-09-01 21:02:19 +02:00
Kacper Michajłow
957118864c win32: don't load dynamically always available functions
They are all available on Windows 7 and newer.
2023-09-01 16:58:56 +02:00
Kacper Michajłow
1bf6325e21 win32/displayconfig: remove custom struct redefinition
Those structs in MinGW-w64 are correct. I compared to Windows SDK and
actually our version have not correct alignment.
2023-09-01 16:58:56 +02:00
Kacper Michajłow
f3f1a79fe3 vo: add --video-crop
Just cropping by VO that works with hwdec.

Fixes: #12222
2023-08-31 17:37:42 +00:00
Kacper Michajłow
6329f742a6 aspect: don't override src_start/src_end
Rely on caller to set them.
2023-08-31 17:37:42 +00:00
Niklas Haas
67d31a8266 vo_gpu_next: improve --tonemapping-visualize
Pick a smarter rect, limit it to right half of screen (to allow more
easily using it simultaneously with stats), and also auto-rotate through
the hue plane by default (wrapping once every 10 seconds of playback).

I briefly considered making it based on wallclock time instead of pts,
but this has the rather unfortunate downside of only being updated
sporadically as the user moves the mouse over OSC elements. (Of course,
we could also forcibly redraw the screen continously to avoid it, but
I'd rather not make such an invasive change for no real reason)

This design also allows you to pause and focus on (via framestepping)
individual parts of the hue graph that you're interested in.
2023-08-30 17:10:13 +02:00
Kacper Michajłow
38ac67308b vo_gpu_next: add support for VOCTRL_HDR_METADATA 2023-08-29 20:58:44 +02:00
Kacper Michajłow
a98c5328dc vo: add VOCTRL_HDR_METADATA to get mp_hdr_metadata 2023-08-29 20:58:44 +02:00
Robert Mader
5a690a168a vo_dmabuf_wayland: unmap osd surface when not needed
Attaching a NULL buffer unmaps the surface, allowing compositors to skip
blending the empty buffer.

Closes #12236
2023-08-28 18:16:10 +00:00
Niklas Haas
3e612c07f4 vo_gpu_next: fix --target-contrast=inf
Somehow this overrode max_luma instead of min_luma...

Fixes: 347fbd6fa3
2023-08-28 18:30:54 +02:00
Niklas Haas
902bbdad35 vo_gpu_next: update tmp params before rendering frame
Gives the correct queue size value for the subsequent pl_queue_update()
calls, which avoids a bit of unnecessary overhead.
2023-08-27 14:39:45 +02:00
Niklas Haas
0fd357a416 vo_gpu_next: make option shim consistent with new API
Avoids some unnecessary #ifdef and allows us to isolate the shim to a
single location.
2023-08-27 14:39:45 +02:00
Niklas Haas
835fd7bdeb vo_gpu_next: avoid duplicate code (cosmetic)
Also avoids 80col violation.
2023-08-27 14:39:45 +02:00
Niklas Haas
6fb9d92b25 vo_gpu_next: correctly set params.frame_mixer
This was incorrectly adapted from the old options system, we forgot to
ever actually assign p->frame_mixer to params.frame_mixer.

Fixes: d2082841df
2023-08-27 14:39:45 +02:00
Niklas Haas
23e9b57791 vo_gpu_next: don't nuke main options state in video_screenshot
This actually fixes a bug that was present in this code even before the
new pl_options system, which is that `video_screenshot` would
permanently leave `peak_detect_params.allow_delayed` as false, until
something else forced options re-application due to options cache
change.
2023-08-27 14:39:45 +02:00
Niklas Haas
87aa65285b vo_gpu_next: don't override main options in draw_frame
Instead, take a stack copy of the relevant struct. Avoids leaving
temporary state dangling after this function returns.

Fixes: 40b6afcfca
2023-08-27 14:39:45 +02:00
Philip Langdale
19ea8b31bd hwtransfer: use the right hardware config to find conversion targets
The last piece in the puzzle for doing hardware conversions
automatically is ensuring we only consider valid target formats for the
conversion. Although it is unintuitive, some vaapi drivers can expose a
different set of formats for uploads vs for conversions, and that is
the case on the Intel hardware I have here.

Before this change, we would use the upload target list, and our
selection algorithm would pick a format that doesn't work for
conversions, causing everything to fail. Whoops.

Successfully obtaining the conversion target format list is a bit of a
convoluted process, with only parts of it encapsulated by ffmpeg.
Specifically, ffmpeg understands the concept of hardware configurations
that can affect the constraints of a device, but does not define what
configurations are - that is left up to the specific hwdevice type.

In the case of vaapi, we need to create a config for the video
processing endpoint, and use that when querying for constraints.

I decided to encapsulate creation of the config as part of the hwdec
init process, so that the constraint query can be down in the
hwtransfer code in an opaque way. I don't know if any other hardware
will need this capability, but if so, we'll be able to account for it.

Then, when we look at probing, instead of checking for what formats
are supported for transfers, we use the results of the constraint query
with the conversion config. And as that config doesn't depend on the
source format, we only need to do it once.
2023-08-26 10:07:55 -07:00
Philip Langdale
59478b0059 hwtransfer: implement support for hw->hw format conversion
Historically, we have not attempted to support hw->hw format conversion
in the autoconvert logic. If a user needed to do these kinds of
conversions, they needed to manually insert the hw format's conversion
filter manually (eg: scale_vaapi).

This was usually fine because the general rule is that any format
supported by the hardware can be used as well as any other. ie: You
would only need to do conversion if you have a specific goal in mind.

However, we now have two situations where we can find ourselves with a
hardware format being produced by a decoder that cannot be accepted by
a VO via hwdec-interop:
 * dmabuf-wayland can only accept formats that the Wayland compositor
   accepts. In the case of GNOME, it can only accept a handful of RGB
   formats.
 * When decoding via VAAPI on Intel hardware, some of the more unusual
   video encodings (4:2:2, 10bit 4:4:4) lead to packed frame formats
   which gpu-next cannot handle, causing rendering to fail.

In both these cases (at least when using VAAPI with dmabuf-wayland), if
we could detect the failure case and insert a `scale_vaapi` filter, we
could get successful output automatically. For `hwdec=drm`, there is
currently no conversion filter, so dmabuf-wayland is still out of luck
there.

The basic approach to implementing this is to detect the case where we
are evaluating a hardware format where the VO can accept the hardware
format itself, but may not accept the underlying sw format. In the
current code, we bypass autoconvert as soon as we see the hardware
format is compatible.

My first observation was that we actually have logic in autoconvert to
detect when the input sw format is not in the list of allowed sw
formats passed into the autoconverter. Unfortunately, we never populate
this list, and the way you would expect to do that is vo-query-format
returning sw format information, which it does not. We could define an
extended vo-query-format-2, but we'd still need to implement the
probing logic to fill it in.

On the other hand, we already have the probing logic in the hwupload
filter - and most recently I used that logic to implement conversion
on upload. So if we could leverage that, we could both detect when
hw->hw conversion is required, and pick the best target format.

This exercise is then primarily one of detecting when we are in this
case and letting that code run in a useful way. The hwupload filter is
a bit awkward to work with today, and so I refactored a bunch of the
set up code to actually make it more encapsulated. Now, instead of the
caller instantiating it and then triggering the probe, we probe on
creation and instantiate the correct underlying filter (hwupload vs
conversion) automatically.
2023-08-26 10:07:55 -07:00
Christoph Heinrich
0c9d8619e8 input: add missing keypad key defines
So far all the keypad keys except for `0` and `,` mapped to the same
MP_KEY_* independent of numlock state, even though different key codes
are received.
Now all the alternative functions map to appropriate MP_KEY_* defines,
with missing ones added.
2023-08-25 15:55:31 +00:00
Kacper Michajłow
ce79976498 win32: don't ignore --screen and --fs-screen
Fixes: 57ba77fc73
Fixes: #12220
2023-08-23 15:37:41 +02:00
James Cuzella
fa378249dd input: add new keys: Back, Tools, ZoomIn, ZoomOut
These were the only keys missing to support mapping all keycodes on a
[popular RF Remote][1] used with Linux HTPC apps.

Note that X11/XWayland + xkbcomp still warns about keycodes > 255, due
to the 8-bit limit in Xorg but `mpv` on Wayland is able to handle these.
For X11 users, there are [a couple options][2]:

- [Gianni Ceccarelli's patched `xf86-input-evdev`][3]
- [Use udev hwdb to map scancodes to keycodes][4]

[1]: https://www.mythtv.org/wiki/Air_mouse_rf_remote
[2]: https://unix.stackexchange.com/a/436233/7688
[3]: https://www.thenautilus.net/SW/xf86-input-evdev/
[4]: https://wiki.archlinux.org/title/Map_scancodes_to_keycodes
2023-08-23 15:37:02 +02:00
Niklas Haas
af9b53f3a3 vo_gpu_next: move line to correct location (cosmetic) 2023-08-21 19:50:20 +02:00
Niklas Haas
32ee937afa vo_gpu_next: correctly handle GAMUT_AUTO
Fixes: https://github.com/mpv-player/mpv/issues/12208
2023-08-21 19:49:59 +02:00
Niklas Haas
ef4c6dfcf5 vo_gpu_next: reword error message on empty screenshot
This can happen under perfectly legitimate circumstances if no file is
loaded yet.
2023-08-21 13:43:20 +02:00
Kacper Michajłow
7d6f9e3739 aspect: change --video-pan-x/y to be relative to the destination rect
It makes it more usable to virtually move dst rect instead of scaled
src.

The issue with the latter is that it is affected by video-zoom
paramters. For example if we do `--video-pan-x=-0.5` in normal case it
will move video -50%, but if we apply video-zoom/scale the video will
float towards the middle in unintuitive way. Extreme case is when one do
--video-zoom-x=0.01, now it is impossible to move video unless you
specify huge video-pan-x value, but it is limited to [-3, 3]. So you
cannot do anything.

With this changes regardless of video scale/zoom, video-pan will keep
center of scaled video in one place.
2023-08-20 23:15:48 +00:00
Kacper Michajłow
56ec3ea9f6 aspect: don't allow scaled_src_size be 0
It doesn't make sense to have zero here and it breaks, logic below.
Width was still campled to 1, but with broken offset.

This fixes things like video-scale-x=0
2023-08-20 23:15:48 +00:00
sfan5
ecbaf34701 meson: rename all features with underscores
The convention is to use dashes.
2023-08-20 21:13:37 +00:00
sfan5
88d0383a26 context_drm_egl: remove references to VAAPI in error messages
VAAPI is not the only hwdec that won't work when the render node
isn't available.
2023-08-20 20:55:57 +02:00
sfan5
d15f11a9f7 context_drm_egl: more correctness fixes for uninit procedure
- uninit gl before the VO
- destroy EGL surface before context: reverse of the creation order.
  I also checked other code which doesn't even call this and leaves
  it up to eglTerminate, which frees everything anyway. But this
  seems more correct since we're destroying the gbm surface afterwards.
- check against at EGL_NO_DISPLAY instead of 0: there is probably no
  EGL implementation where this makes a difference, it is more correct
  regardless
- remove pointless eglDestroyContext call
- check render_fd before close
2023-08-20 20:55:57 +02:00
Zenos
57ba77fc73 w32_common: try to get the monitor from the window bounds 2023-08-20 20:39:05 +02:00
Zenos
da965906ef w32_common: don't fit to screen when VO_WIN_FORCE_POS is set 2023-08-20 20:39:05 +02:00
mwalmer
f88ed14168 win32_common: fixes minimized window being focused on launch
mpv was taking focus when being started with "--window-minimized=yes". This change stops mpv from taking focus when this option is used.

Resolves: #9641
2023-08-20 20:21:14 +02:00
llyyr
bf1e1a7961 drm_common: skip cards that don't have connected outputs
It's possible for systems to have multiple cards, and the first capable
card to not have a connected output. Skip such cards and continue
iterating until we find one with a connected output.
2023-08-20 19:59:36 +02:00
Dudemanguy
f7151932df x11: set sizehint for fs-screen and fs-screen-name
Without doing this, --fs --fs-screen=1 wouldn't actually end up on the
desired screen since the sizehint was never sent. Also check the
screen-name variants for an empty string as well so the option can
properly "undo" itself (not sure if this has any practical effect).
2023-08-20 02:01:39 +00:00
Dudemanguy
200992f90c x11: remove xinerama and refactor window geometry
mpv mixes xinerama and randr usage together which gets kind of
confusing and is also pretty stupid. Xinerama is completely unneccesary
today since randr can do everything it can do and much more. Remove it.
This reworks a lot of the window/geometry handling stuff to be centered
completely around xrandr_display plus some other tweaks to the geometry
handling. An important concept is that current_icc_screen is changed
into current_screen and used more generously since it is useful for
things besides just icc profiles.
2023-08-20 02:01:39 +00:00
Dudemanguy
a0038504a3 x11: require randr 1.4
There really is no reason to not just hard require randr 1.4. xorg added
1.4 support in 2012 and someone somehow using an xorg server older than
that today surely has several other problems.
2023-08-20 02:01:39 +00:00
Arthur Williams
19384e07e4 context_drm_egl: don't free egl properties if they are null
If we failed to create a gbm surface, we would call drm_egl_uninit
to free up any state we had allocated. However, we would segfault if we
tried to cleanup properties there were never initialized. Null checks
have been added to guard against this.
2023-08-20 00:29:57 +02:00
Niklas Haas
2791eb64e8 vo_gpu_next: correctly clear removed hooks
Before d208284, this was implicitly reset back to 0 at the start of
every update_options(). But we no longer explicitly reset par->params,
so we need to do it manually here for the hooks.

Fixes: https://github.com/mpv-player/mpv/issues/12203
2023-08-19 23:39:25 +02:00
Niklas Haas
7ae4396ea5 vo_gpu_next: fix typo in video_screenshot()
Undefined behavior (bad initializer). Somehow didn't trigger a warning
on my end...

Fixes: a8192eda6c
2023-08-19 16:03:09 +02:00
Niklas Haas
a8192eda6c vo_gpu_next: add --libplacebo-opts
To help test not-yet-exposed options, and for debugging purposes.
2023-08-19 14:12:24 +02:00
Niklas Haas
40b6afcfca vo_gpu_next: don't re-set frame_mixer
This is already set by map_scaler, just disable it if unwanted.
2023-08-19 14:12:24 +02:00
Niklas Haas
47f756d64b vo_gpu_next: move allow_delayed to move appropriate place
No need to override this so late in the general (non-screenshot) code.
2023-08-19 14:12:24 +02:00
Niklas Haas
d2082841df vo_gpu_next: switch to new pl_options system
With a backwards compatibility shim for older versions of libplacebo in
which we simply define the relevant subset of this struct ourselves and
initialize it to known-good values, to be able to continue using our
options assigning code.

It's worth pointing out that our use of scalers deviates from how
pl_options was intended to be used, as a consequence of backwards
compatibility with pre-308 versions of libplacebo. But this should work
fine in practice, since we don't care about serializing these custom
scalers correctly. Users can still override them using the built-in
pl_options scalers when loading custom scalers via --libplacebo-options.
(To be added in the next commit)
2023-08-19 14:12:24 +02:00
Niklas Haas
152a95f215 vo_gpu_next: fix leak of --icc-profile-auto on uninit
This was already correctly freed when acquiring a new profile, but never
freed on uninit. Fix by reparenting the profile onto `p`, which is what
vo_gpu also does.
2023-08-18 19:07:39 +02:00
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