diff options
author | Oneric <oneric@oneric.de> | 2024-02-19 22:42:26 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2024-04-06 09:25:03 +0200 |
commit | 0fc975c0d307e9f76ba189778b99a076e16e9acb (patch) | |
tree | 97ff73fd2702b10c02bbb8b8e0794217907d3e04 /libavcodec/ass.c | |
parent | baa64fa4e66465c63f84baaae204734aa19efb3f (diff) | |
download | ffmpeg-0fc975c0d307e9f76ba189778b99a076e16e9acb.tar.gz |
avcodec/ass,webvttdec: implement more portable curly brace escapes
Unlike what the old comment suggested, standard ASS has no character
escape mechanism, but a closing curly bracket doesn't even need one.
For manual authored sub files using a full-width variant of an
appropriate font and with scaling and spacing modifiers is a common
workaround.
This is not an option here, but we can still make things much less bad.
Now the desired opening bracket still shows up in libass, and
standard renders will merely display a backslash in its place
instead of stripping the following text like before.
Diffstat (limited to 'libavcodec/ass.c')
-rw-r--r-- | libavcodec/ass.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/ass.c b/libavcodec/ass.c index c5abf15122..ef906f9c4b 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -181,10 +181,14 @@ void ff_ass_bprint_text_event(AVBPrint *buf, const char *p, int size, if (linebreaks && strchr(linebreaks, *p)) { av_bprintf(buf, "\\N"); - /* standard ASS escaping so random characters don't get mis-interpreted - * as ASS */ - } else if (!keep_ass_markup && strchr("{}", *p)) { - av_bprintf(buf, "\\%c", *p); + /* cancel curly brackets to avoid bogus override tag blocks + * hiding text. Standard ASS has no character escapes, + * though (only) libass provides \{ and \}. + * Unpaired closing brackets don't need escaping at all though and + * to make the situation less bad in standard ASS insert an empty block + */ + } else if (!keep_ass_markup && *p == '{') { + av_bprintf(buf, "\\{{}"); /* append word-joiner U+2060 as UTF-8 to break up sequences like \N */ } else if (!keep_ass_markup && *p == '\\') { |