typedef enum { PST_UNKNOWN =
0, PST_INFO, PST_STYLES, PST_EVENTS, PST_FONTS } parser_state_t;
-struct parser_priv_s {
+struct parser_priv {
parser_state_t state;
char *fontname;
char *fontdata;
#define LIBASS_VERSION 0x00907000
-/* Libass renderer object. Contents are private. */
-typedef struct ass_renderer_s ass_renderer_t;
-
/*
* A linked list of images produced by an ass renderer.
*
* The last bitmap row is not guaranteed to be padded up to stride size,
* e.g. in the worst case a bitmap has the size stride * (h - 1) + w.
*/
-typedef struct ass_image_s {
+typedef struct ass_image {
int w, h; // Bitmap width/height
int stride; // Bitmap stride
unsigned char *bitmap; // 1bpp stride*h alpha buffer
uint32_t color; // Bitmap color and alpha, RGBA
int dst_x, dst_y; // Bitmap placement inside the video frame
- struct ass_image_s *next; // Next image, or NULL
+ struct ass_image *next; // Next image, or NULL
} ass_image_t;
/*
#include "ass_utils.h"
#include "ass_bitmap.h"
-struct ass_synth_priv_s {
+struct ass_synth_priv {
int tmp_w, tmp_h;
unsigned short *tmp;
#include "ass.h"
-typedef struct ass_synth_priv_s ass_synth_priv_t;
+typedef struct ass_synth_priv ass_synth_priv_t;
ass_synth_priv_t *ass_synth_init(double);
void ass_synth_done(ass_synth_priv_t *priv);
-typedef struct bitmap_s {
+typedef struct {
int left, top;
int w, h; // width, height
unsigned char *buffer; // w x h buffer
size_t key_size);
typedef unsigned (*hashmap_hash_t) (void *key, size_t key_size);
-typedef struct hashmap_item_s {
+typedef struct hashmap_item {
void *key;
void *value;
- struct hashmap_item_s *next;
+ struct hashmap_item *next;
} hashmap_item_t;
typedef hashmap_item_t *hashmap_item_p;
-typedef struct hashmap_s {
+typedef struct {
int nbuckets;
size_t key_size, value_size;
hashmap_item_p *root;
#define CREATE_STRUCT_DEFINITIONS
#include "ass_cache_template.h"
-typedef struct bitmap_hash_val_s {
+typedef struct {
bitmap_t *bm; // the actual bitmaps
bitmap_t *bm_o;
bitmap_t *bm_s;
void ass_bitmap_cache_done(hashmap_t *bitmap_cache);
-typedef struct composite_hash_val_s {
+typedef struct {
unsigned char *a;
unsigned char *b;
} composite_hash_val_t;
void ass_composite_cache_done(hashmap_t *composite_cache);
-typedef struct glyph_hash_val_s {
+typedef struct {
FT_Glyph glyph;
FT_Glyph outline_glyph;
FT_BBox bbox_scaled; // bbox after scaling, but before rotation
// describes a bitmap; bitmaps with equivalents structs are considered identical
-START(bitmap, bipmap_hash_key_s)
+START(bitmap, bipmap_hash_key)
GENERIC(char, bitmap) // bool : true = bitmap, false = outline
GENERIC(ass_font_t *, font)
GENERIC(double, size) // font size
END(bitmap_hash_key_t)
// describes an outline glyph
-START(glyph, glyph_hash_key_s)
+START(glyph, glyph_hash_key)
GENERIC(ass_font_t *, font)
GENERIC(double, size) // font size
GENERIC(uint32_t, ch) // character code
END(glyph_hash_key_t)
// Cache for composited bitmaps
-START(composite, composite_hash_key_s)
+START(composite, composite_hash_key)
GENERIC(int, aw)
GENERIC(int, ah)
GENERIC(int, bw)
#define DRAWING_INITIAL_SIZE 256
-enum ass_token_type {
+typedef enum {
TOKEN_MOVE,
TOKEN_MOVE_NC,
TOKEN_LINE,
TOKEN_B_SPLINE,
TOKEN_EXTEND_SPLINE,
TOKEN_CLOSE
-};
+} ass_token_type_t;
-typedef struct ass_drawing_token_s {
- enum ass_token_type type;
+typedef struct ass_drawing_token {
+ ass_token_type_t type;
FT_Vector point;
- struct ass_drawing_token_s *next;
- struct ass_drawing_token_s *prev;
+ struct ass_drawing_token *next;
+ struct ass_drawing_token *prev;
} ass_drawing_token_t;
-typedef struct ass_drawing_s {
+typedef struct {
char *text; // drawing string
int i; // text index
int scale; // scale (1-64) for subpixel accuracy
#define DECO_UNDERLINE 1
#define DECO_STRIKETHROUGH 2
-typedef struct ass_font_desc_s {
+typedef struct {
char *family;
unsigned bold;
unsigned italic;
int treat_family_as_pattern;
} ass_font_desc_t;
-typedef struct ass_font_s {
+typedef struct {
ass_font_desc_t desc;
ass_library_t *library;
FT_Library ftlibrary;
#include <fontconfig/fcfreetype.h>
#endif
-struct fc_instance_s {
+struct fc_instance {
#ifdef CONFIG_FONTCONFIG
FcConfig *config;
#endif
#include <fontconfig/fontconfig.h>
#endif
-typedef struct fc_instance_s fc_instance_t;
+typedef struct fc_instance fc_instance_t;
fc_instance_t *fontconfig_init(ass_library_t *library,
FT_Library ftlibrary, const char *family,
#include <stdarg.h>
-typedef struct ass_fontdata_s {
+typedef struct {
char *name;
char *data;
int size;
} ass_fontdata_t;
-struct ass_library_s {
+struct ass_library {
char *fonts_dir;
int extract_fonts;
char **style_overrides;
#define GLYPH_CACHE_MAX 1000
#define BITMAP_CACHE_MAX_SIZE 50 * 1048576;
-typedef struct double_bbox_s {
+typedef struct {
double xMin;
double xMax;
double yMin;
double yMax;
} double_bbox_t;
-typedef struct double_vector_s {
+typedef struct {
double x;
double y;
} double_vector_t;
-typedef struct free_list_s {
+typedef struct free_list {
void *object;
- struct free_list_s *next;
+ struct free_list *next;
} free_list_t;
-typedef struct ass_settings_s {
+typedef struct {
int frame_width;
int frame_height;
double font_size_coeff; // font size multiplier
} ass_settings_t;
// a rendered event
-typedef struct event_images_s {
+typedef struct {
ass_image_t *imgs;
int top, height;
int detect_collisions;
// describes a glyph
// glyph_info_t and text_info_t are used for text centering and word-wrapping operations
-typedef struct glyph_info_s {
+typedef struct {
unsigned symbol;
FT_Glyph glyph;
FT_Glyph outline_glyph;
bitmap_hash_key_t hash_key;
} glyph_info_t;
-typedef struct line_info_s {
+typedef struct {
double asc, desc;
} line_info_t;
-typedef struct text_info_s {
+typedef struct {
glyph_info_t *glyphs;
int length;
line_info_t *lines;
// Renderer state.
// Values like current font face, color, screen position, clipping and so on are stored here.
-typedef struct render_context_s {
+typedef struct {
ass_event_t *event;
ass_style_t *style;
} render_context_t;
-typedef struct cache_store_s {
+typedef struct {
hashmap_t *font_cache;
hashmap_t *glyph_cache;
hashmap_t *bitmap_cache;
size_t bitmap_max_size;
} cache_store_t;
-struct ass_renderer_s {
+struct ass_renderer {
ass_library_t *library;
FT_Library ftlibrary;
fc_instance_t *fontconfig_priv;
free_list_t *free_tail;
};
-struct render_priv_s {
+struct render_priv {
int top, height;
int render_id;
};
static double x2scr_pos(ass_renderer_t *render_priv, double x);
static double y2scr_pos(ass_renderer_t *render_priv, double y);
-typedef struct rect_s {
+typedef struct {
int x0;
int y0;
int x1;
return event->render_priv;
}
-typedef struct segment_s {
+typedef struct {
int a, b; // top and height
} segment_t;
#define HALIGN_CENTER 2
#define HALIGN_RIGHT 3
+/* Opaque objects internally used by libass. Contents are private. */
+typedef struct ass_renderer ass_renderer_t;
+typedef struct render_priv render_priv_t;
+typedef struct parser_priv parser_priv_t;
+typedef struct ass_library ass_library_t;
+
/* ASS Style: line */
-typedef struct ass_style_s {
+typedef struct {
char *Name;
char *FontName;
double FontSize;
int treat_fontname_as_pattern;
} ass_style_t;
-typedef struct render_priv_s render_priv_t;
-
/*
* ass_event_t corresponds to a single Dialogue line;
* text is stored as-is, style overrides will be parsed later.
*/
-typedef struct ass_event_s {
+typedef struct {
long long Start; // ms
long long Duration; // ms
render_priv_t *render_priv;
} ass_event_t;
-typedef struct parser_priv_s parser_priv_t;
-typedef struct ass_library_s ass_library_t;
-
/*
* ass track represent either an external script or a matroska subtitle stream
* (no real difference between them); it can be used in rendering after the
* headers are parsed (i.e. events format line read).
*/
-typedef struct ass_track_s {
+typedef struct {
int n_styles; // amount used
int max_styles; // amount allocated
int n_events;