Commit Graph

5527 Commits

Author SHA1 Message Date
Philip Langdale ba6af0fb15 vulkan: don't assume all ra_ctx implementations have a swapchain
The dmabuf-wayland vo has a stub ra implementation that doesn't
have a swapchain. That means that it's currently not safe to call
ra_vk_ctx_get on that ra_ctx, but it must be safe to call on all ra
implementations as this is how we discover if it is a vulkan ra.

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

There are two main things going on here:

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

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

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

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

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

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

With that ffmpeg change, we can just use the normal layout information
like all the other hwdecs.
2023-05-29 10:16:29 -07:00
Philip Langdale 872b068cb7 f_hwtransfer: disable vulkan multiplane images when uploading from cuda
Although we can support vulkan multiplane images, cuda lacks any such
support, and so cannot natively import such images for interop. It's
possible that we can do separate exports for each plane in the image
and have it work, but for now, we can selectively disable multiplane
when we know that we'll be consuming cuda frames.

As a reminder, even though cuda is the frame source, interop is one way
so the vulkan images have to be imported to cuda before we copy the
frame contents over.

This logic here is slightly more complex than I'd like but you can't
just set the flag blindly, as it will cause hwframes ctx creation to
fail if the format is packed or if it's planar rgb. Oh well.
2023-05-28 15:46:05 -07:00
Philip Langdale 45a2d8c670 vo: vulkan: request additional extensions and features for ffmpeg
Vulkan hwdec interop with the ffmpeg 6.1 vulkan code will require
additional features beyond those activated by libplacebo by default.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
2023-04-20 14:37:15 -07:00
iczero d65e56216d wayland: correctly scale configure_bounds 2023-04-11 20:05:17 +00:00
Mika Kuoppala 95d7b05e71 video/out/gpu: Fix compilation warning of out of bound access
Make the index into the arrays in copy_image()
unsigned to make compiler trust that we dont access
out of bounds.
2023-04-10 10:48:16 -04:00
quietvoid 1808f264b3 mp_image: always add AV_FRAME_DATA_DOVI_METADATA when present
As the Dolby Vision metadata is only supported for vo_gpu_next, the check
whether to use the metadata is now handled by `mp_map_dovi_metadata_to_pl`.

It doesn't hurt to keep the metadata in `mp_image`, and might be useful to
library users.
2023-04-10 05:18:58 -04:00
Kacper Michajłow 9feeb324ed win32: follow Windows settings and update dark mode state
Microsoft documented how to enable dark mode for title bar:

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

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

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

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

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

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

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

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

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

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

[1]: https://github.com/haasn/libplacebo/blob/master/src/d3d11/swapchain.c
2023-02-28 14:41:33 +00:00
averne 3e351a41e2 vf_gpu: initialize depth=1 on target textures
According to internal documentation, 2D textures should have d=1.
This fixes the correctness of the API usage, not any bug.
2023-02-28 14:13:55 +00:00
averne 4fbc3ad399 video: initialize depth=1 on screenshot textures
According to internal documentation, 2D textures should have d=1.
This fixes the correctness of the API usage, not any bug.
2023-02-28 14:13:55 +00:00
Thomas Weißschuh ed5426c351 various: fix warning -Wimplicit-const-int-float-conversion 2023-02-26 16:45:07 +01:00
Thomas Weißschuh 8d67e891ab vo_gpu_next: fix warning -Wunused-function 2023-02-26 16:45:07 +01:00
Thomas Weißschuh b4ae1551e4 vo_wayland: fix warning -Wvoid-pointer-to-enum-cast 2023-02-26 16:45:07 +01:00
sfan5 5a83745316 vd_lavc: sort hwdecs without hwdevices last for autoprobing
For hwdecs without devices we can't get instant feedback during probing
whether the hwdec can possibly work or not, so we definitely want to try them last.
Independently this would also have solved the issue addressed by the previous commit.
2023-02-26 16:40:59 +01:00
sfan5 1dda09b817 vd_lavc: prioritize mediacodec for hwdec autoprobe
This fixes an issue where mpv would try mediacodec (which may not
be available depending on Android version) and pick v4l2m2m next
which ends up failing even though mediacodec-copy would have been available.
2023-02-26 16:40:59 +01:00
Thomas Weißschuh 16f0cd546d video: make csp option definitions private 2023-02-24 13:55:29 +01:00
Thomas Weißschuh fb48722234 video: make csp equalizer params float
This allows more precise adjustments.

Fixes #11316
2023-02-24 13:55:29 +01:00
sfan5 0d991eba72 vo_gpu: fix newline in log message 2023-02-24 13:33:45 +01:00
Kacper Michajłow 84f6d7a97e vo_gpu_next: fix color space hint with target peak override
Fixes: #11339
2023-02-23 10:14:53 +01:00
Christoph Heinrich c0807e98fb options: remove explicit initialization of integers to 0 2023-02-21 17:15:17 +00:00
Christoph Heinrich 4ebfe9851c options: transition commands from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
Christoph Heinrich 91cc0d8cf6 options: transition options from OPT_FLAG to OPT_BOOL
c784820454 introduced a bool option type
as a replacement for the flag type, but didn't actually transition and
remove the flag type because it would have been too much mundane work.
2023-02-21 17:15:17 +00:00
Thomas Weißschuh 9efce6d4ae various: drop unused #include "config.h"
Most sources don't need config.h.
The inclusion only leads to lots of unneeded recompilation if the
configuration is changed.
2023-02-20 14:21:18 +00:00
rcombs d1cf89b655 Vulkan: add configure check for VK_KHR_display extension
This allows building directly against ICDs that don't implement this extension.
2023-02-20 00:05:26 -06:00
Niklas Haas 9a752e8b26 vo_gpu_next: add --tone-mapping-visualize 2023-02-19 21:01:40 +01:00
quietvoid 41ad51bda2 vo_gpu_next: parse Dolby Vision metadata for dynamic scene brightness
Improves playback for Dolby Vision video files as the metadata can be
used instead of requiring `hdr-compute-peak=yes`.
2023-02-19 20:50:37 +01:00
quietvoid 0d82afbc7f mp_image: forward AV_FRAME_DATA_DOVI_RPU_BUFFER side data
When available, and ignored if `vf=format:dolbyvision=no`.
2023-02-19 20:50:37 +01:00
Dudemanguy e2cdc23af0 Revert "vo_dmabuf_wayland: drop support for linux-dmabuf-v2"
This was originally dropped because it was thought to be unneeded at the
time, but at least some devices (rockchip) apparently are still on old
compositors that use linux-dmabuf v2. It's not much code, and for
testing purposes it's good to have around since it's hard to test
drmprime otherwise. Some minor additions are here to support the newly
added vaapi-format mapping in v2 of the protocol.

This reverts commit a5b9d529ee.
2023-02-18 02:21:54 +00:00
Leo Izen 7607432127 video/image_writer: use effort=4 default for JXL screenshots
effort=4 has a significant increase in quality/bpp compared to effort=3
with a very minor increase in encoding time. It's worth the trade-off
as a default setting for lossy encoding.
2023-02-17 17:40:11 -05:00
Niklas Haas 16ef237da5 vo_gpu_next: allow native CSP screenshots
Useful for getting native screenshots of non-sRGB content, such as HDR
etc.
2023-02-13 21:53:41 +01:00
Niklas Haas c975888584 player/screenshot: pass on ability to output native CSP
Fixes: #10988
2023-02-13 21:53:41 +01:00
Niklas Haas 6d9e72cd89 video/image_writer: force sRGB for unsupported formats
After commit c98e7353, we blindly pass the screenshot colorspace to the
image writer. But since we want to introduces the ability to save images
in HDR and other exotic formats, we should strip this for unsupported
formats.

See-Also: #10988
2023-02-13 21:53:41 +01:00
Niklas Haas 01351a6412 video/image_writer: add image_writer_flexible_csp
PNG only supports this since the introduction of cICP, so put a version
check on the next API version bump after the cICP writing patch got
merged.
2023-02-13 21:53:41 +01:00
Niklas Haas 862be6c237 vo_gpu_next: tag screenshots with correct colorspace
When taking window screenshots with a colorspace override, tag them
appropriately, based on the best-known colorspace info. Note that this
is imperfect, we should ideally also attach the output ICC profile if
one exists. But this is better than nothing.

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

I decided to split this off from subsequent refactors because it is IMO
a bug fix deserving of its own commit.
2023-02-13 21:53:41 +01:00
Niklas Haas 4f84d91df2 vo_gpu_next: be explicit about screenshot repr
Screenshots are currently always RGB. Subject to change, but needs to be
communicated clearly if changed. This commit is not a functional change,
it's merely for code clarity.
2023-02-13 21:53:41 +01:00
Niklas Haas 2d4a243810 vo_gpu_next: expose --tone-mapping=st2094-40 and st2094-10 2023-02-13 17:52:35 +01:00
Niklas Haas 79b093f210 vo_gpu_next: support mapping HDR10+ dynamic metadata
Based on the new upstream helper function `pl_map_hdr_metadata` and the
existing AV_FRAME_DATA_DYNAMIC_HDR_PLUS. This allows us to use SMPTE
2094-40 dynamic HDR tonemapping in mpv, albeit with the limitation of
requiring `--tone-mapping=auto` in order to pick this curve upstream.
2023-02-13 17:52:35 +01:00
Dudemanguy 1126df0d80 vf_sub: undeprecate
3a9e661e92 officially made this video
filter deprecated roughly 6 years ago. Every other video filter in that
commit has actually been removed since then except for vf_sub. ffmpeg
does have its own subtitles filter, but it doesn't have the same control
over scale like vf_sub does. That's probably why wm4 never actually
removed it. Let's stop scaring users with a warning since this filter
probably won't ever get removed. Closes #9254.
2023-02-11 00:50:11 +00:00
Aaron Boxer 49fd6caa43 vo_dmabuf_wayland: reject hw formats not supported by compositor 2023-02-11 00:46:46 +00:00
Leo Izen 8ba7b8f0d2 video/image_writer: change screenshot-tag-colorspace default to yes
With significant improvements to the color tagging support in various
screenshot formats, e.g. cICP in FFmpeg, and JPEG XL's generally robust
color support, it's safe to default this to yes.
2023-02-09 21:03:28 +01:00