0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

51183 Commits

Author SHA1 Message Date
Christoph Heinrich
f41805081b console: wrap rows at the top
The previous commit was already a big improvement, but it was still
somewhat slow on the lua interpreter. By wrapping the table at the top
we loose the consistent placement of items while resizing (at least as
long as the column count didn't change), but we avoid taking all the
off screen items into account.

The fewer items fit on screen the faster this becomes.
2023-11-07 01:36:59 +00:00
Christoph Heinrich
ff131d7a20 console: optimize table generation
Showing all properties was terribly slow.
Instead of starting at one row and increasing the row count until it
fits, the column count can be increased until it doesn't fit anymore.

That alone already reduces the required iterations, but from the column
count an upper and lower bound for the row count can be calculated.

For large tables this dramatically reduces the amount of iterations.
2023-11-07 01:36:59 +00:00
Christoph Heinrich
bca0b20c09 console: enable completions without a prefix
This way it is possible to get a list of all options or all properties,
instead of having to guess the first letter before any suggestions are
shown.
2023-11-07 01:36:59 +00:00
Guido Cella
386de3f275 console.lua: complete raw properties 2023-11-07 00:59:16 +00:00
Christoph Heinrich
43ed0a83d0 console: avoid redundant completion appendage
So far completing something like `${some-pro}` with the cursor between
`o}` would result in `${some-property}}`. Adding that superfluous `}` can
be avoided by checking if it's already in the string after the cursor.
2023-11-07 00:55:15 +00:00
Dudemanguy
4aa3866400 present_sync: remove unneeded clear_values function
This was specifically special logic for drm. Before present_sync, it
would also clear out all of its vsync values like this. The old drm code
would save a bunch of samples which would confuse vo.c when unpausing
since it got old, bogus values. Since we make sure to match successive
vsync samples with the swapchain depth and that present sync samples
also match the swapchain depth, this is unneeded.
2023-11-07 00:52:46 +00:00
Dudemanguy
506e8d9eaf vo: require successive vsyncs to be more than swapchain depth
To make sure that present_sync is in line with the vsync timings here.
2023-11-07 00:52:46 +00:00
Dudemanguy
2872e929bb present_sync: only save as many entries as the swapchain depth
Saving more than the swapchain depth is just wasteful. We can just save
a copy of the vo_opts here and check the value whenever we're updating
values.
2023-11-07 00:52:46 +00:00
Dudemanguy
cf69fa03ca vo: replace max swapchain depth magic number 2023-11-07 00:52:46 +00:00
Christoph Heinrich
bd4bf6e383 DOCS/mpv: consistent formatting of keybindings 2023-11-07 00:43:38 +00:00
Christoph Heinrich
d3355679b3 DOCS/console: correct capitalization of keybindings 2023-11-07 00:43:38 +00:00
Dudemanguy
f4c5fa12cb wayland: improve wl_output guessing before mpv window is mapped
There's some geometry-related things that mpv has to calculate before
the window is actually mapped onto the screen in wayland. But there's no
way to know which output the window will end up on before it happens, so
it's possible to calculate it using the wrong values. mpv corrects
itself later when the surface event happens, but making the initial
guess work better can help in certain cases.

find_output is the only thing that needs to be changed here. Its main
purpose is to grab the right output based on user settings when we're
trying to full screen and giving a fallback in case we don't have
wl->current_output yet. The x11 code already does something similar, so
we're basically just copying it. Allow user settings like --screen and
--screen-name to influence the initial wl_output guess. Those options
won't actually place the window on that specific screen since we can't
do that in wayland, but if the user knows where the window will end up
beforehand it makes sense to listen to the arguments they pass. If
something goes wrong, then we just fallback to 0 like before.
2023-11-06 23:13:31 +00:00
Dudemanguy
953176ee42 sub: adjust offsets when sub seeking/stepping
In the sub seek code path, there was an arbitrary small offset added to
the pts before the seek. However when seeking backwards, the offset was
an additional subtraction. de6eace6e9
added this logic 10 years ago and perhaps it made sense then, but the
additional subtraction when seeking backwards causes the subtitle seek
to go too far to the previous subtitle if the durations overlap. This
should always be an addition to work correctly. Additionally, the sub
stepping code path also could use this offset for the same reason
(duration overlaps). However, it is only applicable to sd_ass not
sd_lavc. sd_lavc has step_sub support but on a sample it didn't even
work anyway. Perhaps it only works for certain kinds of subtitles
(patches welcome).

Anyways instead of keeping this offset as a magic number, we can define
it in sd.h which is handy for this. For sd_ass, we add the offset when
sub stepping, and the offset is always added for sub seeking like it was
before. Update the comment to be a little more relevant to what actually
happens today. Fixes #11445.
2023-11-06 23:12:13 +00:00
Guido Cella
7d004bf15c DOCS/input: stop documenting vf del
Because b56e63e2a9 removed it.
2023-11-06 16:33:57 +00:00
Dudemanguy
ad26c3b0a5 dec_sub: always copy packet for new segments
Since 062104d16e, we started saving cached
packets for subtitles. However, these can point to the same address as
what is stored in sub->new_segment. When a segment is updated, the
packet is potentially freed. Later during decoding, this can lead to a
double free since the cached packets will naturally try to free itself
and update. Fix this by simply always making sub->new_segment a full
copy of the packet so its lifetime doesn't have to be tied to the cached
packet stuff.
2023-11-06 10:12:23 -06:00
Dudemanguy
a96d04f19d drm: use present_sync mechanism for presentation feedback
A ton of code and drm-specific abstractions can be dropped with this.
One important thing to note is that the usage of sbc is completely
dropped here. The utility of that is not particularly clear since the
sbc value was manually incremented before the flip and it's not as if
the drm page flip event gives it to us like it does with the msec and
ust. It can be reintroduced later if there is a need. For drm, we also
add a present_sync_clear_values helper since all presentation feedback
needs to be cleared on pause/resume for it.
2023-11-06 15:44:45 +00:00
Dudemanguy
f629d7a2ff present_sync: rename function to present_sync_update_values
This had to have been a mistake. It was just confusing.
2023-11-06 15:44:45 +00:00
Dudemanguy
261f51b475 present_sync: rewrite around linked list
When this was originally written, the queuing/list approach was
deliberately removed since it adds more complication and xorg/wayland
don't really use it anyway. In practice, you only really have one frame
in flight with presentation timestamps. However, one slight annoyance is
that the drm code has its own thing which is almost exactly the same and
does its own calculations. Ideally, we'd port drm to this instead, but
the implementation there takes into account N-frames in flight which
probably does actually work. So we need to make present_sync smarter and
be able to handle this.

mpv does actually have its own linked list implementation already which
is a good fit for this. mp_present becomes the list and each
mp_present_entry has its own set of timestamps. During initialization,
we create all the entries we need and then simply treat it like a queue
during the lifecycle of the VO. When an entry is fully used
(present_sync_get_info), then we remove it from the list, zero it out,
and append it to the end for future use. This avoids needing to allocate
memory on every frame (which is what drm currently does) and allows for
a reasonable number of in flight frames at the same time as this should
never grow to some obscene number. The nice thing is that current users
of present_sync don't need to change anything besides the initialization
step.
2023-11-06 15:44:45 +00:00
Christoph Heinrich
bcbd821fa9 ytdl_hook: fix mixed thumbnail.preference availability 2023-11-06 14:59:05 +00:00
llyyr
d9b33dd79a Revert "vo: clear vsync_offset if drawing while paused"
This reverts commit 640c07fb19.

This commit isn't needed anymore after the previous commit.
2023-11-06 11:39:45 +01:00
llyyr
0257d53d2c video: reset display_sync_error when resetting state
This would cause mpv to, in some very specific scenarios, have a
negative vsync_offset after seeking which would result in mpv requesting
a pts before the first frame to libplacebo.

Fix it by setting it to 0 when we reset state, such as after seeking.

Fixes: https://github.com/mpv-player/mpv/issues/12813
2023-11-06 11:39:45 +01:00
Kacper Michajłow
a7186777de threads: unbreak mpv on builds without asserts
Also remove duplicated macro.

Fixes: #12818 #12820
2023-11-06 04:14:49 +00:00
Kacper Michajłow
84de84b8aa player/command: add video-params and siblings to MPV_EVENT_TICK
It contains metadata that may change per frame.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
73fbe09a49 ALL: use pl_hdr_metadata and nuke sig_peak
This commit replaces all uses of sig_peak and maps all HDR metadata.

Form notable changes mixed usage of maxCLL and max_luma is resolved and
not always max_luma is used which makes vo_gpu and vo_gpu_next behave
the same way.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
d9a483cb17 demux_mkv: parse mastering metadata 2023-11-05 18:57:36 +01:00
Kacper Michajłow
38da5b89c2 player/command: remove hdr-metadata property
It is now included in video-out-params and was never released in stable
version, so we can safely remove it.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
1174afcccc csputils: add pl_hdr_metadata to mp_colorspace and deprecate sig_peak
Note this commit does not change all uses of sig-peak, this is for
future refactoring.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
07efb63931 player/command: use pl_hdr_metadata_contains 2023-11-05 18:57:36 +01:00
Kacper Michajłow
468feb863b csputils: change mp_hdr_metadata to pl_hdr_metadata 2023-11-05 18:57:36 +01:00
Kacper Michajłow
076be24853 timer: remove unnecesary time conversions 2023-11-05 17:36:17 +00:00
Kacper Michajłow
e268dead30 win32/pthread: remove unused code 2023-11-05 17:36:17 +00:00
Kacper Michajłow
71e888c2a0 timer: remove unused code 2023-11-05 17:36:17 +00:00
Kacper Michajłow
751790c2b3 threads: remove unused code 2023-11-05 17:36:17 +00:00
Kacper Michajłow
f75fe33da7 threads: rename threads.c to threads-posix.c 2023-11-05 17:36:17 +00:00
Kacper Michajłow
1e0aaab78c threads: move pthread debug to threads-posix.h
And remove redundant define while at it.
2023-11-05 17:36:17 +00:00
Kacper Michajłow
56d35da180 mp_thread: add win32 implementation 2023-11-05 17:36:17 +00:00
Kacper Michajłow
55ed50ba90 mp_thread: prefer tracking threads with id
This change essentially removes mp_thread_self() and instead add
mp_thread_id to track threads and have ability to query current thread
id during runtime.

This will be useful for upcoming win32 implementation, where accessing
thread handle is different than on pthreads. Greatly reduces complexity.
Otherweis locked map of tid <-> handle is required which is completely
unnecessary for all mpv use-cases.

Note that this is the mp_thread_id, not to confuse with system tid. For
example on threads-posix implementation it is simply pthread_t.
2023-11-05 17:36:17 +00:00
Kacper Michajłow
174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
Kacper Michajłow
3a8b107f62 threads: add new mp_thread abstraction
This will allow to avoid hacky pthreads symbols/header override.

Inspired by pl_thread from libplacebo.
2023-11-05 17:36:17 +00:00
Dudemanguy
062104d16e sub: redecode cached packets on UPDATE_SUB_HARD or UPDATE_SUB_FILT
UPDATE_SUB_HARD causes all of the ass objects to reset in order to apply
the new style. UPDATE_SUB_FILT doesn't actually reset the sd, but it
should in order to update the actual filters so that was added here.
Doing this causes the current subtitle to be dropped. In the paused
cause, this concidentally works because command.c forces a video refresh
which then reloads the subtitle essentially. But while playing, the
subtitle will be dropped and you won't get anything until the next one
appears.

Instead of using video refreshes, what we can do is just always save the
last two subtitle packets in a cache and redecode them if needed. This
is much easier and also allows us to get rid of all the video refresh
logic in command.c. Fixes #12386.
2023-11-05 15:45:43 +00:00
Dudemanguy
90170c1100 options: add UPDATE_SUB_HARD flag to sub-ass-override
The other options that have to do with ass styles also uses this flag.
It's needed since we have to destroy the ass objects and reinit them.
It's a bit incomplete since it will technically only properly work when
paused (while playing, the current subtitle gets discarded). That fix is
in the next commit.
2023-11-05 15:45:43 +00:00
Dudemanguy
6f8d98f812 vo_gpu_next: update to newer cache API
The old one would actually crash if the libplacebo.cache file was
invalid. Additionally, set a max size of 1 GiB for icc cache and 50 MiB
for gpu shader cache. The per object size limit is removed which puts
mpv in line with plplay. Finally, a few memory leaks are also fixed
since several objects previously were not freed on uninit.
2023-11-05 01:00:02 +00:00
Dudemanguy
784ec0066f ra_pl: drop deprecated cached_program param
This was deprecated in api version 322 which earlier than the current
6.338 version that mpv depends on. So remove it.
2023-11-05 01:00:02 +00:00
Dudemanguy
ed4d21d401 vo_gpu_next: remove unneeded PL_API_VER guarding and defines
Since the minimum required libplacebo version is 6.338, all of these
checks are unneeded.
2023-11-05 01:00:02 +00:00
Kacper Michajłow
7480efa62c mp_image: pass rotation correctly to/from AVFrame
Fixes rotating image by --video-rotate when filtering.

Fixes: #12771
2023-11-03 10:05:41 +01:00
nanahi
fe0d2b4ee9 win32: add more values for monitor refresh rate detection
Add more refresh rates for get_refresh_rate_from_gdi() now (Nov 2023) that
165 Hz is common, 240 Hz is on the rise, and 120 * N Hz is the future.
2023-11-02 17:34:36 +01:00
Guido Cella
0147467e3a DOCS/man/console: update type examples 2023-11-02 16:03:38 +00:00
Dudemanguy
fcc67cc6c1 lua: remove a ton of unneeded parentheses
For whatever reason, some of the lua code (particularly the osc and
ytdl_hook) is full of a bunch of stuff like if (foo), if not (foo ==
nil), etc. The parenthesis aren't needed in lua and actually just look
weird since nobody actually writes lua like this. You can see most of
the other conditionals are written normally. So cleanup the style to
match when the parenthesis clearly aren't doing anything. Not directly
related, but also add some spaces on a few math operations while we're
at it.
2023-11-02 16:03:20 +00:00
Guido Cella
56fada1a5e console.lua: complete file paths 2023-11-02 14:58:28 +00:00
Guido Cella
7846a0cc0c console.lua: complete list option verbs 2023-11-02 14:58:28 +00:00