summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libass/ass_cache.c5
-rw-r--r--libass/ass_render.c10
2 files changed, 11 insertions, 4 deletions
diff --git a/libass/ass_cache.c b/libass/ass_cache.c
index 0252735..3ebf0cc 100644
--- a/libass/ass_cache.c
+++ b/libass/ass_cache.c
@@ -288,6 +288,11 @@ static void glyph_hash_dtor(void *key, size_t key_size, void *value,
void *cache_add_glyph(Hashmap *glyph_cache, GlyphHashKey *key,
GlyphHashValue *val)
{
+ if (val->glyph && val->glyph->format == FT_GLYPH_FORMAT_BITMAP) {
+ FT_Bitmap *bitmap = &((FT_BitmapGlyph) val->glyph)->bitmap;
+ glyph_cache->cache_size += bitmap->rows * bitmap->pitch;
+ }
+
return hashmap_insert(glyph_cache, key, val);
}
diff --git a/libass/ass_render.c b/libass/ass_render.c
index cf11f92..1fdbfe4 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -45,7 +45,7 @@
#define SUBPIXEL_MASK 63
#define SUBPIXEL_ACCURACY 7 // d6 mask for subpixel accuracy adjustment
#define GLYPH_CACHE_MAX 1000
-#define BITMAP_CACHE_MAX_SIZE 50 * 1048576
+#define BITMAP_CACHE_MAX_SIZE 30 * 1048576
static void ass_lazy_track_init(ASS_Renderer *render_priv)
{
@@ -2358,10 +2358,12 @@ ass_start_frame(ASS_Renderer *render_priv, ASS_Track *track,
render_priv->prev_images_root = 0;
}
- if (cache->glyph_cache->count > cache->glyph_max) {
+ if (cache->glyph_cache->count > cache->glyph_max
+ || cache->glyph_cache->cache_size > cache->bitmap_max_size) {
ass_msg(render_priv->library, MSGL_V,
- "Hitting hard glyph cache limit (was: %ld glyphs), resetting.",
- (long) cache->glyph_cache->count);
+ "Hitting hard glyph cache limit (was: %d glyphs, %ld bytes), "
+ "resetting.",
+ cache->glyph_cache->count, (long) cache->glyph_cache->cache_size);
cache->glyph_cache = ass_glyph_cache_reset(cache->glyph_cache);
}