summaryrefslogtreecommitdiffstats
path: root/sub/filter_jsre.c
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-07-23 20:31:15 +0300
committeravih <avih@users.noreply.github.com>2021-08-05 21:32:22 +0300
commit41650203c32e179e5f3cf89e176ef6caccba05d9 (patch)
tree21bb2a4682f33be0ff99f52a3ba3efe847b4d1cb /sub/filter_jsre.c
parent7c264950c0bff588f6852c461c26b37a550a5abb (diff)
downloadmpv-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_jsre.c')
-rw-r--r--sub/filter_jsre.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sub/filter_jsre.c b/sub/filter_jsre.c
index 896382714a..af4fbbeba3 100644
--- a/sub/filter_jsre.c
+++ b/sub/filter_jsre.c
@@ -87,7 +87,7 @@ static bool jsre_init(struct sd_filter *ft)
for (int n = 0; ft->opts->jsre_items && ft->opts->jsre_items[n]; n++) {
char *item = ft->opts->jsre_items[n];
- int err = p_regcomp(p->J, p->num_regexes, item, JS_REGEXP_I);
+ int err = p_regcomp(p->J, p->num_regexes, item, JS_REGEXP_I | JS_REGEXP_M);
if (err) {
MP_ERR(ft, "jsre: %s -- '%s'\n", get_err(p->J), item);
js_pop(p->J, 1);
@@ -111,6 +111,9 @@ static struct demux_packet *jsre_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 found, err = p_regexec(p->J, n, text, &found);
if (err == 0 && found) {