From: Stefano Sabatini <stefasab@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v4 3/4] avcodec/{ass, webvttdec}: more portable curly brace escapes
Date: Thu, 4 Apr 2024 19:48:35 +0200
Message-ID: <Zg7n86XLYS4VAaXf@mariano> (raw)
In-Reply-To: <20240219214227.19814-4-oneric@oneric.de>
On date Monday 2024-02-19 22:42:26 +0100, Oneric wrote:
> 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 apropiate
appropriate?
> font and with scaling and psacing modifiers is a common workaround.
spacing
> 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.
> ---
> libavcodec/ass.c | 12 ++++++++----
> libavcodec/webvttdec.c | 2 +-
> tests/ref/fate/sub-webvtt | 2 +-
> 3 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/ass.c b/libavcodec/ass.c
> index a68d3568b4..e7a1ac0eb5 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 == '\\') {
> diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c
> index 6e55bc5499..35bdbe805d 100644
> --- a/libavcodec/webvttdec.c
> +++ b/libavcodec/webvttdec.c
> @@ -37,7 +37,7 @@ static const struct {
> {"<i>", "{\\i1}"}, {"</i>", "{\\i0}"},
> {"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
> {"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
> - {"{", "\\{"}, {"}", "\\}"}, {"\\", "\\\xe2\x81\xa0"}, // escape to avoid ASS markup conflicts
> + {"{", "\\{{}"}, {"\\", "\\\xe2\x81\xa0"}, // escape to avoid ASS markup conflicts
> {">", ">"}, {"<", "<"},
> {"‎", "\xe2\x80\x8e"}, {"‏", "\xe2\x80\x8f"},
> {"&", "&"}, {" ", "\\h"},
> diff --git a/tests/ref/fate/sub-webvtt b/tests/ref/fate/sub-webvtt
> index ea587b327c..fae50607fb 100644
> --- a/tests/ref/fate/sub-webvtt
> +++ b/tests/ref/fate/sub-webvtt
> @@ -21,7 +21,7 @@ Dialogue: 0,0:00:22.00,0:00:24.00,Default,,0,0,0,,at the AMNH.
> Dialogue: 0,0:00:24.00,0:00:26.00,Default,,0,0,0,,Thank you for walking down here.
> Dialogue: 0,0:00:27.00,0:00:30.00,Default,,0,0,0,,And I want to do a follow-up on the last conversation we did.\Nmultiple lines\Nagain
> Dialogue: 0,0:00:30.00,0:00:31.50,Default,,0,0,0,,When we e-mailed—
> -Dialogue: 0,0:00:30.50,0:00:32.50,Default,,0,0,0,,Didn't we {\b1}talk {\i1}about\N{\i0} enough{\b0} in that conversation? \{I'm not an ASS comment\}
> +Dialogue: 0,0:00:30.50,0:00:32.50,Default,,0,0,0,,Didn't we {\b1}talk {\i1}about\N{\i0} enough{\b0} in that conversation? \{{}I'm not an ASS comment}
> Dialogue: 0,0:00:32.00,0:00:35.50,Default,,0,0,0,,No! No no no no; 'cos 'cos obviously 'cos
> Dialogue: 0,0:00:32.50,0:00:33.50,Default,,0,0,0,,{\i1}Laughs{\i0}
> Dialogue: 0,0:00:35.50,0:00:38.00,Default,,0,0,0,,You know I'm so excited my glasses are falling off here.
Should be good otherwise (but a second look from someone more familiar
with ASS also might be good).
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-04-04 17:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 21:42 [FFmpeg-devel] [PATCH v4 0/4] Fix some active sequences in subtitles Oneric
2024-02-19 21:42 ` [FFmpeg-devel] [PATCH v4 1/4] avcodec/webvttdec: honour bidi marks Oneric
2024-04-04 16:59 ` Stefano Sabatini
2024-02-19 21:42 ` [FFmpeg-devel] [PATCH v4 2/4] avcodec/{ass, webvttdec}: fix handling of backslashes Oneric
2024-04-04 17:44 ` Stefano Sabatini
2024-04-04 17:56 ` Marth64
2024-04-04 18:02 ` Stefano Sabatini
2024-04-04 18:26 ` Marth64
2024-04-04 18:36 ` Oneric
2024-04-04 21:53 ` Stefano Sabatini
2024-02-19 21:42 ` [FFmpeg-devel] [PATCH v4 3/4] avcodec/{ass, webvttdec}: more portable curly brace escapes Oneric
2024-04-04 17:48 ` Stefano Sabatini [this message]
2024-02-19 21:42 ` [FFmpeg-devel] [PATCH v4 4/4] avocdec/ass: simplify linebreaks Oneric
2024-04-04 17:50 ` Stefano Sabatini
2024-02-26 22:26 ` [FFmpeg-devel] [PATCH v4 0/4] Fix some active sequences in subtitles Oneric
2024-03-19 20:59 ` Marth64
2024-03-26 16:01 ` Marth64
2024-04-03 19:50 ` Oneric
2024-04-06 7:27 ` Stefano Sabatini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zg7n86XLYS4VAaXf@mariano \
--to=stefasab@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git