Skip to content

Commit

Permalink
Revert "options: add --sub-visibility=<primary-only|secondary-only>"
Browse files Browse the repository at this point in the history
This reverts commit 04f0b0a.

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.
  • Loading branch information
avih committed Jan 19, 2022
1 parent 04f0b0a commit 9cddd73
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 23 deletions.
2 changes: 0 additions & 2 deletions DOCS/interface-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2607,10 +2607,19 @@ Subtitles

This is a path list option. See `List Options`_ for details.

``--sub-visibility=<no|yes|primary-only|secondary-only>``, ``--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
Expand Down
1 change: 1 addition & 0 deletions etc/input.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")},
Expand Down
1 change: 1 addition & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 5 additions & 7 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
7 changes: 1 addition & 6 deletions sub/dec_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion sub/dec_sub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion sub/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 9cddd73

Please sign in to comment.