Commit Graph

51091 Commits

Author SHA1 Message Date
Dudemanguy 8641cbaab6 vo_dmabuf_wayland: free frame if the visibility check fails
Forgotten in 7b8a30fc81. Every other case
either is either a dummy frame (no allocated memory) or we manage it as
part of the usual wayland buffer release.
2023-10-04 16:21:47 -05:00
Guido Cella ec80981c79 external_files: remove duplicate from cover art whitelist
I made a mistake in 0070a5820e here because there were 2 separate groups
of "front" filenames.
2023-10-04 15:31:38 +00:00
Dudemanguy 7b8a30fc81 vo_dmabuf_wayland: eliminate an extra frame copy
When implementing vo_dmabuf_wayland, it always did a copy of the image
from the current frame and worked with that. The reason was because
mpv's core held onto the frame and caused some timing issues and
rendering glitches depending on when it freed the image. This is pretty
easy to fix: just make vo_dmabuf_wayland manage the the frames. In vo.h,
we add a boolean that a VO can set to make them manage freeing frames
directly. After doing this, change the buffers in vo_dmabuf_wayland to
store the whole vo_frame instead of just the image. Then, just modify
some things a bit so frame is freed instead of the image. Now, we should
truly have zero-copy playback. Well as long as you don't use libass to
render anything (that's still a copy from system memory).
2023-10-03 23:45:20 +00:00
Dudemanguy d147a06e60 TOOLS/lua/autoload: bump the msg-level of some logging
msg.info for when you're potentially adding hundreds of files is way
too spammy and not really useful (autoload loads files, what?). Bump it
up to msg.verbose. Also bump up the previously existing msg.verbose logs
up to msg.debug to keep the difference in log levels. Fixes #12551.
2023-10-03 23:39:42 +00:00
Dudemanguy ace4d252e5 meson: declare libmpv as a dependency and override it
This allows libmpv users to build it as a subproject easily, i.e. meson
setup build --force-fallback-for=mpv -Dmpv:libmpv=true, if the mpv
source is in the subprojects directory. Mainly useful for development.
2023-10-03 15:46:14 +00:00
Kacper Michajłow 01c5346d1a win32: adjust WM_NCACTIVATE for better compatibility with window state
We have to support all changing states, not only borderless.
2023-10-02 21:51:47 +00:00
Dudemanguy 47dec1c7c2 vo_dmabuf_wayland: attach solid buffer when using force window
e125da2096 changed the z order of the
surfaces a bit, but it turns out this has a side effect. If the aspect
ratio of the actual video doesn't match your display, the osd surface
doesn't scale properly and gets clipped. Put the z ordering back where
it used to be. Instead when we have the force window case, simply attach
the already existing solid buffer to the video surface. This allows the
osd surface to actually draw over it instead of always being obscured so
it satisfies the case of not having any real video frames but still
wanting to draw the osd. Also don't mess with any of the viewport source
setting stuff with force window. Weston complains about it, and it's
nonsensical anyway. Fixes #12547.
2023-10-02 15:58:03 -05:00
Dudemanguy 05d79298b8 codec_tags: map some more image mimetypes
This only had jpeg and png in it strangely enough. Fixes #11592.
2023-10-02 17:49:48 +00:00
sfan5 df758880e2 path: don't override "cache" and "state" paths with configdir
This reverts commit 576e86bfa1 (functionally).

Right now, the --config-dir option silently causes all watch_later and cache
files to be written in the --config-dir as well. This is pretty uninitutive
and also not desirable in most cases so get rid of this.
libmpv users will have to set the corresponding options or env vars if they
want to keep the old behaviour.
2023-10-02 18:48:10 +02:00
Dudemanguy 0a1e3d8685 demux: move parent_stream_info before the goto
Previously if the demuxer didn't exist, then it could jump down and try
to free sinfo.filename before it was ever set thus segfaulting. Just
always set the struct unconditionally so we're always sure to free it.
2023-10-01 16:11:53 -05:00
Dudemanguy d50de74c1e Revert "demux: constify a struct member"
Some demuxers actually close the stream right after they are finished
opening like cue. Since the stream->url is no longer copied with this
commit, that means it gets thrown away after the stream closes. This
leads to a use after free. We still need to allocate stream->url so fix
this another way.

This reverts commit 3e85df3b2d.
2023-10-01 16:11:06 -05:00
Guido Cella 0070a5820e external_files: base cover-art-whitelist on cover-art-auto-exts
Combine the cover art whitelist with the extensions in
--cover-art-auto-exts instead of hardcoding them. This is shorter,
checks for more extensions, saves us from updating the whitelist
everytime we add a new image extension, and since the whitelist had
gotten so big and the priority is calculated as
MP_ARRAY_SIZE(cover_files) - n, files like cover.jpg were taking
priority over cover art loaded by --cover-art-auto=exact.
2023-10-01 19:32:45 +00:00
Dudemanguy c4c70d8efe DOCS/interface-changes: also mention --window-affinity
Added in 2c738ca54b. I guess we seem to
always mention any added option these days so might as well.
2023-10-01 12:52:35 -05:00
Kacper Michajłow d64201ce29 DOCS/interface-changes: mention --backdrop-type
Added in f19ada7b58
2023-10-01 17:05:34 +00:00
Kacper Michajłow a98641cf45 win32: add WS_THICKFRAME style in borderless mode
Fixes window resizing in borderless mode after adding WS_SYSMENU.

Fixes: 172d9be300
2023-10-01 15:57:31 +00:00
Dudemanguy 0b70598358 vo: fully replace draw_image with draw_frame
0739cfc209 added the draw_frame API
deprecated draw_image internally. VOs that still used draw_image were
around, but really there's no reason to not just "upgrade" them anyway.
draw_frame is what the "real" VOs that people care about (gpu/gpu-next)
use. So we can just simplfy the code a bit now. VOCTRL_REDRAW_FRAME is
also no longer needed so that can be completely deleted as well. Note
that several of these VOs are legacy crap anyway (e.g. vaapi) and maybe
should just be deleted but whatever. vo_direct3d was also completely
untested (not that anyone should ever use it).
2023-10-01 14:48:38 +00:00
Guido Cella 043189c229 restore-old-bindings.conf: remove unusable bindings
Remove keybindings for properties that have been removed because they
can no longer be used even if you restore them.

Replace dvb-channel-name with dvbin-channel-switch-offset.

Fix the L keybinding: it was bound to cycle-values loop when loop was an
alias for loop-playlist, but now it's an alias for loop-file.

"osd" was a command that cycles osd-level from 0 to 3.

Keep only the newest I show-text "${filename}" from mpv 0.26, the mpv
0.5 line for it is a mistake because it was bound to that in input.conf
from a749c61437 (2012) until 2e84934be7 (2017), while mpv 0.5 is from
2014.
2023-10-01 14:09:46 +00:00
Dudemanguy 9d9e986e06 demux: fix erroneous condition in lazy_stream_needs_wait
Yeah another try at this. So when inspecting lazy_stream_needs_wait, I
realized it had a curious !ds->reader_head condition. Actually, this is
what is messing everything up. This was originally added in
cf2b7a4997 for showing large negative sub
delay values correctly. It worked because the packet will eventually be
discarded during playback causing ds->reader_head not exist and thus the
next one will correctly be read ahead as needed.

But for the "switching subtitle tracks while paused" case, this is
actually bad. As the stream is read, eventually you'll find a packet and
set the reader_head. But it's not going to be the correct packet (unless
you're looking for the very first one), so you need to read more. This
won't happen because of the !ds->reader_head check and unlike the sub
delay case, nothing will eventually discard that packet since playback
isn't occuring. So read_packet exits earlier than it should and isn't
tried again, so the subtitle that you want won't show since the
returned packet has the wrong pts. All that needs to be done here is to
delete this one condition. There's already checks in place to make sure
that it's not read past the desired timestamp and for the sub delay case
(the only other time this logic is used), it makes no difference since
you won't read past the specified pts in the first place.
2023-10-01 14:06:45 +00:00
Kacper Michajłow 172d9be300 win32: set WS_SYSMENU style always
Fixes missing icon when initial window is created without caption.

Fixes: #12472
2023-10-01 14:05:10 +00:00
Christoph Heinrich e9690727a0 DOCS/lua: remove superfluous parameter
This seems to have been a leftover from copying the entry below it.
2023-09-30 15:17:10 +00:00
Dudemanguy 3a572c7a88 Revert "demux: improve stream selection state"
The stream selection state wasn't improved. I didn't realize this messed
with caches. All in all, just not a good idea. Back to drawing board I
guess.

This reverts commit f40bbfec4f.
2023-09-30 09:02:57 -05:00
Dudemanguy 84fa7ea411 msg: use nanosecond precision
The timestamps when making a log file is actually dependent on
MP_START_TIME. This is a 10 microsecond offset that was added to the
timer as an offset. With the nanosecond change, this unit needs to be
converted as well so the offset is the same as before. After doing that,
we need to change the various mp_time_us calls in msg to mp_time_ns and
do the right conversion. This fixes the logs timestamps (i.e. so they
aren't negative anymore).
2023-09-29 18:20:30 -05:00
Kacper Michajłow 0ba6ca6f76 vo: don't invoke wait, when not needed
This causes only problems, because we convert mp_time to realtime, which
is not atomic, so we introduce error. And even though on sane platforms
it should work fine, after all the sleep time is in the past.
winpthreads like to sleep for like over 10ms when the time is less than
current time, but not more than 1s.
2023-09-29 20:48:58 +00:00
Kacper Michajłow 7035debddf vo: increase display refresh rate estimation limit from 99 Hz to 400 Hz
High refresh rate displays exists...
2023-09-29 20:48:58 +00:00
Kacper Michajłow df764bc0c3 vo: change vsync base to nanoseconds
There is no reason to use microseconds precision. We have precise timers
all all relevant platforms.
2023-09-29 20:48:58 +00:00
Kacper Michajłow cdfd5c280a win32/pthread: define _POSIX_TIMERS to notify they are not supported 2023-09-29 20:48:58 +00:00
Kacper Michajłow 318b5471a1 win32/pthread: don't convert time through unrelated timer
Just keep it directly as mp_time for internal implementation.
2023-09-29 20:48:58 +00:00
Kacper Michajłow d263087713 meson: don't link pthreads when internal impl is used 2023-09-29 20:48:58 +00:00
Kacper Michajłow d0e4eabb4e meson: add missing gl-video test dependency 2023-09-29 20:48:58 +00:00
Kacper Michajłow 9606c3fca9 timer: teach it about nanoseconds
Those changes will alow to change vsync base to more precise time base.
In general there is no reason to truncate values returned by system.
2023-09-29 20:48:58 +00:00
Kacper Michajłow 40e0fea6eb timer: rename mp_add_timeout to reflect what it actually does 2023-09-29 20:48:58 +00:00
Kacper Michajłow f338420fd2 timer: remove dead code
This is not a proper way to do unit tests or whatever that was.
2023-09-29 20:48:58 +00:00
Kacper Michajłow 1a529ee1d5 timer: simplify mp_time_us_to_realtime 2023-09-29 20:48:58 +00:00
Kacper Michajłow da4c4d2ebd timer: rename mp_time_us_to_timespec to reflect what it actually does 2023-09-29 20:48:58 +00:00
Kacper Michajłow 381386330b ao_audiotrack: convert to nanoseconds 2023-09-29 20:48:58 +00:00
Mike Will 233f1e46f6 playloop: make chapter property more accurate when seeking chapters
When seeking chapters, `last_chapter_seek` acts as a projection of
what the current chapter will be once mpv has a chance to seek to it.
This allows for more accurate results from the `chapter` property.

It works by comparing the projection to the actual current chapter
and returning the larger of the two indexes, but this only works when
seeking forward.

If we want it to work for both forward and backward chapter seeking,
we can instead use a boolean called `last_chapter_flag`, which gets
switched on when a chapter seek request is made, and then
switched off when the seek has been performed.

We should also check to ensure that we don't allow the chapter index
to be set to -1 unless there is a span of time between the very
beginning of the track and the start of the first chapter.

Since the new approach to resetting `last_chapter_seek` no longer
depends on `last_chapter_pts`, that member variable can be removed.
2023-09-29 20:25:50 +00:00
Dudemanguy 27ef1725e7 vo_dmabuf_wayland: assume counter-clockwise rotations
In practice, most compositors implement the rotation clockwise which
matches mpv's option, but amusingly this is actually incorrect.
According to the spec*, wayland buffer rotations are counter-clockwise.
So with this assumption in mind, in order for the rotation to match
mpv's usual semantics, the 90 degree and 270 degree positions need to be
flipped. Of course, this will make the VO rotate the wrong way on most
compositors, but this is what the spec says (sway master is known to
currently be correct). Fixes #12508 (sort of but will break the rotation
direction on other compositors. Oh well).

*: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
2023-09-29 17:00:05 +02:00
hbiyik c19115c8da hwdec_drmprime: add nv16 support
NV16 is the half subsampled version of NV12 format. Decoders which
support High 4:2:2 of h264 provide the frame in NV16 format to establish
richer colorspace. Similar profiles are also available in HEVC and other
popular codecs. This commit allows NV16 frames to be displayed over
drmprime layers.

Signed-off-by: hbiyik <boogiepop@gmx.com>
2023-09-29 12:10:59 +02:00
Kacper Michajłow ae230b1294 audio/chmap: support up to 64 channels
This fixes AAC 22.2 playback
2023-09-29 02:35:10 +00:00
Kacper Michajłow 4f0b654503 wasapi: clamp number of output channels to 8
This is the most supported in standard layout, if we request more it
tends to fallback to stereo instead. Also channels mask is 32-bit and it
can get truncated.
2023-09-29 02:35:10 +00:00
Kacper Michajłow 0728e4778f chmap: add more channel layouts up to 22.2 2023-09-29 02:35:10 +00:00
Kacper Michajłow db59a1c1a7 audio/chmap: link string buffer size to MP_NUM_CHANNELS 2023-09-29 02:35:10 +00:00
Dudemanguy f9234d890a playloop: don't refresh seek on external sub streams
External subtitles are always read as eager, so they do not need to be
changed on pause/unpause. Don't do the refresh seek since it will just
buffer forever. Fixes f40bbfec4f.
2023-09-28 08:58:02 -05:00
Dudemanguy f40bbfec4f demux: improve stream selection state
This replaces the previous commit and makes more sense. The internal
demux marked tracks as eager depending on their type and for subtitles
it would always lazily read them unless there happened to be no
available av stream. However, we want the sub stream to be eager if the
player is paused. The existing subtitle is still preserved on the
screen, but if the user changes tracks that's when the problem occurs.
So to handle this case, propagate the mpctx->paused down to the stream
selection logic. This modifies both demuxer_refresh_track and
demuxer_select_track to take that boolean value. A few other parts of
the player use this, but we can just assume false there (no change in
behavior from before) since they should never be related to subtitles.
The core player code is aware of its own state naturally, and can always
pass the appropriate value so go ahead and do so. When we change the
pause state, a refresh seek is done on all existing subtitle tracks to
make sure their eager state is the appropriate value (i.e. so it's not
still set to eager after a pause and a track switch). Slightly invasive
change, but it works with the existing logic instead of going around it
so ultimately it should be a better approach. We can additionally remove
the old force boolean from sub_read_packets since it is no longer
needed.
2023-09-27 22:38:13 -05:00
Dudemanguy 09b04fbf09 Revert "demux: eagerly read subtitle streams when switching tracks while paused"
Actually, I thought of a better way of handling this shortly after
merging this. Revert it and redo it in the next commit.

This reverts commit c2c157ebec.
2023-09-27 21:51:49 -05:00
Dudemanguy c2c157ebec demux: eagerly read subtitle streams when switching tracks while paused
a323dfae42 almost fixed subtitle tracks
disappearing when paused but it actually missed one part: the behavior
of demux_read_packet_async_until. It's a bit unintuitive, but for
subtitle streams, that function would only return the very first packet
regardless of whatever pts you pass to it. So the previous commit worked
on the very first subtitle, but not actually any of the others (oops).
This is because subtitle streams never marked as eager and thus never
actually read farther ahead. While the video is playing, this is OK, but
if we're paused and switching subtitle tracks then the stream should be
eagerly read. Luckily, the logic is already there in the function for
this. All we have to do add an extra argument to
demux_read_packet_async_until to force the stream to be read eagerly and
then it just works. Be sure to unset the eager flag when we're done.
Actually fixes the bug for real this time.
2023-09-27 23:10:20 +00:00
Christoph Heinrich 9c22d6b438 osc: move the idle logo behind other overlays
The default `z` of an overlay is 0, which is used by e.g. console.lua.
Having the idle logo at a `z` of 1000 means that it ends up above the
console (and anything that don't set a value higher then 1000).
It doesn't make sense for the idle logo to overshadow other things, so
put it at -1000 instead to prevent that.
2023-09-27 23:05:53 +00:00
Dudemanguy 6b74b55283 meson: don't require swift when checking macos sdk
It turns out that iOS doesn't actually need swift so this sdk check was
too strict and the build failed. Instead, only check this if we have
darwin and then make sure that the osdep subdir is only executed if
there are swift sources in the list. Fixes #12161.
2023-09-27 13:54:04 -05:00
Dudemanguy 5409274e6d command: only warn shared-script-properties once
Evidently I was wrong and mpv only actually warns once on deprecation
(playlist-pos nor display-fps did not and warned every time, but those
were outliers apparently). Someone complained so just hack it into
command_ctx for now.
2023-09-27 13:48:40 -05:00
Jack Mitchell 1b4627f647 wayland: don't double close display fd
Calling wl_display_disconnect closes the file descriptor, no need to
manually do it ourselves beforehand which causes a double close on the
fd.

Signed-off-by: Jack Mitchell <jack.mitchell@tuxable.co.uk>
2023-09-27 16:17:31 +00:00