]> git.sesse.net Git - ffmpeg/commitdiff
lavc/movtextdec: add alpha default to ass header colors
authorJohn Stebbins <jstebbins@jetheaddev.com>
Sat, 4 Apr 2020 17:53:59 +0000 (11:53 -0600)
committerPhilip Langdale <philipl@overt.org>
Fri, 10 Apr 2020 16:32:13 +0000 (09:32 -0700)
Signed-off-by: Philip Langdale <philipl@overt.org>
libavcodec/movtextdec.c
tests/ref/fate/sub-movtext

index 2481c71af696f472c93e0ec88a2169fec2bfe033..eb9c7f57557aeccebaf84a804c9f9adf35f8069e 100644 (file)
@@ -55,7 +55,9 @@ typedef struct {
     const char *font;
     uint8_t fontsize;
     int color;
+    uint8_t alpha;
     int back_color;
+    uint8_t back_alpha;
     uint8_t bold;
     uint8_t italic;
     uint8_t underline;
@@ -186,7 +188,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
     }
     // Background Color
     m->d.back_color = AV_RB24(tx3g_ptr);
-    tx3g_ptr += 4;
+    tx3g_ptr += 3;
+    m->d.back_alpha = AV_RB8(tx3g_ptr);
+    tx3g_ptr += 1;
     // BoxRecord
     tx3g_ptr += 8;
     // StyleRecord
@@ -203,7 +207,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
     m->d.fontsize = *tx3g_ptr++;
     // Primary color
     m->d.color = AV_RB24(tx3g_ptr);
-    tx3g_ptr += 4;
+    tx3g_ptr += 3;
+    m->d.alpha = AV_RB8(tx3g_ptr);
+    tx3g_ptr += 1;
     // FontRecord
     // FontRecord Size
     tx3g_ptr += 4;
@@ -463,8 +469,8 @@ static int mov_text_init(AVCodecContext *avctx) {
     ret = mov_text_tx3g(avctx, m);
     if (ret == 0) {
         return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize,
-                    RGB_TO_BGR(m->d.color),
-                    RGB_TO_BGR(m->d.back_color),
+                    (255 - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
+                    (255 - m->d.back_alpha) << 24 | RGB_TO_BGR(m->d.back_color),
                     m->d.bold, m->d.italic, m->d.underline,
                     ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
     } else
index 94ed22d318ed84f4d4f0c2d4822e00f28b96427e..60470609187ca024b93e6e391de56ae224c1588a 100644 (file)
@@ -6,7 +6,7 @@ PlayResY: 288
 \r
 [V4+ Styles]\r
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\r
-Style: Default,Serif,18,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0\r
+Style: Default,Serif,18,&Hffffff,&Hffffff,&Hff000000,&Hff000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0\r
 \r
 [Events]\r
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r