diff options
author | wm4 <wm4@nowhere> | 2020-05-14 22:14:49 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-14 22:14:49 +0200 |
commit | c6369933f1d9cd204b09be95ef7d4ed1351610e2 (patch) | |
tree | d7b45307780aef2dafde89795f49d564c7aed313 /sub/sd_ass.c | |
parent | 0049ea38be72884fabeee3ce52e2d6796c3abd53 (diff) | |
download | mpv-c6369933f1d9cd204b09be95ef7d4ed1351610e2.tar.bz2 mpv-c6369933f1d9cd204b09be95ef7d4ed1351610e2.tar.xz |
command: add property to return text subtitles in ASS
See manpage additions. This was requested, sort of. Although what has
been requested might be something completely different. So this is
speculative.
This also changes sub_get_text() to return an allocated copy, because
the buffer shit was too damn messy.
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r-- | sub/sd_ass.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c index d51f892dd4..46f16908b0 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -627,7 +627,7 @@ static bool is_whitespace_only(char *s, int len) return true; } -static char *get_text(struct sd *sd, double pts) +static char *get_text_buf(struct sd *sd, double pts, enum sd_text_type type) { struct sd_ass_priv *ctx = sd->priv; ASS_Track *track = ctx->ass_track; @@ -643,7 +643,13 @@ static char *get_text(struct sd *sd, double pts) if (ipts >= event->Start && ipts < event->Start + event->Duration) { if (event->Text) { int start = b.len; - ass_to_plaintext(&b, event->Text); + if (type == SD_TEXT_TYPE_PLAIN) { + ass_to_plaintext(&b, event->Text); + } else { + char *t = event->Text; + while (*t) + append(&b, *t++); + } if (is_whitespace_only(&b.start[start], b.len - start)) { b.len = start; } else { @@ -661,6 +667,11 @@ static char *get_text(struct sd *sd, double pts) return ctx->last_text; } +static char *get_text(struct sd *sd, double pts, enum sd_text_type type) +{ + return talloc_strdup(NULL, get_text_buf(sd, pts, type)); +} + static struct sd_times get_times(struct sd *sd, double pts) { struct sd_ass_priv *ctx = sd->priv; @@ -697,7 +708,7 @@ static void fill_plaintext(struct sd *sd, double pts) ass_flush_events(track); - char *text = get_text(sd, pts); + char *text = get_text_buf(sd, pts, SD_TEXT_TYPE_PLAIN); if (!text) return; |