Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ass_set_cache_limits() to work with composite cache #249

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions libass/ass_render.h
Expand Up @@ -42,8 +42,10 @@
#include "ass_rasterizer.h"

#define GLYPH_CACHE_MAX 10000
#define BITMAP_CACHE_MAX_SIZE 128 * 1048576
#define COMPOSITE_CACHE_MAX_SIZE 64 * 1048576
#define MEGABYTE (1024 * 1024)
#define BITMAP_CACHE_MAX_SIZE (128 * MEGABYTE)
#define COMPOSITE_CACHE_RATIO 2
#define COMPOSITE_CACHE_MAX_SIZE (BITMAP_CACHE_MAX_SIZE / COMPOSITE_CACHE_RATIO)

#define PARSED_FADE (1<<0)
#define PARSED_A (1<<1)
Expand Down
14 changes: 12 additions & 2 deletions libass/ass_render_api.c
Expand Up @@ -180,8 +180,18 @@ void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
int bitmap_max)
{
render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
BITMAP_CACHE_MAX_SIZE;

size_t bitmap_cache, composite_cache;
if (bitmap_max) {
bitmap_cache = MEGABYTE * (size_t) bitmap_max;
composite_cache = bitmap_cache / (COMPOSITE_CACHE_RATIO + 1);
bitmap_cache -= composite_cache;
} else {
bitmap_cache = BITMAP_CACHE_MAX_SIZE;
composite_cache = COMPOSITE_CACHE_MAX_SIZE;
}
render_priv->cache.bitmap_max_size = bitmap_cache;
render_priv->cache.composite_max_size = composite_cache;
}

ASS_FontProvider *
Expand Down