Commit Graph

3312 Commits

Author SHA1 Message Date
Christoph Heinrich bcbd821fa9 ytdl_hook: fix mixed thumbnail.preference availability 2023-11-06 14:59:05 +00: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 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 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 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
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 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
Guido Cella ada89aba83 console.lua: inline mp.options
This avoids a "Redefined local `options`" LSP warning in
list_option_list() after the previous commit. It still works, but
reusing names for local variables is error-prone.
2023-11-02 14:58:28 +00:00
Guido Cella f97593dcee console.lua: complete list options 2023-11-02 14:58:28 +00:00
Guido Cella 8e16dcf2a2 console.lua: complete profiles 2023-11-02 14:58:28 +00:00
Guido Cella e1ca04274d console.lua: complete commands after help
And complete help itself.
2023-11-02 14:58:28 +00:00
Christoph Heinrich b6703873cf console: complete infinite cycle-values arguments
cycle-values already completed the first two arguments, but the command
accepts infinitely many arguments, so enable completion for all of them.
2023-11-01 22:15:48 +00:00
Kacper Michajłow 98a27b3cd1 player/main: set main thread name as mpv
Now that we don't prepend `mpv/` to all thread names, `main` is too
ambiguous and since it is main thread it can be seen as process name.
2023-11-01 13:40:26 +00:00
Dudemanguy cb2b579f61 player/video: loosen logic checks for adjust_sync
Previously, the av sync change calculation was only done if the
audio_status was STATUS_PLAYING, but there is at least one or two more
states where this should be done. player/audio is capable of adding
delay if the state is anything besides STATUS_EOF. This means that while
calling adjust_sync, the delay value could have changed from the audio
side of the equation from the previous playloop, and it doesn't
necessarily mean that the current audio_status is STATUS_PLAYING either.
So the old code would technically skip this case. In practice, this is
just one frame so it hardly matters, but it should be taken into
account. For example, STATUS_READY is definitely possible here in
adjust_sync. I'm not sure if it's actually possible for STATUS_SYNCING
to happen but the audio code can change add delay with that status, so
it doesn't hurt. STATUS_DRAINING is probably not relevant, but again
include it to mirror the audio code logic. Of course, STATUS_EOF is
obviously a no-no since that means no audio at all, so we return from
there. I didn't take hard measurements or anything, but this does seem
to result in slightly smaller av sync fluctuations on discontinuities
(like seeking) which makes sense because we're now making an additional
correction that wasn't previously done.

Another change is to always try adjust_sync as long as the frame_time is
nonzero. The old logic only did this if the video_status was playing or
greater, but it is possible to get new frames with a different PTS that
do not have that status. The audio is still playing so logically it
should be adjusted as well. Again, this happens for just one frame, so
it doesn't really matter in practice but it should make more sense. A
zero frame_time is skipped since that would mean the pts did not advance
and the previous playloop should have done the adjustment for that time
already.
2023-10-30 17:18:35 +00:00
Dudemanguy 1f9d137153 player/video: don't reset ao on video chain reinit
3038e578af recently changed the logic here
so it wouldn't trigger on still images, but after thinking about the
code here some more, I don't believe it's needed at all. Doing an ao
reset when you flip the video track is very disruptive and not really
desirable at all. Since the ao no longer adds bogus delay values while
the video is off, there should be no need to do a full reset for syncing
reasons. The delay value will be zero, so we can let the audio just play
normally and let the video code do its thing. There is one slight trick
here however. When using a display sync mode, part of the syncing code
will try to update the audio and video playback speed. This can cause an
audio underrun if we're just turning the video back one. An easy way to
avoid most of these is to not update the speed if we are in the
STATUS_SYNCING state for video. This isn't quite perfect and underruns
are still possible, but it actually seems to depend on the AO. e.g. I
couldn't trigger an underrun with alsa but I could with pipewire. In any
case, the audio artifact here is much less noticeable than doing a full
ao reset, so it's still an improvement.
2023-10-30 17:18:35 +00:00
Christoph Heinrich 612faed856 ytdl_hook: reverse thumbnail order
ytdl lists thumbnails in ascending order according to height/preference.
all_formats=yes adds formats from best to worst, so the same should also
be done for thumbnails.
2023-10-30 16:46:17 +00:00
Christoph Heinrich 21609953cc ytdl_hook: support the preference field of thumbnails
yt-dlp has a preference field for it's thumbnails, and not all of it's
listed thumbnails have fields with their dimensions.
Therefore prefere the preference field when available and fall back to
height if it's not.
2023-10-30 16:46:17 +00:00
Christoph Heinrich 045f4a7315 ytdl_hook: add thumbnail option
Opening speed could be improved with the "async" prefix, but then the
tracks would be out of order.
2023-10-30 16:46:17 +00:00
Eva a5b0eceeba ytdl_hook: support thumbnails
Similar to "write-sub=", adding "write-thumbnail=" to raw-options will add the highest resolution thumbnail as a video track.

Closes #7041
2023-10-30 16:46:17 +00:00
Kacper Michajłow bc3e850168 scripting: add 'script' to messages 2023-10-27 23:18:56 +00:00
Kacper Michajłow 6bb3e05d49 scripting: rename backend names for concise naming 2023-10-27 23:18:56 +00:00
Kacper Michajłow cb829879af mp_threads: rename threads for consistent naming across all of them
I'd like some names to be more descriptive, but to work with 15 chars
limit we have to make some sacrifice.

Also because of the limit, remove the `mpv/` prefix and prioritize
actuall thread name.
2023-10-27 23:18:56 +00:00
Kacper Michajłow 2f91e1441e player/lua: use mp_msg_find_level in check_loglevel
Fixes off by one error. Allows to use MSGL_STATS, but since this is
internal value, this is mostly cosmetic change.
2023-10-27 18:07:08 +00:00
Dudemanguy 66fb1d1cdb player/audio: fix incorrect check on adding delay
dac977193c changed adding delay to only
when the video is playing but this isn't correct. The video frames
adjust themselves based on the audio, so if we still have audio
processing while the video itself happens to be in some non-playing
state (such as STATUS_READY), the delay still needs to be taken into
account. The correct thing to check is to make sure that it is not
STATUS_EOF. STATUS_EOF covers the case where we have still image, and of
course no video at all is STATUS_EOF. So having a massive bogus delay
value is still avoided.
2023-10-26 22:59:09 -05:00
Dudemanguy b9c42755a7 javascript: use --js-memory-report option instead of MPV_LEAK_REPORT
The MPV_LEAK_REPORT environment variable was previously read in order to
determine whether or not to enable memory reporting for javascript
scripts. This is kind of weird and deviates from the norm of exposing an
option to the user. So let's just add --js-memory-report and disable it
by default instead.
2023-10-26 16:49:56 +00:00
Dudemanguy 36de0d784f options: rename --watch-later-directory to --watch-later-dir
Same logic as the previous commit.
2023-10-25 16:16:37 +00:00
Dudemanguy 1370ecfc1b options: rename --screenshot-directory to --screenshot-dir
Less characters is better? Other options use -dir for directory so
consistency I guess.
2023-10-25 16:16:37 +00:00
Dudemanguy dac977193c player: don't calculate av delay if there's no audio or video
The point of the mpctx->delay field is for calculating a/v sync and
adjusting the frame timings appropriately. However, the frame_time was
always subtracted from mpctx->delay regardless of the audio status. This
meant that for a video with no audio, every single frame had a
subtraction with nothing ever added to it meaning that you get massive
negative delay times. For weird videos where the audio starts way later,
the massive delay leads to the VO sleeping for basically about as long
as the video was previously playing without audio. This results in
nothing being rendered during that brief period of time and just overall
badness. When using display-sync, it happens to work since the video
doesn't adjust itself based on audio and it renders anyway.

The fix is to simply not touch mpctx->delay in player/video.c unless
there's actually audio playing. This is what the rest of the code
already does aside from setting it to 0 on resets or EOFs. Move the
calculation into adjust_sync after the audio status check. It works
exactly the same as before except that we don't constantly subtract
bogus values when there's no audio playing. The reverse situation in
player/audio.c also has the same issue. For something that is only
audio, mpctx->delay is always added to but nothing will ever subtract
from it. It's not really clear if this particular version could ever
cause a real bug, but logically it needs to be guarded in the same way.
The field here should only be updated if the video is actually playing.

Fixes #12025.
2023-10-25 15:43:07 +00:00
Guido Cella c62adc3018 console.lua: complete choice and flag options 2023-10-25 15:42:33 +00:00
Guido Cella 4aa8b628e4 console.lua: remove unused capture from completion patterns
The end position of the word to be completed is never used because all
patterns end with $. Remove it or it would complicate implementing
completers with more patterns.
2023-10-25 15:42:33 +00:00
Guido Cella c4368dc08d console.lua: use string.match()
Avoids the 2 unneeded return values of string.find().
2023-10-25 15:42:33 +00:00
Guido Cella e92d794644 console.lua: generate completion lists lazily
This will allow providing more nested completions without pre-generating
an enormous amount of completions, and it is more efficient since it
only generates the completions needed for each completion attempt.
2023-10-25 15:42:33 +00:00
Guido Cella b89f0ad411 console.lua: remove repetition from build_completers() 2023-10-25 15:42:33 +00:00
Guido Cella b9ab8d1a6c console.lua: remove unnecessary copy 2023-10-25 15:42:33 +00:00
Dudemanguy 7847f15ee2 sub: update subtitles if current track is an image
Any track that has attached picture is also always considered an image.
Not every image is neccesarily an attached picture though. So change the
check here to capture more possible cases where we should be updating
the subtitle. With the previous commits, this fixes #12387.
2023-10-23 19:32:53 +00:00
Kacper Michajłow 1805681aab m_option: initialize m_option_value union properly
C standard says that `= {0}` activates and initializes first member of
union. We expect whole union to be zeroed, it is used as default value.

Initialize union with one zeroed default instance to ensure proper init.

Fixes: #12711
2023-10-23 20:33:51 +02:00
llyyr f5ca11e12b meson: make libplacebo a required dependency
Make it not possible to build mpv without the latest libplacebo anymore.
This will allow for less code duplication between mpv and libplacebo,
and in the future also let us delete legacy ifdefs and track libplacebo
better.
2023-10-23 13:03:29 +02:00
Dudemanguy 1382a854c9 stats.lua: disable tonemapping plot by default
Nobody except a chosen few (I'm not one of them) even knows what it
means. Multiple people thought it was actually some kind of rendering
bug. Just disable it by default. Closes #12671.
2023-10-22 13:34:56 +02:00
Dudemanguy 6e428c261e ytdl_hook: remove extra playlist insert
b388c73540 should have deleted this line
since the insert is done a little below it instead, but it was missed
during review.
2023-10-21 18:29:57 -05:00
Umar Getagazov b388c73540 ytdl_hook: parse the separate cookies field
https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-v8mc-9377-rwjj
https://github.com/yt-dlp/yt-dlp/commit/1ceb657bdd25
2023-10-21 22:30:22 +00:00
NRK d05ef7fdc4 various: sort some standard headers
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
2023-10-20 21:31:09 +02:00
NRK 2070331f64 osdep: remove atomic.h
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
2023-10-20 21:31:09 +02:00