summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-08-28 17:24:24 -0500
committerDudemanguy <random342@airmail.cc>2023-08-29 16:39:00 +0000
commit4009e99b9c8a875e244c908b1f5721bf255966ea (patch)
tree5c78190a92eb61fb50338da3d81d5a512573f845
parent90543610c28f89d0a74c7cb5ede60f7b13ef2973 (diff)
downloadmpv-4009e99b9c8a875e244c908b1f5721bf255966ea.tar.bz2
mpv-4009e99b9c8a875e244c908b1f5721bf255966ea.tar.xz
player: remove auto choice from sub-forced-only
First of all, this never worked. Or if it ever did, it was in some select few scenarios. c9474dc9ed6172a5f17f66f4b7d367da6b077909 is what originally added support for the auto choice. However, that commit worked by propagating a value to a fake option used internally. This shouldn't have ever worked because the underlying m_config_cache was never updated so the value shouldn't have been preserved when accessed in sd_lavc. And indeed with some testing, the value there is always 0 unsurprisingly. This was later rewritten in ba7cc071068f4f57ae354e77f64552712fda6855 along with a lot of other sub changes, but with that, it was still mostly broken. The reason is because one of the key parts of having to hit this logic (prefer_forced) required `--no-subs-with-matching-audio` to be set. If the audio language matches the subtitle language (the requirement also excludes forced subs), the option makes no subtitle selection in the first place so pick->forced_only_def is not set to true and nothing even happens. Another way around this would be to attempt to change your OS language (like with the LANG environment variable) so that the subtitle track gets selected but then audio_matches mistakenly becomes false because it compares the OS language to the audio language which then make preferred_forced 0, so nothing happens. I don't think there's a scenario where pick->forced_only_def is actually set to true (thus meaning `auto` is useless), but maybe someone could contrive something very strange. Regardless, it's definitely not something even remotely common. fbe8f9919428a7ed24a61899bfd85bbb7680e389 changed track selection again but didn't consider this particular case. The net result is that DVD/PGS subs become equivalent to --sub-forced-only being yes, so this a change in behavior and probably not a good one. Note that I wasn't able to actually observe any difference in a PGS sample. It still displayed subtitles fine but that sample probably didn't have the right flags to hit the sub-forced-only logic. Anyways, the auto feature is extremely questionable at best and in my view, not actually worth it. It is meant to be used with `--no-subs-with-matching-audio` to display forced pictures in subtitle tracks that are not marked as forced, but that contradicts that particular option's purpose and description in the manual (secretly selecting a track under certain conditions even though it says not to). Instead of trying to shove all this logic into select_default_track which is already insanely complicated as it is, recognize that this is a trivial lua script. If you absolutely want to turn --sub-forced-only on under these certain conditions (DVD/PGS subtitles, matching audio and subtitle languages, etc.), just look at the current-tracks property and do your thing. The very, very niche behavior that this option tried to accomplish basically never worked, no user even knows what this option does, and well it's just not worth supporting in core mpv code. Drop all this code for sanity's sake and change --sub-forced-only back to a bool.
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/input.rst4
-rw-r--r--DOCS/man/options.rst11
-rw-r--r--options/options.c4
-rw-r--r--options/options.h2
-rw-r--r--player/command.c5
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c12
-rw-r--r--sub/dec_sub.c4
-rw-r--r--sub/sd.h2
-rw-r--r--sub/sd_ass.c2
-rw-r--r--sub/sd_lavc.c3
12 files changed, 13 insertions, 39 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index aa2149ba4d..0fa85796a7 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -47,6 +47,8 @@ Interface changes
- remove special handling of the `auto` value from `--alang/slang/vlang` options
- add `--subs-match-os-language` as a replacement for `--slang=auto`
- add `always` option to `--subs-fallback-forced`
+ - remove `auto` choice from `--sub-forced-only`
+ - remove `auto-forced-only` property
--- mpv 0.36.0 ---
- add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used.
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 2faffef656..07beb67717 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -2886,10 +2886,6 @@ Property list
``yes``/true if the track has the forced flag set in the file,
``no``/false or unavailable otherwise.
- ``track-list/N/auto-forced-only``
- ``yes``/true if the track was autoselected in forced-only mode,
- ``no``/false or unavailable otherwise.
-
``track-list/N/codec``
The codec name used by this track, for example ``h264``. Unavailable
in some rare cases.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index cf0dcdc5ee..de9e92a778 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2621,12 +2621,11 @@ Subtitles
subtitles (if the difference is smaller than 210 ms, the gap or overlap
is removed).
-``--sub-forced-only=<auto|yes|no>``
- Display only forced subtitles for the DVD subtitle stream selected by e.g.
- ``--slang`` (default: ``auto``). When set to ``auto``, enabled when the
- ``--subs-with-matching-audio`` option is on and a non-forced stream is selected.
- Enabling this will hide all subtitles in streams that don't make a distinction
- between forced and unforced events within a stream.
+``--sub-forced-only=<yes|no>``
+ Enabling this displays only forced events within subtitle streams. Only
+ some bitmap subtitle formats (such as DVD or PGS) are capable of having a
+ mixture of forced and unforced events within the stream. Enabling this on
+ text subtitles will cause no subtitles to be displayed (default: ``no``).
``--sub-fps=<rate>``
Specify the framerate of the subtitle file (default: video fps). Affects
diff --git a/options/options.c b/options/options.c
index ae51a010ac..4f0f4be631 100644
--- a/options/options.c
+++ b/options/options.c
@@ -262,8 +262,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"sub-speed", OPT_FLOAT(sub_speed)},
{"sub-visibility", OPT_BOOL(sub_visibility)},
{"secondary-sub-visibility", OPT_BOOL(sec_sub_visibility)},
- {"sub-forced-only", OPT_CHOICE(forced_subs_only,
- {"auto", -1}, {"no", 0}, {"yes", 1})},
+ {"sub-forced-only", OPT_BOOL(forced_subs_only)},
{"stretch-dvd-subs", OPT_BOOL(stretch_dvd_subs)},
{"stretch-image-subs-to-screen", OPT_BOOL(stretch_image_subs)},
{"image-subs-video-resolution", OPT_BOOL(image_subs_video_res)},
@@ -306,7 +305,6 @@ const struct m_sub_options mp_subtitle_sub_opts = {
.defaults = &(OPT_BASE_STRUCT){
.sub_visibility = true,
.sec_sub_visibility = true,
- .forced_subs_only = -1,
.sub_pos = 100,
.sub_speed = 1.0,
.ass_enabled = true,
diff --git a/options/options.h b/options/options.h
index a2fca90432..1f47732d65 100644
--- a/options/options.h
+++ b/options/options.h
@@ -83,7 +83,7 @@ struct mp_subtitle_opts {
float sub_delay;
float sub_fps;
float sub_speed;
- int forced_subs_only;
+ bool forced_subs_only;
bool stretch_dvd_subs;
bool stretch_image_subs;
bool image_subs_video_res;
diff --git a/player/command.c b/player/command.c
index 71363e832d..b9cbdec200 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1975,7 +1975,6 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
{"albumart", SUB_PROP_BOOL(track->attached_picture)},
{"default", SUB_PROP_BOOL(track->default_track)},
{"forced", SUB_PROP_BOOL(track->forced_track)},
- {"auto-forced-only", SUB_PROP_BOOL(track->forced_only_def)},
{"dependent", SUB_PROP_BOOL(track->dependent_track)},
{"visual-impaired", SUB_PROP_BOOL(track->visual_impaired_track)},
{"hearing-impaired", SUB_PROP_BOOL(track->hearing_impaired_track)},
@@ -3015,10 +3014,6 @@ static int mp_property_sub_forced_only_cur(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
int ret = mpctx->opts->subs_rend->forced_subs_only;
- if (ret == -1) {
- struct track *track = mpctx->current_track[0][STREAM_SUB];
- ret = track && track->forced_only_def;
- }
return m_property_bool_ro(action, arg, ret);
}
diff --git a/player/core.h b/player/core.h
index 9b60add51d..0f63f13474 100644
--- a/player/core.h
+++ b/player/core.h
@@ -137,7 +137,6 @@ struct track {
// Current subtitle state (or cached state if selected==false).
struct dec_sub *d_sub;
- bool forced_only_def;
// Current decoding state (NULL if selected==false)
struct mp_decoder_wrapper *dec;
diff --git a/player/loadfile.c b/player/loadfile.c
index cd528624f0..535d486ee0 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -260,8 +260,8 @@ static void print_stream(struct MPContext *mpctx, struct track *t)
char b[2048] = {0};
bool forced_only = false;
if (t->type == STREAM_SUB) {
- int forced_opt = mpctx->opts->subs_rend->forced_subs_only;
- if (forced_opt == 1 || (forced_opt && t->forced_only_def))
+ bool forced_opt = mpctx->opts->subs_rend->forced_subs_only;
+ if (forced_opt)
forced_only = t->selected;
}
APPEND(b, " %3s %-5s", t->selected ? (forced_only ? "(*)" : "(+)") : "", tname);
@@ -630,7 +630,6 @@ struct track *select_default_track(struct MPContext *mpctx, int order,
struct track *forced_pick = NULL;
for (int n = 0; n < mpctx->num_tracks; n++) {
struct track *track = mpctx->tracks[n];
- track->forced_only_def = false;
if (track->type != type)
continue;
if (track->user_tid == tid) {
@@ -672,13 +671,6 @@ struct track *select_default_track(struct MPContext *mpctx, int order,
pick = NULL;
if (pick && !opts->autoload_files && pick->is_external)
pick = NULL;
- if (pick && sub && !pick->forced_track) {
- // If the codec is DVD or PGS, we can display it in forced-only mode.
- if (pick->stream &&
- (!strcmp(pick->stream->codec->codec, "dvd_subtitle") ||
- !strcmp(pick->stream->codec->codec, "hdmv_pgs_subtitle")))
- pick->forced_only_def = true;
- }
cleanup:
talloc_free(langs);
return pick;
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index a476c20396..dc26aa027e 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -69,8 +69,6 @@ struct dec_sub {
struct sd *sd;
struct demux_packet *new_segment;
-
- bool forced_only_def;
};
static void update_subtitle_speed(struct dec_sub *sub)
@@ -144,7 +142,6 @@ static struct sd *init_decoder(struct dec_sub *sub)
.attachments = sub->attachments,
.codec = sub->codec,
.preload_ok = true,
- .forced_only_def = sub->forced_only_def,
};
if (sd->driver->init(sd) >= 0)
@@ -182,7 +179,6 @@ struct dec_sub *sub_create(struct mpv_global *global, struct track *track,
.last_vo_pts = MP_NOPTS_VALUE,
.start = MP_NOPTS_VALUE,
.end = MP_NOPTS_VALUE,
- .forced_only_def = track->forced_only_def,
};
sub->opts = sub->opts_cache->opts;
mpthread_mutex_init_recursive(&sub->lock);
diff --git a/sub/sd.h b/sub/sd.h
index b4e8aa6742..87270c6c4f 100644
--- a/sub/sd.h
+++ b/sub/sd.h
@@ -24,8 +24,6 @@ struct sd {
// Set to false as soon as the decoder discards old subtitle events.
// (only needed if sd_functions.accept_packets_in_advance == false)
bool preload_ok;
-
- bool forced_only_def;
};
struct sd_functions {
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index a4df24e0ae..1ce77384c8 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -577,7 +577,7 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res dim,
// Currently no supported text sub formats support a distinction between forced
// and unforced lines, so we just assume everything's unforced and discard everything.
// If we ever see a format that makes this distinction, we can add support here.
- if (opts->forced_subs_only == 1 || (opts->forced_subs_only && sd->forced_only_def))
+ if (opts->forced_subs_only)
goto done;
double scale = dim.display_par;
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index eb71bdd0c2..5586a4c287 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -195,8 +195,7 @@ static void read_sub_bitmaps(struct sd *sd, struct sub *sub)
MP_ERR(sd, "unsupported subtitle type from libavcodec\n");
continue;
}
- if (!(r->flags & AV_SUBTITLE_FLAG_FORCED) && (opts->forced_subs_only == 1 ||
- (opts->forced_subs_only && sd->forced_only_def)))
+ if (!(r->flags & AV_SUBTITLE_FLAG_FORCED) && opts->forced_subs_only)
continue;
if (r->w <= 0 || r->h <= 0)
continue;