diff options
author | Grigori Goronzy <greg@blackbox> | 2009-08-12 06:20:26 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-08-12 06:20:26 +0200 |
commit | 8a9ef5e2014068a348cb3e0f965113a827d93cd7 (patch) | |
tree | e94067b5011b2b4ce251dc5f2348022667fd3eb6 /libass/ass_render.c | |
parent | e8032bc820dd0079db103165cf3d4d84f429edb7 (diff) | |
download | libass-8a9ef5e2014068a348cb3e0f965113a827d93cd7.tar.bz2 libass-8a9ef5e2014068a348cb3e0f965113a827d93cd7.tar.xz |
Always parse colors as hex for ASS tracks
According to the ASS specification, colors can only be specified in hex.
Modify the color parsing accordingly; this especially means that colors
where the hex sigil (the "H") is missing can now be parsed.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r-- | libass/ass_render.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index f5ed87b..aa67727 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1260,7 +1260,8 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr) } else if (mystrcmp(&p, "alpha")) { uint32_t val; int i; - if (strtocolor(render_priv->library, &p, &val)) { + int hex = render_priv->track->track_type == TRACK_TYPE_ASS; + if (strtocolor(render_priv->library, &p, &val, hex)) { unsigned char a = val >> 24; for (i = 0; i < 4; ++i) change_alpha(&render_priv->state.c[i], a, pwr); @@ -1449,7 +1450,8 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr) } } else if (mystrcmp(&p, "c")) { uint32_t val; - if (!strtocolor(render_priv->library, &p, &val)) + int hex = render_priv->track->track_type == TRACK_TYPE_ASS; + if (!strtocolor(render_priv->library, &p, &val, hex)) val = render_priv->state.style->PrimaryColour; ass_msg(render_priv->library, MSGL_DBG2, "color: %X", val); change_color(&render_priv->state.c[0], val, pwr); @@ -1459,8 +1461,9 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr) int cidx = n - '1'; char cmd = *(p - 1); uint32_t val; + int hex = render_priv->track->track_type == TRACK_TYPE_ASS; assert((n >= '1') && (n <= '4')); - if (!strtocolor(render_priv->library, &p, &val)) + if (!strtocolor(render_priv->library, &p, &val, hex)) switch (n) { case '1': val = render_priv->state.style->PrimaryColour; |