summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Oscarsson <DanOscarsson@users.noreply.github.com>2020-02-09 15:47:55 +0100
committerwm4 <1387750+wm4@users.noreply.github.com>2020-02-09 16:18:34 +0100
commiteb1d50ba201d4efc9959d81112191b68c39eb290 (patch)
tree02f564a3749f78bb9dc7fddb1486f42803c1c294
parenta8553578eb7b19e2df00c263c68f6931564b961e (diff)
downloadmpv-eb1d50ba201d4efc9959d81112191b68c39eb290.tar.bz2
mpv-eb1d50ba201d4efc9959d81112191b68c39eb290.tar.xz
sub: enhance SDH filtering
It is not uncommon with a speaker label with [xxxx] inside. They should also be filtered out.
-rw-r--r--sub/filter_sdh.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sub/filter_sdh.c b/sub/filter_sdh.c
index a04f33a23e..72744ec20e 100644
--- a/sub/filter_sdh.c
+++ b/sub/filter_sdh.c
@@ -83,6 +83,8 @@ static void copy_ass(struct sd *sd, char **rpp, struct buffer *buf)
return;
}
+static bool skip_bracketed(struct sd *sd, char **rpp, struct buffer *buf);
+
// check for speaker label, like MAN:
// normal subtitles may include mixed case text with : after so
// only upper case is accepted and lower case l which for some
@@ -121,6 +123,12 @@ static void skip_speaker_label(struct sd *sd, char **rpp, struct buffer *buf)
while (*rp && rp[0] != ':') {
if (rp[0] == '{') {
copy_ass(sd, &rp, buf);
+ } else if (rp[0] == '[') {
+ // not uncommon with [xxxx]: which should also be skipped
+ if (!skip_bracketed(sd, &rp, buf)) {
+ buf->pos = old_pos;
+ return;
+ }
} else if ((mp_isalpha(rp[0]) &&
(filter_harder || mp_isupper(rp[0]) || rp[0] == 'l')) ||
mp_isdigit(rp[0]) ||