Commit Graph

49356 Commits

Author SHA1 Message Date
sfan5 f9fd50c654 player: make deprecated track/chapter/metadata events internal
We still need these to track or notify of modifications to certain properties,
but they're now gone from the libmpv ABI.
2021-12-15 12:29:10 +01:00
sfan5 dfcd561ba9 lua: remove mp.suspend, resume and resume_all
These functions were deprecated in v0.21.0 and no-ops
since v0.23.0. The matching client API functions were
removed in the previous commit.
2021-12-15 12:29:10 +01:00
sfan5 632059816a libmpv: remove opengl_cb API and other deprecated symbols
Not all deprecated symbols were removed. Only three events were removed for now
since these are not used internally.
This bumps the library version to 2.0.
2021-12-15 12:29:10 +01:00
sfan5 72915e8b76 {player,video}: remove references to obsolete opengl-cb API 2021-12-15 12:29:10 +01:00
Niklas Haas 0bb15c7a13 af_lavcac3enc: fix memory leak on no-op
Simply returning out of this function leaks avpkt, need to always "goto
done".

Rewrite the logic a bit to make it more clear what's going on (IMO).

Fixes #9593
2021-12-14 21:25:02 +01:00
Philip Langdale 584ab29c88 vo_gpu: opengl: some fixes to make compute shaders work with GLES
It's supposed to work with GLES >= 3.1 but we had all sorts of bad
assumptions in our version handling, and then our compute shaders
turn out not to be GLSL-ES compliant.

This change contains some necessary, but insufficient, tweaks to the
shaders. Perhaps we'll make it actually work some day.
2021-12-12 20:23:31 -08:00
Philip Langdale 2fc327f2fd vo_gpu: opengl: fix OpenGL ES version and extension handling
Some of the extension declarations did not include the ES version where
they became core functionality, and in some of these cases, there was
never actually an ES extension - it first appeared in core. We also had
a number of buggy version checks where ES versions were compared
against required desktop GL versions.
2021-12-12 20:23:31 -08:00
Philip Langdale 0e76372e86 vo_gpu: opengl: try and create context at version 440 again
nvidia follow the OpenGL spec very strictly, with two particular
consequences:

* They will give you the exact context version that you ask for,
  rather than the highest possible version that meets your request.
* They will hide extensions that the specs say require a higher
  version than you request, even if it's technically possible to
  provide the extension at lower versions.

In our case, we really want a variety of extensions, particularly
compute shaders that are only available in 4.2 or higher. That means
that we must explicitly include a high enough version in our list of
versions to check for us to be able to get a 'good' enough context.

As for which version? We restore the 4.4 version that we had in the
old version selection logic. This is the highest version we ever asked
for, and we have separate logic that clamps the GLSL version to 4.4,
so anything newer wouldn't make a difference.
2021-12-07 15:37:29 -08:00
Niklas Haas 9b06a71a5d vo_gpu: opengl: fix wrong glMemoryBarrier
This call was completely wrong.
2021-12-06 23:59:14 +01:00
Jan Ekström 77142ed9b8 sub/lavc_conv: only set subtitle text format when required
Since libavcodec major version 59, the requested "ass" format became
the default as the old timing-included format was disabled starting
with that version. Additionally, this option by itself has since
been deprecated as it no longer serves any purpose.

References:
FFmpeg/FFmpeg@1f63665ca5
FFmpeg/FFmpeg@176b8d785b

Fixes #9413
2021-12-05 22:31:32 +02:00
Niklas Haas 036bda9166 vo_gpu_next: fix UB in query_format()
`plane_data_from_imgfmt` doesn't zero-initialize the struct, so this
contained invalid values for e.g. `row_stride`, causing formats to
*randomly* fail. (Especially any formats with specific alignment
requirements)

Might fix #9424 and #9425.
2021-12-05 21:24:57 +01:00
Kurt Kartaltepe fc94c8c365 wayland: ensure read and draw buffers are assigned
This is a workaround for nvidia proprietary drivers. The authors of
those drivers interpret the spec such that eglMakeCurrent will not
reconfigure the read and draw buffers. Thus windows wont display
anything drawn by opengl. nvidia authors refer to
https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_no_config_context.txt
specifically Issues 2/3 which reference eglMakeCurrent.

On mesa this is a non-issue and the read/draw targets are assigned with
eglMakeCurrent.

The context must be made current in order to query OpenGL strings. An
earlier proposal to create the wayland window surface similarly to X11
during init was deemed inappropriate so instead we manually set the
targets once we have created a window surface.
2021-12-04 03:04:17 +00:00
Aman Karmani 181656955b audio: fix typo 2021-12-03 14:04:58 -08:00
Kurt Kartaltepe d86bfebe6d opengl: support DebugMessageCallback on ES
This function is provided by a different extension on OpenGL ES so we
add a separate gl_functions.
2021-12-02 12:20:16 +01:00
Ivan 87ce3b31a9 ao_openal: enable AL_SOFT_direct_channels_remix extension by default
Prevent audio distortions caused by OpenAL's 3D effects.
2021-11-29 11:27:39 +01:00
Leo Izen ac39af461d player: make --keep-open=always work with --loop-playlist
Allow --keep-open=always to work with --loop-playlist, where
before this patch it would work only on the last playthrough of the
playlist. This patch allows it to work on all playthroughs.

Fixes #9470.
2021-11-28 19:45:52 -05:00
Niklas Haas 4991ffa859 vo_gpu_next: implement VOCTRL_SCREENSHOT
Somewhat annoying but still relatively straightforward. There are
several ways to approach this, but I settled on reusing the pl_queue as
a cheap way to get access to the currently mapped frame. This saves us
from having to process `vo_frame` at all, and also avoids any overhead
from re-uploading the same frame twice.

(However maybe there's some circumstance in which `vo_frame` needs to be
queried/updated first, to get a screenshot of the correct frame? I'm not
sure.)

I also had the option of going with either pl_render_image() on the
extract pl_frame, or just calling pl_render_image_mix directly on it. I
went for the latter, because in the optimal case, this allows the
rendered frame to be directly retrieved from the cache, actually
entirely avoiding any sort of recompute overhead. This makes e.g. ctrl+s
during playback essentially free. (Except for the download cost,
obviously)

It would be even neater if we could make this VOCTRL asynchronous and
thereby leverage libplacebo's asynchronous download capabilities. But oh
well. That will have to wait for a sufficiently rainy day.

Closes #9388
2021-11-28 11:58:53 +01:00
Niklas Haas c66f3b0123 vo_gpu_next: factor out some common helpers
In preparation of VOCTRL_SCREENSHOT support
2021-11-28 11:58:53 +01:00
Dudemanguy f08db00d26 client API: also export mpv_client_api_version
20c4036daa switched to using symbol
visibility attributes for mpv client api functions (for the meson build
at least). Unfortunately mpv_client_api_version was mistakenly missed.
We need to export this function as well. Fixes #9531.
2021-11-27 22:46:54 -06:00
Funami580 448fe0226b osc: fix cache displaying 60s in some cases
It was caused by string.format rounding e.g. 59.9 to 60.
2021-11-27 21:37:24 +02:00
Niklas Haas cc4ac14d51 vo_gpu_next: guard sentinel in free_dr_buf
As noticed in #9526, apparently there's some case in which DR buffers
get corrupted. Add an explicit sentinel check to try and figure out
which cases these are.
2021-11-26 19:59:26 +01:00
Solomon Choina 059bd3dcaa meson: correct champ.c to chmap.c
meson: correct champ.c to chmap.c
2021-11-26 15:13:01 +00:00
Dudemanguy ec97b3f279 meson: add a temporary workaround for iconv crap
The initial iconv dependency worked everywhere but was broken on
freebsd. This was fixed in 0.60.2 but the fix accidentally broke mingw
(ouch; kind of my fault for not double checking). There's another PR to
fix this but that won't land until 0.60.3 so for the meantime just
if/else this (both freebsd and windows work with the system method)
until we want to bump the meson version (probably not for a while since
opensuse tumbleweed is weirdly slow).
2021-11-26 04:43:43 +00:00
Dudemanguy 51da9d257e ci: fix the path for logs on failure in mingw
The old directory was wrong. The actual build directory has the matrix
prefix in its name.
2021-11-25 21:33:29 -06:00
Dave Airlie 8ed1368501 vo_gpu: hwdec_vaapi: avoid drm_fourcc.h dependency
Suggested by haasn
2021-11-25 23:11:37 +01:00
Avi Halachmi (:avih) b8926dd484 osc: add options: chapters/playlist OSD, hover chapter format
Previously OSD was always displayed on {ch,pl}_{next,prev} left-click,
and seekbar-hover-chapter was always enabled and with fixed format.

Now it can be controlled with:
- chapters_osd, playlist_osd: yes/no (only affects left-click).
- chapter_fmt: lua string.format template, or "no" to disable.

Fixes #4675
2021-11-25 21:20:48 +02:00
Dudemanguy 1ab9119817 wayland: increase the vblank waiting time
This commit sucks bad, but everything else is worse is other ways.
Basically, the current vblank waiting time in the vo_wayland_wait_frame
function (calculated very carefully using presentation statistics) is
randomly too short. Some compositors are quite variable when they
actually return callback so our timeout expires too quickly and throws
everything off. The fix? Add an arbitrary 5% to the vblank value and
pray that nothing gets off that much. Why did they have to make
swapinterval 1/fifo mode indefinitely block? Fixes #9504.
2021-11-25 17:20:26 +00:00
Dudemanguy 55b085707a wayland: initialize presentation time values as 0
Better to avoid any wonky calculations on startup with garbage values.
The others end up being derived from last_ust/last_msc. refresh_interval
is referenced exactly once and could, in theory, result in some terribly
erroneous vblank time.
2021-11-24 23:28:53 -06:00
Kurt Kartaltepe 79bfcc6723 wayland: cancel prepared reads when no events
A read can be prepared on the wayland display FD that is never actually
read. This occurs when events are triggered on other FDs in the fd set.
This change cancels a prepared read if poll reported no events for it.

This fixes some hangs due to how nvidia's EGL implementation polls on
the wayland fd unlike mesa implementations. It is based on nvidia's
proposed fix for qt's similar message pump in
https://codereview.qt-project.org/c/qt/qtwayland/+/373473

Signed-off-by: Kurt Kartaltepe <kkartaltepe@gmail.com>
2021-11-25 04:09:31 +00:00
Dave Airlie a6e5eba6ab vo_gpu: hwdec_vaapi: add dma-buf modifiers support.
If the EGL extension is present, pass the modifiers for each plane
to the EGL driver.
2021-11-23 23:18:54 +01:00
sfan5 dc73f1ad4b vo_gpu_next: implement OpenGL context support
Wrapping the context is pretty straightforward. This is only complicated
by needing to account for the upside-down framebuffer in a few places.
2021-11-22 18:08:56 +01:00
sfan5 d5d62c6a64 vo_gpu_next: factor out context-specific code to gpu_next/context.c
This is done to avoid cluttering vo_gpu_next.c with more ifdeffery and context-specific code
when additional backends are added in the near future.
Eventually gpu_ctx is intended to take the place of ra_ctx to further separate gpu and gpu_next.
2021-11-22 18:08:56 +01:00
sfan5 f32ea013dd video: opengl: teach start_frame() about out_fbo == NULL
This case was added in 662c793a55
for use in vo_gpu_next as a visibility test before rendering a frame.
The OpenGL context doesn't have this so it just returns true.
2021-11-22 18:08:56 +01:00
Niklas Haas 4ca6c2ff34 vo_gpu_next: respect tagged YUV colorspace
Fixes 2b2442ee67
2021-11-22 14:40:11 +01:00
Niklas Haas 2b2442ee67 vo_gpu_next: apply csp overrides for RGB/XYZ/YUV formats
This is needed when the color system is not explicitly tagged, but
instead needs to be inferred by the VO.

Note that there exists the function mp_image_params_guess_csp for this
sort of stuff, but it contains a lot of baggage that I don't want to
replicate, in order to move as much of this logic into pl_renderer as
possible, and therefore also give it the best chance of knowing what
shortcuts it can and can't take.

Fixes the other half of https://github.com/mpv-player/mpv/issues/9499
2021-11-22 12:38:43 +01:00
Dudemanguy 67c1ff8dad vo_gpu_next: fix timings without interpolation
Adding vsync_offset to the pts in pl_queue_update actually messes up
frame timings if one isn't using interpolation. The easiest way to see
this is to have the monitor's refresh rate at an integer multiple of a
video during a panning shot (classic case). There will be very visible
judder/stutter in this case that does not happen in vo_gpu. The cause of
this is the addition of the extra vsync_offset. Just match the semantics
of vo_gpu where this is only used when interpolating.
2021-11-21 22:56:30 +01:00
Aman Karmani ac3d567bd3 audio: stop corrupting audio on underreads
regression introduced in b74c09efbf

Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-11-20 12:08:32 -08:00
Niklas Haas 970061efdc vo_gpu_next: fix OOM on wayland
Similar to ff0864d5f0

Fixes #9484
2021-11-20 19:21:50 +01:00
Dudemanguy d2c2bf5a13 wayland: fix a potential segfault on surface enter
This possibility actually existed for years. The wayland protocol is
asynchronous and there's no restriction on when a compositor can send a
surface enter event. In mpv's case, the surface enter event is used to
set some vital things regarded geometry/scaling etc. However, this
implictly assumes that wl->current_output is actually initialized. The
vast majority of the time, vo_wayland_reconfig will happen first which
is where wl->current_output is, and should, be created. There's no
rule/law that the ordering of events will always occur in this order.
Plasma with certain auto-profile conditions can send the surface enter
event before mpv does its initial reconfig. That segfaults of course.
Just add a check to make sure we have wl->current_output here and return
if we don't. This assumes that the compositor will send us another
surface enterance event when mpv actually does the initial surface
commit and roundtrip request later. Wayland logs indicate this does
happen. Fixes #9492.
2021-11-20 10:48:09 -06:00
Dudemanguy 21cdc713bc wayland: support modifiers during axis events
It was never implemented before but it's trivial. As an aside, touch
events currently don't support modifiers either (is this a thing?). Well
if someone complains that can be done later. Fixes #9490.
2021-11-20 09:17:41 -06:00
Dudemanguy 59898331dd DOCS/ao: remove incorrect note about openal
The audio rewrite in d27ad96542 originally
broke this ao. However, 0ac724f002 fixed
and the documentation was never updated to reflect that. OpenAL has
worked fine for a while not. Just remove this sentence.
2021-11-19 16:57:37 -06:00
Niklas Haas 170259c7c3 vo_gpu_next: always cache still frames
Even when not display synced. Prevents redraw overhead for refreshes
while paused.

Also make the logic slightly clearer to follow (since it's inverted).
2021-11-19 22:42:21 +01:00
Leo Izen 763e0d259f vo_gpu_next: fix lancozs typo to lanczos
Fix typo in the warning to avoid ewa_lanczossharp because
it might be removed in the future.
2021-11-19 23:35:27 +02:00
Niklas Haas 7acbecf7b8 vo_gpu: libplacebo: make version logging slightly clearer
Matches what `pl_log_create` does as well.
2021-11-19 21:50:59 +01:00
Dudemanguy e095bdb5f5 meson: use gnu_symbol_visibility for libmpv
Following the previous commit, we can just set gnu_symbol_visibility to
'hidden' to hide everything except for the symbols we explictly want to
export. This should work on gcc, clang, and msvc.
2021-11-19 14:16:41 +00:00
Dudemanguy 20c4036daa client API: use symbol visibility attributes
In mpv, the only symbols we want to export are the functions from the
client API. This is accomplised using a specific .def whitelist, but the
main compilers people use (gcc or clang) like these attributes since it
allows for further optimizations. MSVC also allegedly supports this as
well (untested of course), so use __declspec for tht case.
2021-11-19 14:16:41 +00:00
Niklas Haas 75ee35cec9 vo_gpu_next: simplify and improve frame redrawing logic
This almost perfectly recreates the semantics of --vo=gpu, i.e.:

- still frames are never interpolated
- non-repeated frames bypass single frame cache

The only difference is that libplacebo doesn't do a cache/blit on the
full output image, but rather it re-runs the last rendering step. This
has some advantages and some drawbacks. The most notable advantage is
that it also allows re-using the image contents when the only thing that
changes is the OSD (whereas `--vo=gpu` would force a full re-render for
that). The most notable drawback is that it also implies going through
the dithering and output LUT logic on redraws. All in all, I think this
is a pretty good trade-off in favor of `--vo=gpu-next`.

Fully fixes the last remaining performance difference in #9430.
2021-11-19 14:51:48 +01:00
Tom Yan d1e9f4a159 ao_opensles: add guards for sample rate to use
Upstream "Wilhelm" (the Android OpenSLES implementation) supports
only 8000 <= rate <= 192000. Make sure mpv resamples the audio
when necessary.
2021-11-19 14:27:52 +01:00
Niklas Haas 17df53519f vo_gpu_next: fix panning on rotated videos
Closes #9454
2021-11-19 12:10:25 +01:00
Dudemanguy b89d3f205b meson: fix typo in header check
This should be EGL not GL. Fixes #9469.
2021-11-18 07:43:51 -06:00