diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2015-05-23 00:06:40 +0300 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2015-05-25 00:16:55 +0300 |
commit | 36db47b89cd5f4edfb2b02780ff2ddd8022190db (patch) | |
tree | a7f90c2fe0c4a103de2894b3587d3738d1518003 /libass/ass_utils.h | |
parent | 409ce02b6b9f9147af548cdc46695350af97d801 (diff) | |
download | libass-36db47b89cd5f4edfb2b02780ff2ddd8022190db.tar.bz2 libass-36db47b89cd5f4edfb2b02780ff2ddd8022190db.tar.xz |
Parse and animate all colors and alpha values like VSFilter
* Allow exactly one of these prefixes in header values:
0x, 0X, &h, &H. Note that "0x0xFFFFFF" is a correct value,
as the first 0x is consumed by the parser and the second by
the string-to-number conversion following strtol semantics.
* Allow arbitrary numbers of leading & and H
(and not h) in any order in override tag values.
* Reduce header values modulo 2**32 instead
of saturating them to LLONG_MIN/MAX.
* Saturate override tag values to INT32_MIN/MAX
rather than to LLONG_MIN/MAX.
* Don't fiddle with bytes in alpha override tag values.
(They can be outside of the 0..255 range.)
Also change the byte swapping code to be more sensible.
Fixes #80.
Fixes #145.
Fixes #178.
Also fixes our behavior in the case described in
https://code.google.com/p/xy-vsfilter/issues/detail?id=80.
Diffstat (limited to 'libass/ass_utils.h')
-rw-r--r-- | libass/ass_utils.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libass/ass_utils.h b/libass/ass_utils.h index 2ad8c5b..45ebbb6 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -85,9 +85,11 @@ void skip_spaces(char **str); void rskip_spaces(char **str, char *limit); int mystrtoi(char **p, int *res); int mystrtoll(char **p, long long *res); -int mystrtou32(char **p, int base, uint32_t *res); int mystrtod(char **p, double *res); -uint32_t string2color(ASS_Library *library, char *p, int hex); +int mystrtoi32(char **p, int base, int32_t *res); +int32_t parse_alpha_tag(char *str); +uint32_t parse_color_tag(char *str); +uint32_t parse_color_header(char *str); char parse_bool(char *str); int parse_ycbcr_matrix(char *str); unsigned ass_utf8_get_char(char **str); @@ -111,6 +113,16 @@ static inline size_t ass_align(size_t alignment, size_t s) return (s + (alignment - 1)) & ~(alignment - 1); } +static inline uint32_t ass_bswap32(uint32_t x) +{ +#ifdef _MSC_VER + return _byteswap_ulong(x); +#else + return (x & 0x000000FF) << 24 | (x & 0x0000FF00) << 8 | + (x & 0x00FF0000) >> 8 | (x & 0xFF000000) >> 24; +#endif +} + static inline int d6_to_int(int x) { return (x + 32) >> 6; |