Since a6683ea3c9 it is possible to bind
MBTN_LEFT to something useful without conflicting with VO dragging.
However, currently wayland edge resizing is an exception and trying to
resize still triggers MBTN_LEFT. This is not a problem on win32 which
does not pass these inputs to the input system.
Fix this on wayland to do the same.
Change to always use drmModeAddFB2WithModifiers for all formats and fall
back on using drmModeAddFB2 if drmModeAddFB2WithModifiers fail.
With the DRM_MODE_FB_MODIFIERS-flag now only being used for formats with
modifiers all formats without modifiers should also work.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Similar to handles the modifiers must be supplied for each plane of the
format or a framebuffer cannot be created.
Use the format_modifier tied to the object used for the plane to fix use
of formats with modifiers.
Also fix the improper use of the DRM_MODE_FB_MODIFIERS-flag for formats
without modifiers.
This fixes playback of videos decoded by e.g. rpivid into a NV12 format
using SAND128 modifer on RPi using the drmprime-overlay interop.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Now that we have identified the device types associated with each hwdec, we
can take advantage of this to ensure that get the right hwdec is chosen when
decoding frames and there are multiple choices available with different device
types.
This is also plumbed into the filter initialisation logic, although in practice
the decision on the hwdec has already been made at this point - still it's
easier than retaining the ambiguous look up logic and worrying that it might
lead to an inconsistent result.
As the first step towards handling scenarios where the are multiple hwdecs for
a given image format but backed by different AVHWDeviceTypes, let us annotate
the hwdecs with their corresponding device types.
From this, we can also see how all the existing hwdecs which match the same
image format also match the same device type.
It won't be TA allocated and would fail on header check. Also
documentation doesn't mention that ownership is transfered to mpv, so it
is unexpected.
This will cause existing clients of this API leak this memory, but I
doubt anyone really used it in this broken state.
Fixes: #14633
Unlike most other platforming backends, wayland has its own specific
sub_options struct. 027ca4fb85 originally
introduced this and some more options were added later, but in
retrospect it's an unneccesary complication. There are already x11,
and windows-specific options within vo_opts. In fact, there actually is
a wayland one in there already as well (wayland-content-type) so it's
split btween two places. The wayland code already has to handle vo_opts
and it is already handles callbacks if needed. There is no advantage to
having a separate wayland-specific sub_options struct which is stuck
with whatever you set at init time.
So solve everything by deleting the old sub_options struct, moving it to
vo_opts and make some minor option naming changes for clarity (i.e.
adding a 'wl_' in front of the name). This simplifies the wayland common
code and also makes it have more functionality since you get runtime
updates for free.
Set UPDATE_VO to GPU API options that are only set on init.
To change multiple options without multiple reinits, use
set vo null; set opengl-foo 1; set opengl-bar 1; set vo gpu
This will allow reiniting the VO when more options are changed without
hardcoding them in options.c
Also reinit the VO when changing --gpu-debug and --gpu-sw.
if no NSApplication has been initialized, applications using Appkit
functionality are not supposed to work properly or just deadlock
indefinitely. properly error out on macvk context creation in that case.
Described in more detail in the upstream MR*. mpv naively rounds which
makes us susceptible to the mentioned error. Fix this by keeping
wl->scaling and wl->pending_scaling in the base 120 units. Use the
simple rounding algorithm when needed for calculating widths/heights.
Create a wl->scaling_factor as convenient shorthand for scale / 120
which is what wl->scaling used to previously be.
*: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/309
On X11, aspect ratio constraint is applied on the window manager side,
so whenever keepaspect and keepaspect-window change, mpv should update
the size hint immediately, otherwise the new constraint isn't applied.
Window classes are global per process, but they are associated with the
module that registered them. Documentation is clear that it is the DLL's
responsibility to unregister its own classes:
No window classes registered by a DLL are unregistered when the DLL is
unloaded. A DLL must explicitly unregister its classes when it is
unloaded.
See: https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-registerclassw
Using a window class after the DLL is unloaded would result in access
violation errors. This is not that important for libmpv, where it is
unlikely someone would use the "mpv" window class externally. The real
issue comes from the fact that reloading libmpv would fail to register
the class (as it still exists) and consequently fail to create a window.
This commit fixes the operability of libmpv after reloading it.
Fixes: #11638
Client side cursors have always had some issues with fractional scaling.
However since we changed to using viewporter for cursor scaling, most
(or all?) of the problems can be fixed. Unfortunately, a scaling factor
was being truncated to int instead of kept as a double. This matched the
old behavior with buffer_scale, but it's better to use double so the
viewport is actually set to the correct size. Of course, none of this is
relevant if the compositor is using cursor shape.
Fixes f0a6578259Fixes#14001
This follows up 96e1f1dfa5 which converted --gpu-context, and has the
same advantages as listed there.
Unlike with --gpu-context auto can be used anywhere in the list, e.g.
--gpu-api=d3d11,auto works.
I wanted to use the list of GPU contexts as the description in
get_type_desc(), but there is no talloc context to allocate it to, so I
set a print_help_list to print them. The APIs go before the contexts so
that etc/_mpv.zsh doesn't try to complete the contexts.
This function is used to reject invalid context names early, and without
it the context fails to create and only audio is played, but it doesn't
need to check for known entries again.
Mainly for debugging. It might be handy to disable presentation feedback
on wayland to make sure something isn't going wrong with the
calculations somewhere.
Most of these are pretty obscure things that were replaced a long time
ago. The special messages they were printing are also not really useful
at all so just remove them.
These were all deprecated in mpv 0.37.0 or earlier and are not
considered common enough options to warrant keeping the deprecated
mapping longer. Since demux_cue had only a single option in it, the
entire option substract is removed. This can be readded later if someone
wants to introduce a specific option to it again.
No need to reset mp_pass_perf which is only read when desc.len > 0.
This avoids zeroing >16384 uint64_t's every time it's called.
Profiling shows that this reduces CPU usage for frame rendering by ~4%.
If the output display reports high bitdepth, 12-bit and 10-bit swapchain
is used the value returned from d3d11_color_depth needs to take it into
account.
VapourSynth introduced their version 4 API in R55, 3 years ago. mpv is
still using the deprecated version 3. I think it is good to migrate
before VapourSynth completely removes it.
The most impacted area is the video format. Previously we have a fixed
table of supported formats, each represented by an integer. In v4, the
integer is replaced by pointer to the full struct of the format.
Second, the way to create video filter is changed. Previously caller
needs to supply a "initialization" callback to `createFilter()`, which
sets up video info etc. In v4, video info is prepared first, passed to
the `createVideoFilter2()` and we get back the node.
Also, previously mpv was using the `fmSerial` filter mode, which means
VapourSynth 1) can only request one frame from mpv at a time, and 2) the
order of frames requested must be sequential. I propose to change it to
the parallel request mode, which requests multiple frames at a time in
semi random order. The reasons are, for 1), the get frame function,
`infiltGetFrame()`, unlocks the mutex during output image generation,
thus can benefit from parallel requests. For 2) thanks to the frame
buffer, unordered frame requests are acceptable. Just make sure the
buffer is large enough.
Third, the way VapourSynth scripting environment works change. In v4,
the scripting API is operated through struct pointer, much like the
exist `vsapi` pointer. The "finalize" function is also no longer needed.
Currently the vapoursynth video filter does not accept any argument for
passing arbitrary user data. This limits what the VS script can do.
Ideally, the vapoursynth filter has an user-data parameter that contain
string value. mpv passes that value to the VS script just like
container_fps and others. Once the VS script gets the data, it can do
all sorts of data extraction and transformation.
Another benefit is that instead of mpv always have to catch up to user
needs for this filter, with this users can just pass whatever needed
themselves, thus becomes more future-proof.
Fixes#14214
Wayland protocol only guarantees the delivery of modifier information after
the enter event. To handle it properly for keys pressed in the enter
event, save those keys for later processing in the modifier event.
Also, if the position is valid, set it to 1 / INF. Windows interprets 0
as non-progress.
Progress is quantized into uint8 range, it is good enough for this
use-case. This avoids unnecessary vo_control and
ITaskbarList3::SetProgressValue calls and should be visually
indistinguishable in practice.
Fixes#14282
The values provided since last disjoint event may include significant
error in case there are periods of slower presentation. We should look
at more localized/current values of presentation.
For more accurate approximation of vsync rate I plan to add better
algorithm to calculate it.
Revert this commit alone as it is not neccessary and gives as separation
from other changes for better regression testing.
This reverts commit f27767f59e.
If mpv is launched with --fs, the x11 code tries to reset the size and
position of the window when the fullscreen exits. This has bad behavior
with multiple monitors because the saved nofsrc is not reliable in many
situations. Particularly if the window manager moves the fullscreen
window somewhere else while mpv is fullscreen. The result will be that
exiting fullscreen always goes back to screen 0.
Fix this by translating the rc coordinates of the nofsrc rc to the new
monitor when we're leaving fullscreen from an initial --fs case. By
giving get_current_display a specific rc, we can return what xrandr
display the coordinates are associated with and decide if the nofsrc
should be translated to its new location. After that bit of math, the
usual move/resize logic takes care of the rest but this time it actually
works off of the correct position. Fixes#14226.
This is required by the wayland protocol to keep the logical keyboard
state consistent.
Quoting 9e4f256927:
> In the wl_keyboard logical state, this event sets the active surface to
> the surface argument and the keys currently logically down to the keys
> in the keys argument.
The idle inhibit protocol specifies that the compositor may ignore the
idle inhibitor if the surface is occluded. In the case of
vo_dmabuf_wayland, wl->surface corresponds to typical black bars when
the video aspect ratio is different than the display's. So in many
cases, wl->surface is actually occluded by wl->video_surface which sits
above it. Change this so that the idle inhibitor is created on
wl->callback_surface instead which is either wl->surface for the gpu VOs
or wl->video_surface for vo_dmabuf_wayland. Fixes#14206.
This might not always be correct depending on filtering done in VS. But
unless VS send us all the metadata we have to get it from somewhere.
Fixes dynamic frame metadata, which was copied from fmt_in, initialized
only upon reinitialization.
Fixes crashes caused by the use of stale pointers.
Fixes: #13956
Conditional jump or move depends on uninitialised value(s)
at 0x10FE22: drm_prime_remove_handle_ref (drm_prime.c:144)
by 0x10FCCD: drm_prime_destroy_framebuffer (drm_prime.c:107)
by 0x10FEB1: set_current_frame (hwdec_drmprime_drm.c:73)
by 0x11054F: overlay_frame (hwdec_drmprime_drm.c:223)
by 0xF1311: gl_video_render_frame (video.c:3315)
by 0xFA015: draw_frame (vo_gpu.c:85)
by 0xF8FDB: render_frame (vo.c:961)
by 0xF943F: vo_thread (vo.c:1099)
by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
Uninitialised value was created by a heap allocation
at 0x484713C: realloc (vg_replace_malloc.c:1437)
by 0x10258B: ta_realloc_size (ta.c:195)
by 0x10325D: ta_xrealloc_size (ta_utils.c:298)
by 0x10FDBF: drm_prime_add_handle_ref (drm_prime.c:133)
by 0x10FC57: drm_prime_create_framebuffer (drm_prime.c:87)
by 0x1102FF: overlay_frame (hwdec_drmprime_drm.c:188)
by 0xF1311: gl_video_render_frame (video.c:3315)
by 0xFA015: draw_frame (vo_gpu.c:85)
by 0xF8FDB: render_frame (vo.c:961)
by 0xF943F: vo_thread (vo.c:1099)
by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
Conditional jump or move depends on uninitialised value(s)
at 0x10FCE4: drm_prime_destroy_framebuffer (drm_prime.c:109)
by 0x10FEB1: set_current_frame (hwdec_drmprime_drm.c:73)
by 0x11054F: overlay_frame (hwdec_drmprime_drm.c:223)
by 0xF1311: gl_video_render_frame (video.c:3315)
by 0xFA015: draw_frame (vo_gpu.c:85)
by 0xF8FDB: render_frame (vo.c:961)
by 0xF943F: vo_thread (vo.c:1099)
by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
Uninitialised value was created by a heap allocation
at 0x484713C: realloc (vg_replace_malloc.c:1437)
by 0x10258B: ta_realloc_size (ta.c:195)
by 0x10325D: ta_xrealloc_size (ta_utils.c:298)
by 0x10FDBF: drm_prime_add_handle_ref (drm_prime.c:133)
by 0x10FC57: drm_prime_create_framebuffer (drm_prime.c:87)
by 0x1102FF: overlay_frame (hwdec_drmprime_drm.c:188)
by 0xF1311: gl_video_render_frame (video.c:3315)
by 0xFA015: draw_frame (vo_gpu.c:85)
by 0xF8FDB: render_frame (vo.c:961)
by 0xF943F: vo_thread (vo.c:1099)
by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
`cuInit` wakes up the nvidia dgpu on nvidia laptops. This is bad news because the wake up process
is blocking and takes a few seconds. It also needlessly increases power consumption.
Sometimes, a VO loads several hwdecs (like `dmabuf_wayland`). When `cuda` is loaded, it calls
`cuInit` before running all interop inits. However, the first checks in the interops do not
require cuda initialization, so we only need to call `cuInit` after those checks.
This commit splits the interop `init` function into `check` and `init`. `check` can be called without
initializing the Cuda backend, so cuInit is only called *after* the first interop check.
With these changes, there's no cuda initialization if no OpenGL/Vulkan backend is available. This prevents
`dmabuf_wayland` and other VOs which automatically load cuda from waking up the nvidia dgpu unnecessarily,
making them start faster and decreasing power consumption on laptops.
Fixes: https://github.com/mpv-player/mpv/issues/13668
by default utilises the color space of the screen on which the window is
located. if a specific value is defined, it will instead be utilised.
depending on the chosen color space the macOS EDR (HDR) support is
activated and that OS's transformation (tone mapping) is used.
Fixes#7341
WS_POPUP windows cannot be maximized, so instead of forcing it with
unavoidable side-effects, change the window style before maximizing to
make it work correctly.
This makes the context menu items accessible from the window menu,
which can be opened by either right-clicking on the title bar or
left-clicking on the mpv icon on the title bar.
Currently if VO init fails, the context menu is leaked. Additionally,
init/uninit are in the VO thread, while other accesses are in the GUI
thread.
Fix this by moving them to the GUI thread, similar to other resources.
This also lets init function take the mpv HWND in the next commit.
If we get either preferred_scale or preferred_buffer_scale this early
during initialization the wl->scaling value should be immediately
updated instead of being deferred until later for correct geometry.
Fixes#14019.
After explorer is restarted while show-in-taskbar is false, toggling
show-in-taskbar no longer puts mpv back to the taskbar until it's
unfocused and refocused.
My guess of how this works is that the HWND of the taskbar is cached,
and setting the WS_EX_TOOLWINDOW style internally uses this value to
show/hide the taskbar button. But after explorer is restarted it no
longer works until its taskbar state needs to change (such as focusing).
Only then it realizes the HWND is no longer valid and refreshes it.
Fix this by following MS documentation on this: the window needs to be
hidden before changing the style, and be shown after that. This
unfortunately can sometimes introduce a brief window flash, but it
fixes the problem.
Abstract out EGL, and allow choosing between EGL and vulkan at runtime.
vf_gpu_egl.c contains GL specific context and creation/destroy code,
vf_gpu_vulkan.c contains Vulkan specific. This allows vf_gpu being
built in systems where EGL is not available and where Vulkan is
available.
the Screen property localizedName returns a none unique dynamic name
that doesn't allow a specific selection of a Screen on every OS boot.
the name consists of the vendor name and model name (eg DELL U2723QE).
if the same model display is connected to the system several times,
macOS starts to add numbers to the localizedName (eg DELL U2723QE (1)),
that may not be associated to the same Screen on every OS boot or
connecting the display. it also changes the name of the first connected
display by adding that numeration. this makes it impossible specify the
proper screen with the screen-name option every time.
to circumvent this we remove the enumeration from the name and instead
add the serial number to the display-names property. this makes the
actual Screen unique and none dynamic. furthermore the selection of a
screen by name will check for equality for the old localizedName, simple
name without enumeration, serial number and the combined name with
serial number. this makes it possible to select the screen by either of
those names and identifiers, and keeps backwards compatibility with the
old behaviour.
Examples:
localized name (System Settings name): DELL U2723QE, DELL U2723QE (1)
simple name: DELL U2723QE
serial number: 123456789
combined name: DELL U2723QE (123456789)
When this was originally implemented, the fixed conversion factor was
accidentally reverse engineered. It was left as is though. Instead, use
the wl_fixed_from_int helper, so it's more obvious what is going on
here.
DXGI debug interface encapsulate multiple message queues, which allows
to get validation not only for D3D11 calls, but also DXGI ones.
Also this makes leak detector not report self debug interface as alive
like it was before. And same as with validation, it has ability to
detect more alive objects, not being limited to D3D11.
Not all cards support gbm which means the creation of the gbm device
will fail. However during the uninit process, the destruction of the
device was unconditionally done which leads to a segfault. Guard it
instead. Fixes#13929.
Previously, the code required a check against the old saved geometry to
make sure the size and/or position was different before updating. The
doesn't work with the previous changes that allow a geometry value to be
set again with the same value as before. It would probably be nicer to
check against something that always keeps track of the actual window
size in real time, but it seems geometry in x11 doesn't quite work that
way so we'll do it the easier way instead.
Now that obj_settings_list is used for GPU contexts, detailed
descriptions can be added so that --gpu-context=help can print
the descriptions of the GPU contexts using standard
obj_settings_list help printing.
This adds a dummy context at the start of the context lists, which
serves three purposes:
- The "auto" option is listed for --gpu-context=help.
- Some special handlings of "auto" string are removed.
- Make sure that lists have at least one element, so MP_ARRAY_SIZE()
works as intended.
Since the list of available GPU contexts is a compile time constant,
use obj_settings_list instead of opt_string_validate for GPU contexts.
This has several advantages:
- Aligns with the existing usage of vo, ao, and filter lists.
- Allows custom probing order.
- Allows list option suffixes. (--gpu-context-append, etc.)
- Allows autocomplete in console.lua.
- Uses the standard obj_settings_list help printing, so the custom
help printing function is no longer needed.
This also deduplicates some context creation code for ra_ctx_create
and ra_ctx_create_by_name.
This adds a new option --show-in-taskbar, which controls whether
mpv appears in taskbars. This is useful for picture-in-picture
setups where the video window should not appear in taskbars.
On X11, this can be controled by setting the
_NET_WM_STATE_SKIP_TASKBAR window state.
Adds support for extracting codec profile. Old properties are redirected
to new one and removed from docs. Likely will stay like that forever as
there is no reason to remove them.
As a effect of unification of properties between audio and video,
video-codec will now print codec (format) descriptive name, not decoder
long name as it were before. In practice this change fixes what docs
says. If you really need decoder name, use the `track-list/N/decoder-desc`.
The protocol strongly implies that this only happens when the value
changes, and it's also what you would naturally expect. But maybe it's
worth guarding this in cause for some reason the same value twice in a
row happens.
The mpv window overlapping multiple outputs with different scale values
can result in some weird behavior when dragging it from one monitor to
another one. This is due to the way some compositors implement
preferred_scale or preferred_buffer_scale (integer scale equivalent).
Depending on the scale values, mpv window has to be resized to match the
new scaling value (due to fractional scaling requiring a viewport). This
can cause the window to become smaller and no longer overlap the monitor
you were just trying to drag it to. Repeat this and the window will
become smaller and smaller. Depending on the layout, the reverse can
also happen (the window becomes larger). This can cause additional
events to fire as the preferred_scale value may change again which does
more weird things.
It seems kwin is not affected by this because their implementation of
preferred_scale sends the event only if the window is fully on the new
monitor. Honestly, this is probably more logical anyway but we should at
least deal with the other implementations better. Try to deal with it by
reworking scaling changes so they only occur when the mpv window is
fully on one monitor. If we get a preferred_scale event and there is an
overlap, save it as a pending change to be performed on the next
surface_enter or surface_leave event (whichever results in there being
only one monitor. Some weird rendering glitches can still happen during
overlap but this makes it usable again.
Turns out libplacebo uses unrotated target crop in relation to source.
Use dst rect from VO, instead of extracting it from pl_frame, to avoid
another unrotating operation.
Fixes: a9354b36ca
Previously if mpv's size was constrained by the compositor's configure
bounds event, there was no attempt to preserve the aspect ratio of the
given coordinates if --keepaspect (the default) was used. Be sure to
apply keepaspect to the bounded widths and heights if we are using this
event.
The reconfigure event handles setting fullscreen, maximize, etc. We were
implictly relying on the compositor to just ignore mpv if we set a
redundant state (e.g. setting fullscreen when we're already fullscreen),
but kwin actually doesn't and operates again. This causes some subtle
issues when handling geometry on state changes. Rework the state change
calls so they are only executed if wl->geometry_configured isn't set yet
(i.e. the window just opened up for the first time). It's the only time
this is actually needed.
If mpv is coming out of some locked size state (fullscreen, maximized,
tiled), the window size given by the reconfigure event should be used
assuming the --auto-window-size option is set.
Fixes 8a9749b8a5
this will prevent jumping of the window size in the case the window size
was 'externally' modified and not via the window-scale property, when
using the pinch gesture.
Fixes#11594Fixes#13799
Lots of filters have generic internal function names like "process".
On a stack trace, all of the different filters use this name,
which causes confusion of the actual filter being processed.
This renames these internal function names to carry the filter names.
This matches what had already been done for some filters.
This commit was originally sparked by a change in sway. When looking at
the wording of the spec, it was believed that the rotation should be
counter-clockwise. But that was interpreted incorrectly. The rotation
direction in the spec is meant for compositors not clients. Clients
should be rotating clockwise and compositors rotate it the opposite
direction. Also see the discussion in upstream wayland*.
*: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/369
This reverts commit 27ef1725e7.
Allows to avoid non-portable strlen usage. Also avoid "initializer
element is not constant" warnings on older GCC that doesn't like
explicit type specification in aggregate initialization.
Co-authored-by: NRK <nrk@disroot.org>
Co-authored-by: nanahi <130121847+na-na-hi@users.noreply.github.com>
This is multiple times faster than just writing every pixel sequence
separately. Especially on slower terminal emulators. In general no need
to stress I/O, while we can just prepare the frame to print and do it
once.
This change is mostly motivated by missing
VK_KHR_portability_enumeration instance extension when enumerating the
devices. Which causes issues with MoltenVK which does not advertise full
Vulkan conformance.
To avoid duplicating code use pl_vk_inst_create() which correctly query
availability and enables the mentioned extension.
While at it fix the VkInstance leaking in vk_validate_dev().
the unfsContentFrame wasn't updated when externally resized leading to
a wrong unfs window size afterwards. update it on windowDidResize event
when not in fs, not animating and not live resizing.
At least on some compositors, when the pointer enters a surface,
only a wl_pointer_enter event is generated, but not wl_pointer_motion.
This results in the initial mouse position being lost, which is
especially problematic when input simulation is used.
Fix this by setting the mouse position on pointer enter event.
this broke with the recent refactor of the input handling. one of the
edge cases was not considered, where not every mouse down event has a
corresponding mouse up event, eg all double clicks or more only have one
up event after the first down event.
this was handled correctly previously.
Fixes#13777
win32 does not respect --native-keyrepeat option, and native key
repeat has been broken since 0ab3482f73.
This lets mpv respect the --native-keyrepeat option on win32.