From aa3cf6d57b1a2aa475bd002ded6db6359fd9ef31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Wed, 8 May 2024 03:21:42 +0200 Subject: [PATCH] command: add dolby-vision-profile and dolby-vision-level to track-list --- DOCS/interface-changes/dolby-vision-configuration.txt | 1 + DOCS/man/input.rst | 6 ++++++ demux/demux_lavf.c | 3 +++ demux/demux_mkv.c | 6 ++++++ demux/stheader.h | 4 ++++ player/command.c | 4 ++++ 6 files changed, 24 insertions(+) create mode 100644 DOCS/interface-changes/dolby-vision-configuration.txt diff --git a/DOCS/interface-changes/dolby-vision-configuration.txt b/DOCS/interface-changes/dolby-vision-configuration.txt new file mode 100644 index 0000000000..9383310fb9 --- /dev/null +++ b/DOCS/interface-changes/dolby-vision-configuration.txt @@ -0,0 +1 @@ +add `track-list/N/dolby-vision-profile` and `track-list/N/dolby-vision-level` diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index df4766b5be..e0bfadf98f 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -3185,6 +3185,10 @@ Property list values currently. It's possible that future mpv versions will make these properties unavailable instead in this case. + ``track-list/N/dolby-vision-profile``, ``track-list/N/dolby-vision-level`` + Dolby Vision profile and level. May not be available if the container + does not provide this information. + When querying the property with the client API using ``MPV_FORMAT_NODE``, or with Lua ``mp.get_property_native``, this will return a mpv_node with the following contents: @@ -3229,6 +3233,8 @@ Property list "replaygain-track-gain" MPV_FORMAT_DOUBLE "replaygain-album-peak" MPV_FORMAT_DOUBLE "replaygain-album-gain" MPV_FORMAT_DOUBLE + "dolby-vision-profile" MPV_FORMAT_INT64 + "dolby-vision-level" MPV_FORMAT_INT64 ``current-tracks/...`` This gives access to currently selected tracks. It redirects to the correct diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 94b1c893c5..c1dbe6a8a8 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -796,6 +796,9 @@ static void handle_new_stream(demuxer_t *demuxer, int i) MP_VERBOSE(demuxer, "Found Dolby Vision config record: profile " "%d level %d\n", cfg->dv_profile, cfg->dv_level); av_format_inject_global_side_data(avfc); + sh->codec->dovi = true; + sh->codec->dv_profile = cfg->dv_profile; + sh->codec->dv_level = cfg->dv_level; } // This also applies to vfw-muxed mkv, but we can't detect these easily. diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 8d8a5d66de..4a9bfb2faf 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1687,6 +1687,12 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) sh_v->rotate = rotate; } + if (track->dovi_config) { + sh_v->dovi = true; + sh_v->dv_level = track->dovi_config->dv_level; + sh_v->dv_profile = track->dovi_config->dv_profile; + } + done: demux_add_sh_stream(demuxer, sh); diff --git a/demux/stheader.h b/demux/stheader.h index 036c8f54e7..6025aa5a0c 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -121,6 +121,10 @@ struct mp_codec_params { struct pl_color_repr repr; // color representaion info where available struct mp_rect crop; // crop to be applied + bool dovi; + uint8_t dv_profile; + uint8_t dv_level; + // STREAM_VIDEO + STREAM_AUDIO int bits_per_coded_sample; char *format_name; // pixel format (video) or sample format (audio) diff --git a/player/command.c b/player/command.c index d16b510ed4..65469988d9 100644 --- a/player/command.c +++ b/player/command.c @@ -2079,6 +2079,10 @@ static int get_track_entry(int item, int action, void *arg, void *ctx) .unavailable = !has_rg}, {"replaygain-album-gain", SUB_PROP_FLOAT(rg.album_gain), .unavailable = !has_rg}, + {"dolby-vision-profile", SUB_PROP_INT(p.dv_profile), + .unavailable = !p.dovi}, + {"dolby-vision-level", SUB_PROP_INT(p.dv_level), + .unavailable = !p.dovi}, {0} };