Commit Graph

50417 Commits

Author SHA1 Message Date
Philip Langdale 4501e07996 vd_lavc: try other hwdecs when falling back after an hwdec failure
Today, if hwdec initialisation succeeds, we move on to attempting
decoding, and if decoding fails, we enter a fallback path that will
only do software decoding.

This is suboptimal because some hwdecs and codec combinations can
pass hwdec init, but then fail at hwaccel init, or even frame decoding.
In these situations, we will never attempt other hwdecs in the `auto`
or manually specified lists which might work.

One good example is someone tries to use `vulkan,auto` and tries to
play av1 content. The vulkan decoding will fail at hwaccel init time,
and then fallback to software instead of going through the auto list
which would allow vaapi, nvdec, etc to play the file.

Instead, let's not give up immediately, and try the next hwdec after
a failure, just like we do if hwdec init fails.

The key part of this change is to keep track of the hwdecs we have
tried, so that each time we run through hwdec selection, we don't try
the same one over and over again. If we really get through the whole
list with no success, we will then fall back to software decoding.

Fixes #11865
2023-07-14 20:41:24 -07:00
Dudemanguy 1f683401aa vo_dmabuf_wayland: error out if compositor doesn't support the format
This was never implemented so in cases where the compositor didn't have
support for the underlying format, the window would just be black and
quite unhelpful. Well it turns out that fixing this is actually really
easy because mpv has reconfig2 which returns the entire mp_image on
every reconfig. We can just use that mp_image to try and obtain the
format and modifier pair and then use that to check against what we know
the compositor supports. If there are any problems, error out
gracefully. Some code duplication with the vaapi/drmprime importers, but
it's probably better to keep these separate. Fixes #11198 and fixes #11664
2023-07-14 14:24:45 +00:00
Dudemanguy 2616b2b11e build: make dmabuf-wayland a build option and require drm
It makes more sense as an option at this point. Also libdrm is not
optional at all. You have to get a drm format and modifier for this to
even work (the VO will just fail without DRM). Just hard require it and
remove the guards. vaapi can remain optional.
2023-07-14 14:24:45 +00:00
Christoph Heinrich cf0373e15b console: sort the output from the `help` command
Closes #11927
2023-07-14 13:06:01 +00:00
Guido Cella fc43faa026 player: delete watch later redirect entries again
6a365b258a broke deleting redirect entries for resuming playback. If you
do mpv dir1 dir2, quit-watch-later on a file in dir1, then later
quit-watch-later on a file in dir2, mpv dir1 dir2 would not resume from
dir2 because the redirect entry for dir1 is never deleted.

Fix this by deleting watch later config files for directory/playlist
entries.
2023-07-14 13:05:40 +00:00
Dudemanguy 828dd65ef8 wayland: use xdg_surface_set_window_geometry
mpv has never used this because we never really seemed to need it, but
it actually has a purpose. This informs the compositor of the actual
dimensions of the mpv window and avoids errors with sizes not matching
(particularly with weston). It's a better way to fix the "maximizing
causing an error on weston" issue since it also works for dmabuf-wayland
(which always had this problem).
2023-07-13 12:12:37 +00:00
Dudemanguy 4ff27d5220 Revert "wayland_gl: wait until resize to create egl_window"
The original reason for this commit was to prevent a compositor error on
weston when going into the maximized state. The configured dimensions of
mpv didn't match its actual size and Weston is super strict about this
so it threw a compositor error which is fatal. It only happened in
opengl and this seemed like an OK workaround, so I went with this.
However, there's actually a far easier way to solve this problem and we
don't need this anymore. This has the benefit of avoiding a harmless
warning message that appears with gpu-next on opengl. The next commit is
the proper solution. Closes #10324.

This reverts commit 661b5542de.
2023-07-13 12:12:37 +00:00
Dudemanguy 33130741f4 vo_dmabuf_wayland: guard in destroy_osd_buffers
*sigh*
2023-07-12 22:20:20 -05:00
Dudemanguy 7409f4a6c9 vo_dmabuf_wayland: stop lazy loading hwdec
The implementation was copied from vo_gpu/vo_gpu_next but fundamentally
it doesn't make sense for this VO. Hardware decoding is not optional in
vo_dmabuf_wayland. We should be sure to request and load all supported
formats in the preinit and fail if there are any problems. There should
be no functional change from before, but it's more conceptually correct
this way.
2023-07-12 16:59:59 -05:00
Dudemanguy b57cf110c9 vo_dmabuf_wayland: don't try to get pts without frame->current
Fixes a segfault with --force-window=immediate.
2023-07-12 16:59:47 -05:00
Dudemanguy f3c1dcf7a1 draw_bmp: ensure last slice is less than total width (again)
Essentially the same as d1d2370d07 except
for clear_rgba_overlay. From some empirical testing, the s->x1 value is
either 0 or SLICE_W (256). In the case where it is 256 and s->x0 is 0,
then it writes memory. For most slices, this is fine. However for the
very last slice in the loop, it is possible for the width here to exceed
the total width of the line (p->w). If that occurs, the memset triggers
a buffer overflow. This last case needs to be guarded in the same way as
the previously mentioned commit (total width - SLICE_W * x) and with
MPMIN in case s->x1 is 0 here to preserve the old behavior. It's unknown
if anything other than dmabuf-wayland can possibly hit this, but it's
definitely a problem within mp_draw_sub_overlay itself.
2023-07-12 19:19:54 +00:00
Dudemanguy c958990833 vo_dmabuf_wayland: add osd support
This adds osd support via shm buffers using a similar approach that the
normal buffers do, but it differs in a few key areas. One thing to note
is that sway and weston actually handle this extremely differently which
required all the abstractions here. In particular, weston does not cope
well with destroying the wl_buffer from shm outside of the release
handler at all (i.e. it segfaults). The workaround here is to simply
attach a NULL to the osd surface and do a surface commit before we
destroy the buffers. This is reasonable enough and seems to work well
although it's pretty weird. Sway is more straightforward although it
actually releases the osd buffer when the window goes out of sight.
Also, I found that it doesn't always release every buffer before you
close it unlike weston seems to do which is part of the reason all this
bookkeeping is required. I don't know if there's any other compositor
out there that can possibly handle vo_dmabuf_wayland right now, but
suffering through these two is good enough for now I think.
2023-07-12 19:19:54 +00:00
Dudemanguy 180a3df1f1 vo_dmabuf_wayland: init wl_list at the top of preinit
Otherwise, we could fail and skip to uninit without initalizing this
which then will segfault because the list is null and accessed while
trying to destroy buffers.
2023-07-12 19:19:54 +00:00
Dudemanguy a890d7be2a vo_dmabuf_wayland: stop guarding viewport interfaces
It's entirely pointless. Not having viewport is already a fatal error
for this VO as it cannot possibly work without that protocol. Just drop
all these redundant if's.
2023-07-12 19:19:54 +00:00
NRK dc06dec1ee video/image_writer: check for write errors
make sure that fwrite is error checked. and if any data was still
remaining on the buffer, it will be flushed - and errors checked - via
the fclose() call below.
2023-07-11 19:55:28 +02:00
NRK 6b76000f0b video/image_writer: fix file leak in error path
regression from de7f4fb1e
2023-07-11 19:55:28 +02:00
Adam Sampson 6461fb9c44 wscript: add 1.32 protocols to sources
The patch that added these protocols didn't include them in the list of
sources, which caused build failure with wayland-protocols 1.32.
2023-07-11 17:33:59 +00:00
m154k1 cbb1af64d5 stats.lua: set sans-serif as default font
sans is deprecated and unsupported on some platforms.
2023-07-10 16:58:54 +02:00
llyyr a0f1bbddff wayland: add xdg_toplevel.wm_capabilities handler
Fixes crash when compositors advertise xdg_toplevel version >= 5
2023-07-10 13:37:23 +00:00
Dudemanguy 7beae9ac86 wayland: add support for suspended toplevel state
mpv already guesses when the window is hidden so plugging in a proper
event that actually tells us this is really trivial. Note that there's
some redundancy with setting wl->hidden in a few spots, but nothing can
really be done about that as long as the crappy hack is still in place.
2023-07-09 19:22:53 +00:00
Dudemanguy 589da09e5a wayland: add cursor-shape-v1 support
This protocol no longer requires us to draw a separate cursor surface
and all of that horrible stuff. We can just ask the compositor for the
default cursor instead since that's literally all mpv cares about.
2023-07-09 18:10:19 +00:00
Kacper Michajłow fc3e28f1e9 vd_lavc: fix delay_queue for videos with frames < max_delay_queue
In case there are no packets from demuxer we cannot send EAGAIN, because
we will not proceed and get stuck with one frame in queue and never
output it. Just respect avcodec_receive_frame ret code and act
accordingly. The only case to care about is EOF when we have to drain
already queued frames.

Fixes playback of 1-2 frame videos.
2023-07-09 11:59:32 +02:00
Kacper Michajłow bf77f1ae74 vd_lavc: prefer d3d11va-copy over dxva2-copy
There is no reason to prefer dxva2. I believe it was mistake from
initial commit that added the hwdec list that has been propagated
through years.
2023-07-09 11:59:32 +02:00
Dudemanguy ab3002851e vo_wlshm: bail out of resize if width/height is 0
It can happen during initialization and of course nothing good will
happen if we let this go through (i.e. segfault). Return and wait for
geometry to finish setting up in the wayland stuff before doing the
initial resize.
2023-07-08 20:47:35 -05:00
Dudemanguy 0242055564 wayland: fix memory leak with multiple monitors
Very dumb. I can't remember if it was always like this or if I broke it
at some point, but clearly each wl_output should just be freed in
remove_output. Freeing it if it happens to be wl->current_output only
works for that one monitor, so remove that whole line. This has to
happen before we close the wayland connection so reorder the uninit a
little bit.
2023-07-08 20:31:09 -05:00
Dudemanguy 6a365b258a player: delete watch_later file after successful load
Currently, mpv immediately deletes the watch_later file after an attempt
at playing the file is made. This is not really ideal because the file
may fail to load for a variety of reasons (including not even existing),
but the state is cleared anyway unconditionally. Instead, just wait
until after playback is successfully initialized before deleting it.
This way silly mistakes like forgetting to mount the drive doesn't
result in deleting your watch_later data. Fixes #3427.
2023-07-08 14:33:47 +00:00
cvzi f5eb7ea1a9 json: unify json_parse depth to MAX_JSON_DEPTH=50 2023-07-08 11:36:15 +02:00
NRK 2e7fcc5a2a terminal-unix: better error detection logic
the reason for checking `EBADF|EINVAL` specifically is unknown. but it's
clearly not working as intended since it can cause issues like #11795.

instead of checking for "bad errors" check for known "good errors" where
we might not want to break out. this includes:

* EINTR: which can happen if read() is interrupted by some signal.
* EAGAIN: which happens if a non-blocking fd would block. `tty_in` is
  _not_ non-blocking, so EAGAIN should never occur here. but it's added
  just in case that changes in the future.

Fixes: https://github.com/mpv-player/mpv/issues/11795
Closes: https://github.com/mpv-player/mpv/pull/11805
2023-07-08 09:03:06 +02:00
Dudemanguy 6ed521fd14 TOOLS/idet: fix some outdated cli syntax
d3cef97ad3 changed the way the command
line was parsed and syntax like "--foo value" stopped being considered
valid. This old script still was using the old syntax and thus was
broken. Update it to "--msg-level=ffmpeg=v" which is the recommended
syntax. Fixes #11892.
2023-07-06 22:40:51 -05:00
Christoph Heinrich 2da0c0b33f demux_playlist: sort files before directories 2023-07-06 18:17:45 +00:00
Christoph Heinrich f266eadf1e demux_playlist: add option to control recursive directory loading
Directories were always loaded recursively, which can be slow
(e.g. one of the subdirectories is a mounting point to a slow device)
and can unexpectedly expand into a massive playlist.

Due to the problems described in 503dada42f,
this defaults to recursive loading.

ref. https://github.com/mpv-player/mpv/issues/9652
2023-07-06 18:17:45 +00:00
llyyr 9ad14e0886 TOOLS/lua/autoload: allow extending ext sets from script-opts 2023-07-06 13:42:54 +00:00
Dudemanguy ee69d99bd4 various: correctly ignore cache files with --no-config
--no-config should prevent loading user files of any type: configs,
cache, etc. For cache files, this case wasn't properly handled and it
was assumed they would always get something. vo_gpu's shader cache
actually already handles this, so it was left untouched. In theory,
demuxer cache should never have this issue because saving it to disk is
disabled by default (and likely that will never change), but go ahead
and change it for consistency's sake. Fixes some segfaults with
--no-config and various combinations of settings (particularly
--vo=gpu-next).
2023-07-06 13:08:23 +00:00
Dudemanguy 48e0ee9979 vo_gpu/vo_gpu_next: enable gpu shader and icc cache by default
4502522a7a changed the way mpv handled and
saved cached files. In particular, it made a separate boolean option for
actually enabling cache and left the *-dir options as purely just a path
(i.e. having a dir set didn't mean you save cache). This technically
regressed people's configs, so let's just turn the cache on by default.
Linux users already expect random stuff in ~/.cache and well everyone
else can just live with some files possibly appearing in their config
directory.
2023-07-04 22:14:43 +00:00
Dudemanguy d6a6901090 vo_gpu: fix some cache related memory leaks
I goofed this up.
2023-07-04 22:14:43 +00:00
Dudemanguy dbc0fcea1b player: add --input-cursor-passthrough option
Add an option for allowing pointer events to pass through the mpv
window. This could be useful in cases where a user wants to display
transparent images/video with mpv and interact with applications beneath
the window. This commit implements this functionality for x11 and
wayland. Note that whether or not this actually works likely depends on
your window manager and/or compositor. E.g. sway ignores pointer events
but the entire window becomes draggable when you float it (nothing under
the mpv window receives events). Weston behaves as expected however so
that is a compositor bug. Excuse the couple of completely unrelated
style fixes (both were originally done by me).
2023-07-04 19:16:43 +00:00
Eva 3ba446d0b0 TOOLS/lua/autoload: avoid unnecessary playlist manipulation, performance
We used to sort the playlist with playlist-move after every loadfile.
Instead, append all files in order and call playlist-move once to move
the only entry we don't control the position of.
Don't fetch every playlist item separately, reuse native property.
We used to pick up on new files added to the directory, but only when
playing an entry at the edge of the playlist due to an early return.
New files are now added to the playlist on every file change.
This still works as expected and doesn't load duplicate files on
shuffled playlists or playlists with files manually added after autoload

33% faster on average for my test directory with 1371 files.
2023-07-03 02:41:58 +00:00
Dudemanguy c8a54a8c23 wscript: bump required libplacebo-next version to 5.266
Was forgotten in b73d96776c. Can't wait
until we finally remove the waf build.
2023-07-02 20:04:42 +03:00
Kacper Michajłow d2c28bc4df vo_gpu_next: remove synchronization from info_callback
VOCTRL is processed on VO thread.
2023-07-02 16:20:48 +02:00
Kacper Michajłow b73d96776c vo_gpu_next: use pl_dispatch_info_move to avoid useless data copy
Instead copy the data on-demand when VOCTRL_PERFORMANCE_DATA is
requested.
2023-07-02 16:20:48 +02:00
Kacper Michajłow c637beb522 ci/msys2: double down on running meson through python3.11
Run not only scripts inside build system, but also meson itself with
Python 3.11.

Fixes: eb4da3400a
2023-07-02 15:15:43 +02:00
NRK b616a6cef1 vo_x11: don't rely on XFree to free calloc-ed data 2023-07-02 12:47:31 +02:00
NRK fa7503989f vo_x11: check for calloc() failure 2023-07-02 12:47:31 +02:00
Dudemanguy f76c441ba2 win32: add support for drag-and-drop option 2023-07-01 02:06:02 +00:00
Dudemanguy 6625a94608 options: add no to drag-and-drop
Suggested by @sfan5. Naturally, "no" disables all drag and drop
behavior.
2023-07-01 02:06:02 +00:00
cloud11665 b45be3d6e9 test/meson: explicitly specify lavf dependency
Added stubs for mp_set_avdict().
2023-07-01 02:05:23 +00:00
cloud11665 695172f63e player/screenshot: add "screenshot" logger 2023-07-01 02:05:23 +00:00
cloud11665 de7f4fb1ee video/image_writer: add avif screenshot support
Notes:
- converts the (image) write() api to filenames, because using avio
with FILE* is a pain.
- adds more debug logs for screenshots.

build: rename av1 dependency to avif_muxer
wscript: unify lavf dependency with meson
2023-07-01 02:05:23 +00:00
NRK 0bfafd2451 options: drop unnecessary casts
the reason for these casts are unknown but they were presumably to
silence warnings 9 years ago. but it doesn't seem to be necessary
nowadays, so just drop the casts and also drop the `const` from the
compound literal type.

some small technical notes:

1. while string literals aren't `const` in C, writing to them is
   undefined (do not ask me why). and so compilers will typically put
   string literals into read only section anyways, regardless of
   weather `const` was used in the source or not. so this shouldn't make
   any difference codegen wise.
2. making the array of pointers `const` on the other hand might affect
   codegen, eg: `(char *const []){...}`. however, that'd trigger a lot
   of discarded qualifier warnings.
2023-06-30 10:22:15 +02:00
NRK 39957c251c options: use designated initializer
shorter and more robust this way instead of inserting at an index by
manually counting.

the surrounding code also uses `[STREAM_*] = ..` so it's more consistent
as well.
2023-06-30 10:22:15 +02:00