diff mbox series

[FFmpeg-devel,20/23] lavc/movtextenc: handle cancel overrides callback

Message ID 20200406175218.1299994-21-jstebbins@jetheaddev.com
State Superseded
Headers show
Series [FFmpeg-devel,01/23] lavc/movtextdec: fix ass header colors | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork warning Failed to apply patch

Commit Message

John Stebbins April 6, 2020, 5:52 p.m. UTC
---
 libavcodec/movtextenc.c | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 9e657c9635..2e65489c4d 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -396,9 +396,8 @@  static void mov_text_end_cb(void *priv)
     mov_text_style_start((MovTextContext*)priv);
 }
 
-static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
+static void mov_text_ass_style_set(MovTextContext *s, ASSStyle *style)
 {
-    ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
     uint8_t    style_flags, alpha;
     uint32_t   color;
 
@@ -412,9 +411,27 @@  static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
         alpha = 255 - ((uint32_t)style->primary_color >> 24);
         mov_text_alpha_set(s, alpha);
         mov_text_font_size_set(s, style->font_size);
+    } else {
+        // End current style record, go back to defaults
+        mov_text_style_start(s);
     }
 }
 
+static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
+{
+    ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
+
+    mov_text_ass_style_set(s, style);
+}
+
+static void mov_text_cancel_overrides_cb(void *priv, const char * style_name)
+{
+    MovTextContext *s = priv;
+    ASSStyle * style = ff_ass_style_get(s->ass_ctx, style_name);
+
+    mov_text_ass_style_set(s, style);
+}
+
 static uint16_t utf8_strlen(const char *text, int len)
 {
     uint16_t i = 0, ret = 0;
@@ -454,13 +471,14 @@  static void mov_text_new_line_cb(void *priv, int forced)
 }
 
 static const ASSCodesCallbacks mov_text_callbacks = {
-    .text      = mov_text_text_cb,
-    .new_line  = mov_text_new_line_cb,
-    .style     = mov_text_style_cb,
-    .color     = mov_text_color_cb,
-    .alpha     = mov_text_alpha_cb,
-    .font_size = mov_text_font_size_cb,
-    .end       = mov_text_end_cb,
+    .text             = mov_text_text_cb,
+    .new_line         = mov_text_new_line_cb,
+    .style            = mov_text_style_cb,
+    .color            = mov_text_color_cb,
+    .alpha            = mov_text_alpha_cb,
+    .font_size        = mov_text_font_size_cb,
+    .cancel_overrides = mov_text_cancel_overrides_cb,
+    .end              = mov_text_end_cb,
 };
 
 static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,