4480 Commits

Author SHA1 Message Date
Kacper Michajłow 7608348908 win32/smtc: allow toggling at runtime
The client observes media-controls, creates the window once the option
is enabled and toggles IsEnabled on later changes.

Fixes: #17885
2026-10-16 20:06:01 +02:00
Kacper Michajłow b43bb95d4c ytdl_hook: default cookies without a Domain to the host of origin
yt-dlp builds the cookies field of each format for the url of that
format and leaves out the Domain attribute when the cookie has an empty
domain in its jar. Cookies imported from a browser can have one, and
the jar then matches them against every url.

Store every cookie the same way and default its domain to the host of
the url the cookies were built for, which makes it a host-only cookie.
The port and userinfo are stripped, since neither libcurl nor lavf
matches a domain that includes them. A cookie that still has no domain
because the url has no http host is dropped.

This includes some cleanup of leftover implementation details of old
lavf cookie option merge, removed in 6017d1fd1c.

Fixes: #18506
2026-10-16 20:05:44 +02:00
Kacper Michajłow 2ddd0f027c select.lua: open context_menu.lua in d3d11 exclusive fullscreen
Load context_menu.lua when --d3d11-exclusive-fs is enabled and open it
instead of the native context menu. Native context menu cannot be
displayed over the exlusive window.

Fixes: #18181
2026-10-15 20:37:15 +02:00
Mike Will accb7b2821 command: unset metadata key if string is empty 2026-10-10 20:00:15 +02:00
nanahi c006642813 osc.lua: fix bar height calculation
Menu bar has height of 26 and playback control bar has height of 30.
Before 266cb79f38 the clickable height
were set 15 and 30 respectively, so some areas of menu bar were not
clickable. After that commit, they were set to 27 and 29, which left
a 0.5 pixel gap on top and botton of the bar. The top became unclickable
for topbar layout.

Fix by using the exact height.

Fixes: 266cb79f38
2026-10-09 12:05:29 +02:00
Guido Cella 5d85ba5fb3 osc.lua: make wheel commands on the seekbar configurable
Fixes #18562.
2026-10-05 19:47:30 +02:00
Kacper Michajłow 38aed4d1f2 common/encode_lavc: prefix global functions with mp_
To avoid conflicts with xavs2.
2026-09-26 00:49:37 +02:00
Kacper Michajłow a98d3ede9f ytdl_hook: pass a default format again
This is a revert of a6f3236c3a with bestvideo* added. Dropping the
default format was meant to follow yt-dlp's `bv*+ba/b`, but yt-dlp only
selects that when it finds ffmpeg to merge the tracks. Otherwise it
falls back to `best`, a muxed format, which is most of the time is not
optimal selection.
2026-09-13 15:37:23 +02:00
llyyr c611c1c6f7 player/loadfile: don't replace external chapters file on runtime update
`--chapters-file` is documented to replace the file's chapters, and
load_chapters honors that so make the runtime update handler honor it
too.
2026-09-08 03:24:04 +02:00
Kacper Michajłow 87b8d352d2 stream_curl: use the Content-Disposition file name as the filename
Only stream_curl sets it for now.
2026-09-07 15:53:31 +02:00
Kacper Michajłow 4ec439128c player/audio: treat all non-PCM formats as passthrough
Generalize the spdif PCM fallback and the output format verification to
any bitstream format instead of only IEC61937 formats.
2026-09-06 01:27:27 +02:00
Kacper Michajłow 182fa6ca49 player/discnav: allow window dragging on menu 2026-08-26 18:04:17 +02:00
Kacper Michajłow c318236b88 player: drop the enhancement-layer pairing when the media has no EL 2026-08-26 01:47:41 +02:00
Kacper Michajłow 79186bd167 discnav: poll the disc VM while playback idles
The BD-J VM progresses only on reads. With playback at EOF or on a
held still nothing reads anymore, applet playlist switches never
surface and menus freeze, libbluray documents this polling requirement
for idle states. Drive one nav read per tick and keep the core awake.
The slave demuxer latches its EOF and stops touching the stream, so
the read path peeks the stream itself to run its event loop. Poll the
same way while paused in a menu, highlight redraws would otherwise
wait for the next core wakeup. dvdnav stills release on user input,
not reads, and the pump bypasses the cache limits, so no pumping
outside these states.
2026-08-26 01:47:41 +02:00
Kacper Michajłow abbbffe0dd demux_disc: hold BD jump boundaries for the player's resync seek
The resync seek that follows a disc-initiated jump must not reposition
the VM. On BD the jump is handled out-of-band by reopening the slave
demuxer on the packet-read path, and the VM already sits at the jump
destination. Repositioning it with the (stale) seek target time would
hop to the wrong place. Adopting the discontinuity counter here would
leave the old slave demuxer parsing the new playlist's data with the
wrong codec context. Flush our side only, and keep the counter stale so
the read path still performs the reopen.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 4109805d0c demux_disc: follow the disc's initial audio stream selection
The player's default track selection picks the first probed audio
track, but the substream the disc's current PGC actually plays is
decided by the DVD VM and may be a different one. On discs whose menu
domain plays LPCM while the mux also carries an (unreferenced) AC3
substream, mpv selected the AC3 track, which has no data. We have to
keep track of what VM wants to output and what LAVF expects.
2026-08-26 01:47:41 +02:00
Kacper Michajłow c855d13170 stream_dvdnav: resync disc-initiated jumps through the seek path
When the disc VM jumps (menu activation, end of title), the demuxer
and player have to flush and reinitialize exactly at the boundary.

Hold an EOF at the boundary until the demuxer acks it, and resync
the player with a regular seek, which already orders flush, decoder
reset and restart. d_seek recognizes the held boundary and releases
it instead of repositioning the VM.

Also log the VM domain in nav event messages.
2026-08-26 01:47:41 +02:00
Kacper Michajłow daaab42166 player: rejoin the restart for a video frame after a transient EOF
A sparse video stream can report a transient EOF during a restart. The
DVD-Audio still track is read lazily and its first frame may arrive a
moment after the video chain already drained. Treat a frame arriving
while the restart is in progress as the restart's first frame.
2026-08-26 01:47:41 +02:00
Kacper Michajłow b3e3d1774e player: fix timing of sparse still-image video streams
Sparse video with continuous audio broke playback timing in several
ways:

- The first frame after a seek/restart was always shown immediately.
  With sparse video the frame at the seek target may not exist, and the
  next still can lie minutes ahead. Showing it early displays the wrong
  image.
- hr-seeks dropped frames with PTS below the target. For sparse video
  the nearest preceding still is the correct frame to show.
- Frame scheduling used the incremental A/V delay accounting, which is
  unusable across the video-EOF gaps between stills. Schedule sparse
  frames directly against the audio clock instead.
2026-08-26 01:47:41 +02:00
Kacper Michajłow a2448f3b81 stream_dvda: expose DVD-Audio still images as a cover-art video track
DVD-Audio discs carry an Audio Still Video Set (ASVS). An MPEG-2 still
images (cover art, booklet/lyric pages) that the disc associates with
tracks.

A new STREAM_CTRL_GET_STILL returns the still for a given playback time.
demux_disc exposes it as a selectable mpeg2video track and injects the
still as a keyframe at the track's playback time. It changes as playback
crosses track boundaries (and follows onset times when a disc encodes
them).

--dvda-page (with the new STREAM_CTRL_SET_STILL_PAGE) forces a specific
still page instead of the scheduled one. The still state is guarded by
a mutex, runtime page changes arrive from the player thread while the
demuxer thread extracts stills.
2026-08-26 01:47:41 +02:00
Kacper Michajłow c9422ff88f stream: turn the highlight fields into mp_dvdnav_highlight
The highlight rectangle and palette were passed around as loose fields
in three places. Bundle them into a struct, pass the whole nav state to
the sd_lavc control.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 8356c7f674 demux_disc: keep one-shot DVD menu subpictures deliverable
Keep DVD SPU streams always enabled at the slave level and retain the
last subpicture per substream. Re-deliver the retained copy when a sub
track is (re)selected and when the player resets playback state.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 3897b3a579 stream_dvdnav: add support for still frames
DVDNAV_STILL_FRAME means the VM is holding a frame indefinitely (menu
pages, some logos) or for a timed duration. Report the indefinite case
via nav state so the player holds playback at EOF instead of ending
the file, and skip timed stills, which would otherwise stall playback.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 5f19209953 stream_bluray: use 1-based angle, same as in DVD
Internally the angle stays 0-based (matching the libbluray API), only
the user-visible option/property values are 1-based. BD_EVENT_ANGLE
delivers a 1-based value and is converted on arrival.
2026-08-26 01:47:41 +02:00
Kacper Michajłow f0bc30aaf1 demux: adapt caching to interactive disc navigation
The disc VM advances when the stream is read, so in nav mode the cache
must not run ahead of what the user is seeing. Never read ahead (a
looping menu is endless). Never satisfy seeks from the cache either.

This applies to the whole disc session, not only while a menu is on
screen. The VM can jump at any time (BD-J timers, end of title), so
the cache must never run ahead of playback.

Activations still must be able to drive the VM while nothing is
consumed. demux_drive_nav() forces a single read for them.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 70174945a4 discnav: sync track selection state with VM
The disc VM selects audio and subpicture streams itself (menu SPU
highlights, title-authored stream changes on jumps). Follow the VM's
selection on every hop, and turn subtitles on/off with the disc's
sub_visible flag.

The sync only applies while the corresponding track selection is on
auto. An explicitly chosen track (--aid/--sid or runtime cycling) is
never overridden.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 216e26c871 player/command: add discnav command and bind default keys
User-facing entry point for in-disc menu navigation. The command
forwards an action (up/down/left/right/select/menu/title-menu/popup/
prev/mouse-move/mouse-click) to the current disc stream handler.

The new discnav input section allows binding controls that are only
active while a disc menu is on screen.

Setting the edition property on a disc jumps to the title through the
stream directly, so selecting the currently-playing edition can still
return to it from a menu.
2026-08-26 01:47:41 +02:00
Kacper Michajłow a5682eb2ad player/command: add disc-menu-active property 2026-08-26 01:47:41 +02:00
Kacper Michajłow 5713c30160 player/loadfile: react to runtime chapter/edition list updates
On DEMUX_EVENT_LISTS, re-copy the chapter list and notify the
chapter/edition properties, so a disc title change is reflected in
observed properties and the OSC.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 816eca1fef player/loadfile: auto-select default tracks added after initial open
play_current_file picks default tracks once, then leaves them alone.
That leaves later-surfacing streams without a default selection. This
applies to all demuxers with late-added streams, not only discs.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 652ca81af9 player: add disc-menu state holder and overlay support
The new player/discnav.c owns the player-side state for the in-disc
menu UI, shared between stream_bluray and stream_dvdnav. Once per
playloop iteration it pulls the stream's nav state and

- pushes the BD menu plane to the OSD (OSDTYPE_DISC_MENU) and the DVD
  highlight state to the dvd_subtitle decoders,
- resyncs playback when the disc VM jumped on its own, detected
  through the stream's discontinuity counter,
- mirrors the disc's current title into demuxer->edition,
- force-selects a dvd_subtitle track while a DVD menu is up, so the
  menu graphics decoded by sd_lavc reach the OSD, and
- enables the {discnav} input section while a menu is interactive.

The per-file state is reset on every new playlist entry.
2026-08-26 01:47:41 +02:00
Kacper Michajłow b573edaaa1 sub/osd: change osd_set_external2 into generic osd_set_bitmaps
Let the caller pick the OSD object instead of hardcoding EXTERNAL2, so
other bitmap overlay sources can reuse the same path. No functional
change, EXTERNAL2 is still the only user.
2026-08-26 01:47:41 +02:00
Kacper Michajłow 654e9382c0 command: add colorspace and luminance arguments to overlay-add
Add primaries, transfer, max_luma and video_colorspace arguments.
Allows tagging the colorspace of the overlay bitmap instead of assuming
sRGB. video_colorspace interprets the bitmap in the video's colorspace,
so it is tone mapped exactly like the video. max_luma overrides the
luminance peak of the bitmap. Currently only vo_gpu_next honors these
parameters. vo_gpu keeps its sRGB assumption regardless of the tag.

Fixes #10678
2026-08-23 18:09:02 +02:00
verygoodlee 9f9f8c4dd4 select.lua: fix some incorrect boolean values in the property menu
`false` value in the `value or mp.get_property_native(property)`
expression will trigger `mp.get_property_native`, but some
sub-properties cannot be accessed directly, the obtained value is nil.
2026-08-23 10:45:18 +02:00
Kacper Michajłow b955aa28f3 f_enhancement_pair: keep retained frames within the hw surface budget
Reduce the queue to 8 frames and reserve that many extra surfaces on
both the BL and EL decoders.
2026-08-22 21:00:11 +02:00
sharpchen b6d3434493 script_format_time: fix typo in comment 2026-08-17 19:52:11 +02:00
subotac dd5d17d328 osc.lua: ignore seek ranges without usable duration
seekRangesF() accepts a zero duration and produces NaN/Inf coordinates,
which assdraw cannot format. Ignore seek-range metadata when the native
duration property is unavailable or zero.

Fixes #18344
2026-08-07 22:41:57 +02:00
nanahi 731229bd2b options: add --playlist-inherit-options option
This allows controlling whether the files in a playlist inherit the
per-file options of the playlist file itself. For playlists created
by --autocreate-playlist, --playlist-inherit-options=current allows
inheriting only for the item the playlist is created from.
2026-07-26 11:49:16 +02:00
nanahi 19215efe61 player/loadfile: inherit file-local options when resolving playlist file
Currently, if a playlist file is played and replaced by its contents,
the per-file options of the playlist file are ignored.

This commit makes these options inherited for its contents so they work
as expected.
2026-07-26 11:49:16 +02:00
Guido Cella 1c4adc9819 console.lua: limit how many completions are printed to the terminal
This prevents mpv from freezing e.g. when completing very large
directories.
2026-07-23 13:04:55 +02:00
Kacper Michajłow 11a9054b1d player/lua: pre-allocate tables of known size 2026-07-23 12:16:59 +02:00
Kacper Michajłow e61d819bf6 console.lua: add coroutine to filter selectable items asynchronously
Make the filtering and user input render asynchronously, such that there
is no latency penalty for user typing.

A single keystroke with hundreds of thousands of selectable items blocks
the script for significant time. Especially filtering by single letter
which would produce a lot of matches. This could be fixed by delaying
filtering by the time user "stops" typing, but this adds artificial
delay on top of the filtering delay itself. Instead we start the
filtering always, but have a deadline of 5 ms, at which point the
coroutine is paused and script is allowed to process user events again.
If user typed or closed the dialog, we simply abort the filtering and
start new one. Instead of waiting for full filtering to finish when the
result is already stale.

The first slice runs synchronously, so anything but huge item lists is
still filtered within the keypress handler exactly as before.

Fixes: #18268
2026-07-23 12:16:59 +02:00
Kacper Michajłow 893ffae982 console.lua: speed up filtering of selectable items
Store just the indices of the matching items in matches. The text is
looked up in selectable_items, and the positions to highlight are
computed in get_matches_to_print() only for the rendered matches, using
the query that produced the current matches. This reduces useless work
of computing highlight positions when only handful of items can be
displayed at the time on screen in practice.

Sort matches without lua comparator, this significantly speeds up
sorting of big lists, where C->Lua round-trip was problematic.

Overall it's 10x-20x times faster in my testcase.
2026-07-23 12:16:59 +02:00
Kacper Michajłow 0583bb892e fzy.lua: use lookup table for precompute_bonus
Replace those conditions with precomputed lookup. It's not huge win, but
it's free, so we can do it.

JIT:
* score() x 44875 matches: 35 -> 25 ms
* filter_range 'p': 50 -> 25 ms
* filter_range 'pf': 61 -> 37 ms

interpreter:
* score() x 44875 matches: 295 -> 254 ms
* filter_range 'p': 412 -> 284 ms
* filter_range 'pf': 531 -> 388 ms

The lookup is dense, to avoid hash tables, which makes things slower,
but in fact the tables are reused, so it's low on memory.
2026-07-23 12:16:59 +02:00
Kacper Michajłow 181090e70d fzy.lua: add filter_range() for interactive filtering of large lists
Add fzy.filter_range() which computes only scores, appends to
caller-provided arrays instead of allocating tables per match, takes
an inclusive range so callers can process a large list in slices while
handling pending input in between, and accepts optional pre-lowercased
haystacks so repeated calls don't allocate a lowercase copy of the whole
list each time.
2026-07-23 12:16:59 +02:00
Kacper Michajłow e2eaf31ce2 fzy.lua: optimize main compute() a little
There could be a lot more done if we target luajit only. Or if we port
this to C. But for now let's keep it this way. It's 2-3x faster than
before, and the issue is mostly only on very big inputs, which are not
that common in practice.

Previously computing scores allocated two matrices of lua tables per
call. With hundreds of thousands of items this made fuzzy matching in
console.lua GC-bound.

When only the score is needed, keep two reused rolling matrix rows,
making repeated scoring allocation-free. positions() still keeps all
rows since tracing back the matched positions requires them.

fzy.filter() of 300000 items drops from 1013 ms to 356 ms (on my setup)
for a worst-case single-character needle, and a standalone score() call
no longer allocates at all.
2026-07-23 12:16:59 +02:00
Kacper Michajłow e4abaaa26b fzy.lua: do byte comparision instead string ones
This are char comparisions, but in lua they are expressed as full string
compare. Compare as bytes instead, this is significantly faster,
especially with luajit compiled code.
2026-07-23 12:16:59 +02:00
idontwannagoo 8ab3f8b66d options: add secondary-sub-scale
This allows scaling secondary subtitles independently from primary subtitles. The option defaults to 1 like --sub-scale and follows the other secondary-sub-* options by not inheriting from the primary subtitle setting.

Fixes #14989.
2026-07-22 19:32:01 +00:00
llyyr 25451bcc11 player/command: don't refresh sub stream on UPDATE_SUB option updates
Back when reselect_demux_stream call was added in this path in 700f72f,
sub_redecode_cached_packets only retained the last two packets. The
subtitle decoder cache was changed in 0a4b098 to retain the whole packet
sequence. Therefore sub_redecode_cached_packets by itself can rebuild
the new decoder state entirely from packets held in memory, and we no
longer need the demuxer to refresh the track.

This fixes expensive track refresh for network streams, where changing
some sub-* options during runtime of network streams would cause the
cache to be dropped
2026-07-22 20:51:55 +02:00
Kacper Michajłow e517fd6043 player/command: make track-list/N/ff-index optional
The `ff-index` is just a index of in the track order, it doesn't carry
much meaning and may be wrong or unavailable when other than lavf
demuxer is used. Additionally some tracks may be virtual like DOVI EL
track or merged image tile grid. In which case those track are not
related to lavf at all.

No deprecation period. It was never guaranteed to match FFmpeg anyway,
so anyone who has a hard dependency on this property should reconsider.
It's not really possible to provide backward compatibility given the
ambiguity of this index. It's better to make it unavailable than making
mismatch. For user it's clear when it's not available, but not possible
to know when it's wrong.
2026-07-09 05:04:11 +02:00