Skip to content

BD/DVD more options and control over VM - #18416

Open
kasper93 wants to merge 16 commits into
mpv-player:masterfrom
kasper93:bd-dvd2
Open

BD/DVD more options and control over VM#18416
kasper93 wants to merge 16 commits into
mpv-player:masterfrom
kasper93:bd-dvd2

Conversation

@kasper93

Copy link
Copy Markdown
Member

No description provided.

dvdnav_get_video_aspect() is declared to return uint8_t, but hands back -1
when the VM has not started or the IFO's display_aspect_ratio is neither 0
nor 3, so read it back as int8_t and reject negative values. Only 0 (4:3)
and 3 (16:9) are valid, the "2 -- 16:9" in libdvdnav's header comment does
not match what vm_get_video_aspect() does. The control now fails instead of
silently claiming 16:9.
dvdnav_get_title_string() returns a name libdvdnav reads by opening the
device and pulling a fixed offset out of a raw sector, so it only answers
for a device or an image and stays empty for a VIDEO_TS directory.
dvdnav_get_volid_string() asks libdvdread for the UDF volume identifier and
falls back to the ISO one, so it answers in cases the title string cannot.
Use it when available.
Wire the key file to bd_open.
BD_EVENT_ENCRYPTED says the .m2ts is encrypted and cannot be played.
bd_get_current_title() returns the title index libbluray last stored, and
that is only written by bd_select_playlist() and bd_select_title(). Neither
runs under menu navigation, so the value goes stale. The event's own param
is no substitute either, it carries the HDMV title number from PSR4 where 0
is the top menu and 0xffff is First Play, a different numbering from the
index into the list bd_get_titles() built. Log it and leave current_title
alone.
A playlist is a list of clips and every clip carries its own stream
table. We were always reading clips[0], which may not always be valid,
if there are some clips in front that are not "main" content.

The track list covers the whole playlist, so a query can name a pid the
played clip does not carry. Fall back to the other clips in that case,
instead of reporting no language at all.
Discs carry a large number of very short playlists that exist only to drive
their menus, and every one of them becomes an mpv edition. Add an option
to filter them out.
SPRM16 and SPRM18 hold the preferred audio and subtitle language and the
disc's own selection commands compare against them. libdvdnav initializes
both to English and mpv never touched them, so on a multi language disc
the author's selection logic always landed on English no matter what the
user asked for. Only two letter codes fit the register, so the first such
entry is used.
PSR16 and PSR17 hold the preferred audio and PG language and libbluray uses
them to pick the initial streams for a playlist. Set them, based on
alang/slang. To make it flexible, list all languages on disc, and match
with mp_match_lang(), then select top match, which is available on dics,
and set that.
Both are player settings libbluray keeps in its register file, so split
bd_open() into bd_init() and bd_open_disc() to get a handle to set them on
before the disc is opened.
This should preempt the common questions: "why the menu is not working?"
libdvdnav initializes SPRM20 to 0x1, under a comment that calls it
region free. It is not, it is region 1, and a disc that checks the
player region against it can refuse to play anywhere else. Claim one of
the regions the disc allows, or the one the user asked for.
We already use this flag, wire it now to commands too.
The IFO says whether a subtitle stream is forced, whether it is a caption
track, and whether an audio or subtitle track is a commentary or is meant
for the visually impaired. These live in code_extension. The byte dvdread
calls lang_extension is reserved by the spec, so readers that use it, its
own ifo_print.c included, are reading nothing.
Wire more actions, but without default keybindings this time. May be
added later if needed, but most actions are arrows+select in practice.
dvdnav_get_audio_logical_stream() does not do what its name says. It calls
vm_get_audio_stream(), which takes the logical stream number, the index into
the PGC's audio_control and into the title set's attribute table, and returns
the physical substream number the stream is muxed under. The subpicture
counterpart is the same, and the subpicture code here already inverted
it correctly by searching for the logical stream whose physical number
matches.
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.

1 participant