From 9cddd73f67f11dba2f2921124e2c39c77af01651 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Wed, 19 Jan 2022 21:56:28 +0200 Subject: [PATCH] Revert "options: add --sub-visibility=" This reverts commit 04f0b0abe48d664aaa1400d1dddb02b434999b85. It's not a good idea to unify the names only for visibility, while keeping secondary-* for everything else. This needs a bit more thought before we allow secondary sub to be visible on its own. --- DOCS/interface-changes.rst | 2 -- DOCS/man/options.rst | 11 ++++++++++- etc/input.conf | 1 + options/options.c | 8 +++----- options/options.h | 1 + player/command.c | 12 +++++------- sub/dec_sub.c | 7 +------ sub/dec_sub.h | 1 - sub/osd.c | 2 +- 9 files changed, 22 insertions(+), 23 deletions(-) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 82f23149c9..63a08071ec 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -39,8 +39,6 @@ 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 31b43fdea0..7b51b585e8 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2607,10 +2607,19 @@ Subtitles This is a path list option. See `List Options`_ for details. -``--sub-visibility=``, ``--no-sub-visibility`` +``--sub-visibility``, ``--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 cb2418f54a..76c246a4fc 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -121,6 +121,7 @@ #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 9ba5a7ae41..1341cb891c 100644 --- a/options/options.c +++ b/options/options.c @@ -240,9 +240,8 @@ 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_CHOICE(sub_visibility, - {"no", 0}, {"yes", 1}, {"primary-only", 2}, {"secondary-only", 3}) - }, + {"sub-visibility", OPT_FLAG(sub_visibility)}, + {"secondary-sub-visibility", OPT_FLAG(sec_sub_visibility)}, {"sub-forced-only", OPT_CHOICE(forced_subs_only, {"auto", -1}, {"no", 0}, {"yes", 1})}, {"stretch-dvd-subs", OPT_FLAG(stretch_dvd_subs)}, @@ -286,6 +285,7 @@ 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,8 +880,6 @@ 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 90e9ad6424..53e8de7852 100644 --- a/options/options.h +++ b/options/options.h @@ -73,6 +73,7 @@ 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 8d0b5c859d..4f2eb4741d 100644 --- a/player/command.c +++ b/player/command.c @@ -4003,13 +4003,11 @@ static const struct property_osd_display { {"sub-delay", "Sub delay"}, {"sub-speed", "Sub speed"}, {"sub-visibility", - .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})}" - }, + .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)}}"}, {"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 6525c41653..a283a5151d 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -453,12 +453,7 @@ 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->sub_visibility == 1 || sub->opts->sub_visibility == 3; + return !!sub->opts->sec_sub_visibility; } diff --git a/sub/dec_sub.h b/sub/dec_sub.h index dea5f7c5b8..6257e74c65 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -51,7 +51,6 @@ 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); diff --git a/sub/osd.c b/sub/osd.c index 297ad88fe8..e422716ada 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -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 && sub_is_primary_visible(obj->sub)) + if (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))