From 1884f6ef05673941c4db6bc89a8850c167905eff Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 21 Oct 2022 00:47:17 +0200 Subject: refactor: prefix all internal API with ass_ If static libass is linked into a binary defining functions of the same name there will be issues. To avoid this use an ass_ prefix for namespacing. Before this commit we already did this for most but not yet all internal API. read_file is renamed to ass_load_file as ass_read_file already exists as a public API function. All other functions are simply prefixed with ass_. Fixes: https://github.com/libass/libass/issues/222 Fixes: https://github.com/libass/libass/issues/654 --- libass/ass.c | 8 ++-- libass/ass_bitmap.c | 30 +++++++-------- libass/ass_bitmap.h | 14 +++---- libass/ass_blur.c | 2 +- libass/ass_cache.c | 4 +- libass/ass_drawing.c | 24 ++++++------ libass/ass_font.c | 16 ++++---- libass/ass_font.h | 2 +- libass/ass_fontselect.c | 4 +- libass/ass_library.h | 2 +- libass/ass_outline.c | 86 ++++++++++++++++++++--------------------- libass/ass_outline.h | 44 ++++++++++----------- libass/ass_parse.c | 30 +++++++-------- libass/ass_parse.h | 14 +++---- libass/ass_rasterizer.c | 14 +++---- libass/ass_rasterizer.h | 14 +++---- libass/ass_render.c | 100 ++++++++++++++++++++++++------------------------ libass/ass_render.h | 4 +- libass/ass_shaper.c | 2 +- libass/ass_shaper.h | 2 +- libass/ass_utils.c | 2 +- libass/ass_utils.h | 2 +- 22 files changed, 210 insertions(+), 210 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 08cbf16..99746ee 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -417,7 +417,7 @@ static int parse_ycbcr_matrix(char *str) #define STYLEVAL(name) \ } else if (ass_strcasecmp(tname, #name) == 0) { \ - target->name = lookup_style(track, token); + target->name = ass_lookup_style(track, token); // skip spaces in str beforehand, or trim leading spaces afterwards static inline void advance_token_pos(const char **const str, @@ -1420,7 +1420,7 @@ out: * \param bufsize out: file size * \return pointer to file contents. Caller is responsible for its deallocation. */ -char *read_file(ASS_Library *library, const char *fname, FileNameSource hint, size_t *bufsize) +char *ass_load_file(ASS_Library *library, const char *fname, FileNameSource hint, size_t *bufsize) { int res; long sz; @@ -1552,7 +1552,7 @@ static char *read_file_recode(ASS_Library *library, char *fname, char *buf; size_t bufsize; - buf = read_file(library, fname, FN_EXTERNAL, &bufsize); + buf = ass_load_file(library, fname, FN_EXTERNAL, &bufsize); if (!buf) return 0; #ifdef CONFIG_ICONV @@ -1608,7 +1608,7 @@ int ass_read_styles(ASS_Track *track, char *fname, char *codepage) ParserState old_state; size_t sz; - buf = read_file(track->library, fname, FN_EXTERNAL, &sz); + buf = ass_load_file(track->library, fname, FN_EXTERNAL, &sz); if (!buf) return 1; #ifdef CONFIG_ICONV diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index 805f549..1b858cc 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -122,8 +122,8 @@ void ass_synth_blur(const BitmapEngine *engine, Bitmap *bm, ass_aligned_free(tmp); } -bool alloc_bitmap(const BitmapEngine *engine, Bitmap *bm, - int32_t w, int32_t h, bool zero) +bool ass_alloc_bitmap(const BitmapEngine *engine, Bitmap *bm, + int32_t w, int32_t h, bool zero) { unsigned align = 1 << engine->align_order; size_t s = ass_align(align, w); @@ -140,10 +140,10 @@ bool alloc_bitmap(const BitmapEngine *engine, Bitmap *bm, return true; } -bool realloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int32_t w, int32_t h) +bool ass_realloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int32_t w, int32_t h) { uint8_t *old = bm->buffer; - if (!alloc_bitmap(engine, bm, w, h, false)) + if (!ass_alloc_bitmap(engine, bm, w, h, false)) return false; ass_aligned_free(old); return true; @@ -154,13 +154,13 @@ void ass_free_bitmap(Bitmap *bm) ass_aligned_free(bm->buffer); } -bool copy_bitmap(const BitmapEngine *engine, Bitmap *dst, const Bitmap *src) +bool ass_copy_bitmap(const BitmapEngine *engine, Bitmap *dst, const Bitmap *src) { if (!src->buffer) { memset(dst, 0, sizeof(*dst)); return true; } - if (!alloc_bitmap(engine, dst, src->w, src->h, false)) + if (!ass_alloc_bitmap(engine, dst, src->w, src->h, false)) return false; dst->left = src->left; dst->top = src->top; @@ -168,15 +168,15 @@ bool copy_bitmap(const BitmapEngine *engine, Bitmap *dst, const Bitmap *src) return true; } -bool outline_to_bitmap(ASS_Renderer *render_priv, Bitmap *bm, - ASS_Outline *outline1, ASS_Outline *outline2) +bool ass_outline_to_bitmap(ASS_Renderer *render_priv, Bitmap *bm, + ASS_Outline *outline1, ASS_Outline *outline2) { RasterizerData *rst = &render_priv->rasterizer; - if (outline1 && !rasterizer_set_outline(rst, outline1, false)) { + if (outline1 && !ass_rasterizer_set_outline(rst, outline1, false)) { ass_msg(render_priv->library, MSGL_WARN, "Failed to process glyph outline!\n"); return false; } - if (outline2 && !rasterizer_set_outline(rst, outline2, !!outline1)) { + if (outline2 && !ass_rasterizer_set_outline(rst, outline2, !!outline1)) { ass_msg(render_priv->library, MSGL_WARN, "Failed to process glyph outline!\n"); return false; } @@ -202,13 +202,13 @@ bool outline_to_bitmap(ASS_Renderer *render_priv, Bitmap *bm, int32_t tile_w = (w + mask) & ~mask; int32_t tile_h = (h + mask) & ~mask; - if (!alloc_bitmap(render_priv->engine, bm, tile_w, tile_h, false)) + if (!ass_alloc_bitmap(render_priv->engine, bm, tile_w, tile_h, false)) return false; bm->left = x_min; bm->top = y_min; - if (!rasterizer_fill(render_priv->engine, rst, bm->buffer, - x_min, y_min, bm->stride, tile_h, bm->stride)) { + if (!ass_rasterizer_fill(render_priv->engine, rst, bm->buffer, + x_min, y_min, bm->stride, tile_h, bm->stride)) { ass_msg(render_priv->library, MSGL_WARN, "Failed to rasterize glyph!\n"); ass_free_bitmap(bm); return false; @@ -223,7 +223,7 @@ bool outline_to_bitmap(ASS_Renderer *render_priv, Bitmap *bm, * The glyph bitmap is subtracted from outline bitmap. This way looks much * better in some cases. */ -void fix_outline(Bitmap *bm_g, Bitmap *bm_o) +void ass_fix_outline(Bitmap *bm_g, Bitmap *bm_o) { if (!bm_g->buffer || !bm_o->buffer) return; @@ -248,7 +248,7 @@ void fix_outline(Bitmap *bm_g, Bitmap *bm_o) * \brief Shift a bitmap by the fraction of a pixel in x and y direction * expressed in 26.6 fixed point */ -void shift_bitmap(Bitmap *bm, int shift_x, int shift_y) +void ass_shift_bitmap(Bitmap *bm, int shift_x, int shift_y) { assert((shift_x & ~63) == 0 && (shift_y & ~63) == 0); diff --git a/libass/ass_bitmap.h b/libass/ass_bitmap.h index 3909b59..e21d100 100644 --- a/libass/ass_bitmap.h +++ b/libass/ass_bitmap.h @@ -97,19 +97,19 @@ typedef struct { uint8_t *buffer; // h * stride buffer } Bitmap; -bool alloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int32_t w, int32_t h, bool zero); -bool realloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int32_t w, int32_t h); -bool copy_bitmap(const BitmapEngine *engine, Bitmap *dst, const Bitmap *src); +bool ass_alloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int32_t w, int32_t h, bool zero); +bool ass_realloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int32_t w, int32_t h); +bool ass_copy_bitmap(const BitmapEngine *engine, Bitmap *dst, const Bitmap *src); void ass_free_bitmap(Bitmap *bm); -bool outline_to_bitmap(ASS_Renderer *render_priv, Bitmap *bm, - ASS_Outline *outline1, ASS_Outline *outline2); +bool ass_outline_to_bitmap(ASS_Renderer *render_priv, Bitmap *bm, + ASS_Outline *outline1, ASS_Outline *outline2); void ass_synth_blur(const BitmapEngine *engine, Bitmap *bm, int be, double blur_r2); bool ass_gaussian_blur(const BitmapEngine *engine, Bitmap *bm, double r2); -void shift_bitmap(Bitmap *bm, int shift_x, int shift_y); -void fix_outline(Bitmap *bm_g, Bitmap *bm_o); +void ass_shift_bitmap(Bitmap *bm, int shift_x, int shift_y); +void ass_fix_outline(Bitmap *bm_g, Bitmap *bm_o); #endif /* LIBASS_BITMAP_H */ diff --git a/libass/ass_blur.c b/libass/ass_blur.c index 5302832..efea0df 100644 --- a/libass/ass_blur.c +++ b/libass/ass_blur.c @@ -583,7 +583,7 @@ bool ass_gaussian_blur(const BitmapEngine *engine, Bitmap *bm, double r2) } assert(w == end_w && h == end_h); - if (!realloc_bitmap(engine, bm, w, h)) { + if (!ass_realloc_bitmap(engine, bm, w, h)) { ass_aligned_free(tmp); return false; } diff --git a/libass/ass_cache.c b/libass/ass_cache.c index 2306008..a5c8575 100644 --- a/libass/ass_cache.c +++ b/libass/ass_cache.c @@ -234,8 +234,8 @@ static void outline_destruct(void *key, void *value) { OutlineHashValue *v = value; OutlineHashKey *k = key; - outline_free(&v->outline[0]); - outline_free(&v->outline[1]); + ass_outline_free(&v->outline[0]); + ass_outline_free(&v->outline[1]); switch (k->type) { case OUTLINE_GLYPH: ass_cache_dec_ref(k->u.glyph.font); diff --git a/libass/ass_drawing.c b/libass/ass_drawing.c index 8f90519..4e6e932 100644 --- a/libass/ass_drawing.c +++ b/libass/ass_drawing.c @@ -165,10 +165,10 @@ static bool drawing_add_curve(ASS_Outline *outline, ASS_Rect *cbox, } return (started || - outline_add_point(outline, p[0], 0)) && - outline_add_point(outline, p[1], 0) && - outline_add_point(outline, p[2], 0) && - outline_add_point(outline, p[3], OUTLINE_CUBIC_SPLINE); + ass_outline_add_point(outline, p[0], 0)) && + ass_outline_add_point(outline, p[1], 0) && + ass_outline_add_point(outline, p[2], 0) && + ass_outline_add_point(outline, p[3], OUTLINE_CUBIC_SPLINE); } /* @@ -177,7 +177,7 @@ static bool drawing_add_curve(ASS_Outline *outline, ASS_Rect *cbox, bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox, const char *text, ASS_Library *lib) { - if (!outline_alloc(outline, DRAWING_INITIAL_POINTS, DRAWING_INITIAL_SEGMENTS)) + if (!ass_outline_alloc(outline, DRAWING_INITIAL_POINTS, DRAWING_INITIAL_SEGMENTS)) return false; rectangle_reset(cbox); @@ -198,9 +198,9 @@ bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox, pen = token->point; rectangle_update(cbox, pen.x, pen.y, pen.x, pen.y); if (started) { - if (!outline_add_segment(outline, OUTLINE_LINE_SEGMENT)) + if (!ass_outline_add_segment(outline, OUTLINE_LINE_SEGMENT)) goto error; - outline_close_contour(outline); + ass_outline_close_contour(outline); started = false; } token = token->next; @@ -208,9 +208,9 @@ bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox, case TOKEN_LINE: { ASS_Vector to = token->point; rectangle_update(cbox, to.x, to.y, to.x, to.y); - if (!started && !outline_add_point(outline, pen, 0)) + if (!started && !ass_outline_add_point(outline, pen, 0)) goto error; - if (!outline_add_point(outline, to, OUTLINE_LINE_SEGMENT)) + if (!ass_outline_add_point(outline, to, OUTLINE_LINE_SEGMENT)) goto error; started = true; token = token->next; @@ -246,9 +246,9 @@ bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox, // Close the last contour if (started) { - if (!outline_add_segment(outline, OUTLINE_LINE_SEGMENT)) + if (!ass_outline_add_segment(outline, OUTLINE_LINE_SEGMENT)) goto error; - outline_close_contour(outline); + ass_outline_close_contour(outline); } if (lib) @@ -261,6 +261,6 @@ bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox, error: drawing_free_tokens(tokens); - outline_free(outline); + ass_outline_free(outline); return false; } diff --git a/libass/ass_font.c b/libass/ass_font.c index 1496924..4c13aa3 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -191,7 +191,7 @@ static uint32_t convert_unicode_to_mb(FT_Encoding encoding, uint32_t codepoint) * Select a good charmap, prefer Microsoft Unicode charmaps. * Otherwise, let FreeType decide. */ -void charmap_magic(ASS_Library *library, FT_Face face) +void ass_charmap_magic(ASS_Library *library, FT_Face face) { int i; int ms_cmap = -1; @@ -436,7 +436,7 @@ static int add_face(ASS_FontSelector *fontsel, ASS_Font *font, uint32_t ch) if (!face) return -1; - charmap_magic(font->library, face); + ass_charmap_magic(font->library, face); set_font_metrics(face); font->faces[font->n_faces] = face; @@ -722,16 +722,16 @@ bool ass_get_glyph_outline(ASS_Outline *outline, int32_t *advance, assert(face->glyph->format == FT_GLYPH_FORMAT_OUTLINE); FT_Outline *source = &face->glyph->outline; if (!source->n_points && !n_lines) { - outline_clear(outline); + ass_outline_clear(outline); return true; } size_t max_points = 2 * source->n_points + 4 * n_lines; size_t max_segments = source->n_points + 4 * n_lines; - if (!outline_alloc(outline, max_points, max_segments)) + if (!ass_outline_alloc(outline, max_points, max_segments)) return false; - if (!outline_convert(outline, source)) + if (!ass_outline_convert(outline, source)) goto fail; if (flags & DECO_ROTATE) { @@ -746,7 +746,7 @@ bool ass_get_glyph_outline(ASS_Outline *outline, int32_t *advance, if (llabs(dv) > 2 * OUTLINE_MAX) goto fail; ASS_Vector offs = { dv, -desc }; - if (!outline_rotate_90(outline, offs)) + if (!ass_outline_rotate_90(outline, offs)) goto fail; } @@ -755,10 +755,10 @@ bool ass_get_glyph_outline(ASS_Outline *outline, int32_t *advance, FT_Orientation dir = FT_Outline_Get_Orientation(source); int iy = (dir == FT_ORIENTATION_TRUETYPE ? 0 : 1); for (int i = 0; i < n_lines; i++) - outline_add_rect(outline, 0, line_y[i][iy], adv, line_y[i][iy ^ 1]); + ass_outline_add_rect(outline, 0, line_y[i][iy], adv, line_y[i][iy ^ 1]); return true; fail: - outline_free(outline); + ass_outline_free(outline); return false; } diff --git a/libass/ass_font.h b/libass/ass_font.h index 02d4508..2959cbc 100644 --- a/libass/ass_font.h +++ b/libass/ass_font.h @@ -49,7 +49,7 @@ struct ass_font { double size; }; -void charmap_magic(ASS_Library *library, FT_Face face); +void ass_charmap_magic(ASS_Library *library, FT_Face face); ASS_Font *ass_font_new(ASS_Renderer *render_priv, ASS_FontDesc *desc); void ass_face_set_size(FT_Face face, double size); void ass_font_set_size(ASS_Font *font, double size); diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c index c229189..4a7dc5e 100644 --- a/libass/ass_fontselect.c +++ b/libass/ass_fontselect.c @@ -182,7 +182,7 @@ static void load_fonts_from_dir(ASS_Library *library, const char *dir) continue; ass_msg(library, MSGL_INFO, "Loading font file '%s'", path); size_t size = 0; - void *data = read_file(library, path, FN_DIR_LIST, &size); + void *data = ass_load_file(library, path, FN_DIR_LIST, &size); if (data) { ass_add_font(library, name, data, size); free(data); @@ -984,7 +984,7 @@ static void process_fontdata(ASS_FontProvider *priv, int idx) num_faces = face->num_faces; - charmap_magic(library, face); + ass_charmap_magic(library, face); memset(&info, 0, sizeof(ASS_FontProviderMetaData)); if (!get_font_info(selector->ftlibrary, face, NULL, &info)) { diff --git a/libass/ass_library.h b/libass/ass_library.h index e30609f..0a97960 100644 --- a/libass/ass_library.h +++ b/libass/ass_library.h @@ -40,6 +40,6 @@ struct ass_library { void *msg_callback_data; }; -char *read_file(struct ass_library *library, const char *fname, FileNameSource hint, size_t *bufsize); +char *ass_load_file(struct ass_library *library, const char *fname, FileNameSource hint, size_t *bufsize); #endif /* LIBASS_LIBRARY_H */ diff --git a/libass/ass_outline.c b/libass/ass_outline.c index 2bdc31a..7434283 100644 --- a/libass/ass_outline.c +++ b/libass/ass_outline.c @@ -28,7 +28,7 @@ * \brief Initialize ASS_Outline to an empty state * Equivalent to zeroing of outline object and doesn't free any memory. */ -void outline_clear(ASS_Outline *outline) +void ass_outline_clear(ASS_Outline *outline) { outline->points = NULL; outline->segments = NULL; @@ -40,17 +40,17 @@ void outline_clear(ASS_Outline *outline) /* * \brief Initialize ASS_Outline and allocate memory */ -bool outline_alloc(ASS_Outline *outline, size_t max_points, size_t max_segments) +bool ass_outline_alloc(ASS_Outline *outline, size_t max_points, size_t max_segments) { assert(max_points && max_segments); if (max_points > SIZE_MAX / sizeof(ASS_Vector)) { - outline_clear(outline); + ass_outline_clear(outline); return false; } outline->points = malloc(sizeof(ASS_Vector) * max_points); outline->segments = malloc(max_segments); if (!outline->points || !outline->segments) { - outline_free(outline); + ass_outline_free(outline); return false; } @@ -62,10 +62,10 @@ bool outline_alloc(ASS_Outline *outline, size_t max_points, size_t max_segments) /* * \brief Free previously initialized ASS_Outline - * Outline state after the call is the same as after outline_clear(). + * Outline state after the call is the same as after ass_outline_clear(). * Outline pointer can be NULL. */ -void outline_free(ASS_Outline *outline) +void ass_outline_free(ASS_Outline *outline) { if (!outline) return; @@ -73,7 +73,7 @@ void outline_free(ASS_Outline *outline) free(outline->points); free(outline->segments); - outline_clear(outline); + ass_outline_clear(outline); } @@ -86,7 +86,7 @@ static bool valid_point(const FT_Vector *pt) * \brief Convert FT_Ouline into ASS_Outline * Outline should be preallocated to a sufficient size. */ -bool outline_convert(ASS_Outline *outline, const FT_Outline *source) +bool ass_outline_convert(ASS_Outline *outline, const FT_Outline *source) { enum Status { S_ON, S_Q, S_C1, S_C2 @@ -245,8 +245,8 @@ bool outline_convert(ASS_Outline *outline, const FT_Outline *source) * Outline should be preallocated to a sufficient size * and coordinates should be in the allowable range. */ -void outline_add_rect(ASS_Outline *outline, - int32_t x0, int32_t y0, int32_t x1, int32_t y1) +void ass_outline_add_rect(ASS_Outline *outline, + int32_t x0, int32_t y0, int32_t x1, int32_t y1) { assert(outline->n_points + 4 <= outline->max_points); assert(outline->n_segments + 4 <= outline->max_segments); @@ -276,7 +276,7 @@ void outline_add_rect(ASS_Outline *outline, * Outline should be allocated and will be enlarged if needed. * Also adds outline segment if segment parameter is nonzero. */ -bool outline_add_point(ASS_Outline *outline, ASS_Vector pt, char segment) +bool ass_outline_add_point(ASS_Outline *outline, ASS_Vector pt, char segment) { assert(outline->max_points); if (abs(pt.x) > OUTLINE_MAX || abs(pt.y) > OUTLINE_MAX) @@ -291,14 +291,14 @@ bool outline_add_point(ASS_Outline *outline, ASS_Vector pt, char segment) outline->points[outline->n_points] = pt; outline->n_points++; - return !segment || outline_add_segment(outline, segment); + return !segment || ass_outline_add_segment(outline, segment); } /* * \brief Add a segment to the outline * Outline should be allocated and will be enlarged if needed. */ -bool outline_add_segment(ASS_Outline *outline, char segment) +bool ass_outline_add_segment(ASS_Outline *outline, char segment) { assert(outline->max_segments); if (outline->n_segments >= outline->max_segments) { @@ -315,7 +315,7 @@ bool outline_add_segment(ASS_Outline *outline, char segment) /* * \brief Close last contour */ -void outline_close_contour(ASS_Outline *outline) +void ass_outline_close_contour(ASS_Outline *outline) { assert(outline->n_segments); assert(!(outline->segments[outline->n_segments - 1] & ~OUTLINE_COUNT_MASK)); @@ -326,7 +326,7 @@ void outline_close_contour(ASS_Outline *outline) /* * \brief Inplace rotate outline by 90 degrees and translate by offs */ -bool outline_rotate_90(ASS_Outline *outline, ASS_Vector offs) +bool ass_outline_rotate_90(ASS_Outline *outline, ASS_Vector offs) { assert(abs(offs.x) <= INT32_MAX - OUTLINE_MAX); assert(abs(offs.y) <= INT32_MAX - OUTLINE_MAX); @@ -345,11 +345,11 @@ bool outline_rotate_90(ASS_Outline *outline, ASS_Vector offs) * Result outline should be uninitialized or empty. * Source outline can be NULL. */ -bool outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, - int scale_ord_x, int scale_ord_y) +bool ass_outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, + int scale_ord_x, int scale_ord_y) { if (!source || !source->n_points) { - outline_clear(outline); + ass_outline_clear(outline); return true; } @@ -366,11 +366,11 @@ bool outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, scale_ord_y = FFMAX(scale_ord_y, -32); if (!lim_x || !lim_y) { - outline_clear(outline); + ass_outline_clear(outline); return false; } - if (!outline_alloc(outline, source->n_points, source->n_segments)) + if (!ass_outline_alloc(outline, source->n_points, source->n_segments)) return false; int sx = scale_ord_x + 32; @@ -378,7 +378,7 @@ bool outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, const ASS_Vector *pt = source->points; for (size_t i = 0; i < source->n_points; i++) { if (abs(pt[i].x) > lim_x || abs(pt[i].y) > lim_y) { - outline_free(outline); + ass_outline_free(outline); return false; } // that's equivalent to pt[i].x << scale_ord_x, @@ -397,15 +397,15 @@ bool outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, * Result outline should be uninitialized or empty. * Source outline can be NULL. */ -bool outline_transform_2d(ASS_Outline *outline, const ASS_Outline *source, - const double m[2][3]) +bool ass_outline_transform_2d(ASS_Outline *outline, const ASS_Outline *source, + const double m[2][3]) { if (!source || !source->n_points) { - outline_clear(outline); + ass_outline_clear(outline); return true; } - if (!outline_alloc(outline, source->n_points, source->n_segments)) + if (!ass_outline_alloc(outline, source->n_points, source->n_segments)) return false; const ASS_Vector *pt = source->points; @@ -415,7 +415,7 @@ bool outline_transform_2d(ASS_Outline *outline, const ASS_Outline *source, v[k] = m[k][0] * pt[i].x + m[k][1] * pt[i].y + m[k][2]; if (!(fabs(v[0]) < OUTLINE_MAX && fabs(v[1]) < OUTLINE_MAX)) { - outline_free(outline); + ass_outline_free(outline); return false; } outline->points[i].x = lrint(v[0]); @@ -432,15 +432,15 @@ bool outline_transform_2d(ASS_Outline *outline, const ASS_Outline *source, * Result outline should be uninitialized or empty. * Source outline can be NULL. */ -bool outline_transform_3d(ASS_Outline *outline, const ASS_Outline *source, - const double m[3][3]) +bool ass_outline_transform_3d(ASS_Outline *outline, const ASS_Outline *source, + const double m[3][3]) { if (!source || !source->n_points) { - outline_clear(outline); + ass_outline_clear(outline); return true; } - if (!outline_alloc(outline, source->n_points, source->n_segments)) + if (!ass_outline_alloc(outline, source->n_points, source->n_segments)) return false; const ASS_Vector *pt = source->points; @@ -454,7 +454,7 @@ bool outline_transform_3d(ASS_Outline *outline, const ASS_Outline *source, v[1] *= w; if (!(fabs(v[0]) < OUTLINE_MAX && fabs(v[1]) < OUTLINE_MAX)) { - outline_free(outline); + ass_outline_free(outline); return false; } outline->points[i].x = lrint(v[0]); @@ -469,9 +469,9 @@ bool outline_transform_3d(ASS_Outline *outline, const ASS_Outline *source, /* * \brief Find minimal X-coordinate of control points after perspective transform */ -void outline_update_min_transformed_x(const ASS_Outline *outline, - const double m[3][3], - int32_t *min_x) { +void ass_outline_update_min_transformed_x(const ASS_Outline *outline, + const double m[3][3], + int32_t *min_x) { const ASS_Vector *pt = outline->points; for (size_t i = 0; i < outline->n_points; i++) { double z = m[2][0] * pt[i].x + m[2][1] * pt[i].y + m[2][2]; @@ -486,7 +486,7 @@ void outline_update_min_transformed_x(const ASS_Outline *outline, /* * \brief Update bounding box of control points */ -void outline_update_cbox(const ASS_Outline *outline, ASS_Rect *cbox) +void ass_outline_update_cbox(const ASS_Outline *outline, ASS_Rect *cbox) { for (size_t i = 0; i < outline->n_points; i++) rectangle_update(cbox, @@ -622,12 +622,12 @@ static bool emit_point(StrokerState *str, ASS_Vector pt, if (dir & 1) { ASS_Vector res = { pt.x + dx, pt.y + dy }; - if (!outline_add_point(str->result[0], res, segment)) + if (!ass_outline_add_point(str->result[0], res, segment)) return false; } if (dir & 2) { ASS_Vector res = { pt.x - dx, pt.y - dy }; - if (!outline_add_point(str->result[1], res, segment)) + if (!ass_outline_add_point(str->result[1], res, segment)) return false; } return true; @@ -1466,9 +1466,9 @@ static bool close_contour(StrokerState *str, int dir) str->contour_start = true; } if (dir & 1) - outline_close_contour(str->result[0]); + ass_outline_close_contour(str->result[0]); if (dir & 2) - outline_close_contour(str->result[1]); + ass_outline_close_contour(str->result[1]); str->contour_first[0] = str->result[0]->n_points; str->contour_first[1] = str->result[1]->n_points; return true; @@ -1485,11 +1485,11 @@ static bool close_contour(StrokerState *str, int dir) * \param eps approximate allowable error * \return false on allocation failure */ -bool outline_stroke(ASS_Outline *result, ASS_Outline *result1, - const ASS_Outline *path, int xbord, int ybord, int eps) +bool ass_outline_stroke(ASS_Outline *result, ASS_Outline *result1, + const ASS_Outline *path, int xbord, int ybord, int eps) { - outline_alloc(result, 2 * path->n_points, 2 * path->n_segments); - outline_alloc(result1, 2 * path->n_points, 2 * path->n_segments); + ass_outline_alloc(result, 2 * path->n_points, 2 * path->n_segments); + ass_outline_alloc(result1, 2 * path->n_points, 2 * path->n_segments); if (!result->max_points || !result1->max_points) return false; diff --git a/libass/ass_outline.h b/libass/ass_outline.h index a7fe580..25848b5 100644 --- a/libass/ass_outline.h +++ b/libass/ass_outline.h @@ -87,40 +87,40 @@ typedef struct { #define OUTLINE_MAX (((int32_t) 1 << 28) - 1) // cubic spline splitting requires 8 * OUTLINE_MAX + 4 <= INT32_MAX -void outline_clear(ASS_Outline *outline); -bool outline_alloc(ASS_Outline *outline, size_t n_points, size_t n_segments); -void outline_free(ASS_Outline *outline); +void ass_outline_clear(ASS_Outline *outline); +bool ass_outline_alloc(ASS_Outline *outline, size_t n_points, size_t n_segments); +void ass_outline_free(ASS_Outline *outline); // expects preallocated outline and works inplace -bool outline_convert(ASS_Outline *outline, const FT_Outline *source); -void outline_add_rect(ASS_Outline *outline, - int32_t x0, int32_t y0, int32_t x1, int32_t y1); +bool ass_outline_convert(ASS_Outline *outline, const FT_Outline *source); +void ass_outline_add_rect(ASS_Outline *outline, + int32_t x0, int32_t y0, int32_t x1, int32_t y1); // enlarges outline automatically -bool outline_add_point(ASS_Outline *outline, ASS_Vector pt, char segment); -bool outline_add_segment(ASS_Outline *outline, char segment); -void outline_close_contour(ASS_Outline *outline); +bool ass_outline_add_point(ASS_Outline *outline, ASS_Vector pt, char segment); +bool ass_outline_add_segment(ASS_Outline *outline, char segment); +void ass_outline_close_contour(ASS_Outline *outline); // works inplace -bool outline_rotate_90(ASS_Outline *outline, ASS_Vector offs); +bool ass_outline_rotate_90(ASS_Outline *outline, ASS_Vector offs); // creates a new outline for the result -bool outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, - int scale_ord_x, int scale_ord_y); -bool outline_transform_2d(ASS_Outline *outline, const ASS_Outline *source, - const double m[2][3]); -bool outline_transform_3d(ASS_Outline *outline, const ASS_Outline *source, - const double m[3][3]); +bool ass_outline_scale_pow2(ASS_Outline *outline, const ASS_Outline *source, + int scale_ord_x, int scale_ord_y); +bool ass_outline_transform_2d(ASS_Outline *outline, const ASS_Outline *source, + const double m[2][3]); +bool ass_outline_transform_3d(ASS_Outline *outline, const ASS_Outline *source, + const double m[3][3]); // info queries -void outline_update_min_transformed_x(const ASS_Outline *outline, - const double m[3][3], - int32_t *min_x); -void outline_update_cbox(const ASS_Outline *outline, ASS_Rect *cbox); +void ass_outline_update_min_transformed_x(const ASS_Outline *outline, + const double m[3][3], + int32_t *min_x); +void ass_outline_update_cbox(const ASS_Outline *outline, ASS_Rect *cbox); // creates new outlines for the results (positive and negative offset outlines) -bool outline_stroke(ASS_Outline *result, ASS_Outline *result1, - const ASS_Outline *path, int xbord, int ybord, int eps); +bool ass_outline_stroke(ASS_Outline *result, ASS_Outline *result1, + const ASS_Outline *path, int xbord, int ybord, int eps); #endif /* LIBASS_OUTLINE_H */ diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 242fa4c..78f2fcd 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -80,7 +80,7 @@ static inline int mystrcmp(char **p, const char *sample) /** * \brief Change current font, using setting from render_priv->state. */ -void update_font(ASS_Renderer *render_priv) +void ass_update_font(ASS_Renderer *render_priv) { unsigned val; ASS_FontDesc desc; @@ -280,8 +280,8 @@ static ASS_Style *lookup_style_strict(ASS_Track *track, char *name, size_t len) * of a number of spaces immediately preceding '}' or ')' * \param pwr multiplier for some tag effects (comes from \t tags) */ -char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, - bool nested) +char *ass_parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, + bool nested) { for (char *q; p < end; p = q) { while (*p != '\\' && p != end) @@ -560,7 +560,7 @@ char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, render_priv->state.family.str = render_priv->state.style->FontName; render_priv->state.family.len = strlen(render_priv->state.style->FontName); } - update_font(render_priv); + ass_update_font(render_priv); } else if (tag("alpha")) { int i; if (nargs) { @@ -712,7 +712,7 @@ char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, p = args[cnt].start; if (args[cnt].end < end) { assert(!nested); - p = parse_tags(render_priv, p, args[cnt].end, k, true); + p = ass_parse_tags(render_priv, p, args[cnt].end, k, true); } else { assert(q == end); // No other tags can possibly follow this \t tag, @@ -802,10 +802,10 @@ char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, } else if (tag("r")) { if (nargs) { int len = args->end - args->start; - reset_render_context(render_priv, + ass_reset_render_context(render_priv, lookup_style_strict(render_priv->track, args->start, len)); } else - reset_render_context(render_priv, NULL); + ass_reset_render_context(render_priv, NULL); } else if (tag("be")) { double dval; if (nargs) { @@ -824,13 +824,13 @@ char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, if (!nargs || !(val == 0 || val == 1 || val >= 100)) val = render_priv->state.style->Bold; render_priv->state.bold = val; - update_font(render_priv); + ass_update_font(render_priv); } else if (tag("i")) { int32_t val = argtoi32(*args); if (!nargs || !(val == 0 || val == 1)) val = render_priv->state.style->Italic; render_priv->state.italic = val; - update_font(render_priv); + ass_update_font(render_priv); } else if (tag("kt")) { // v4++ double val = 0; @@ -917,7 +917,7 @@ char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, return p; } -void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event) +void ass_apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event) { int v[4]; int cnt; @@ -1008,7 +1008,7 @@ void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event) /** * \brief determine karaoke effects - * Karaoke effects cannot be calculated during parse stage (get_next_char()), + * Karaoke effects cannot be calculated during parse stage (ass_get_next_char()), * so they are done in a separate step. * Parse stage: when karaoke style override is found, its parameters are stored in the next glyph's * (the first glyph of the karaoke word)'s effect_type and effect_timing. @@ -1017,7 +1017,7 @@ void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event) * 2. sets effect_timing for all glyphs to x coordinate of the border line between the left and right karaoke parts * (left part is filled with PrimaryColour, right one - with SecondaryColour). */ -void process_karaoke_effects(ASS_Renderer *render_priv) +void ass_process_karaoke_effects(ASS_Renderer *render_priv) { long long tm_current = render_priv->time - render_priv->state.event->Start; @@ -1107,7 +1107,7 @@ void process_karaoke_effects(ASS_Renderer *render_priv) * \return ucs4 code of the next char * On return str points to the unparsed part of the string */ -unsigned get_next_char(ASS_Renderer *render_priv, char **str) +unsigned ass_get_next_char(ASS_Renderer *render_priv, char **str) { char *p = *str; unsigned chr; @@ -1147,10 +1147,10 @@ unsigned get_next_char(ASS_Renderer *render_priv, char **str) // Return 1 if the event contains tags that will apply overrides the selective // style override code should not touch. Return 0 otherwise. -int event_has_hard_overrides(char *str) +int ass_event_has_hard_overrides(char *str) { // look for \pos and \move tags inside {...} - // mirrors get_next_char, but is faster and doesn't change any global state + // mirrors ass_get_next_char, but is faster and doesn't change any global state while (*str) { if (str[0] == '\\' && str[1] != '\0') { str += 2; diff --git a/libass/ass_parse.h b/libass/ass_parse.h index 6c96e41..c40546b 100644 --- a/libass/ass_parse.h +++ b/libass/ass_parse.h @@ -26,13 +26,13 @@ #define _b(c) (((c) >> 8) & 0xFF) #define _a(c) ((c) & 0xFF) -void update_font(ASS_Renderer *render_priv); -void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event); -void process_karaoke_effects(ASS_Renderer *render_priv); -unsigned get_next_char(ASS_Renderer *render_priv, char **str); -char *parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, - bool nested); -int event_has_hard_overrides(char *str); +void ass_update_font(ASS_Renderer *render_priv); +void ass_apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event); +void ass_process_karaoke_effects(ASS_Renderer *render_priv); +unsigned ass_get_next_char(ASS_Renderer *render_priv, char **str); +char *ass_parse_tags(ASS_Renderer *render_priv, char *p, char *end, double pwr, + bool nested); +int ass_event_has_hard_overrides(char *str); void ass_apply_fade(uint32_t *clr, int fade); diff --git a/libass/ass_rasterizer.c b/libass/ass_rasterizer.c index 36d7883..213cf45 100644 --- a/libass/ass_rasterizer.c +++ b/libass/ass_rasterizer.c @@ -51,7 +51,7 @@ static inline int ilog2(uint32_t n) } -bool rasterizer_init(const BitmapEngine *engine, RasterizerData *rst, int outline_error) +bool ass_rasterizer_init(const BitmapEngine *engine, RasterizerData *rst, int outline_error) { rst->outline_error = outline_error; rst->linebuf[0] = rst->linebuf[1] = NULL; @@ -89,7 +89,7 @@ static inline bool check_capacity(RasterizerData *rst, int index, size_t delta) return true; } -void rasterizer_done(RasterizerData *rst) +void ass_rasterizer_done(RasterizerData *rst) { free(rst->linebuf[0]); free(rst->linebuf[1]); @@ -262,8 +262,8 @@ static bool add_cubic(RasterizerData *rst, const ASS_Vector *pt) } -bool rasterizer_set_outline(RasterizerData *rst, - const ASS_Outline *path, bool extra) +bool ass_rasterizer_set_outline(RasterizerData *rst, + const ASS_Outline *path, bool extra) { if (!extra) { rectangle_reset(&rst->bbox); @@ -719,9 +719,9 @@ static bool rasterizer_fill_level(const BitmapEngine *engine, RasterizerData *rs return true; } -bool rasterizer_fill(const BitmapEngine *engine, RasterizerData *rst, - uint8_t *buf, int x0, int y0, - int width, int height, ptrdiff_t stride) +bool ass_rasterizer_fill(const BitmapEngine *engine, RasterizerData *rst, + uint8_t *buf, int x0, int y0, + int width, int height, ptrdiff_t stride) { assert(width > 0 && height > 0); assert(!(width & ((1 << engine->tile_order) - 1))); diff --git a/libass/ass_rasterizer.h b/libass/ass_rasterizer.h index 21c3420..b94d3e0 100644 --- a/libass/ass_rasterizer.h +++ b/libass/ass_rasterizer.h @@ -56,8 +56,8 @@ typedef struct { uint8_t *tile; } RasterizerData; -bool rasterizer_init(const BitmapEngine *engine, RasterizerData *rst, int outline_error); -void rasterizer_done(RasterizerData *rst); +bool ass_rasterizer_init(const BitmapEngine *engine, RasterizerData *rst, int outline_error); +void ass_rasterizer_done(RasterizerData *rst); /** * \brief Convert outline to polyline and calculate exact bounds @@ -65,8 +65,8 @@ void rasterizer_done(RasterizerData *rst); * \param extra in: true if path is second border outline * \return false on error */ -bool rasterizer_set_outline(RasterizerData *rst, - const ASS_Outline *path, bool extra); +bool ass_rasterizer_set_outline(RasterizerData *rst, + const ASS_Outline *path, bool extra); /** * \brief Polyline rasterization function @@ -76,9 +76,9 @@ bool rasterizer_set_outline(RasterizerData *rst, * \return false on error * Deletes preprocessed polyline after work. */ -bool rasterizer_fill(const BitmapEngine *engine, RasterizerData *rst, - uint8_t *buf, int x0, int y0, - int width, int height, ptrdiff_t stride); +bool ass_rasterizer_fill(const BitmapEngine *engine, RasterizerData *rst, + uint8_t *buf, int x0, int y0, + int width, int height, ptrdiff_t stride); #endif /* LIBASS_RASTERIZER_H */ diff --git a/libass/ass_render.c b/libass/ass_render.c index 6253ecc..0118003 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -91,7 +91,7 @@ ASS_Renderer *ass_renderer_init(ASS_Library *library) priv->engine = &ass_bitmap_engine_c; #endif - if (!rasterizer_init(priv->engine, &priv->rasterizer, RASTERIZER_PRECISION)) + if (!ass_rasterizer_init(priv->engine, &priv->rasterizer, RASTERIZER_PRECISION)) goto fail; priv->cache.font_cache = ass_font_cache_create(); @@ -152,7 +152,7 @@ void ass_renderer_done(ASS_Renderer *render_priv) ass_shaper_free(render_priv->shaper); ass_cache_done(render_priv->cache.font_cache); - rasterizer_done(&render_priv->rasterizer); + ass_rasterizer_done(&render_priv->rasterizer); if (render_priv->fontselect) ass_fontselect_free(render_priv->fontselect); @@ -1032,7 +1032,7 @@ static void init_font_scale(ASS_Renderer *render_priv) * \brief partially reset render_context to style values * Works like {\r}: resets some style overrides */ -void reset_render_context(ASS_Renderer *render_priv, ASS_Style *style) +void ass_reset_render_context(ASS_Renderer *render_priv, ASS_Style *style) { style = handle_selective_style_overrides(render_priv, style); @@ -1052,7 +1052,7 @@ void reset_render_context(ASS_Renderer *render_priv, ASS_Style *style) render_priv->state.treat_family_as_pattern = style->treat_fontname_as_pattern; render_priv->state.bold = style->Bold; render_priv->state.italic = style->Italic; - update_font(render_priv); + ass_update_font(render_priv); render_priv->state.border_style = style->BorderStyle; render_priv->state.border_x = style->Outline; @@ -1101,11 +1101,11 @@ init_render_context(ASS_Renderer *render_priv, ASS_Event *event) render_priv->state.effect_skip_timing = 0; render_priv->state.reset_effect = false; - apply_transition_effects(render_priv, event); + ass_apply_transition_effects(render_priv, event); render_priv->state.explicit = render_priv->state.evt_type != EVENT_NORMAL || - event_has_hard_overrides(event->Text); + ass_event_has_hard_overrides(event->Text); - reset_render_context(render_priv, NULL); + ass_reset_render_context(render_priv, NULL); render_priv->state.alignment = render_priv->state.style->Alignment; render_priv->state.justify = render_priv->state.style->Justify; } @@ -1239,26 +1239,26 @@ size_t ass_outline_construct(void *key, void *value, void *priv) break; ASS_Outline src; - if (!outline_scale_pow2(&src, &k->outline->outline[0], - k->scale_ord_x, k->scale_ord_y)) + if (!ass_outline_scale_pow2(&src, &k->outline->outline[0], + k->scale_ord_x, k->scale_ord_y)) return 1; - if (!outline_stroke(&v->outline[0], &v->outline[1], &src, - k->border.x * STROKER_PRECISION, - k->border.y * STROKER_PRECISION, - STROKER_PRECISION)) { + if (!ass_outline_stroke(&v->outline[0], &v->outline[1], &src, + k->border.x * STROKER_PRECISION, + k->border.y * STROKER_PRECISION, + STROKER_PRECISION)) { ass_msg(render_priv->library, MSGL_WARN, "Cannot stroke outline"); - outline_free(&v->outline[0]); - outline_free(&v->outline[1]); - outline_free(&src); + ass_outline_free(&v->outline[0]); + ass_outline_free(&v->outline[1]); + ass_outline_free(&src); return 1; } - outline_free(&src); + ass_outline_free(&src); break; } case OUTLINE_BOX: { ASS_Outline *ol = &v->outline[0]; - if (!outline_alloc(ol, 4, 4)) + if (!ass_outline_alloc(ol, 4, 4)) return 1; ol->points[0].x = ol->points[3].x = 0; ol->points[1].x = ol->points[2].x = 64; @@ -1276,8 +1276,8 @@ size_t ass_outline_construct(void *key, void *value, void *priv) } rectangle_reset(&v->cbox); - outline_update_cbox(&v->outline[0], &v->cbox); - outline_update_cbox(&v->outline[1], &v->cbox); + ass_outline_update_cbox(&v->outline[0], &v->cbox); + ass_outline_update_cbox(&v->outline[1], &v->cbox); if (v->cbox.x_min > v->cbox.x_max || v->cbox.y_min > v->cbox.y_max) v->cbox.x_min = v->cbox.y_min = v->cbox.x_max = v->cbox.y_max = 0; v->valid = true; @@ -1364,7 +1364,7 @@ get_bitmap_glyph(ASS_Renderer *render_priv, GlyphInfo *info, memcpy(m, m2, sizeof(m)); if (info->effect_type == EF_KARAOKE_KF) - outline_update_min_transformed_x(&info->outline->outline[0], m, leftmost_x); + ass_outline_update_min_transformed_x(&info->outline->outline[0], m, leftmost_x); BitmapHashKey key; key.outline = info->outline; @@ -1519,17 +1519,17 @@ size_t ass_bitmap_construct(void *key, void *value, void *priv) ASS_Outline outline[2]; if (k->matrix_z.x || k->matrix_z.y) { - outline_transform_3d(&outline[0], &k->outline->outline[0], m); - outline_transform_3d(&outline[1], &k->outline->outline[1], m); + ass_outline_transform_3d(&outline[0], &k->outline->outline[0], m); + ass_outline_transform_3d(&outline[1], &k->outline->outline[1], m); } else { - outline_transform_2d(&outline[0], &k->outline->outline[0], m); - outline_transform_2d(&outline[1], &k->outline->outline[1], m); + ass_outline_transform_2d(&outline[0], &k->outline->outline[0], m); + ass_outline_transform_2d(&outline[1], &k->outline->outline[1], m); } - if (!outline_to_bitmap(render_priv, bm, &outline[0], &outline[1])) + if (!ass_outline_to_bitmap(render_priv, bm, &outline[0], &outline[1])) memset(bm, 0, sizeof(*bm)); - outline_free(&outline[0]); - outline_free(&outline[1]); + ass_outline_free(&outline[0]); + ass_outline_free(&outline[1]); return sizeof(BitmapHashKey) + sizeof(Bitmap) + bitmap_size(bm); } @@ -2044,7 +2044,7 @@ static bool parse_events(ASS_Renderer *render_priv, ASS_Event *event) unsigned code = 0; while (*p) { if ((*p == '{') && (q = strchr(p, '}'))) { - p = parse_tags(render_priv, p, q, 1., false); + p = ass_parse_tags(render_priv, p, q, 1., false); assert(*p == '}'); p++; } else if (render_priv->state.drawing_scale) { @@ -2059,7 +2059,7 @@ static bool parse_events(ASS_Renderer *render_priv, ASS_Event *event) p = q; break; } else { - code = get_next_char(render_priv, &p); + code = ass_get_next_char(render_priv, &p); break; } } @@ -2613,7 +2613,7 @@ static inline void rectangle_combine(ASS_Rect *rect, const Bitmap *bm, ASS_Vecto * with extreme values are the theoretical limit of the worst case. * Make sure to use the right pixel value range in the simulation! */ -int be_padding(int be) +int ass_be_padding(int be) { if (be <= 3) return be; @@ -2650,15 +2650,15 @@ size_t ass_composite_construct(void *key, void *value, void *priv) } } - int bord = be_padding(k->filter.be); + int bord = ass_be_padding(k->filter.be); if (!bord && n_bm == 1) { - copy_bitmap(render_priv->engine, &v->bm, last->bm); + ass_copy_bitmap(render_priv->engine, &v->bm, last->bm); v->bm.left += last->pos.x; v->bm.top += last->pos.y; - } else if (n_bm && alloc_bitmap(render_priv->engine, &v->bm, - rect.x_max - rect.x_min + 2 * bord, - rect.y_max - rect.y_min + 2 * bord, - true)) { + } else if (n_bm && ass_alloc_bitmap(render_priv->engine, &v->bm, + rect.x_max - rect.x_min + 2 * bord, + rect.y_max - rect.y_min + 2 * bord, + true)) { Bitmap *dst = &v->bm; dst->left = rect.x_min - bord; dst->top = rect.y_min - bord; @@ -2677,13 +2677,13 @@ size_t ass_composite_construct(void *key, void *value, void *priv) } } if (!bord && n_bm_o == 1) { - copy_bitmap(render_priv->engine, &v->bm_o, last_o->bm_o); + ass_copy_bitmap(render_priv->engine, &v->bm_o, last_o->bm_o); v->bm_o.left += last_o->pos_o.x; v->bm_o.top += last_o->pos_o.y; - } else if (n_bm_o && alloc_bitmap(render_priv->engine, &v->bm_o, - rect_o.x_max - rect_o.x_min + 2 * bord, - rect_o.y_max - rect_o.y_min + 2 * bord, - true)) { + } else if (n_bm_o && ass_alloc_bitmap(render_priv->engine, &v->bm_o, + rect_o.x_max - rect_o.x_min + 2 * bord, + rect_o.y_max - rect_o.y_min + 2 * bord, + true)) { Bitmap *dst = &v->bm_o; dst->left = rect_o.x_min - bord; dst->top = rect_o.y_min - bord; @@ -2709,29 +2709,29 @@ size_t ass_composite_construct(void *key, void *value, void *priv) ass_synth_blur(render_priv->engine, &v->bm_o, k->filter.be, r2); if (!(flags & FILTER_FILL_IN_BORDER) && !(flags & FILTER_FILL_IN_SHADOW)) - fix_outline(&v->bm, &v->bm_o); + ass_fix_outline(&v->bm, &v->bm_o); if (flags & FILTER_NONZERO_SHADOW) { if (flags & FILTER_NONZERO_BORDER) { - copy_bitmap(render_priv->engine, &v->bm_s, &v->bm_o); + ass_copy_bitmap(render_priv->engine, &v->bm_s, &v->bm_o); if ((flags & FILTER_FILL_IN_BORDER) && !(flags & FILTER_FILL_IN_SHADOW)) - fix_outline(&v->bm, &v->bm_s); + ass_fix_outline(&v->bm, &v->bm_s); } else if (flags & FILTER_BORDER_STYLE_3) { v->bm_s = v->bm_o; memset(&v->bm_o, 0, sizeof(v->bm_o)); } else { - copy_bitmap(render_priv->engine, &v->bm_s, &v->bm); + ass_copy_bitmap(render_priv->engine, &v->bm_s, &v->bm); } // Works right even for negative offsets // '>>' rounds toward negative infinity, '&' returns correct remainder v->bm_s.left += k->filter.shadow.x >> 6; v->bm_s.top += k->filter.shadow.y >> 6; - shift_bitmap(&v->bm_s, k->filter.shadow.x & SUBPIXEL_MASK, k->filter.shadow.y & SUBPIXEL_MASK); + ass_shift_bitmap(&v->bm_s, k->filter.shadow.x & SUBPIXEL_MASK, k->filter.shadow.y & SUBPIXEL_MASK); } if ((flags & FILTER_FILL_IN_SHADOW) && !(flags & FILTER_FILL_IN_BORDER)) - fix_outline(&v->bm, &v->bm_o); + ass_fix_outline(&v->bm, &v->bm_o); return sizeof(CompositeHashKey) + sizeof(CompositeHashValue) + bitmap_size(&v->bm) + bitmap_size(&v->bm_o) + bitmap_size(&v->bm_s); @@ -2803,7 +2803,7 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, // Find shape runs and shape text ass_shaper_set_base_direction(render_priv->shaper, - resolve_base_direction(render_priv->state.font_encoding)); + ass_resolve_base_direction(render_priv->state.font_encoding)); ass_shaper_find_runs(render_priv->shaper, render_priv, text_info->glyphs, text_info->length); if (!ass_shaper_shape(render_priv->shaper, text_info)) { @@ -2834,7 +2834,7 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, wrap_lines_smart(render_priv, max_text_width); // depends on glyph x coordinates being monotonous within runs, so it should be done before reorder - process_karaoke_effects(render_priv); + ass_process_karaoke_effects(render_priv); reorder_text(render_priv); diff --git a/libass/ass_render.h b/libass/ass_render.h index e9fe6dc..f8613e3 100644 --- a/libass/ass_render.h +++ b/libass/ass_render.h @@ -148,7 +148,7 @@ typedef struct glyph_info { ASS_Vector cluster_advance; Effect effect_type; int32_t effect_timing; // time duration of current karaoke word - // after process_karaoke_effects: distance in subpixels from the karaoke origin. + // after ass_process_karaoke_effects: distance in subpixels from the karaoke origin. // part of the glyph to the left of it is displayed in a different color. int32_t effect_skip_timing; // delay after the end of last karaoke word bool reset_effect; @@ -346,7 +346,7 @@ typedef struct { int y1; } Rect; -void reset_render_context(ASS_Renderer *render_priv, ASS_Style *style); +void ass_reset_render_context(ASS_Renderer *render_priv, ASS_Style *style); void ass_frame_ref(ASS_Image *img); void ass_frame_unref(ASS_Image *img); ASS_Vector ass_layout_res(ASS_Renderer *render_priv); diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index a7cec8c..c8ffb07 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -1128,7 +1128,7 @@ FriBidiStrIndex *ass_shaper_get_reorder_map(ASS_Shaper *shaper) * can be used for autodetection. * \param enc Windows font encoding */ -FriBidiParType resolve_base_direction(int enc) +FriBidiParType ass_resolve_base_direction(int enc) { switch (enc) { case -1: diff --git a/libass/ass_shaper.h b/libass/ass_shaper.h index 66bfed0..0c7a11b 100644 --- a/libass/ass_shaper.h +++ b/libass/ass_shaper.h @@ -47,7 +47,7 @@ bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info); void ass_shaper_cleanup(ASS_Shaper *shaper, TextInfo *text_info); FriBidiStrIndex *ass_shaper_reorder(ASS_Shaper *shaper, TextInfo *text_info); FriBidiStrIndex *ass_shaper_get_reorder_map(ASS_Shaper *shaper); -FriBidiParType resolve_base_direction(int font_encoding); +FriBidiParType ass_resolve_base_direction(int font_encoding); void ass_shaper_font_data_free(ASS_ShaperFontData *priv); diff --git a/libass/ass_utils.c b/libass/ass_utils.c index 7692c9a..9075e20 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -292,7 +292,7 @@ void ass_utf16be_to_utf8(char *dst, size_t dst_size, uint8_t *src, size_t src_si * Returns 0 if no styles found => expects at least 1 style. * Parsing code always adds "Default" style in the beginning. */ -int lookup_style(ASS_Track *track, char *name) +int ass_lookup_style(ASS_Track *track, char *name) { int i; // '*' seem to mean literally nothing; diff --git a/libass/ass_utils.h b/libass/ass_utils.h index c9e9b7c..7d68326 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -103,7 +103,7 @@ void ass_utf16be_to_utf8(char *dst, size_t dst_size, uint8_t *src, size_t src_si __attribute__ ((format (printf, 3, 4))) #endif void ass_msg(ASS_Library *priv, int lvl, const char *fmt, ...); -int lookup_style(ASS_Track *track, char *name); +int ass_lookup_style(ASS_Track *track, char *name); /* defined in ass_strtod.c */ double ass_strtod(const char *string, char **endPtr); -- cgit v1.2.3