diff options
-rw-r--r-- | libass/ass_cache.c | 20 | ||||
-rw-r--r-- | libass/ass_fontconfig.c | 2 | ||||
-rw-r--r-- | libass/ass_parse.c | 2 | ||||
-rw-r--r-- | libass/ass_utils.h | 11 |
4 files changed, 17 insertions, 18 deletions
diff --git a/libass/ass_cache.c b/libass/ass_cache.c index 91801a0a..8234e5f0 100644 --- a/libass/ass_cache.c +++ b/libass/ass_cache.c @@ -242,14 +242,16 @@ Cache *ass_cache_create(HashFunction hash_func, HashCompare compare_func, void *ass_cache_put(Cache *cache, void *key, void *value) { unsigned bucket = cache->hash_func(key, cache->key_size) % cache->buckets; - CacheItem **item = &cache->map[bucket]; - while (*item) - item = &(*item)->next; - (*item) = calloc(1, sizeof(CacheItem)); - (*item)->key = malloc(cache->key_size); - (*item)->value = malloc(cache->value_size); - memcpy((*item)->key, key, cache->key_size); - memcpy((*item)->value, value, cache->value_size); + CacheItem **bucketptr = &cache->map[bucket]; + + CacheItem *item = calloc(1, sizeof(CacheItem)); + item->key = malloc(cache->key_size); + item->value = malloc(cache->value_size); + memcpy(item->key, key, cache->key_size); + memcpy(item->value, value, cache->value_size); + + item->next = *bucketptr; + *bucketptr = item; cache->items++; if (cache->size_func) @@ -257,7 +259,7 @@ void *ass_cache_put(Cache *cache, void *key, void *value) else cache->cache_size++; - return (*item)->value; + return item->value; } void *ass_cache_get(Cache *cache, void *key) diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index b8ad9ec5..dcb0bcf9 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -188,7 +188,7 @@ static char *select_font(ASS_Library *library, FCInstance *priv, */ FcPatternDel(pat, "lang"); - fsorted = FcFontSort(priv->config, pat, FcTrue, NULL, &result); + fsorted = FcFontSort(priv->config, pat, FcFalse, NULL, &result); ffullname = match_fullname(library, priv, family, bold, italic); if (!fsorted || !ffullname) goto error; diff --git a/libass/ass_parse.c b/libass/ass_parse.c index c74f3b30..c3292c92 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -966,7 +966,7 @@ void process_karaoke_effects(ASS_Renderer *render_priv) dt = (tm_current - tm_start); if ((s1->effect_type == EF_KARAOKE) || (s1->effect_type == EF_KARAOKE_KO)) { - if (dt > 0) + if (dt >= 0) x = x_end + 1; else x = x_start; diff --git a/libass/ass_utils.h b/libass/ass_utils.h index e5e0ecd1..b797c8c9 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -119,7 +119,8 @@ static inline int rot_key(double a) return double_to_d22(a) % m; } -#define FNV1_32A_INIT (unsigned)0x811c9dc5 +#define FNV1_32A_INIT 0x811c9dc5U +#define FNV1_32A_PRIME 16777619U static inline unsigned fnv_32a_buf(void *buf, size_t len, unsigned hval) { @@ -127,9 +128,7 @@ static inline unsigned fnv_32a_buf(void *buf, size_t len, unsigned hval) unsigned char *be = bp + len; while (bp < be) { hval ^= (unsigned) *bp++; - hval += - (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + - (hval << 24); + hval *= FNV1_32A_PRIME; } return hval; } @@ -138,9 +137,7 @@ static inline unsigned fnv_32a_str(char *str, unsigned hval) unsigned char *s = (unsigned char *) str; while (*s) { hval ^= (unsigned) *s++; - hval += - (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + - (hval << 24); + hval *= FNV1_32A_PRIME; } return hval; } |