static uint32_t string2color(ASS_Library *library, char *p)
{
uint32_t tmp;
- (void) strtocolor(library, &p, &tmp);
+ (void) strtocolor(library, &p, &tmp, 0);
return tmp;
}
} 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);
}
} 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);
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;
return 0;
}
-int strtocolor(ASS_Library *library, char **q, uint32_t *res)
+int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex)
{
uint32_t color = 0;
int result;
char *p = *q;
+ int base = hex ? 16 : 10;
if (*p == '&')
++p;
++p;
result = mystrtou32(&p, 16, &color);
} else {
- result = mystrtou32(&p, 0, &color);
+ result = mystrtou32(&p, base, &color);
}
{
int mystrtoll(char **p, long long *res);
int mystrtou32(char **p, int base, uint32_t *res);
int mystrtod(char **p, double *res);
-int strtocolor(ASS_Library *library, char **q, uint32_t *res);
+int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex);
char parse_bool(char *str);
unsigned ass_utf8_get_char(char **str);
void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...);