diff mbox series

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

Message ID MN2PR04MB59812361D5136BB7B47F332EBAA19@MN2PR04MB5981.namprd04.prod.outlook.com
State Superseded, archived
Headers show
Series [FFmpeg-devel,v8,01/13] global: Prepare AVFrame for subtitle handling | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Soft Works Sept. 21, 2021, 11:54 p.m. UTC
Signed-off-by: softworkz <softworkz@hotmail.com>
---
 libavcodec/ass_split.c | 12 ++++++++++--
 libavcodec/ass_split.h |  2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

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);
     /** @} */
 
     /**