Commit Graph

3342 Commits

Author SHA1 Message Date
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
NRK 2fa695c3f9 osdep: drop atomic fallback
even msvc (which mpv apparently doesn't support) supports C11 atomics
now. no need to carry around fallback with subtle semantic differences.
2023-10-20 21:31:09 +02:00
Guido Cella 9a40a0977b stats.lua: hide images' FPS
It is useless to show this because it's just a bogus value taken from
--mf-fps.
2023-10-19 13:33:47 -05:00
Kacper Michajłow 02d009bc5c player/command: truncate anything < 1e-4 in pretty printer
To avoid switching to scientific notation. Apparently it is "jarring"
for some users.

This preserves status quo from before 9dddfc4f where pretty printer were
truncated to 3 decimal places.
2023-10-18 11:34:52 +02:00
Dudemanguy 8f432b2e37 timer: remove microsecond timer functions
With the previous series of commits, all internal usage has been
replaced by the nanosecond functions. There's not really any point in
keeping these around anymore plus there are macros for unit conversions
now so we can just axe them. It's worth noting that mpv_get_time_us()
obviously still needs to work for API reasons, but we can just divide
mp_time_ns() by 1000 to get the same thing.
2023-10-16 15:38:59 +00:00
Dudemanguy 92976b1e8c client: change underlying mpv_wait_event timer to nanoseconds
No change in the actual API.
2023-10-16 15:38:59 +00:00
Dudemanguy 9ac0085031 dispatch: change mp_dispatch_queue_process timer to nanoseconds
The playloop is the only thing that adjusts the timeout with a value
other than 0, so nothing else needs to be changed.
2023-10-16 15:38:59 +00:00
Dudemanguy 9d3e607cf7 command: unbreak runtime play-dir changes
The whole mess with setting the option value explictly and saving the
old stop_play value only needs to happen if we're at the end of file.
Doing it in general is unneccessary and breaks other things.
Fixes #12424.
2023-10-16 09:14:20 -05:00
llyyr 056072bf95 stats.lua: remove compatibility aliases of properties
These are ancient and have existed since before stats.lua lived in the
mpv repository. We don't need to worry about ancient mpv versions
anymore, so remove these.
2023-10-15 14:30:09 +00:00
Christoph Heinrich 4a88e3d5c0 stats.lua: fix page 2 alignment of "Total"
The text didn't line up with with the percentages above it because it
didn't use a monospace font.

Instead insert the text at the same position in the template as the
percentages and convert one o.prefix_sep from the percentages into hard
coded \h\h to ensure alignment even when the user changes o.prefix_sep.
2023-10-15 13:39:46 +00:00
Kacper Michajłow 991f834e9e stats.lua: add chroma-location 2023-10-14 12:30:46 +02:00
Kacper Michajłow 28ecbcd36b stats.lua: change "Pixel Format" to "Format" 2023-10-14 12:30:46 +02:00
Kacper Michajłow 81cf697e28 stats.lua: fix missing newline when print_perfdata_passes is enabled 2023-10-14 12:30:46 +02:00
Kacper Michajłow 73db283296 stats.lua: sort filter parameters to ensure consistent output 2023-10-14 12:30:46 +02:00
Kacper Michajłow 9dddfc4fcc player/command: change how floating point number are printed
Use "%.7g" to show 7 significant digits. Removes the trailing zeros, and
in general makes it more readable, than fixed 3 decimal digits.

For avsync use "%+.2g" to add plus sign, similar to display-sync
values.
2023-10-14 12:30:46 +02:00
Kacper Michajłow 52fc378494 stats.lua: don't print custom pixel format, when hwdec
There is already other place to indicate hw decoding. "cuda" or "d3d11"
is not a pixel format.
2023-10-14 12:30:46 +02:00
Kacper Michajłow e5446399e1 stats.lua: remove leading zeros from pass timings
Makes it more readable in my opinion.
2023-10-14 12:30:46 +02:00
Kacper Michajłow 31ba5cd6df stats.lua: add frame info 2023-10-14 12:30:46 +02:00
Kacper Michajłow 6ff165f4a4 stats.lua: simplify fps display
- rename prefix to `Framerate:`
- if both estimated and specified values are the same display fps once
- skip the suffix if both the estimated and specified values agrees
2023-10-14 12:30:46 +02:00
Kacper Michajłow c4b8ddeee3 stats.lua: adjust spacing between values a little 2023-10-14 12:30:46 +02:00
Kacper Michajłow 499a9d90ab stats.lua: show HDR meta if not equal to 203
SDR white (203) is indeed not interesting, but anything else, even if
lower is.
2023-10-14 12:30:46 +02:00
Kacper Michajłow f2f33ac1e8 stats.lua: separate video parameters from video out
Source video parameters are interesting, but we mix them with video
output/target parameters. Which will differ. Add "Display" showing
true output params from VO, including HDR passthrough info and
everything. This makes much more consistent output and alows to quickly
diagnose how is source video translated to target display.
2023-10-14 12:30:46 +02:00
Kacper Michajłow c4f0b24deb command: fix fps property name
fps property was not renamed in events.
2023-10-14 12:30:46 +02:00
Kacper Michajłow eb4031e6db command: early exit in some properties to avoid going through VOCTRL 2023-10-14 12:30:46 +02:00
Guido Cella c470934236 command: fix segfault with playlist-{next,prev}-playlist
This was wrongly assuming that playlist_path is always set for the
current playlist entry, but it's only set when a file was added by
expanding a playlist.

The crash in playlist_get_first_in_next_playlist can be reproduced with
mpv foo.mkv foo.zip, playlist-next, playlist-prev,
playlist-next-playlist. You need to run playlist-next, playlist-prev
first because foo.zip's playlist_path is NULL until you do that, which
makes playlist_get_first_in_next_playlist return immediately.

The crash in cmd_playlist_next_prev_playlist can be replicated with mpv
--loop-playlist foo.zip foo.mkv, running playlist-next until foo.mkv,
and playlist-play-next. Again, you need to open foo.zip first or its
playlist_path is NULL which skips running strcmp(entry->playlist_path,
mpctx->playlist->current->playlist_path).

Fixes https://github.com/mpv-player/mpv/issues/12495#issuecomment-1760968608
2023-10-13 13:54:43 +00:00
Guido Cella 9c9ba3cf30 console.lua: print the log and input line to the terminal 2023-10-11 21:09:40 +00:00
Guido Cella 8134f18c28 ytdl_hook.lua: set metadata with single tracks
Use EDL for single tracks with metadata to set the uploader, channel url
and description metadata with --ytdl-format=best. Currently, these are
only set with the other ytdl formats with video and audio in different
streams.

The uploader tag is commonly available in sites other than Youtube too,
so it may be simpler to always use EDL with single tracks.
2023-10-11 21:05:33 +00:00
Mike Will 5ac37500c5 defaults.lua: add a disabled parameter to timer constructors
Added to the functions `mp.add_timeout` and `mp.add_periodic_timer`.

If the `disabled` argument is set to `true` or a truthy value, the
timer will wait to be manually started with a call to its `resume()`
method.
2023-10-11 21:04:13 +00:00
Dudemanguy fcebee9080 libmpv: add mpv_time_ns()
9606c3fca9 added mp_time_ns(). Since we
apparently expose the mp_time_us() to clients already, there's no reason
to not also expose the new nanosecond one.
2023-10-10 19:10:55 +00:00
Dudemanguy c82c55b4b9 vo: use nanoseconds for frame duration and pts 2023-10-10 19:10:55 +00:00
Dudemanguy 8fccd6bf91 player: store last_time timestamp in nanoseconds 2023-10-10 19:10:55 +00:00
Dudemanguy ae335ef155 vo: remove vo_get_estimated_vsync_interval conversion to seconds
This is weird. The caller should be responsible for converting the value
if desired. Move the conversion to player/command.c instead.
2023-10-10 19:10:55 +00:00
Guido Cella cf762c1482 console.lua: exit with with Ctrl+[
This binding commonly closes similar input buffers like vim's
Command-line mode and dmenu.
2023-10-10 18:18:07 +00:00
Guido Cella 81dea9031d command: add playlist-next-playlist and playlist-prev-playlist
playlist-prev-playlist goes to the beginning of the previous playlist
because this seems more useful and symmetrical to
playlist-next-playlist. It does not go to the beginning when the current
playlist-path starts with the previous playlist-path, e.g. with mpv
--loop-playlist foo/, which expands to foo/{1..9}.zip, the current
playlist path foo/1.zip beings with the playlist-path foo/ of {2..9}.zip
and thus playlist-prev-playlist goes to 9.zip rather than to 2.zip.

Closes #12495.
2023-10-09 15:09:35 +00:00
Dudemanguy e17375f151 core: remove duplicate init_{audio,video}_decoder declarations 2023-10-08 09:57:41 -05:00
lcksk 89261178d7 core: remove declarations of unused functions 2023-10-08 14:56:51 +00:00
Christoph Heinrich e475e1abc0 console: support utf8 for table formatting 2023-10-07 22:45:50 +00:00
Christoph Heinrich d2c92f7653 console: cull lines outside of visible area
Lines that would be outside of the visible area are now culled.
The log messages were already culled, however with the introduction
of suggestions, they also needed a small update.
2023-10-07 22:45:50 +00:00
Christoph Heinrich ed8a919812 console: show completion suggestions as table
Completion suggestions are now nicely formatted into a table.
Maximum width of the table is estimated based on OSD size and
font size.
This requires a new scaling factor option `font_hw_ratio`.
A factor of 2.15 works great for me,
but the default is 2.0 to avoid problems with other fonts.
The space between columns is automatically adjusted to be
between 2 and 8 spaces.
It tries to use as few rows as possible.
2023-10-07 22:45:50 +00:00
Christoph Heinrich 659353b7d6 console: show suggestions for completion
Tab completion now shows a list of all potential completions
between the log messages and prompt.
The text is colored to differentiate it from regular text.
The color matches the theme and is similar to the mpv logo.
2023-10-07 22:45:50 +00:00
Christoph Heinrich 898a4cd8a8 console: refactor text styles for log levels
The text styles are now in a table.
The color definitions of the theme where the colors were taken from
are now included in a comment for future reference.
The colors have been converted to BGR as is required by ASS.
2023-10-07 22:45:50 +00:00
Kacper Michajłow bc81b3d19e player/video: mention --profile=fast and --hwdec in AV desync message 2023-10-07 23:06:16 +02:00
Kacper Michajłow 44c398c3e1 Revert "video: remove another redundant wakeup"
vo_still_displaying() is racey with vo_request_wakeup_on_done() and above
that it doesn't work as expected. VO can run out of work and go to sleep
for 1000s, while the play thread still returns on vo_still_displaying()
check, because of a check `now < frame_end` so it never advances and go
to sleep itself.

This fixes dead lock that we have when image parameters changes during
playback.

This reverts commit 0c9ac5835b.

Fixes: #12575
2023-10-07 17:50:50 +00:00
Dudemanguy 07995f5d5f vo_gpu_next: improve updating overlays
fbe154831a added a new VOCTRL to signal
when the OSD changed for gpu-next's handling of subtitles, but this is
both not necessary and actually incomplete. The VOCTRL would signal OSD
changes, but not all subtitle changes (like selecting another
non-external sub track for example). VOCTRL_OSD_CHANGED was used to
increment p->osd_sync which would then redraw the blended subtitles if
the player was paused.

But there's already a VOCTRL_PAUSE and VOCTRL_RESUME. Plus, the
sub_bitmap_list object will have items in it if it changed in any way,
so we don't need the VOCTRL_OSD_CHANGED method at all. That can be
removed.

The check that fp->osd_sync < p->osd_sync stays in place since that's an
optimization while the video is playing, but we also check the pause
state as well since the VO can know this. If we're paused, then always
do update_overlays since core must be signalling a redraw to us if we
get a draw_frame call here. Additionally in update_overlays itself, the
p->osd_sync counter is incremented if we have any items since the frame
signature will need that. As for the actual bug that is fixed, changing
subtitle tracks while paused with blended subtitles now correctly works.
Previously, it was never updated so the old subtitle stayed there
forever until you deselected it (since VOCTRL_OSD_CHANGED triggered
there).

Also include some cosmetic code fixes that were noticed.
2023-10-05 22:32:06 +00:00
Dudemanguy 817c6f9cb7 player: remove unused mutate argument in mp_next_file
e277fadd60 originally added this but it
never actually did anything in the function... wm4 probably changed his
mind but forget to delete it so just remove it here.
2023-10-05 17:09:43 +02:00
Dudemanguy 034f75dacd loadfile: fix an old wonky playlist heuristic
2c6a3cb1f2 originally added this struct
member and then 1be863afdb later added
some more logic to loadfile that uses this. There's been more changes
since then of course, but bits using playback_short and playback_start
have mostly stayed the same. It's a bit strange it's worked this way for
so long since it makes an assumption on how long files should be and
leads to weird, broken behavior on playlists with shorter videos. The
main reason for playlist_short, as far as I can tell, is to deal with
some fringe cases with short videos and trying to go back in the
playlist. More specifically, if you use --loop=inf on a very short video
(say less than 1 second) and try to go back in the playlist, you won't
be able to without any of this special logic that deals with it. But the
current approach has several side effects like going back multiple items
in the playlist instead of just one if the video is less than one
second. This is just bad so delete everything related to playlist_short
and playlist_start.

Instead, let's handle this by keeping track of playlist-prev attempts.
Going forward in the playlist doesn't require any special handling since
a bad/broken file will just advance to the next one. So it's only going
backwards that requires some special consideration. If we're going
backwards and the user isn't using force, then mark the playlist entry
with a special flag. If the file loads successfully in
play_current_file, we can just clear the flag and not worry about it.
However if there's a failure, then we set a bool telling
play_current_file that it should go back one more item in the playlist
if possible and try again. This way, we avoid the previously mentioned
--loop=inf edgecase and the user can still attempt to retry previously
failed items in the playlist (like a url or such).

Fixes #6576, fixes #12548.
2023-10-05 17:09:43 +02:00
Ashyni d32f1aac3f af/vf-command: add ability to target a specific lavfi filter
fixes: #11180
2023-10-05 11:41:09 +02: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
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 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
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 40e0fea6eb timer: rename mp_add_timeout to reflect what it actually does 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
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 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
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 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
Dudemanguy 1d00aee8e1 command: deprecate shared-script-properties
user-data is simply better.
2023-09-27 14:04:59 +00:00
Dudemanguy c0c595b588 osc: remove shared-script-properties usage
0b4860248b added user-data which is
completely superior and makes this property obsolete. We've already had
one mpv release with the osc using user-data so drop this.
2023-09-27 14:04:59 +00:00
Guido Cella 649409140c console.lua: complete properties after cycle-values 2023-09-27 14:03:44 +00:00
Mike Will 9cd2a9fc48 osc.lua: fix calculation for slider's min-max average
Average of two numbers is given by the sum of the two numbers
divided by two. It's gone unnoticed because `s_min` is
basically always zero.
2023-09-25 16:07:34 +00:00
Dudemanguy fb46666395 options: remove deprecated --record-file option
No wonder wm4 wanted to get rid of this. This option requires touching a
bunch of crap in the core player code. --stream-record works perfectly
fine and is a lot nicer so there's no need for this to exist anymore.
2023-09-21 16:06:29 +00:00
Dudemanguy 4b2276b730 command: stop restarting playback when writing to playlist-pos
e9e93b4dbe added a warning about writing
the same value to the playlist-pos property that in the future it would
stop restarting playback. Instead, you should use the
playlist-play-index command for that. Well go ahead and drop the old
deprecated behavior now and do what wm4 wanted this to do: just ignore
if the same value is written again.
2023-09-21 16:06:29 +00:00
Dudemanguy 29b481da54 command: remove some old deprecated properities
drop-frame-count and vo-drop-frame-count are ancient and have no reason
to exist anymore. The other change is that support for writing to
display-fps has been removed, and the property is strictly read-only
now. 3a2dc8b22e is what deprecated it with
a warning to users, so we can remove it without much trouble.
2023-09-21 16:06:29 +00:00
llyyr 27f0a35c53 various: add missing include in header flles
Mostly cosmetic
2023-09-21 14:40:11 +00:00
Dudemanguy 69b7af3106 mp_image: add force_window field
It's useful for some VOs (dmabuf-wayland) to know if the image params
are actually real or fake ones sent by the core for the purpose of
force_window.
2023-09-21 14:08:52 +00:00
Kacper Michajłow 20e584f60b options: make video-crop validation more strict 2023-09-20 19:08:19 +00:00
Kacper Michajłow 582c7556c6 player/video: don't try to restore old crop when invalid were provided
Instead just reset the crop to give user feedback that it was wrong.
Also don't override decoder crop on invalid crops.
2023-09-20 19:08:19 +00:00
Kacper Michajłow eab3842d8b cplugin: allow loading mpv_* symbols dynamically
Defining MPV_CPLUGIN_DYNAMIC_SYM during plugin compilation will replace mpv_*
functions with function pointers. Those pointer will be initialized when
loading the plugin.

It is recommended to use this symbol table when targeting Windows. The loader
does not have notion of global symbols. Loading cplugin into mpv process will
not allow this plugin to call any of the symbols that may be available in
other modules. Instead cplugin has to link explicitly to specific PE binary,
libmpv-2.dll/mpv.exe or any other binary that may have linked mpv statically.
This limits portability of cplugin as it would need to be compiled separately
for each of target PE binary that includes mpv's symbols. Which in practice
is unrealictis, as we want one cplugin to be loaded without those restrictions.

Instead of linking to any PE binary, we create function pointer for all mpv's
exported symbols. For convinience names of entrypoints are redefined to those
pointer so no changes are required in cplugin source code, except defining
MPV_CPLUGIN_DYNAMIC_SYM. Those function pointer are exported to make them
available for mpv to init with correct values during runtime, before calling
`mpv_open_cplugin`.

Note that those pointer are decorated with `selectany` attribute, so no need
to worry about multiple definitions, linker will keep only single instance.

This fixes cplugin usability on Windows. Without any API changes, only
recompilation with -DMPV_CPLUGIN_DYNAMIC_SYM is needed.
2023-09-20 02:16:45 +00:00