[FFmpeg-devel] [PATCH v8 10/13] avcodec/ass_split: Extend ass dialog parsing

Soft Works softworkz at hotmail.com
Wed Sep 22 02:54:51 EEST 2021


Signed-off-by: softworkz <softworkz at hotmail.com>
---
 libavcodec/ass_split.c | 12 ++++++++++--
 libavcodec/ass_split.h |  2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index 05c5453e53..e58585d3da 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -497,8 +497,8 @@ int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,
             while (*buf == '\\') {
                 char style[2], c[2], sep[2], c_num[2] = "0", tmp[128] = {0};
                 unsigned int color = 0xFFFFFFFF;
-                int len, size = -1, an = -1, alpha = -1;
-                int x1, y1, x2, y2, t1 = -1, t2 = -1;
+                int len, size = -1, an = -1, alpha = -1, scale = 0;
+                int x1, y1, x2, y2, t1 = -1, t2 = -1, accel = 1;
                 if (sscanf(buf, "\\%1[bisu]%1[01\\}]%n", style, c, &len) > 1) {
                     int close = c[0] == '0' ? 1 : c[0] == '1' ? 0 : -1;
                     len += close != -1;
@@ -546,6 +546,14 @@ int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,
                 } else if (sscanf(buf, "\\org(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {
                     if (callbacks->origin)
                         callbacks->origin(priv, x1, y1);
+                } else if (sscanf(buf, "\\t(%d,%d,%1[\\}]%n", &t1, &t2, sep, &len) > 2 ||
+                           sscanf(buf, "\\t(%d,%d,%d,%1[\\}]%n", &t1, &t2, &accel, sep, &len) > 3) {
+                    if (callbacks->animate)
+                        callbacks->animate(priv, t1, t2, accel, tmp);
+                } else if (sscanf(buf, "\\p%1[\\}]%n", sep, &len) > 0 ||
+                           sscanf(buf, "\\p%u%1[\\}]%n", &scale, sep, &len) > 1) {
+                    if (callbacks->drawing_mode)
+                        callbacks->drawing_mode(priv, scale);
                 } else {
                     len = strcspn(buf+1, "\\}") + 2;  /* skip unknown code */
                 }
diff --git a/libavcodec/ass_split.h b/libavcodec/ass_split.h
index a45fb9b8a1..bda7bb27db 100644
--- a/libavcodec/ass_split.h
+++ b/libavcodec/ass_split.h
@@ -156,7 +156,9 @@ typedef struct {
      * @{
      */
     void (*move)(void *priv, int x1, int y1, int x2, int y2, int t1, int t2);
+    void (*animate)(void *priv, int t1, int t2, int accel, char *style);
     void (*origin)(void *priv, int x, int y);
+    void (*drawing_mode)(void *priv, int scale);
     /** @} */
 
     /**
-- 
2.30.2.windows.1



More information about the ffmpeg-devel mailing list