Commit Graph

6062 Commits

Author SHA1 Message Date
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
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
Kacper Michajłow 71ce0cb71f mp_image: don't copy crop value from opaque_ref
It is already set above.

Fixes: #12577, #12587
2023-10-07 14:36:06 +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