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

6192 Commits

Author SHA1 Message Date
sfan5
f36ab2c609 wayland_common: free DND resources on shutdown and error
This leaked only in edge cases, if at all.
2024-02-29 17:24:05 +01:00
der richter
15c48f3dc1 cocoa-cb: render on main queue instead of dedicated queue
initially we drew on a dedicated render queue to circumvent certain
bottlenecks on the main queue, like concurrent events that could lead
to late drawing.

though due to the way cocoa works we need to draw an the main queue
otherwise we get undefined behaviour that could lead to crashes.

Fixes #10276
2024-02-29 16:40:52 +01:00
der richter
7758f6f50e mac/vulkan: set NSView as layer delegate like recommended by MoltenVK 2024-02-29 16:38:10 +01:00
der richter
be6c22f93b mac/vulkan: remove old deprecated VK_MVK_macos_surface extension remains 2024-02-29 14:06:14 +01:00
Kacper Michajłow
0897604298 various: avoid function pointer casts
The opt validator functions are casted to generic validator, which has
erased type for value. Calling function by pointer of different
definition is an UB.

Avoid that by generating wrapper function that does proper argument type
conversion and calls validator function. Type erased functions have
mangled type in the name.

Fixes UBSAN failures on Clang 17, which enabled fsanitize=function by
default.
2024-02-28 16:04:02 +00:00
der richter
86fa9b18a3 osdep/mac: make mac naming of files, folders and function consistent
rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to
make naming consistent.
2024-02-28 15:52:47 +01:00
Dudemanguy
661f45377a wayland: drop some unneeded curly braces (no-op)
Not sure why all of these single line if's were being braced. Probably
some cargo cult from years ago but might as well fix it now since it's
bothering me.
2024-02-27 22:18:12 +00:00
Dudemanguy
f0a6578259 wayland: drop buffer scale for cursor as well
Could have been done in e32554cd57, but I
skipped it there. However, using viewporter is actually a win here.
There's been a longstanding issue in upstream wayland* exactly related
to this. I even forgot about cd7a7a1de8
which was made for this exactly problem and explains the random
spawn_cursor calls. Anyways, just not using buffer scale and instead
scaling the cursor surface via viewporter works just fine and completely
sidesteps this problem. This means we can drop the random looking
spawn_cursor calls and some additional checks.

*: https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
2024-02-27 22:18:12 +00:00
Dudemanguy
34c0a67ace wayland: rename configured to geometry_configured (no-op)
Makes it clearer.
2024-02-27 22:18:12 +00:00
Dudemanguy
7b03a2ff17 wayland: fix check for set_surface_scaling
We don't want to use this if we have fractional scaling or version 6 of
the wl_surface interface which has a preferred buffer scale event which
is superior to this. We were checking in the important place (surface
entrance events) but not technically in the output. So just move the
conditional to set_surface_scaling itself. Also through the VO_EVENT_DPI
in there for convenience.
2024-02-27 22:18:12 +00:00
der richter
c15307244f mac: remove unnecessary metal layer colour space update
this logic was copied from the cocoa-cb opengl backend, since it was
assumed both layers work similar. apparently they don't and a nil value
on the metal layer means use the display colour profile, while on the
opengl layer it means undefined behaviour.

this also fixes a problem with the target-colorspace-hint option, since
moltenvk needs to set this colour space itself for a proper hint. both
mechanism would compete to set the colour space.
2024-02-27 14:03:15 +01:00
der richter
7a1b387aa9 mac: set layer content scale on init
usually the content scale updates automatically, though on init it is
possible the wrong scale is used for the initial rendering leading to a
wrongly sized surface.

properly set the initial content scale of the layer.
2024-02-27 14:02:08 +01:00
der richter
a7c4a113b8 cocoa-cb: remove pre-allocation and initialise only when used
cocoa-cb was always pre-allocated in the Application itself because
libmpv needs to be set up before usage, an opengl context has to be set
and because it was decided mac specific code should be kept out of
libmpv.

this means that a completely working libmpv and opengl renderer was set
up even if it wasn't used. leading to unnecessary log message, resources
being used or reserved on the system that might not be used, triggering
of dedicated GPU unnecessarily and many other things.

even if not optimal, this wasn't the biggest problem since we only had
that one working vo on macOS. though now that we have a vulkan
gpu(-next) backend on macOS that was made the default, we always have
that dangling cocoa-cb instance, which is completely unnecessary.

move the cocoa-cb initialisation into libmpv preinit function and only
init cocoa-cb when we are a standalone App and cocoa-cb support is build
into.
2024-02-27 14:01:38 +01:00
Dudemanguy
fa0fccc2a7 vo_gpu_next: simplify pl_clear_mode enum mapping
No reason for there to be two columns and this also fixes a
-Wenum-conversion warning on clang.
2024-02-26 20:07:43 -06:00
Dudemanguy
bc4003d219 vo_gpu_next: add --border-background option
Allow for setting the border background independently from the
background option.
2024-02-26 16:46:00 +00:00
Dudemanguy
be198c0f0a vo_gpu_next: support --background option
Requires using the new pl_clear_mode enum in libplacebo.
2024-02-26 16:46:00 +00:00
Dudemanguy
183f63c8c9 vo_gpu: pre-multiply alpha when dealing with background colors
This was simply wrong for who knows how long.
2024-02-26 16:46:00 +00:00
Dudemanguy
c72c47204d vo_gpu/vo_gpu_next: rework --alpha into --background option
The --alpha option currently covers two related but different concepts:
whether or not to ignore the alpha component and possibly blending it
with a background. Because of the way the option currently works, it is
impossible to have a transparent window (which requires setting
--alpha=yes) while blending it with the background at the same time. To
solve this, let's rework it so it it superseded by the background
option.

--background controls what kind of background to set for the image if
possible. It can be blended with the set background color, with tiles,
or not blended at all (the last one is still broken on X11/mesa except
for GLX, *sigh*). In this new paradigm, --alpha=no has no real purpose
because you can simply set the background to color and whatever color
you want for exactly the same effect. So the option is removed. Instead,
the hint set by windowing backends (i.e. setting
ra_ctx->opts.want_alpha) can by done with the --background option.

As an aside, the colors in vo_gpu are currently bugged due to not
pre-multiplying the alpha and it seems no one ever noticed. The next
commit fixes that. vo_gpu_next support happens latter since it requires
new things from libplacebo.

Fixes #9615.
2024-02-26 16:46:00 +00:00
Dudemanguy
c774b5f517 player: rename --background to --background-color
This better represents what it actually does. --background will be used
for another, related option in the next commit.
2024-02-26 16:46:00 +00:00
Dudemanguy
b7fd232524 vo_gpu/vo_gpu_next: set ctx->opts.want_alpha in specific functions
Currently this was being duplicated on init and on runtime updates
between both VOs. Since the conditions for setting this will get more
complicated in the future commits, it's better to just handle it in one
place. We could combine the vo_gpu and vo_gpu_next handling into one
single function but vo_gpu_next has an additional condition for
determining alpha that vo_gpu_does not, so we'll leave these separate
for simplicity. Also this technically fixes a memory leak where gl_opts
weren't being freed.
2024-02-26 16:46:00 +00:00
sfan5
bbbc0e248b hwdec/dmabuf_interop: reduce magic constant use 2024-02-26 17:37:20 +01:00
sfan5
73556036a2 hwdec/dmabuf_interop_gl: migrate to EXT_EGL_image_storage on desktop GL
As it turns out OES_EGL_image is only defined for OpenGL ES.
OpenGL drivers implement this extension anyway because it used to be
the only way of importing EGLImages into GL.

An equivalent extension for OpenGL was defined with EXT_EGL_image_storage.
The only difference is the interaction with immutability, which requires
textures to be recreated since they can be bound only once.

Note: this commit can in theory cause certain systems to lose vaapi / drmprime
support. Since EXT_EGL_image_storage is 7 years old this hopefully doesn't happen.
If it does, the init checks can be relaxed to still permit OES_EGL_image.
2024-02-26 17:37:20 +01:00
sfan5
1ae0282c1b hwdec/dmabuf_interop_gl: refactor texture creation
no functional changes in preparation for the next commit
2024-02-26 17:37:20 +01:00
sfan5
c294408ce0 hwdec/dmabuf_interop_gl: restyle macros to fit line length 2024-02-26 17:37:20 +01:00
sfan5
861e9566f6 video: don't define IMGFMT_VULKAN conditionally
We generally try to avoid that due to the #ifdef mess.
The equivalent format is defined in ffmpeg 4.4 while our interop code
requires a higher version, but that doesn't cause any problems.
2024-02-26 17:37:20 +01:00
Dudemanguy
76472e1ba8 wayland: remove old sway/wlroots hack
It's actually been like this for years, but wlroots doesn't keep track
of resizes a client does independent of the compositor. When using sway,
this leads to weird behavior with floating clients resizing themselves
back to the old size if you unfocus it. mpv has been working around this
for a long time, but it's really annoying to selectively ignore events
based on a weird heuristic. Since Sway finally fixed this bug, let's go
ahead and drop this crap. Note that other wlroots compositors may
possibly experience a regression if they didn't correct for this like
sway does, but it's for their own good.
2024-02-26 15:51:16 +00:00
nanahi
6ecdedabe5 vo_gpu_next: fix win32 io wrap
Fixes 84015959cc
2024-02-26 09:37:24 +01:00
David Vaughan
a8a314b829 input: add insert-next support for drag-and-drop
This commit adds a DND_INSERT_NEXT action option for drag-and-drop,
allows for selecting it through the --drag-and-drop=insert-next option,
and adds the necessary plumbing to make that happen when something is
dragged onto the player.
2024-02-26 02:03:21 +00:00
nanahi
3e8d69e3e8 image_writer: cleanup leftover files if image writing fails
This avoids leaving an empty/corrupt file if fopen succeeds but
image writing fails afterwards.
2024-02-25 11:37:44 +01:00
Dudemanguy
17d9abd08f player/command: handle runtime toggling of hidpi-window-scale
Wayland was the only backend that attempted this, but it can be done in
a centralized place for anything that supports this. hidpi-window-scale
is just the same as a normal window scale but with the OS DPI as the
factor.
2024-02-24 20:31:08 +00:00
Dudemanguy
a3648ddac8 win32: clean up hidpi window scale behavior
Same as X11. An accurate dpi scale should always be reported and
UNFS_WINDOW_SIZE shouldn't take dpi scale as an additional multiplier.
2024-02-24 20:31:08 +00:00
Dudemanguy
006822434a x11: clean up hidpi-window-scale behavior
Several related things but in a nutshell makes it more like wayland.

1. Remove unneeded --hidpi-window-scale checks. The backend should
   always report the actual dpi value regardless of what this option
   says.
2. Remove dpi_scale factors from UNFS_WINDOW_SIZE VOCTRLs. It makes
   things more complicated and unintuitive for no reason. A window scale
   of 1 should mean 1. It annoyed a few years ago in #9437, and I agree
   with them (wayland was never implemented like this).
3. Change the dpi log messages to be more brief and remove the unneeded
   comments about prescaling.
2024-02-24 20:31:08 +00:00
nanahi
3e17d9da8f vo_gpu: use fbo texture height for fragment coordinate calculation
Previous fix only worked when the video output doesn't have vertical
black bars. This fixes the cases like fullscreen, video-zoom etc.

Fixes: https://github.com/mpv-player/mpv/pull/13528
2024-02-24 21:12:17 +01:00
nanahi
84015959cc osdep/io: move I/O utility functions to misc/io_utils
The purpose of osdep/io is to provide a wrapper for POSIX I/O functions
on Windows. The last 2 functions are utility functions which don't serve
this purpose.
Move them to a separate file.
2024-02-23 21:35:57 +01:00
nanahi
ae1a4ed28a vo_gpu: fix fragment coordinate calculation when dithering
When doing the dithering pass, the fragment coordinate is queried, but
doesn't take the fbo texture flipped property into account. This results
in different dithering patterns when toggling between fbo flipped and
non-flipped state. This can be reproduced with --vo=gpu --gpu-api=opengl
and easily seen with --dither-depth=1 when toggling between playing and
pausing.

Fix this by flipping the fragment y coordinate if the fbo is flipped
when calculating dithering coordinate.
2024-02-22 12:35:40 +01:00
nanahi
74f2260cd6 vo_gpu: fix fragment coordinate calculation when drawing checkerboard
When redrawing cached frames while the fbo texture is flipped,
the texture after drawing to screen pass will be flipped when blitting.
However, when rendering the checkerboard, the fragment coordinate
doesn't take this into account, so the coordinate before flipping is used,
resulting in different checkerboard location when toggling between
flipped and non-flipped state. This can be reproduced with --vo=gpu
and --gpu-api=opengl: the checkerboard patterns when playing and
pausing are different (vertically flipped).

Fix this by flipping the fragment y coordinate if the fbo is flipped
when calculating checkerboard coordinate.
2024-02-22 12:35:40 +01:00
nanahi
531704e35d x11_common: handle window dragging in ButtonPress event
Begin the _NET_WM_MOVERESIZE window dragging in ButtonPress event
to match the behavior of win32 and wayland, simplify logic by dropping
the win_drag_button1_down hack required by the old method, and fix a race
condition described in commit 19f101db68,
which happens when moving the mouse and releasing the button at the same time.

The race condition can be easily triggered when using a touch screen
(tested with libinput driver), where a tap is translated to MotionNotify,
ButtonPress, MotionNotify, and ButtonRelease in sequence, with the last 2
events having the same timestamp. This has caused some window managers to
not stop dragging after the ButtonRelease, resulting in window being stuck
in dragging state after a single tap.
2024-02-21 22:39:28 +01:00
der richter
d954646d29 various: make mentions of macOS consistent
change all mentions and variations of OSX, OS X, MacOSX, MacOS X, etc
consistent. use the official naming macOS.
2024-02-21 20:46:53 +01:00
der richter
0e441525cf vo: make libmpv last in the auto-probing order for cocoa-cb only
this partially reverts commit 7b5a258. back then the only properly
working vo on macOS was cocoa-cb (libmpv). it would always use the
deprecated opengl cocoa backend or no vo at all. because of that libmpv
was moved to the top of the auto-probing order, so the preferred vo
was used on macOS only.

we now have a working vulkan gpu/gpu-next backend on macOS which should
be the new default vo. though disabling the auto-probing again for
libmpv would probably cause the undesired behaviour on macOS that
cocoa-cb would never be auto selected again. especially if not build
with vulkan support or without vulkan driver on macOS, this would lead
to no video output at all. so instead of completely reverting the
mentioned commit, we instead move libmpv to the bottom of the
auto-probing order but only auto select it when mpv was built with
cocoa-cb support. this restores the previous behaviour on all other
platforms besides macOS, but also lets us auto select cocoa-cb if
supported.
2024-02-20 20:42:02 +01:00
Julian Orth
0ef78c1aa5 wayland_common: update pointer serial on pointer_enter 2024-02-18 18:21:02 +00:00
der richter
ac275a823d cocoa-cb: lock CGLContext on uninit and manual redraw
this fixes a crash on quit, when a CATransaction from a system owned
thread/event is happening at the same time. locking the context
synchronises these access and prevents the race condition.

the draw operation induced by any display call from the CAOpenGLLayer
doesn't need that lock, since the display function already does lock
that current context.

Fixes #11681
2024-02-18 17:25:05 +01:00
Dudemanguy
bd5b80ba2c vo_gpu_next: fix some lut-related memory leaks 2024-02-17 18:56:20 +00:00
Dudemanguy
85e84f6d92 vo_gpu_next: move gpu-next opts to specific sub option
This matches the general workflow in the codebase. We keep a cache of
these new options and update them if needed.

Fixes #13481 and fixes #11518.
2024-02-17 18:56:20 +00:00
Dudemanguy
073858fcdd vo: remove VOCTRL_SET_EQUALIZER and simplify into UPDATE_VIDEO
Since 03cf150ff3, the only purpose of this
VOCTRL was to signal a redraw to the vo. It actualy could have been
removed in 531868fe0d, but this was
missed. The UPDATE_VIDEO flag is better anyway because it allows us to
handle a wide variety of options scattered around that require the VO to
update itself and redraw. We can remove both of the custom callbacks in
vo.c and only leave the VOCTRL_VO_OPTS_CHANGED one. Additionally, that
commit also introduced vo_set_want_redraw, but this is redundant and not
needed. The VOs that use VOCTRL_UPDATE_RENDER_OPTS already set
vo->want_redraw, and those are the only VOs where these options are
relevant in the first place. So we can remove this as well and just let
the big callback in player/command do everything.
2024-02-17 18:56:20 +00:00
nanahi
fb33bb7fc4 wayland_common: drop shape device check when spawning cursor
It's only necessary to check the existance of cursor_shape_manager.
Also drop the pointer check to handle multi-seat since a removed seat
sets the cursor_seat to NULL.
2024-02-17 16:09:41 +00:00
nanahi
b441a5dd1f wayland_common: properly determine has_keyboard_input
Track has_keyboard_input per seat and consider mpv having keyboard input
if at least one seat has keyboard input.
2024-02-17 16:09:41 +00:00
nanahi
a6ae2e7e60 wayland_common: handle scroll accumulation for each seat
Since it's needed to determine whether an axis event has axis_value120,
do this per seat to avoid interference between seats.
2024-02-17 16:09:41 +00:00
nanahi
04bc6a4a43 wayland_common: handle keyboard state per seat
Avoids modifiers from mulitple seats from interfering with each other
and messing up xkb states.
2024-02-17 16:09:41 +00:00
nanahi
b6dcf9ecee wayland_common: set cursor visibility for all seats for voctrl
For VOCTRL_SET_CURSOR_VISIBILITY, set cursors visibility for all seats.
The return is VO_NOTAVAIL is none of the seats have cursor, and
VO_FALSE if setting visibility failed for at least one seat.
2024-02-17 16:09:41 +00:00
nanahi
b86768b356 wayland_common: handle removal of seats 2024-02-17 16:09:41 +00:00
nanahi
cdca02a34d wayland_common: prevent cursor_seat stale reference
Set it to NULL on vo uninit.
2024-02-17 16:09:41 +00:00
nanahi
a593a9ec12 wayland_common: handle cursor_shape_device per seat
The cursor_shape_device is per pointer, which is per seat. Handle it
together with other seat objects. This in turn also handles cursor
visibility per seat.
2024-02-17 16:09:41 +00:00
nanahi
27d973ba34 wayland_common: drop unnecessary xdg_toplevel null check
The vo init already fails if xdg_toplevel creation fails, so these
checks after the vo is initialized is unnecessary.
2024-02-17 16:09:41 +00:00
nanahi
2274311b25 wayland_common: implement multi-seat support
On a multi-seat setup, wl_registry_global advertises wl_seat multiple times,
one for each seat. if wl->seat is already set, the previous value will be
overwritten, preventing it from being freed.

Additionally, if the latter seat doesn't have the capabilities of the
former seat, the keyboard/pointer/touch input devices will be destroyed
because the current wl_seat_capabilities doesn't distinguish between
different seats. This casues keyboard/pointer/touch not working if the
latter seat has no such capabilities.

Fix this by implementing multi-seat support.
This allows receiving inputs from all devices on all seats.
All seat-specific objects (wl_keyboard/pointer/touch, wl_data_device)
are grouped with their respective seats so they can be managed together.

Note that currently inputs from all seats are interleaved with each other
and modify the same global input states.
2024-02-17 16:09:41 +00:00
nanahi
5557eda842 wayland_common: indentation nit 2024-02-17 16:09:41 +00:00
nanahi
e0ddc0f69e vulkan/context_win: make --alpha work and runtime changeable
If libplacebo manages to create a vulkan swapchain that allows
alpha composition mode to be controlled by the DWM API,
this makes it runtime changeable.
2024-02-17 16:06:33 +00:00
nanahi
095038b1bc opengl/context_win: make --alpha runtime changeable
Same as d3d11, but since SetPixelFormat can be only called once,
cAlphaBits in PIXELFORMATDESCRIPTOR must be set to make this work.
2024-02-17 16:06:33 +00:00
nanahi
8de67a4af5 d3d11: make --alpha runtime changeable
The DWM compositor transparency API is runtime changeable.
Handle this in update_render_opts.
2024-02-17 16:06:33 +00:00
nanahi
117622cd4a opengl/context_win: make --alpha=yes work
Specify cAlphaBits in PIXELFORMATDESCRIPTOR makes the pixel format
transparent, as is already the case for d3d11. Also makes the
window transparent when --alpha=yes is used.

Works on --vo=gpu and --vo=gpu-next.
2024-02-17 16:06:33 +00:00
nanahi
a61026aec3 d3d11: set window to transparent if --alpha=yes is specified
This makes --alpha=yes work with d3d11 and --d3d11-flip=no.
transparent window doesn't work with flip model swapchain by design.
2024-02-17 16:06:33 +00:00
nanahi
cef378b0a3 w32_common: add function to control window transparency state
Use the DWM API to enable and disable compositor transparency.
2024-02-17 16:06:33 +00:00
Dudemanguy
c0c32b270e vo_gpu_next: don't add 0 width/height sub bitmaps to pl_overlay
Previously, libplacebo would fail to render the image since mpv was
feeding it bogus bitmaps with 0 width/height. An easy way to encounter
this would be to set sub-scale to 0 with bitmap/image subs.
2024-02-16 22:46:31 +01:00
Dudemanguy
25bba7c811 vo_gpu_next: move the frame->redraw check for blended subtitles
Cosmetic. Since the previous commit eliminated wasteful redraws, nuke
the comment while we're at it.
2024-02-15 16:43:11 +00:00
Kacper Michajłow
5098a27e66 vo: ensure that frames are not eaten on reconfig
This avoids clearing the queued frame and the currently displayed one on
VO reconfiguration requests that happen when new frames arrive. Instead,
let those frames be fully displayed.

Fixes mf:// playback issues introduced after commit ef11d31.

Instead of removing the frame timing check embrace and fix it to wake up
the playloop as needed. The frame display duration is problematic to
handle as both VO and playloop thread would already be sleeping, but in
certain use cases it is needed to display frames in full, so in this
case, let the VO sleep to the end of frame, wake up the core as
requested and go back sleeping.

Note that this patch series reintroduces 0c9ac5835, which is esenitally
fixed in this commit. It is still not perfect, but it is better than
just busy waiting on playloop, even if those events when this would be
needed are quite rare.
2024-02-15 16:39:58 +00:00
Kacper Michajłow
a329bb546c Reapply "video: remove another redundant wakeup"
This reverts commit 44c398c3e1.
2024-02-15 16:39:58 +00:00
Kacper Michajłow
0bf4da0f5e Revert "vo: remove frame timing check from vo_still_displaying()"
This reverts commit ef11d31c3a.
2024-02-15 16:39:58 +00:00
sfan5
4981690fb6 x11_common: fix Xft.dpi detection ignoring --hidpi-window-scale
closes #13466
fixes: 4b69164147
2024-02-12 13:51:25 +01:00
nanahi
71598ca07e various: replace dead links in comments
Replace various dead links with live replacements or archives.
Less friction for anyone who wants to look up these references.
2024-02-11 04:01:24 +00:00
Guido Cella
86e0882733 wayland: don't press keys again when releasing modifiers
Since 1f8013ff3f, if you release a modifier before a regular key on
Wayland, that key gets immediately pressed again because
keyboard_handle_modifiers() calls mp_input_put_key() regardless of
whether a modifier is pressed or released, e.g. if you press Ctrl+s it
easy to take an another screenshot with s by accident. Fix this by
releasing keys when releasing modifiers.

Ideally, releasing the modifier should input the key alone after
--input-ar-delay, while this patch disables it forever, e.g. on X11 if
you type something in the console, hold Ctrl+h, and release Ctrl, it
starts typing h instead of deleting characters. This doesn't work
because keyboard_handle_key() is only called when you first press a key,
while on X11 KeyPress keeps getting sent as you hold down the key. But
this difference in behavior between X11 and Wayland can also be
reproduced with GTK and Qt applications, so I guess this is acceptable.
2024-02-11 04:01:14 +00:00
Philip Langdale
f5c4f0b0f4 hwdec_drmprime: check for AV_PIX_FMT_P210 before using it
This isn't present in older ffmpeg releases.

Fixes #13454
2024-02-10 13:29:04 -08:00
Dudemanguy
a45518cf57 wayland: set current_output on surface leave if applicable
When the mpv surface leaves the output, we no longer mark it as the
current output. However, this implicitly depends on there being a
preceding surface entrance event to a different output. This is not
necessarily the case. Consider moving the window from monitor 1, to
monitor 1-2, and then back to 1 again. mpv gets the entrance event to
monitor 2 and sets that as the current output to work off of. Then when
you move back to only monitor 1, it removes monitor 2 from the current
output. However, monitor 1 is not updated again as the current output
because there is not a new surface entrance event in this case (the
window never left). So the numbers that mpv's core is using are
incorrect and for the wrong monitor. Luckily, we already keep track of
what outputs the mpv surface is currently on no matter how many there
are so it is simply a matter of setting current output again in the
leave event if we have a different output that has the mpv surface.

Ref: https://github.com/swaywm/sway/issues/7932
2024-02-08 22:26:15 +00:00
Kacper Michajłow
9ce2bafbe9 vo_vdpau: cosmetic changes to timings
Remove unneded range check.
Print time difference with more precision.
Use the same data formats for fps and interval as in other VOs.
2024-02-07 14:45:07 +00:00
Dudemanguy
343a5fd345 player: remove all rpi-specific code
vo_rpi and its related code has pretty much historically been a
disaster in mpv. The build regularly gets broken and since nobody uses
it, it takes months for anyone to notice. There was also that time where
fullscreen was broken for about a year and a half. Also building in waf
was entirely broken for about a couple of years or so due to mysterious
reasons no one ever figured out (meson magically fixed it).

Anyways, once again the build is broken due to rpi being forgotten about
again, but instead of pretending to support this crap. Just drop it all.
Nowadays, mmal hwdec is a relic since these devices are better off using
the v4l2m2m ffmpeg fork instead which actually uses KMS properly. RPI 1
and 2 probably can't do this and will remain broken but oh well blame
Broadcom for being special snowflakes and not using standard APIs (my
rockpro worked out of the box; just saying). RPI 2 is nearly 10 years
old anyways, so I think you can afford a new SBC by now. If we were
nicer, there would be a deprecation period, but this is broken in the
last major release anyway so too late.

Closes #13402.
2024-02-05 17:41:06 +00:00
Dudemanguy
531868fe0d player: ensure runtime updates of certain rendering options
When adding things like brightness or gamma, the video obviously needs a
redraw if paused. This happened to work in the normal case because the
OSD notification triggered a redraw, but if you use no-osd the picture
won't change. Fix this by adding another option flag, UPDATE_VIDEO, and
simply signalling we want a redraw. This gets handled along with the
normal osd redrawing check in the playloop so something like "no-osd add
gamma 1" actually works.
2024-02-05 17:23:47 +00:00
Dan Oscarsson
b23e8b2ffb vo_vdpau: fix timing for nanoseconds
df764bc0c3 and
c82c55b4b9 blindly converted the units for
this VO since neither of us actually have the hardware/setup to test the
VO. Well it was not actually correct (maybe just one was wrong or both
who knows) since vo_vdpau using timing very differently than all the
other VOs and no one reported on it until just now. Anyways, just apply
this random patch from @DanOscarsson which apparently works for him and
call it a day. Fixes #13397.
2024-02-04 10:01:49 -06:00
nanahi
27cb193f0e wayland_common: warn if scrolling will be broken
Since the scroll event handler is moved to wl_pointer_frame, version 5 of
wl_seat is required. Warn that scrolling is broken if the compositor
doesn't support that verison.
2024-02-04 02:14:11 +00:00
nanahi
e0f9cf61b9 wayland_common: add touch listener boilerplate
Required if seat version >=6 is used.
2024-02-04 02:14:11 +00:00
nanahi
b3edb46fd9 wayland_common: prefer axis_value120 if supported
Prefer axis_value120 for high resolution scrolling if supported, which
matches the existing win32 behavior.
2024-02-04 02:14:11 +00:00
nanahi
f95b7146d7 wayland_common: properly handle high resolution scrolling
Commit f54ad8eb05 broke high resolution
scrolling because one logical mouse click is generated for every scroll
event, no matter the magnitude. This makes scrolling on trackpad way
too fast.

Revert the axis scaling change in that commit and clamp the resulting
value between -1 and 1 to make sure mouse wheel scrolling works as
intended on compositors which send a value larger than 10 for these events.
2024-02-04 02:14:11 +00:00
nanahi
aaaadc9d6b x11_common: support --title-bar
Some X11 window managers support controlling the title bar independently
from other window decorations with _MOTIF_WM_HINTS. This allows hiding
the title bar while keeping other decorations like the resizing borders.

Let mpv respect the --title-bar option on X11 so --no-title-bar can hide
the title bar only like on win32.
2024-02-02 11:39:30 +01:00
Dudemanguy
adcc6794b5 wayland: look for "default" cursor as well as "left_ptr"
Some themes are apparently getting rid of "left_ptr" and using the
cursor spec names instead. Check for "default" as well. Fixes #13376.
2024-02-01 15:26:46 +00:00
Kacper Michajłow
e2e75906da io: add mp_save_file
Move from vo_gpu_next.c to io.c and return result.
2024-01-31 15:38:21 +00:00
Kacper Michajłow
69891c4070 vo_gpu_next: save cache to separate files
Save the cache to separate files to avoid loading/saving a huge combined
libplacebo.cache. This approach allows the saving of only new cache
objects and avoids resaving the entire cache, especially even if only a
tiny change was made.

This commit improves the cold start time of mpv and avoids saving data
when it's not necessary.

Number of changes were made:
- each cached object is saved in its own file
- cache files are prefixed with the name of cached object
- cache directory is cleaned on each uninit
    - the least recently used cache files are removed if cumulative cache
      size is above limit
    - files used in the recent 24 hours are not removed to allow changes
      to mpv.conf without worrying about the cache being removed during
      experimentation
- shader cache size limit is set to 128 MiB
- icc cache size limit is set to 1.5 GiB
- cache objects are loaded/saved as needed

This commit eliminates the runtime performance penalty associated with
the size cache. While we continue to maintain the cache limit to prevent
retaining stale objects, mpv now only loads a small subset of files that
are currently required for playback, instead of loading all files.
2024-01-31 15:38:21 +00:00
boogie
d90a5ff17a hwdec_drmprime: add P010 and P210 support 2024-01-28 13:56:58 -08:00
sfan5
c6ccabe585 hwdec_aimagereader: handle lack of JNI gracefully
Hwdec drivers are always loaded so it's rude to abort.
fixes #13367
2024-01-27 22:35:25 +01:00
Kacper Michajłow
dd491c7c61 vo: change vo_frame duration to double
32-bit signed integer can hold ~2.1s stored as nanoseconds. While frame
duration doesn't make sense to be this long, the existing clamp is to
10s. Change type to double, which is consistent with other fields in
vo_frame.
2024-01-27 05:12:36 +00:00
Dudemanguy
c243946338 vo_dmabuf_wayland: scale smarter in hidpi situations
Previously, all scaling was forced to 1 with this vo and all coordinates
were calculated as if the scale was 1. This works since viewport relies
on the compositor completely for scaling so it doesn't really matter if
we don't draw directly to the correct size since the compositor will
just scale the rest for us. This does have some downsides however since
the OSD text might not be drawn at the actual resolution of the final
size of the video.

We can instead handle this by getting rid of the dmabuf_wayland specific
scaling logic and using the same values as everything else. In the
resize in vo_dmabuf_wayland, we just need to adjust the viewport
destination calls so they go to the wayland local coordinates and not
the physical ones. This should ensure that vo_dmabuf_wayland directly
goes to the desired size and the compositor doesn't need to operate on
it after the fact.
2024-01-27 05:12:12 +00:00
Dudemanguy
ded181f642 wayland: don't rescale dimensions if hidpi-window-scale is disabled
If the scaling value changed for some reason, the window geometry would
be recalculated with the new scaling even if this option was disabled.
Properly ignore it.
2024-01-27 05:12:12 +00:00
Dudemanguy
e32554cd57 wayland: drop buffer_scale use for viewporter
The core wayland protocol way of handling scaling is to use the
buffer_scale mechanism. But this sucks in several ways for reasons I
won't list here and fractional scaling rightly avoids this altogether
and uses a buffer_scale of 1 (i.e. not setting it) along with
viewporter. When originally implemented, this was only specifically used
when the fractional scale protocol was available, but we actually can
use it as a full replacement instead. This means that mpv now hard
requires viewporter, but this protocol is supported by everyone and is
one of the few that is actually stable.

How it works is the same regardless of fractional scaling or not. When
the compositor has a scale value not equal to 1, it will always scale
the client by that factor (unless you set buffer_scale). What we do here
is pass a viewporter size that exactly undos the compositor-side scale
(sans a possible rounding error). So what we are left with is just the
exactly physical pixels we want to display. Fixes #13316.
2024-01-27 05:12:12 +00:00
Dudemanguy
99d387bbc8 vo: ensure a dropped frame is always freed
7b8a30fc81 made it possible for a VO to
have direct ownership of frame objects since the it may be beneficial
for the frame to follow the lifecycle of that particular VO instead
(i.e. the wayland compositor for dmabuf-wayland). But when frames are
dropped, this always has to be unconditionally freed since the VO isn't
aware of it. Fixes #13364.
2024-01-26 22:56:50 -06:00
Kacper Michajłow
e9076896cd all: add missing repr assignments
Fixes: 66e451f4
2024-01-26 18:17:02 +02:00
Kacper Michajłow
431759c70c vo_gpu_next: simplify after recent changes 2024-01-22 14:54:55 +00:00
Kacper Michajłow
475f76dc6d csputils: replace more primitives with pl_
We can go deeper, but need to stop somewhere to not reimplement vo_gpu
using libplacebo...
2024-01-22 14:54:55 +00:00
Kacper Michajłow
47be5ad4aa csputils: replace mp_chroma_location with pl_chroma_location 2024-01-22 14:54:55 +00:00
Kacper Michajłow
0ac7a40dac csputils: replace mp_alpha_type with pl_alpha_mode 2024-01-22 14:54:55 +00:00
Kacper Michajłow
66e451f4e6 csputils: replace mp_colorspace with pl_color_space 2024-01-22 14:54:55 +00:00
nanahi
1ea9e51f78 win32: stop waiting for messages if the window is destroyed
GetMessageW will indefinitely block after the window is destroyed.
2024-01-21 17:54:57 +00:00
nanahi
a0ba10b62e command: export current-gpu-context property
This exports `current-gpu-context` property, which is the string
description of the current active GPU context. This allows scripts to
uniquely identify the platform and backend used for --vo=gpu
and --vo=gpu-next.
2024-01-20 17:12:07 +00:00
llyyr
a05c363b7f chmap: mp_image_pool: drop stale mentions of Libav in comments 2024-01-20 16:10:20 +00:00
Guido Cella
07dd577a6b libplacebo: fix out-of-bounds read with --really-quiet
With --really-quiet the message level is -1 which is not in the
msg_lev_to_pl_log enum, so handle it explicitly.
2024-01-20 16:09:54 +00:00
nanahi
146bef059a wayland_common: guard against negative configure sizes
Negative values are nonsense to mpv, and can cause protocol error afterwards,
like xdg_surface::set_window_geometry which doesn't accept negative values.
Treat any negative values as zero (client determines size) for now.
2024-01-19 23:55:52 +00:00
nanahi
9267600792 win32: change to alphanumeric mode on the first keypress
Needed in case the timer solution fails. Note that this will leave the
mode indicator in the language bar showing the original mode until
a key is pressed.
2024-01-15 16:06:06 +00:00
nanahi
758a9658d6 win32: default to alphanumeric input when the IME is first initialized
Some IMEs initialize to composition mode for new windows, which is
undesirable for keyboard control.
Default to alphanumeric input to solve this.
2024-01-15 16:06:06 +00:00
nanahi
7ffd947830 win32: move IME candidate window to video window
By default the IME candidate window appears on the top left corner
of the monitor. Move it to the video window for sane behavior.
2024-01-15 16:06:06 +00:00
nanahi
2b1024fa50 win32: handle WM_UNICHAR
WM_UNICHAR is sent by some 3rd-party IMEs.
2024-01-15 16:06:06 +00:00
nanahi
33e922eabe win32: re-enable IME
The IME is useful for text input. Additionally, Alt+Shift input language
switching doesn't work when IME is disabled even when the languages don't
require IME.

Re-add the VK_PROCESSKEY logic to ensure that IME is handled properly.

Reverts bf6b981367.
2024-01-15 16:06:06 +00:00
llyyr
bd35dc8ce7 wayland: accept active modifiers even if they aren't physically held
We don't care about the physical state of keys, only if they are
effective or not and whether they should affect key processing.
2024-01-13 17:10:52 +00:00
llyyr
02533e5928 wayland: don't ignore key modifiers if they were consumed
According to the xkbcommon docs, `xkb_state_mod_index_is_consumed` is
true when a modifier *may affect* key translation. A key modifier may
be consumed but not be active. See xkb documentation for this function
for further details. This breaks key modifiers in cases where
L_Shift+R_Shift for example is used to change keyboard layout with
`xkb_options grp:shifts_toggle`. Instead, replace it with a simple
check for a valid modifier.
2024-01-13 17:10:52 +00:00
nanahi
4b69164147 x11_common: prefer Xft.dpi for HiDPI scaling
Xft.dpi is much more widely used nowadays by GUI programs compared to
the X11 screen DPI.
This is the best we can get for a vendor-neutral scaling preference
value under X11 in terms of adoption.
If Xft.dpi isn't available, the X11 screen DPI is used as a fallback.
2024-01-10 00:33:05 +01:00
nanahi
a504e696c8 x11_common: allow DPI scale in unit of 0.5
~144 DPI displays are pretty common and neither 1x nor 2x scales are
the right size for it. Allow DPI scale in unit of 0.5 to fix this.

Additionally, add a note about the current behavior of the API used
to get the scale factor.
2024-01-10 00:33:05 +01:00
nanahi
41259db952 vo_gpu_next: respect d3d11 swapchain output format preference
Currently, libplacebo always tries to reconfigure the d3d11 swapchain
to a 10-bit output format because disable_10bit_sdr isn't set to true,
even when an 8-bit format is explicitly requested via
--d3d11-output-format.

Fix this by passing the requested output format preference to libplacebo.
Document that this option may be ignored.
2024-01-06 23:46:12 +01:00
Guido Cella
a16bad4004 vo_sdl: support the focused property 2023-12-29 11:31:18 +01:00
nanahi
26df531b14 win32: add support for --input-cursor-passthrough option
This completes the support for all supported desktop platforms.
2023-12-28 15:45:24 +00:00
sfan5
9565675488 various: use correct PATH_MAX for win32
In commit c09245cdf2
long-path support was enabled for mpv without actually
making sure that there was no code left that used the
old limit (260 Unicode chars) for buffer sizes.
This commit fixes all but one case.
2023-12-27 22:55:56 +01:00
der richter
4d7763e6a6 mac: add support for --input-cursor-passthrough option 2023-12-25 13:59:48 +01:00
der richter
0d47e48437 mac: add support for --auto-window-resize option
Fixes #9325
2023-12-23 01:15:53 +01:00
der richter
fa4ca16f66 mac: update geometry/autofit opts on runtime 2023-12-23 01:15:53 +01:00
Philip Langdale
ef56c0c20a hwdec_drmprime: try and declare support for weird forked ffmpeg formats
As a result of the work I did the explicitly check for formats
supported by the vo in the f_autoconvert logic, I introduced a
regression in the handling of the rpi4_8 and rpi4_10 formats. These
require special handling because they only exist in the rpi forks and
not upstream ffmpeg, which means they don't have stable pix fmt values
that we can use directly.

Previously, we simply didn't declare them as supported, which was ok,
as nothing was really enforcing the list of supported formats, but that
has changed.

As we still can't simply use the pix fmts, I had to do a slightly
ridiculous dance to look them up by name, and if they exist, then
register them as supported.

Good times.
2023-12-15 14:17:19 -08:00
Dudemanguy
f575b3d1bd w32_common: remove executable bit from file
5736737750 mistakenly changed the mode
from 644 to 755. Change it back.
2023-12-15 10:27:44 -06:00
der richter
c661435648 mac: add support for drag-and-drop option 2023-12-15 16:59:52 +01:00
der richter
f805b180d0 mac: add support for window-id property
returns the NSWindow
2023-12-15 09:20:10 +01:00
nanahi
566a96f220 w32_common: rename some camelCase struct member names to snake_case 2023-12-10 16:35:40 +01:00
nanahi
66ebce758f win32: temporarily disable aero shake while dragging hack is active
The dragging hack can cause unwanted aero shake activation.
Prevent this by saving the window arrangement state before dragging,
temporarily disable it while dragging hack is active, and restore to
the original state after dragging ends.
2023-12-10 16:35:40 +01:00
nanahi
5736737750 win32: stop fullscreen window from moving while dragging hack is active
The mouse down handler checks w32->current_fs to determine whether
to begin the dragging hack. Unfortunately, the w32->current_fs value
is stale, because the input is handled asynchronously, and we cannot
wait for an up-to-date value if dragging needs to be kept resonsive.

As a result, when the fullscreen state changes after the dragging
model loop is entered, the opposite value is used, so the window stays
draggable after entering fullscreen, and becomes undraggable after
exiting fullscreen.

With the resonsiveness and model loop constraints, the up-to-date
state must be queried inside WM_MOVING messages which are sent while
dragging. The message handler now checks if the dragging hack is active
while the window is in fullscreen, and overrides the new window position
with the current one, in effect prevents the window from being moved.

The old check is also removed, so the window is now draggable after
exiting fullscreen while dragging hack is active.
2023-12-10 16:35:40 +01:00
nanahi
5cc810e7f8 x11_common: fix compose key handling
Compose key doesn't function in X11 because XFilterEvent() isn't called,
and XNInputStyle is set to a wrong value. This results in KeyPress events
for the separate keyboard inputs in the compose key input sequence
instead of the composed character, making it impossible to input certain
characters which require compose key.

Fix this by calling the required XFilterEvent() and set XNInputStyle
to the correct value.
2023-12-10 14:55:41 +01:00
nanahi
79068baf43 win32: properly handle WM_XBUTTONUP and WM_XBUTTONDOWN
According to MS documentation, an application should return TRUE from
WM_XBUTTONUP and WM_XBUTTONDOWN if it processes these messages.
DefWindowProc generates the WM_APPCOMMAND message when it processes the
WM_XBUTTONUP message, so if an application properly handles WM_XBUTTONUP
messages, extra WM_APPCOMMAND messages won't be generated.

Because mpv doesn't properly handle these messages,
WM_XBUTTONUP causes APPCOMMAND_BROWSER_BACKWARD to be generated, resulting
in duplicated keys and improper fix 438ead7a, which prevents the processing
of the appcommand from sources other than mouse clicks.

Fix this by following the documentation, and the back and forward
appcommands can be added.
2023-12-06 11:07:37 +01:00
nanahi
4c47dbe22c input: add missing forward media key
XF86Back and XF86Forward are mostly used to navigate file and web browsers
to go back/forward in history. XF86Forward isn't recognized right now,
so add it.

Because XF86AudioForward already takes the "FORWARD" name, rename the
browse keys to GO_BACK and GO_FORWARD instead.
2023-12-06 11:07:37 +01:00
Kacper Michajłow
06e627048f image_writer: default to lossless AVIF screenshots
Also change the example to crf=23. crf=32 is pretty bad quality, don't
give users bad usage ideas.
2023-12-04 20:34:17 +01:00
Kacper Michajłow
fca3e60827 image_writer: add missing mp_image_params in convert_image
Fixes chroma location for screenshots.

Also set the crop to full frame to not trip mp_image_params_equal check
if not necessary.
2023-12-04 20:34:17 +01:00
Kacper Michajłow
a722194684 image_writer: print screenshot format in verbose log
It is useful information, not only for debugging.
2023-12-04 20:34:17 +01:00
Kacper Michajłow
4949cab734 image_writer: use common format selection for AVIF screenshots
--screenshot-avif-pixfmt no longer defaults to yuv420p.
2023-12-04 20:34:17 +01:00
der richter
f551a9da34 mac: report modifier keys on precise scrolling
modifier keys weren't reported when using the trackpad to scroll.

Fixes #11195
2023-12-02 14:59:59 +01:00
der richter
aaff9edf57 mac: fix initial window size and position when already maximized
in the case the window was already set to a maximized size via geometry
or related options (100%x100%) the maximize function would try to
maximize the window again. this reset the position and slightly
increased the size further.

to prevent this only maximize on init if we really want to maximize. in
the reverse case make a noop call by passing the current zoom state.

Fixes #11193
2023-12-02 14:58:01 +01:00
Dudemanguy
8f1f188bd6 vo_gpu: fix ra_fbo stack-use-after-scope
281b1d8999 introduced a stack use after
scope because dest_fbo can be reassigned a new pointer and then be used
by pass_draw_to_screen outside of that scope where the pointer is no
longer valid. Fix this by rearranging the variables so the assignment is
done in the same scope as the pass_draw_to_screen call instead.
2023-11-28 18:47:05 +00:00
Kacper Michajłow
0262ec3829 vo_kitty: init all fields of struct sigaction before using it 2023-11-28 10:46:16 +01:00
Kacper Michajłow
e27eb3dead ra_pl: add missing initializer 2023-11-28 10:46:16 +01:00
Kacper Michajłow
d5222ece6b vo: don't pass VADRMPRIMESurfaceDescriptor by value 2023-11-28 10:46:16 +01:00
Kacper Michajłow
f2fdea9921 wayland: simplify reading data
- read directly to bstr
- use talloc for OOM checks
- don't parent temporary allocation
- don't check for NULL buffer after already writting to it
2023-11-28 10:46:16 +01:00
Kacper Michajłow
4e84ea22d7 mp_image: remove local params copy from mp_image_setfmt
No longer needed after 079f67268f.
2023-11-28 10:46:16 +01:00
Kacper Michajłow
c78f0237ef vo_gpu: don't pass gl_user_shader_hook by value 2023-11-28 10:46:16 +01:00
Kacper Michajłow
3b1cb5d6aa vo_gpu: don't pass mp_pass_perf by value 2023-11-28 10:46:16 +01:00
Kacper Michajłow
281b1d8999 vo_gpu: don't pass ra_fbo by value
Make it easier on compiler, no need to alloca and copy things around.
2023-11-28 10:46:16 +01:00
Kacper Michajłow
a3f505d4cb vaapi: bump vaapi info callback to verbose messages
The info provided for libva might be useful. Specifically on Windows it
seems to not use the error callback for what should be logged as error.

[   0.080][v][vaapi] libva: VA-API version 1.20.0
[   0.080][v][vaapi] libva: Trying to open <path>/vaon12_drv_video.dll
[   0.080][v][vaapi] libva: va_openDriver() returns -1
[   0.080][e][vaapi] Failed to initialize VAAPI: unknown libva error

As we can see only the "unknown" error is printed to the error callback
and important information is printed on the info callback. Print it to
verbose log to make it easier to find.
2023-11-26 18:19:11 +01:00
Kacper Michajłow
02aa4f5e28 vaapi: add missing NULL check
ctx->destroy_native_ctx is guarded, but this early exit was not.
2023-11-26 18:19:11 +01:00
der richter
cc09a28d96 mac: fix a race condition when updating the window title
the title is updated on the main thread (mandatory with cocoa)
asynchronously, because otherwise it would either deadlock when done
synchronously, lead to undefined behaviour or just crashes. the problem
here is that the c string was only copied to an NSString within that
asynchronous call, which potentially would access the pointer when it
is accessed, modified or freed by another thread. it is only safe to
access this pointer as long as the control callback wasn't returned yet.

to fix this we move the copying and creation of the String from the
c string pointer outside of the asynchronous call where the conversion
of an untyped pointer to a typed pointer is done too. since the
resulting String is a copy it's safe to be used in the asynchronous
call.

also reverting ee6ad40, since the problem was most likely an SDK problem
or the very same problem as mentioned here. i retested the crash case
again und can't reproduce it anymore. using a swift String again instead
of an NSSstring.

Fixes #12935
2023-11-25 19:31:26 +01:00
der richter
5aac4c1aee mac: cleanup some unused and unneeded code 2023-11-25 19:04:07 +01:00
Kacper Michajłow
ed107c4116 meson: adjust win32 defines
- Don't define _GNU_SOURCE on Windows, no need
- Define WIN32_LEAN_AND_MEAN to strip some unneded headers from
  windows.h
- Define NOMINMAX and _USE_MATH_DEFINES as they are common for Windows
  headers
2023-11-25 12:38:20 +01:00
sfan5
aa362fdcf4 various: replace some OOM handling
We prefer to fail fast rather than degrade in unpredictable ways.
The example in sub/ is particularly egregious because the code just
skips the work it's meant to do when an allocation fails.
2023-11-24 10:04:55 +01:00
Kacper Michajłow
5220725ca5 vo: add params mutex
This mostly is added to resolve player command synchronization with VO
thread discussed in 477a0f83.

The current uses does not necessarily need this as they are all managed
by playloop. But for future use with other params that will be handy.

Those params are mostly to observe current state of VO and does not
necessarly need to be locked along with frame drawing, that changes the
params once at the end.
2023-11-22 11:51:46 +01:00
Kacper Michajłow
67deebc5b5 vaapi: add support for vaapi-win32
Only vaapi-copy variant as nothing can map D3D12 resources currently.

And even if we would add resource sharing to D3D11 it would invoke copy
at some point, so there is no point really. Maybe in the future when
libplacebo get smarter about resource sharing on Windows, but practical
advantages are really small. I've tested it with Vulkan <-> D3D11
sharing and GPU <-> GPU copy is still invoked. Better than CPU memcpy,
something for the future.
2023-11-22 11:43:20 +01:00
Kacper Michajłow
73eecdb415 vaapi: pass module into create()
Useful for logging
2023-11-22 11:43:20 +01:00
Kacper Michajłow
66e3b53eb9 d3d11: expose mp_get_dxgi_adapter and mp_dxgi_validate_adapter
To be able to reuse them in other parts of code.
2023-11-22 11:43:20 +01:00
Kacper Michajłow
eb7ba44acf d3d11: rename d3d11 adapter to DXGI adapter
There is nothing d3d11 about those adapters.
2023-11-22 11:43:20 +01:00
Kacper Michajłow
5a12015c4b vo_gpu_next: reduce number of requested frames from VO
Up to 2x playback rate is the most we can offer currently. Should work
fine for most kernels with radius <= 2.

This avoids limitation of hwdecs number of frames in-flight.

Fixes: #12927
2023-11-21 01:33:10 +00:00
der richter
48455a9403 mac: title bar fix 1px none covered video at top
there is 1px border at the top of the window that is not covered by our
title bar and the video below is visible. this broke in some newer macOS
version even so the calculation of size and position of the title bar is
still correct. add 1px the the height of the title bar to cover up the
unwanted border.
2023-11-20 23:16:43 +01:00
der richter
947800ceb8 mac: fix reporting of left wheel and right wheel scrolling
left wheel and right wheel was swapped. this was copied from the old
cocoa backend. a delta <0 is a right scroll, >0 is a left scroll.

Fixes #12899
2023-11-20 23:16:43 +01:00
Niklas Haas
d40e623fd5 vo_gpu_next: bump ICC cache size limit to 20 MB
These are less likely to be modified from run to run, and with the
avoidance of redundant re-saving we can get away with a larger size.

This is enough to save 10 3DLUTs at typical sizes.
2023-11-20 17:32:40 +01:00
Niklas Haas
70db887553 vo_gpu_next: don't re-save unmodified cache
Backwards compatibility wrapper can be bumped once sufficient libplacebo
version is a minimum dependency.

See-Also: https://github.com/mpv-player/mpv/pull/12902
2023-11-20 17:32:40 +01:00
Niklas Haas
e62dac8338 vo_gpu_next: dramatically simplify cache code
I have no idea why this code is such a convoluted mess of options and
possibilities. First of all, why is dumping both caches to a single file
even a supported use case? Why is the cache path generated multiple
times, once for saving and once for loading, instead of just generated
once and stored? Why even create a pl_cache if you're not going to
save/load it? Why so much code duplication?

I don't know. But I rewrote it in a way that makes far more sense to me.
2023-11-20 17:32:40 +01:00
Kacper Michajłow
6e161ff13f vo_direct3d: remove redundant condition
talloc_free is safe to call with NULL.
2023-11-18 23:55:28 +00:00
Kacper Michajłow
4d8c074431 opengl/context: remove duplicated conditions 2023-11-18 23:55:28 +00:00
Kacper Michajłow
df28e87ae9 ra_d3d11: fix off by one check 2023-11-18 23:55:28 +00:00
Kacper Michajłow
1b28b94585 vo: add missing return variable assignment 2023-11-18 23:55:28 +00:00
Kacper Michajłow
4449f38c17 various: add some missing error checks 2023-11-18 23:55:28 +00:00
Kacper Michajłow
8dbc84dc16 vo_gpu_next: disable drift compensation for screenshots
This change prevents unwanted adjustments. Generally, screenshots
shouldn't invoke pl_queue_update, as this action could cull the already
mapped frames in the queue.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
ba5071a7ef vo_gpu_next: add validation for invalid pl_queue usage
This is mainly for debugging purposes, as it should't happen in normal
use. If it does, it needs fixing.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
fe748e54f1 vo_gpu_next: set frame duration if provided by VO 2023-11-18 22:54:29 +00:00
Kacper Michajłow
bd1ac498bb vo_gpu_next: interpolate only if display_synced or a still frame
If !display_synced, some values may not be correct or zeroed. Therefore,
it makes no sense to interpolate in this case.

For a non-moving frame, we always want to show an uninterpolated frame.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
4dcf2d1385 vo_gpu_next: request more frames to account for anti aliasing
libplacebo requires additional frames when VPS is lower than FPS and
anti-aliasing is enabled. Supports up to a 1/4 ratio. VO has a limit of
10 frames, so in practice, not many more can fit.

Note that the internal libplacebo mixing limit is 16 frames.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
c8a2f8eb7f vo_gpu_next: make the first frame check less ominous
It is valid to disable interpolation on resets and when the vsync error
exceeds the duration of the frames that we have available.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
dc2d58b514 vo_gpu_next: remove incorrect interpolation disabling
We can possibly have all the frames needed for interpolation, even after
a reset, so there's no need to prevent that.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
faed191397 vo_gpu_next: fix pl_queue refill on reset
On reset, we would ignore all the frames that were seen before. This is
incorrect and would drop valid frames that should be rendered.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
88fc947552 vo: pass approximate frame duration in vo_frame
This information is already there, but speed adjusted. To avoid
duplicating the calculation of frame duration, it's kept in the
vo_frame structure.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
d9e0ae737a vo: avoid overshooting the expected end of the frame during pause
The `current_frame` can be redrawn even if the remaining `num_vsync` is
equal to 0. In this scenario, the vsync offset would be incremented
beyond the target point.
2023-11-18 22:54:29 +00:00
nanahi
6fce181a25 vo_sdl: fix broken mouse wheel multiplier
It only registers 1 mouse wheel event per 10 physical mouse wheel clicks.
2023-11-18 21:02:17 +00:00
Dudemanguy
69f3c70733 hwdec_vulkan: use VK_NULL_HANDLE when counting the number of images
Otherwise you can get "error: comparison between pointer and integer"
while compiling in some cases.
2023-11-18 20:46:11 +00:00
Dudemanguy
4b0f03d455 vo_gpu_next: set max cache size back down to 10 MiB
It turns out that mpv will rewrite the entire cache file on every single
quit. It's not so great since after viewing a ton of files, your cache
can grow to massive sizes and slow down quitting the player to a
noticeable amount. Turn down the max size of both caches to 10 MiB for
now as a workaround until this gets improved later.
2023-11-18 18:33:21 +00:00
rcombs
ca45b71edc hwdec: support videotoolbox with libplacebo 2023-11-16 09:48:20 -08:00
Kacper Michajłow
39cab760b3 vo: delay vsync samples by at least 10 refreshes
This filters out vastly inaccurate values from presentation feedback
that can happen shortly after restarting playback or seeking.

Makes estimated vsync converge almost instantly instead of waiting
until those outliers are dropped from the past samples.
2023-11-14 15:09:03 +00:00
Kacper Michajłow
ff7f105c85 vo_gpu_next: guard from cache save conflict
If multiple instances of mpv are closed at the same time, they will
write to the same temporary file. Fix that by using unique temporary
file.
2023-11-14 15:00:00 +00:00
Kacper Michajłow
5b4a119267 vo_gpu_next: disable libplacebo drift_compensation
In commit de6d57f0 libplacebo enabled drift compensation by default.

mpv already tracks error and adjust the speed by itself.

This commit fixes judder visible when slowing video a lot, ex. playing
back at 10% speed.

Set ideal vsync duration also when dropping frames, libplacebo estimate
currently own values anyway, will be useful later...

See: de6d57f021
2023-11-12 20:22:26 +00:00
Dudemanguy
ca6ae6fb5f vo_gpu_next: update overlays for blend subtitles on frame redraws
The commit subject sounds reasonable except that frame redraws get
spammed in certain cases (still image with subtitles) all the time
regardless if the subtitle actually has changed or not. So this is
stupid and wasteful, but you'll always see subtitles. vo_gpu currently
has this behavior as well, so we're just matching it but later mpv's
core should be fixed so this works reasonably. Fixes #11335.
2023-11-12 17:18:04 +00:00
Kacper Michajłow
7cab30cec7 vo_gpu_next: fix interpolation
Fixes gpu-next completely ignoring any speed adjustment, either DS or
playback.

Frames in pl_queue have raw PTS values, so when querying them we have to
use the same time base. There was misunderstanding between mpv and
libplacebo, where the former was querying the frames based on display
vblank timeline, but this cannot work if the playback speed is adjusted
and display timeline is not aligned with video timelien. In which case
we have to schedule "video vsync" points that we want to display.

Previous code was working only when playback speed was 1.0x, but since
DS almost always changes the speed the interpolation was mostly not
timied correctly.
2023-11-11 20:44:01 +00:00
Kacper Michajłow
5e5a32534a vo: add frame vsync and vsync duration
Relative to frame PTS timeline as oposed to display vblank.

Those values are relative to unadjusted video timeline. They will be
used by gpu-next where it expect virtual frame vsync, not display vblank
time.
2023-11-11 20:44:01 +00:00
Dudemanguy
332619042f vo_gpu_next: improve PTS clamping
Originally suggested by @haasn. Instead of awkwardly using a pts from
the previous render loop, we can just peek into pl_queue and use the pts
of the first frame instead. This eliminates a lot of weird artifacts
that can happen on discontinuities like seeking. Fixes #12355.
2023-11-11 20:44:01 +00:00
Dudemanguy
9199afc405 vo_gpu_next: add some additional sanity checking for interpolation
Several related things in regards to interpolation. Essentially this
adds more general sanity checking to bring it more in line with what
vo_gpu does.

- Add a can_interpolate bool which determines whether or not this frame
  is allowed to interpolate.
- p->is_interpolated was sometimes lying and because you can have a mix
  frames greater than 1 depending on the video and settings. Make sure
  that vsync_offset is not 0 so we know if it's actually interpolated or
  not. This prevents a redundant redraw for those edge cases when
  pausing.
- When the vo wants a reset, i.e. some sort of discontinuity, don't try
  to interpolate the frame. Interpolation is only valid for
  monotonically increasing times.

This fixes #11519 because of the additional check to make sure that we
have more than 1 frame. The PTS clamping part is still not great. That
is for the next commit.
2023-11-11 20:44:01 +00:00
Christoph Heinrich
7302f871d1 wayland: fix shift+tab keyboard input
When pressing shift+tab we get 0xfe20 instead of 0xff09, which
corresponds to the XKB_KEY_ISO_Left_Tab define.
2023-11-11 20:43:12 +00:00
Dudemanguy
9c8b8ac9d9 wayland: obey initial size hints set by the compositor
In the past, this worked by accident because the initial startup was
racy and sometimes the initial firing of handle_toplevel_config would
happen after reconfig. Since we now properly wait on all compositor
events we can save the initial size hint that is given to us and try to
use that as the window-size/geometry provided the --autofit/geometry
options aren't explictly set. Fixes #11134.
2023-11-10 22:41:35 +00:00
der richter
fc4db187d0 cocoa: remove OpenGL cocoa backend
the OpenGL cocoa backend was deprecated in 0.29, it has lot of bugs, is
completely unmaintained and can't properly playback anything anymore on
the newest macOS. it is time to remove it.
2023-11-10 14:54:37 +01:00
der richter
a54cc02341 mac: change display name retrieval to localizedName NSScreen property
the old displayName property via the IODisplay API is not working
anymore on ARM based macs and was broken in at least one other case.

instead we use the new localizedName property introduced in 10.15 of the
NSScreen. we don't need any backwards compatibility since 10.15 is the
oldest version we support now.

configs and scripts that use the options and properties fs-screen-name,
screen-name or display-names need to be adjusted since the names could
differ from the previous implementation via the IODisplay API.

Fixes #9697
2023-11-10 14:30:32 +01:00
der richter
040a921964 mac: fix build on older swift versions
this is apparently something that was added with swift 5.5, though it is
hard to find anything officially.

don't capture self in closure but explicitly access all variables by
prepending self.

Fixes #12653
2023-11-10 14:29:23 +01:00
sfan5
b4e14b9420 vo_gpu_next: overwrite cache files atomically 2023-11-10 11:26:10 +01:00
sfan5
cad24deea1 vo_gpu_next: refactor cache saving code
No functional change.
2023-11-10 11:26:10 +01:00
Kacper Michajłow
7d86807a5f vo: don't sleep 1ms always when requested time is in the past
Fixes a899e14b which changed clamp from 0 to 1 ms which effectivelly
introduced 1ms sleep always, even if requested until_time_ns is in the
past and should request 0 timeout.

While at it also fix mp_poll wrapper to respect negative timeout which
should mean infinite wait.

Also keep the 37d6604 behaviour for very short timeouts, but round only
the ones > 100us, anything else is 0.

Fixes: a899e14b
2023-11-09 21:31:58 +00:00
Dudemanguy
a89ba2c749 vo: replace some magic numbers with timer macros
Most importantly, the wait_until addition was missed while doing the
unit conversions to nanoseconds which meant mpv woke up roughly every
second since not nearly enough time was added. It was meant to be 1000
seconds (1e9 in microseconds). Use a macro so it's more readable. Also
put some other wild 1e9 calculations inside of a macro as well.

Fixes a899e14bcc.
2023-11-09 21:31:58 +00:00
der richter
23de1deaaa mac: remove runtime checks and compatibility for macOS older than 10.15
we stopped supporting macOS older than 10.15 and hence can remove all
the unnecessary runtime checks and compatibility layers.
2023-11-09 18:12:25 +00:00
Dudemanguy
a5bf211e12 meson: remove several macos-10-* build options
These have been build options since the waf build, but that doesn't
really make sense. The build can detect whatever macOS sdk version is
available and then use that information to determine whether to enable
the features or not. Potentially disabling multiple sdk versions doesn't
really make any sense. Because f5ca11e12b
effectively made macOS 10.15 the minimum supported version, we can drop
all of these checks and bump the required sdk version to 10.15. The rest
of the build simplifies from there.
2023-11-09 18:12:25 +00:00
Kacper Michajłow
477a0f8318 vo: replace VOCTRL_HDR_METADATA with direct VO params read
Currently VOCTRL are completely unusable for frequent data query. Since
the HDR parameter addition to video-params, the parameters can change
each frame. In which case observe on those parameter would be triggered
constantly. The problem is that quering those parameters involves VOCTRL
which in turn involves whole render cycle of delay.

Instead update VO params on each draw_frame. This requires changes to VO
reconfiguration condition, but in practice it should only be triggered
when image size or data layout changes. In other cases it will be
handled internal by VO driver.

I'm not quite happy with this solution, but don't see better one without
changing observe/notify logic significantly. There is no good way
currently to handle VOCTRL that are constantly queried.

This adds unfortunate synchronization of player command with VO thread,
but there is not way around that and if too frequent queries of this
param becomes a problem we can thing of other solutions.

Changes the way to get data from VO driver added by a98c5328dc

Fixes: 84de84b
Fixes: #12825
2023-11-08 21:45:07 +00:00
Niklas Haas
293fe9d74a vo_gpu_next: add --target-gamut option
Fixes: https://github.com/mpv-player/mpv/issues/12777
2023-11-08 00:55:39 +01:00
Kacper Michajłow
6dafc44ed0 win32: fix hit test using client rc instead window
windowrc in vo_w32_state is actually client size, for hit test we need
proper window size. When border is disabled those sizes are the same,
but when only title bar is disabled it is not.

Reduce the hit area to more sane values when the border is not
drawn to minimize amount of covered client area in borderless mode.
2023-11-07 16:42:28 +00:00
sfan5
242066a5ef vo_gpu: apply ICC profile and dithering only to window screenshots 2023-11-07 16:15:19 +01:00
sfan5
ff521dfbd1 vo_gpu_next: drop alpha channel from screenshots if unneeded 2023-11-07 16:15:19 +01:00
sfan5
8c751a0d78 image_writer: improve format conversion logging 2023-11-07 16:15:19 +01:00
Dudemanguy
4aa3866400 present_sync: remove unneeded clear_values function
This was specifically special logic for drm. Before present_sync, it
would also clear out all of its vsync values like this. The old drm code
would save a bunch of samples which would confuse vo.c when unpausing
since it got old, bogus values. Since we make sure to match successive
vsync samples with the swapchain depth and that present sync samples
also match the swapchain depth, this is unneeded.
2023-11-07 00:52:46 +00:00
Dudemanguy
506e8d9eaf vo: require successive vsyncs to be more than swapchain depth
To make sure that present_sync is in line with the vsync timings here.
2023-11-07 00:52:46 +00:00
Dudemanguy
2872e929bb present_sync: only save as many entries as the swapchain depth
Saving more than the swapchain depth is just wasteful. We can just save
a copy of the vo_opts here and check the value whenever we're updating
values.
2023-11-07 00:52:46 +00:00
Dudemanguy
cf69fa03ca vo: replace max swapchain depth magic number 2023-11-07 00:52:46 +00:00
Dudemanguy
f4c5fa12cb wayland: improve wl_output guessing before mpv window is mapped
There's some geometry-related things that mpv has to calculate before
the window is actually mapped onto the screen in wayland. But there's no
way to know which output the window will end up on before it happens, so
it's possible to calculate it using the wrong values. mpv corrects
itself later when the surface event happens, but making the initial
guess work better can help in certain cases.

find_output is the only thing that needs to be changed here. Its main
purpose is to grab the right output based on user settings when we're
trying to full screen and giving a fallback in case we don't have
wl->current_output yet. The x11 code already does something similar, so
we're basically just copying it. Allow user settings like --screen and
--screen-name to influence the initial wl_output guess. Those options
won't actually place the window on that specific screen since we can't
do that in wayland, but if the user knows where the window will end up
beforehand it makes sense to listen to the arguments they pass. If
something goes wrong, then we just fallback to 0 like before.
2023-11-06 23:13:31 +00:00
Dudemanguy
a96d04f19d drm: use present_sync mechanism for presentation feedback
A ton of code and drm-specific abstractions can be dropped with this.
One important thing to note is that the usage of sbc is completely
dropped here. The utility of that is not particularly clear since the
sbc value was manually incremented before the flip and it's not as if
the drm page flip event gives it to us like it does with the msec and
ust. It can be reintroduced later if there is a need. For drm, we also
add a present_sync_clear_values helper since all presentation feedback
needs to be cleared on pause/resume for it.
2023-11-06 15:44:45 +00:00
Dudemanguy
f629d7a2ff present_sync: rename function to present_sync_update_values
This had to have been a mistake. It was just confusing.
2023-11-06 15:44:45 +00:00
Dudemanguy
261f51b475 present_sync: rewrite around linked list
When this was originally written, the queuing/list approach was
deliberately removed since it adds more complication and xorg/wayland
don't really use it anyway. In practice, you only really have one frame
in flight with presentation timestamps. However, one slight annoyance is
that the drm code has its own thing which is almost exactly the same and
does its own calculations. Ideally, we'd port drm to this instead, but
the implementation there takes into account N-frames in flight which
probably does actually work. So we need to make present_sync smarter and
be able to handle this.

mpv does actually have its own linked list implementation already which
is a good fit for this. mp_present becomes the list and each
mp_present_entry has its own set of timestamps. During initialization,
we create all the entries we need and then simply treat it like a queue
during the lifecycle of the VO. When an entry is fully used
(present_sync_get_info), then we remove it from the list, zero it out,
and append it to the end for future use. This avoids needing to allocate
memory on every frame (which is what drm currently does) and allows for
a reasonable number of in flight frames at the same time as this should
never grow to some obscene number. The nice thing is that current users
of present_sync don't need to change anything besides the initialization
step.
2023-11-06 15:44:45 +00:00
llyyr
d9b33dd79a Revert "vo: clear vsync_offset if drawing while paused"
This reverts commit 640c07fb19.

This commit isn't needed anymore after the previous commit.
2023-11-06 11:39:45 +01:00
Kacper Michajłow
73fbe09a49 ALL: use pl_hdr_metadata and nuke sig_peak
This commit replaces all uses of sig_peak and maps all HDR metadata.

Form notable changes mixed usage of maxCLL and max_luma is resolved and
not always max_luma is used which makes vo_gpu and vo_gpu_next behave
the same way.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
1174afcccc csputils: add pl_hdr_metadata to mp_colorspace and deprecate sig_peak
Note this commit does not change all uses of sig-peak, this is for
future refactoring.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
468feb863b csputils: change mp_hdr_metadata to pl_hdr_metadata 2023-11-05 18:57:36 +01:00
Kacper Michajłow
076be24853 timer: remove unnecesary time conversions 2023-11-05 17:36:17 +00:00
Kacper Michajłow
55ed50ba90 mp_thread: prefer tracking threads with id
This change essentially removes mp_thread_self() and instead add
mp_thread_id to track threads and have ability to query current thread
id during runtime.

This will be useful for upcoming win32 implementation, where accessing
thread handle is different than on pthreads. Greatly reduces complexity.
Otherweis locked map of tid <-> handle is required which is completely
unnecessary for all mpv use-cases.

Note that this is the mp_thread_id, not to confuse with system tid. For
example on threads-posix implementation it is simply pthread_t.
2023-11-05 17:36:17 +00:00
Kacper Michajłow
174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
Dudemanguy
6f8d98f812 vo_gpu_next: update to newer cache API
The old one would actually crash if the libplacebo.cache file was
invalid. Additionally, set a max size of 1 GiB for icc cache and 50 MiB
for gpu shader cache. The per object size limit is removed which puts
mpv in line with plplay. Finally, a few memory leaks are also fixed
since several objects previously were not freed on uninit.
2023-11-05 01:00:02 +00:00
Dudemanguy
784ec0066f ra_pl: drop deprecated cached_program param
This was deprecated in api version 322 which earlier than the current
6.338 version that mpv depends on. So remove it.
2023-11-05 01:00:02 +00:00
Dudemanguy
ed4d21d401 vo_gpu_next: remove unneeded PL_API_VER guarding and defines
Since the minimum required libplacebo version is 6.338, all of these
checks are unneeded.
2023-11-05 01:00:02 +00:00
Kacper Michajłow
7480efa62c mp_image: pass rotation correctly to/from AVFrame
Fixes rotating image by --video-rotate when filtering.

Fixes: #12771
2023-11-03 10:05:41 +01:00
nanahi
fe0d2b4ee9 win32: add more values for monitor refresh rate detection
Add more refresh rates for get_refresh_rate_from_gdi() now (Nov 2023) that
165 Hz is common, 240 Hz is on the rise, and 120 * N Hz is the future.
2023-11-02 17:34:36 +01:00
Niklas Haas
f537378d90 vo_gpu_next: use pl_queue_params() macro
In case new default parameters are added later.
2023-10-31 20:42:04 +01:00
Kacper Michajłow
908e75ee83 vf_vapoursynth: set crop metadata after mapping vapoursynth frame
Vapoursynth does not provide crop metadata and input one is likely to be
invalidated during filtering. Set crop to full frame if image dimensions
were changed during filtering.

Fixes: #12780
2023-10-31 03:25:59 +00:00
Guido Cella
040622f6b7 various: remove trailing whitespace 2023-10-30 16:45:47 +00:00
Kacper Michajłow
cb829879af mp_threads: rename threads for consistent naming across all of them
I'd like some names to be more descriptive, but to work with 15 chars
limit we have to make some sacrifice.

Also because of the limit, remove the `mpv/` prefix and prioritize
actuall thread name.
2023-10-27 23:18:56 +00:00
Philip Langdale
7a58763ad9 Revert "hwdec_vulkan: account for vulkan frames now using presentation size"
ffmpeg is again setting the frame dimensions to the coded size, so we
need to reintroduce our work-around to get the logical frame dimensions
from the frames_ctx rather than the frame itself.

ffmpeg commit:
* 9ee4f47c94

This reverts commit c40bd88872.
2023-10-26 09:51:47 -07:00
Kacper Michajłow
34d99840a5 timer: use MP_TIME macros 2023-10-26 16:49:38 +00:00
Dudemanguy
9924102c66 options: rename --override-display-fps to --display-fps-override
Other similar options are in the form of --foo-override not
--override-foo. The display-fps one was backwards so flip it around the
other way for consistency reasons.
2023-10-25 16:16:37 +00:00
Kacper Michajłow
869faadc68 options: disable --allow-delayed-peak-detect by default
Peak detection greatly increases HDR experience. Performance hit of
non-delayed detection is not that significant and is in line with
current default settings.
2023-10-25 11:55:56 +02:00
llyyr
f5ca11e12b meson: make libplacebo a required dependency
Make it not possible to build mpv without the latest libplacebo anymore.
This will allow for less code duplication between mpv and libplacebo,
and in the future also let us delete legacy ifdefs and track libplacebo
better.
2023-10-23 13:03:29 +02:00
Kacper Michajłow
0a799547aa vo: define <= 0 as unsupported for last_queue_display_time
Also sanitize vsync values, just in case.
2023-10-23 00:10:49 +00:00
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
b26d2ab01c img_format: remove duplicated macros
these are defined in osdep/endian.h already
2023-10-23 00:10:42 +00:00
NRK
a1f465b582 aspect: remove unused multiplication
the variable `w` is unused as a whole.
2023-10-23 00:10:42 +00:00
chainikdn
ce03b42424 vf_vapoursynth: set nominal_fps after the filter 2023-10-21 22:29:31 +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
Kacper Michajłow
9a7291d48e mp_image: set crop metadata when converting to AVFrame
So it is not lost after filtering.
2023-10-20 17:43:01 +00: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
Niklas Haas
50cd363c01 video/mp_image: handle non-power-of-two alignment
Needed for odd formats like rgb24.
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