aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJohn Stebbins <jstebbins@jetheaddev.com>2020-04-09 13:12:39 -0600
committerPhilip Langdale <philipl@overt.org>2020-04-10 09:32:13 -0700
commitad3f6212ac88c710404dc9c176ff9af3ada9a1bd (patch)
treee6d6715961fd806a6039ab94b6f3417e4bbd95f7 /libavcodec
parenteeef87085161d3ca3816b71bbb07a8408b47a898 (diff)
downloadffmpeg-ad3f6212ac88c710404dc9c176ff9af3ada9a1bd.tar.gz
lavc/movtextenc: handle changes to hilight alpha
Signed-off-by: Philip Langdale <philipl@overt.org>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/movtextenc.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 58a916ae0e..d8dbc546aa 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -479,19 +479,23 @@ static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color
if (color_id == 1) { //primary color changes
mov_text_color_set(s, color);
} else if (color_id == 2) { //secondary color changes
- if (s->box_flags & HLIT_BOX) { //close tag
- s->hlit.end = s->text_pos;
- } else {
+ if (!(s->box_flags & HCLR_BOX))
+ // Highlight alpha not set yet, use current primary alpha
+ s->hclr.color = s->style_attributes_temp->style_color;
+ if (!(s->box_flags & HLIT_BOX) || s->hlit.start == s->text_pos) {
s->box_flags |= HCLR_BOX;
s->box_flags |= HLIT_BOX;
s->hlit.start = s->text_pos;
- s->hclr.color = color | 0xFF; //set alpha value to FF
+ s->hclr.color = color | (s->hclr.color & 0xFF);
}
+ else //close tag
+ s->hlit.end = s->text_pos;
+ /* If there are more than one secondary color changes in ASS,
+ take start of first section and end of last section. Movtext
+ allows only one highlight box per sample.
+ */
}
- /* If there are more than one secondary color changes in ASS, take start of
- first section and end of last section. Movtext allows only one
- highlight box per sample.
- */
+ // Movtext does not support changes to other color_id (outline, background)
}
static void mov_text_alpha_set(MovTextContext *s, uint8_t alpha)
@@ -510,8 +514,23 @@ static void mov_text_alpha_cb(void *priv, int alpha, int alpha_id)
{
MovTextContext *s = priv;
+ alpha = 255 - alpha;
if (alpha_id == 1) // primary alpha changes
- mov_text_alpha_set(s, 255 - alpha);
+ mov_text_alpha_set(s, alpha);
+ else if (alpha_id == 2) { //secondary alpha changes
+ if (!(s->box_flags & HCLR_BOX))
+ // Highlight color not set yet, use current primary color
+ s->hclr.color = s->style_attributes_temp->style_color;
+ if (!(s->box_flags & HLIT_BOX) || s->hlit.start == s->text_pos) {
+ s->box_flags |= HCLR_BOX;
+ s->box_flags |= HLIT_BOX;
+ s->hlit.start = s->text_pos;
+ s->hclr.color = (s->hclr.color & 0xffffff00) | alpha;
+ }
+ else //close tag
+ s->hlit.end = s->text_pos;
+ }
+ // Movtext does not support changes to other alpha_id (outline, background)
}
static uint16_t find_font_id(MovTextContext * s, const char * name)