summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2022-07-30 15:06:01 -0500
committerrcombs <rcombs@rcombs.me>2022-11-15 21:14:37 -0600
commit75d2d3705486691e777429d8caa5240d438a98b6 (patch)
treedcfe0dbe5ca38ac8ba52ac6873b47f6ef1b1db0d
parentb79678d8434c2d2fec71c7d41f24c2341572df3e (diff)
downloadlibass-75d2d3705486691e777429d8caa5240d438a98b6.tar.bz2
libass-75d2d3705486691e777429d8caa5240d438a98b6.tar.xz
ass_render: add text_info_init function
-rw-r--r--libass/ass_render.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index dc50b32..45f9b9e 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -48,6 +48,25 @@
#define BLUR_PRECISION (1.0 / 256) // blur error as fraction of full input range
+static bool text_info_init(TextInfo* text_info)
+{
+ text_info->max_bitmaps = MAX_BITMAPS_INITIAL;
+ text_info->max_glyphs = MAX_GLYPHS_INITIAL;
+ text_info->max_lines = MAX_LINES_INITIAL;
+ text_info->n_bitmaps = 0;
+ text_info->combined_bitmaps = calloc(MAX_BITMAPS_INITIAL, sizeof(CombinedBitmapInfo));
+ text_info->glyphs = calloc(MAX_GLYPHS_INITIAL, sizeof(GlyphInfo));
+ text_info->event_text = calloc(MAX_GLYPHS_INITIAL, sizeof(FriBidiChar));
+ text_info->breaks = malloc(MAX_GLYPHS_INITIAL);
+ text_info->lines = calloc(MAX_LINES_INITIAL, sizeof(LineInfo));
+
+ if (!text_info->combined_bitmaps || !text_info->glyphs || !text_info->lines ||
+ !text_info->breaks || !text_info->event_text)
+ return false;
+
+ return true;
+}
+
ASS_Renderer *ass_renderer_init(ASS_Library *library)
{
int error;
@@ -106,17 +125,7 @@ ASS_Renderer *ass_renderer_init(ASS_Library *library)
priv->cache.bitmap_max_size = BITMAP_CACHE_MAX_SIZE;
priv->cache.composite_max_size = COMPOSITE_CACHE_MAX_SIZE;
- priv->text_info.max_bitmaps = MAX_BITMAPS_INITIAL;
- priv->text_info.max_glyphs = MAX_GLYPHS_INITIAL;
- priv->text_info.max_lines = MAX_LINES_INITIAL;
- priv->text_info.n_bitmaps = 0;
- priv->text_info.combined_bitmaps = calloc(MAX_BITMAPS_INITIAL, sizeof(CombinedBitmapInfo));
- priv->text_info.glyphs = calloc(MAX_GLYPHS_INITIAL, sizeof(GlyphInfo));
- priv->text_info.event_text = calloc(MAX_GLYPHS_INITIAL, sizeof(FriBidiChar));
- priv->text_info.breaks = malloc(MAX_GLYPHS_INITIAL);
- priv->text_info.lines = calloc(MAX_LINES_INITIAL, sizeof(LineInfo));
- if (!priv->text_info.combined_bitmaps || !priv->text_info.glyphs ||
- !priv->text_info.lines || !priv->text_info.breaks)
+ if (!text_info_init(&priv->text_info))
goto fail;
priv->state.renderer = priv;