diff options
author | John Stebbins <jstebbins@jetheaddev.com> | 2020-04-04 13:36:51 -0600 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2020-04-10 09:32:13 -0700 |
commit | 32cf264d8f3a7da00b7662e88e34df5d7fc3163e (patch) | |
tree | 7c5810676f9bf75339b60acf38a118d2e8e4ff0d /libavcodec | |
parent | a52eef68d4ba4b7166b8a7681e1a8812c2866823 (diff) | |
download | ffmpeg-32cf264d8f3a7da00b7662e88e34df5d7fc3163e.tar.gz |
lavc/movtextenc: use correct color component order
Signed-off-by: Philip Langdale <philipl@overt.org>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/movtextenc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index c19ef384bc..8638e303fe 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -39,6 +39,7 @@ #define HLIT_BOX (1<<1) #define HCLR_BOX (1<<2) +#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff)) #define av_bprint_append_any(buf, data, size) av_bprint_append_data(buf, ((const char*)data), size) typedef struct { @@ -134,13 +135,14 @@ static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) { - uint32_t tsmb_size; + uint32_t tsmb_size, color; if (s->box_flags & HCLR_BOX) { tsmb_size = 12; tsmb_size = AV_RB32(&tsmb_size); + color = AV_RB32(&s->hclr.color); av_bprint_append_any(&s->buffer, &tsmb_size, 4); av_bprint_append_any(&s->buffer, &tsmb_type, 4); - av_bprint_append_any(&s->buffer, &s->hclr.color, 4); + av_bprint_append_any(&s->buffer, &color, 4); } } @@ -289,6 +291,8 @@ static void mov_text_style_cb(void *priv, const char style, int close) static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color_id) { MovTextContext *s = priv; + + color = BGR_TO_RGB(color) << 8; if (color_id == 2) { //secondary color changes if (s->box_flags & HLIT_BOX) { //close tag s->hlit.end = AV_RB16(&s->text_pos); @@ -296,7 +300,7 @@ static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color s->box_flags |= HCLR_BOX; s->box_flags |= HLIT_BOX; s->hlit.start = AV_RB16(&s->text_pos); - s->hclr.color = color | (0xFF << 24); //set alpha value to FF + s->hclr.color = color | 0xFF; //set alpha value to FF } } /* If there are more than one secondary color changes in ASS, take start of |