[FFmpeg-devel] [PATCH v22 23/23] avcodec/webvttenc: convert hard-space tags to  

Soft Works softworkz at hotmail.com
Thu Dec 9 14:13:08 EET 2021


Signed-off-by: softworkz <softworkz at hotmail.com>
---
 libavcodec/webvttenc.c       |  6 ++++++
 tests/ref/fate/sub-webvttenc | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index 43dace6575..a4997969ee 100644
--- a/libavcodec/webvttenc.c
+++ b/libavcodec/webvttenc.c
@@ -123,6 +123,11 @@ static void webvtt_new_line_cb(void *priv, int forced)
     webvtt_print(priv, "\n");
 }
 
+static void webvtt_hard_space_cb(void *priv)
+{
+    webvtt_print(priv, " ");
+}
+
 static void webvtt_style_cb(void *priv, char style, int close)
 {
     if (style == 's') // strikethrough unsupported
@@ -147,6 +152,7 @@ static void webvtt_end_cb(void *priv)
 static const ASSCodesCallbacks webvtt_callbacks = {
     .text             = webvtt_text_cb,
     .new_line         = webvtt_new_line_cb,
+    .hard_space       = webvtt_hard_space_cb,
     .style            = webvtt_style_cb,
     .color            = NULL,
     .font_name        = NULL,
diff --git a/tests/ref/fate/sub-webvttenc b/tests/ref/fate/sub-webvttenc
index f4172dcc84..ee9de2859e 100644
--- a/tests/ref/fate/sub-webvttenc
+++ b/tests/ref/fate/sub-webvttenc
@@ -132,26 +132,26 @@ but show this: {normal text}
 \ N is a forced line break
 \ h is a hard space
 Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.
-The line will never break automatically right before or after a hard space. :-D
+The line will never break automatically right before or after a hard space. :-D
 
 00:54.501 --> 00:56.500
 
-     A (05 hard spaces followed by a letter)
+     A (05 hard spaces followed by a letter)
 A (Normal  spaces followed by a letter)
 A (No hard spaces followed by a letter)
 
 00:56.501 --> 00:58.500
-     A (05 hard spaces followed by a letter)
+     A (05 hard spaces followed by a letter)
 A (Normal  spaces followed by a letter)
 A (No hard spaces followed by a letter)
 Show this: \TEST and this: \-)
 
 00:58.501 --> 01:00.500
 
-A letter followed by 05 hard spaces: A     
+A letter followed by 05 hard spaces: A     
 A letter followed by normal  spaces: A
 A letter followed by no hard spaces: A
-05 hard  spaces between letters: A     A
+05 hard  spaces between letters: A     A
 5 normal spaces between letters: A     A
 
 ^--Forced line break
-- 
2.30.2.windows.1



More information about the ffmpeg-devel mailing list