diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2021-07-23 20:31:15 +0300 |
---|---|---|
committer | avih <avih@users.noreply.github.com> | 2021-08-05 21:32:22 +0300 |
commit | 41650203c32e179e5f3cf89e176ef6caccba05d9 (patch) | |
tree | 21bb2a4682f33be0ff99f52a3ba3efe847b4d1cb /sub/filter_regex.c | |
parent | 7c264950c0bff588f6852c461c26b37a550a5abb (diff) | |
download | mpv-41650203c32e179e5f3cf89e176ef6caccba05d9.tar.bz2 mpv-41650203c32e179e5f3cf89e176ef6caccba05d9.tar.xz |
sub: sub-filter-regex and jsre: support ass-to-plaintext
Using --sub-filter-regex-plain (default:no)
The ass-to-plaintext functionality already existed at sd_ass.c, but
it's internal and uses a private buffer type, so a trivial utility
wrapper was added with standard char*/bstr interface.
The plaintext can be multi-line, and the multi-line regexp flag is now
always set, but only affects plaintext (the ASS source is one line).
Diffstat (limited to 'sub/filter_regex.c')
-rw-r--r-- | sub/filter_regex.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sub/filter_regex.c b/sub/filter_regex.c index 66e4b1a1da..8e299918ce 100644 --- a/sub/filter_regex.c +++ b/sub/filter_regex.c @@ -30,7 +30,7 @@ static bool rf_init(struct sd_filter *ft) MP_TARRAY_GROW(p, p->regexes, p->num_regexes); regex_t *preg = &p->regexes[p->num_regexes]; - int err = regcomp(preg, item, REG_ICASE | REG_EXTENDED | REG_NOSUB); + int err = regcomp(preg, item, REG_ICASE | REG_EXTENDED | REG_NOSUB | REG_NEWLINE); if (err) { char errbuf[512]; regerror(err, preg, errbuf, sizeof(errbuf)); @@ -63,6 +63,9 @@ static struct demux_packet *rf_filter(struct sd_filter *ft, char *text = bstrto0(NULL, sd_ass_pkt_text(ft, pkt, p->offset)); bool drop = false; + if (ft->opts->rf_plain) + sd_ass_to_plaintext(text, strlen(text), text); + for (int n = 0; n < p->num_regexes; n++) { int err = regexec(&p->regexes[n], text, 0, NULL, 0); if (err == 0) { |