diff options
author | Ripose <ripose@protonmail.com> | 2021-11-13 15:55:53 -0800 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2022-01-19 14:27:04 +0000 |
commit | 04f0b0abe48d664aaa1400d1dddb02b434999b85 (patch) | |
tree | cc784261e29a6834d7e81ff763fc060867672748 | |
parent | 1ab3f56df0d7be3b4152bd9e0cc50c1938ff6d70 (diff) | |
download | mpv-04f0b0abe48d664aaa1400d1dddb02b434999b85.tar.bz2 mpv-04f0b0abe48d664aaa1400d1dddb02b434999b85.tar.xz |
options: add --sub-visibility=<primary-only|secondary-only>
Adds --sub-visibility choices 'primary-only' for only displaying the
primary subtitle track, and 'secondary-only' for only displaying
secondary subtitle track.
Removes --secondary-sub-visibility and displays a message telling the
user to use --sub-visibility=yes/primary-only instead.
These changes make it so that the default 'sub-visibility' bind 'v'
cycles through all the 'sub-visibility' choices, 'no', 'yes',
'primary-only', and 'secondary-only'.
-rw-r--r-- | DOCS/interface-changes.rst | 2 | ||||
-rw-r--r-- | DOCS/man/options.rst | 11 | ||||
-rw-r--r-- | etc/input.conf | 1 | ||||
-rw-r--r-- | options/options.c | 8 | ||||
-rw-r--r-- | options/options.h | 1 | ||||
-rw-r--r-- | player/command.c | 12 | ||||
-rw-r--r-- | sub/dec_sub.c | 7 | ||||
-rw-r--r-- | sub/dec_sub.h | 1 | ||||
-rw-r--r-- | sub/osd.c | 2 |
9 files changed, 23 insertions, 22 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 63a08071ec..82f23149c9 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -39,6 +39,8 @@ Interface changes - add `--tone-mapping-mode`, replacing `--tone-mapping-desaturate` and `--tone-mapping-desaturate-exponent`. - add `dolbyvision` sub-parameter to `format` video filter + - remove `--secondary-sub-visibility` and introduces + `--sub-visibility=primary-only` and `--sub-visibility=secondary-only` --- mpv 0.34.0 --- - deprecate selecting by card number with `--drm-connector`, add `--drm-device` which can be used instead diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 7b51b585e8..31b43fdea0 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2607,19 +2607,10 @@ Subtitles This is a path list option. See `List Options`_ for details. -``--sub-visibility``, ``--no-sub-visibility`` +``--sub-visibility=<no|yes|primary-only|secondary-only>``, ``--no-sub-visibility`` Can be used to disable display of subtitles, but still select and decode them. -``--secondary-sub-visibility``, ``--no-secondary-sub-visibility`` - Can be used to disable display of secondary subtitles, but still select and - decode them. - - .. note:: - - If ``--sub-visibility=no``, secondary subtitles are hidden regardless of - ``--secondary-sub-visibility``. - ``--sub-clear-on-seek`` (Obscure, rarely useful.) Can be used to play broken mkv files with duplicate ReadOrder fields. ReadOrder is the first field in a diff --git a/etc/input.conf b/etc/input.conf index 76c246a4fc..cb2418f54a 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -121,7 +121,6 @@ #R add sub-pos +1 # move subtitles down #t add sub-pos +1 # move subtitles down #v cycle sub-visibility # hide or show the subtitles -#Alt+v cycle secondary-sub-visibility # hide or show the secondary subtitles #V cycle sub-ass-vsfilter-aspect-compat # toggle stretching SSA/ASS subtitles with anamorphic videos to match the historical renderer #u cycle-values sub-ass-override "force" "no" # toggle overriding SSA/ASS subtitle styles with the normal styles #j cycle sub # switch subtitle track diff --git a/options/options.c b/options/options.c index 1341cb891c..9ba5a7ae41 100644 --- a/options/options.c +++ b/options/options.c @@ -240,8 +240,9 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-delay", OPT_FLOAT(sub_delay)}, {"sub-fps", OPT_FLOAT(sub_fps)}, {"sub-speed", OPT_FLOAT(sub_speed)}, - {"sub-visibility", OPT_FLAG(sub_visibility)}, - {"secondary-sub-visibility", OPT_FLAG(sec_sub_visibility)}, + {"sub-visibility", OPT_CHOICE(sub_visibility, + {"no", 0}, {"yes", 1}, {"primary-only", 2}, {"secondary-only", 3}) + }, {"sub-forced-only", OPT_CHOICE(forced_subs_only, {"auto", -1}, {"no", 0}, {"yes", 1})}, {"stretch-dvd-subs", OPT_FLAG(stretch_dvd_subs)}, @@ -285,7 +286,6 @@ const struct m_sub_options mp_subtitle_sub_opts = { .size = sizeof(OPT_BASE_STRUCT), .defaults = &(OPT_BASE_STRUCT){ .sub_visibility = 1, - .sec_sub_visibility = 1, .forced_subs_only = -1, .sub_pos = 100, .sub_speed = 1.0, @@ -880,6 +880,8 @@ static const m_option_t mp_opts[] = { {"pphelp", OPT_REMOVED(NULL)}, {"rawaudio", OPT_REMOVED("use --demuxer-rawaudio-...")}, {"rawvideo", OPT_REMOVED("use --demuxer-rawvideo-...")}, + {"secondary-sub-visibility", OPT_REMOVED( + "use --sub-visibility=primary-only/yes")}, {"spugauss", OPT_REPLACED("sub-gauss")}, {"srate", OPT_REPLACED("audio-samplerate")}, {"ss", OPT_REPLACED("start")}, diff --git a/options/options.h b/options/options.h index 53e8de7852..90e9ad6424 100644 --- a/options/options.h +++ b/options/options.h @@ -73,7 +73,6 @@ typedef struct mp_vo_opts { // Subtitle options needed by the subtitle decoders/renderers. struct mp_subtitle_opts { int sub_visibility; - int sec_sub_visibility; int sub_pos; float sub_delay; float sub_fps; diff --git a/player/command.c b/player/command.c index 4f2eb4741d..8d0b5c859d 100644 --- a/player/command.c +++ b/player/command.c @@ -4003,11 +4003,13 @@ static const struct property_osd_display { {"sub-delay", "Sub delay"}, {"sub-speed", "Sub speed"}, {"sub-visibility", - .msg = "Subtitles ${!sub-visibility==yes:hidden}" - "${?sub-visibility==yes:visible${?sub==no: (but no subtitles selected)}}"}, - {"secondary-sub-visibility", - .msg = "Secondary Subtitles ${!secondary-sub-visibility==yes:hidden}" - "${?secondary-sub-visibility==yes:visible${?secondary-sid==no: (but no secondary subtitles selected)}}"}, + .msg = "Subtitles ${?sub-visibility==no:hidden}" + "${?sub-visibility==yes:visible}" + "${?sub-visibility==primary-only:visible (primary only" + "${?sid==no: but no subtitles selected})}" + "${?sub-visibility==secondary-only:visible (secondary only" + "${?secondary-sid==no: but no subtitles selected})}" + }, {"sub-forced-only", "Forced sub only"}, {"sub-scale", "Sub Scale"}, {"sub-ass-vsfilter-aspect-compat", "Subtitle VSFilter aspect compat"}, diff --git a/sub/dec_sub.c b/sub/dec_sub.c index a283a5151d..6525c41653 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -453,7 +453,12 @@ void sub_set_play_dir(struct dec_sub *sub, int dir) pthread_mutex_unlock(&sub->lock); } +bool sub_is_primary_visible(struct dec_sub *sub) +{ + return sub->opts->sub_visibility == 1 || sub->opts->sub_visibility == 2; +} + bool sub_is_secondary_visible(struct dec_sub *sub) { - return !!sub->opts->sec_sub_visibility; + return sub->opts->sub_visibility == 1 || sub->opts->sub_visibility == 3; } diff --git a/sub/dec_sub.h b/sub/dec_sub.h index 6257e74c65..dea5f7c5b8 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -51,6 +51,7 @@ void sub_reset(struct dec_sub *sub); void sub_select(struct dec_sub *sub, bool selected); void sub_set_recorder_sink(struct dec_sub *sub, struct mp_recorder_sink *sink); void sub_set_play_dir(struct dec_sub *sub, int dir); +bool sub_is_primary_visible(struct dec_sub *sub); bool sub_is_secondary_visible(struct dec_sub *sub); int sub_control(struct dec_sub *sub, enum sd_ctrl cmd, void *arg); @@ -291,7 +291,7 @@ static struct sub_bitmaps *render_object(struct osd_state *osd, check_obj_resize(osd, osdres, obj); if (obj->type == OSDTYPE_SUB) { - if (obj->sub) + if (obj->sub && sub_is_primary_visible(obj->sub)) res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts); } else if (obj->type == OSDTYPE_SUB2) { if (obj->sub && sub_is_secondary_visible(obj->sub)) |