summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2010-08-01 03:30:59 +0200
committerGrigori Goronzy <greg@blackbox>2010-08-01 03:35:19 +0200
commitec0d975158e5f3b1c6a60c44fb10171f1b3c1b32 (patch)
tree88bbd0ee922abcd25bab3bca4ead1aa6dbdb1596 /libass/ass_render.c
parent7bdeea8453b2643b1925223acab41f5c7b56b6e2 (diff)
downloadlibass-ec0d975158e5f3b1c6a60c44fb10171f1b3c1b32.tar.bz2
libass-ec0d975158e5f3b1c6a60c44fb10171f1b3c1b32.tar.xz
Limit (bitmap) glyph cache size
Now that bitmap glyphs (for vector clip masks) are stored in the glyph cache, make sure it cannot grow indefinitely easily. Similar to the bitmap cache, track approximate size of the cached elements and reset if the cache exceeds a certain limit. Also, reduce default bitmap cache size to 30 MB as we have essentially two bitmap caches now. That's still plenty in all use cases where caching matters.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r--libass/ass_render.c10
1 files changed, 6 insertions, 4 deletions
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);
}