diff options
author | Oneric <oneric@oneric.stub> | 2022-10-21 00:47:17 +0200 |
---|---|---|
committer | Oneric <oneric@oneric.stub> | 2022-10-22 18:05:11 +0200 |
commit | 1884f6ef05673941c4db6bc89a8850c167905eff (patch) | |
tree | fd0a322e183ad90ff5545c03f138f2c469b0ef35 | |
parent | cb49725e2f446f0c24aa1bcd161eb74abfe11291 (diff) | |
download | libass-1884f6ef05673941c4db6bc89a8850c167905eff.tar.bz2 libass-1884f6ef05673941c4db6bc89a8850c167905eff.tar.xz |
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
-rw-r--r-- | libass/ass.c | 8 | ||||
-rw-r--r-- | libass/ass_bitmap.c | 30 | ||||
-rw-r--r-- | libass/ass_bitmap.h | 14 | ||||
-rw-r--r-- | libass/ass_blur.c | 2 | ||||
-rw-r--r-- | libass/ass_cache.c | 4 | ||||
-rw-r--r-- | libass/ass_drawing.c | 24 | ||||
-rw-r--r-- | libass/ass_font.c | 16 | ||||
-rw-r--r-- | libass/ass_font.h | 2 | ||||
-rw-r--r-- | libass/ass_fontselect.c | 4 | ||||
-rw-r--r-- | libass/ass_library.h | 2 | ||||
-rw-r--r-- | libass/ass_outline.c | 86 | ||||
-rw-r--r-- | libass/ass_outline.h | 44 | ||||
-rw-r--r-- | libass/ass_parse.c | 30 | ||||
-rw-r--r-- | libass/ass_parse.h | 14 | ||||
-rw-r--r-- | libass/ass_rasterizer.c | 14 | ||||
-rw-r--r-- | libass/ass_rasterizer.h | 14 | ||||
-rw-r--r-- | libass/ass_render.c | 100 | ||||
-rw-r--r-- | libass/ass_render.h | 4 | ||||
-rw-r--r-- | libass/ass_shaper.c | 2 | ||||
-rw-r--r-- | libass/ass_shaper.h | 2 | ||||
-rw-r--r-- | libass/ass_utils.c | 2 | ||||
-rw-r--r-- | 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 ( |