Skip to content

Add DVD / Blu-Ray menu support#18080

Open
kasper93 wants to merge 38 commits into
mpv-player:masterfrom
kasper93:bd-dvd
Open

Add DVD / Blu-Ray menu support#18080
kasper93 wants to merge 38 commits into
mpv-player:masterfrom
kasper93:bd-dvd

Conversation

@kasper93

@kasper93 kasper93 commented Jun 6, 2026

Copy link
Copy Markdown
Member

It's rebased on top of #17932, because I don't want to rebase those conflicts again. (The DV pull request got stalled unfortunatelly)

@kasper93 kasper93 force-pushed the bd-dvd branch 3 times, most recently from 072b324 to 499ba28 Compare June 6, 2026 02:33
@kasper93 kasper93 force-pushed the bd-dvd branch 3 times, most recently from e2c0128 to d698b40 Compare June 7, 2026 01:46
kasper93 added 23 commits June 7, 2026 23:04
Don't try to select dependent track as main and feedback to base track.
To avoid situations where tracks are deselected only to select the same
group again.
This joins Dolby Vision EL track with base one. libbluray current (as of
1.4.1) doesn't even expose this info, it will be available in next
version, but it is less code to ask lavf for this info in fact.
To avoid truncated description.
DVDNAV_VTS_CHANGE casts the just-written event payload to
dvdnav_vts_change_event_t. The cast was reading from s->buffer (the
stream's ring buffer, untouched by this read), not buf (the demuxer's
destination that dvdnav_get_next_block actually wrote into).

While here, drop the message to MP_VERBOSE and fix its wording.
"switched to title" is misleading because this is a VTS-change event.
not a title change.
This is connected to standard DVD subs renderer, with additional state
passed for highlight color.
They are expected in normal operation of libdvdread, where changing
titles, causes natural jump in PTS.
kasper93 added 15 commits June 7, 2026 23:05
Define three new stream controls so disc backends (libdvdnav, libbluray)
can expose their in-disc menu/highlight state to the player.

STREAM_CTRL_NAV_CMD - send a navigation action
STREAM_CTRL_GET_NAV_STATE - get current menu state
STREAM_CTRL_GET_NAV_OVERLAY - get BGRA overlay that should be drawn (BD)

Not used yet, will get use in next commits.
Drive libdvdnav's menu state through the new disc-nav protocol so the
player can show / interact with VMGM and VTSM menus:
Add HDMV menu support to stream_bluray. Activated by opening with
"bd://menu/..." or by the global --disc-menu option

Lots of plumbing the libbluary event loop. Menus are read though
different function even.

STREAM_CTRL_NAV_CMD maps arrow/select/menu/popup/mouse onto
bd_user_input and bd_mouse_select. SELECT and MOUSE_CLICK queue an
HDMV VM command (often PlayPlaylist) that won't execute until the
next demuxer read, so we bump discontinuity_id pre-emptively; the
player's post-action check then sees the change and flushes cached
audio/video that would otherwise keep playing for seconds while the
new playlist is already arriving.
Playing a disc through the menu means crossing playlist boundaries at
runtime: menu -> title (and back), sub-menu -> sub-menu, title -> title
on a "Play next" button. Each new playlist can have a different stream
count and/or a different codec mix (a MPEG-2 menu into an H.264 main
feature is common on BD-Video). The previous slave demuxer was probed
once at open and never refreshed, so after a hop the player either kept
decoding stale streams or saw nothing at all.

Tear down and re-open the slave on every nav discontinuity.

add_stream_editions() now appends a synthetic "Disc Menu" entry at
index num_titles.
New player/discnav.c owns the state for the in-disc menu UI. Used to
display menu and control the DVD / BD playback. This is common part
between stream_bluray.c and stream_dvdnav.c.
play_current_file picks default tracks once, then leaves them alone.
That leaves later-surfacing streams without a default selection.
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 is defined to allow binding specific
controls only for disc menu.
Fixes track switching on some discs.
Adds support for ARGB callback from libbluray. For some reason they
don't have unified support, and sometimes it uses ARGB (for BD-J) and
RLE (for HDMV), while they could convery RLE encoded menus into ARGB
bitmaps, if only one is supproted. We have to support both.

When Java VM is not available, fallbacks to non-menu playback.
VM events are processed in fill_buffer callback, which are called by the
demuxer thread. In some cases even if we don't need data, we have to
drive the event loop, to actually get the playlist/menu switch request
from the VM.
Comment thread player/discnav.c
@@ -0,0 +1,449 @@
/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file could be a builtin client.

As long as mpv provides the overlay images, the clients have all the necessary parts to display and control menu with discnav and overlay-add commands.

There are code later using osd_set_external2 which overwrite user added overlay-add overlays. This does not belong to the core.

Comment thread stream/stream_bluray.c
{
for (int i = 0; i < 256; i++) {
int Y = pg[i].Y, Cb = pg[i].Cb, Cr = pg[i].Cr, T = pg[i].T;
// BT.709 limited->full.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IG/PG can be 601, 709, or 2020. Matrix should be inferred from the base layer.

@qyot27

qyot27 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Just to mention it in case it might need some adjustment with all these changes before they finalize, but how easily would potential future DVD-Audio support slot in amongst this? I'm not sure if it employs any visual menuing, since most DVD players would pick up the VIDEO_TS part of the disc instead.

libdvd{css,read} can properly handle DVD-Audio now, and VLC has it enabled in the nightlies, but I don't know if it can easily be bolted onto mpv's existing DVD-Video parsing or if it would require much deeper changes (or at worst, just get siloed off into its own component if it's too different and accessed via dvda://whatever).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants