mirror of https://github.com/odrling/Aegisub
Merge libass updates into 2.1.8: r3176, r3446, r3448.
Originally committed to SVN as r3491.
This commit is contained in:
parent
78259cfa39
commit
7784a2610c
|
@ -15,7 +15,8 @@ libass_aegisub_a_SOURCES = \
|
||||||
ass_fontconfig.c \
|
ass_fontconfig.c \
|
||||||
ass_library.c \
|
ass_library.c \
|
||||||
ass_render.c \
|
ass_render.c \
|
||||||
ass_utils.c
|
ass_utils.c \
|
||||||
|
ass_parse.c
|
||||||
|
|
||||||
libass_aegisub_a_SOURCES += \
|
libass_aegisub_a_SOURCES += \
|
||||||
*.h
|
*.h
|
||||||
|
|
|
@ -38,11 +38,16 @@
|
||||||
#include "ass_utils.h"
|
#include "ass_utils.h"
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
|
|
||||||
typedef enum { PST_UNKNOWN =
|
typedef enum {
|
||||||
0, PST_INFO, PST_STYLES, PST_EVENTS, PST_FONTS } parser_state_t;
|
PST_UNKNOWN = 0,
|
||||||
|
PST_INFO,
|
||||||
|
PST_STYLES,
|
||||||
|
PST_EVENTS,
|
||||||
|
PST_FONTS
|
||||||
|
} ParserState;
|
||||||
|
|
||||||
struct parser_priv_s {
|
struct parser_priv {
|
||||||
parser_state_t state;
|
ParserState state;
|
||||||
char *fontname;
|
char *fontname;
|
||||||
char *fontdata;
|
char *fontdata;
|
||||||
int fontdata_size;
|
int fontdata_size;
|
||||||
|
@ -52,7 +57,7 @@ struct parser_priv_s {
|
||||||
#define ASS_STYLES_ALLOC 20
|
#define ASS_STYLES_ALLOC 20
|
||||||
#define ASS_EVENTS_ALLOC 200
|
#define ASS_EVENTS_ALLOC 200
|
||||||
|
|
||||||
void ass_free_track(ass_track_t *track)
|
void ass_free_track(ASS_Track *track)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -77,12 +82,14 @@ void ass_free_track(ass_track_t *track)
|
||||||
ass_free_event(track, i);
|
ass_free_event(track, i);
|
||||||
free(track->events);
|
free(track->events);
|
||||||
}
|
}
|
||||||
|
free(track->name);
|
||||||
|
free(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Allocate a new style struct
|
/// \brief Allocate a new style struct
|
||||||
/// \param track track
|
/// \param track track
|
||||||
/// \return style id
|
/// \return style id
|
||||||
int ass_alloc_style(ass_track_t *track)
|
int ass_alloc_style(ASS_Track *track)
|
||||||
{
|
{
|
||||||
int sid;
|
int sid;
|
||||||
|
|
||||||
|
@ -91,20 +98,20 @@ int ass_alloc_style(ass_track_t *track)
|
||||||
if (track->n_styles == track->max_styles) {
|
if (track->n_styles == track->max_styles) {
|
||||||
track->max_styles += ASS_STYLES_ALLOC;
|
track->max_styles += ASS_STYLES_ALLOC;
|
||||||
track->styles =
|
track->styles =
|
||||||
(ass_style_t *) realloc(track->styles,
|
(ASS_Style *) realloc(track->styles,
|
||||||
sizeof(ass_style_t) *
|
sizeof(ASS_Style) *
|
||||||
track->max_styles);
|
track->max_styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
sid = track->n_styles++;
|
sid = track->n_styles++;
|
||||||
memset(track->styles + sid, 0, sizeof(ass_style_t));
|
memset(track->styles + sid, 0, sizeof(ASS_Style));
|
||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Allocate a new event struct
|
/// \brief Allocate a new event struct
|
||||||
/// \param track track
|
/// \param track track
|
||||||
/// \return event id
|
/// \return event id
|
||||||
int ass_alloc_event(ass_track_t *track)
|
int ass_alloc_event(ASS_Track *track)
|
||||||
{
|
{
|
||||||
int eid;
|
int eid;
|
||||||
|
|
||||||
|
@ -113,19 +120,19 @@ int ass_alloc_event(ass_track_t *track)
|
||||||
if (track->n_events == track->max_events) {
|
if (track->n_events == track->max_events) {
|
||||||
track->max_events += ASS_EVENTS_ALLOC;
|
track->max_events += ASS_EVENTS_ALLOC;
|
||||||
track->events =
|
track->events =
|
||||||
(ass_event_t *) realloc(track->events,
|
(ASS_Event *) realloc(track->events,
|
||||||
sizeof(ass_event_t) *
|
sizeof(ASS_Event) *
|
||||||
track->max_events);
|
track->max_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
eid = track->n_events++;
|
eid = track->n_events++;
|
||||||
memset(track->events + eid, 0, sizeof(ass_event_t));
|
memset(track->events + eid, 0, sizeof(ASS_Event));
|
||||||
return eid;
|
return eid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_free_event(ass_track_t *track, int eid)
|
void ass_free_event(ASS_Track *track, int eid)
|
||||||
{
|
{
|
||||||
ass_event_t *event = track->events + eid;
|
ASS_Event *event = track->events + eid;
|
||||||
if (event->Name)
|
if (event->Name)
|
||||||
free(event->Name);
|
free(event->Name);
|
||||||
if (event->Effect)
|
if (event->Effect)
|
||||||
|
@ -136,9 +143,9 @@ void ass_free_event(ass_track_t *track, int eid)
|
||||||
free(event->render_priv);
|
free(event->render_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_free_style(ass_track_t *track, int sid)
|
void ass_free_style(ASS_Track *track, int sid)
|
||||||
{
|
{
|
||||||
ass_style_t *style = track->styles + sid;
|
ASS_Style *style = track->styles + sid;
|
||||||
if (style->Name)
|
if (style->Name)
|
||||||
free(style->Name);
|
free(style->Name);
|
||||||
if (style->FontName)
|
if (style->FontName)
|
||||||
|
@ -171,7 +178,7 @@ static void rskip_spaces(char **str, char *limit)
|
||||||
* Returnes 0 if no styles found => expects at least 1 style.
|
* Returnes 0 if no styles found => expects at least 1 style.
|
||||||
* Parsing code always adds "Default" style in the end.
|
* Parsing code always adds "Default" style in the end.
|
||||||
*/
|
*/
|
||||||
static int lookup_style(ass_track_t *track, char *name)
|
static int lookup_style(ASS_Track *track, char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (*name == '*')
|
if (*name == '*')
|
||||||
|
@ -188,14 +195,14 @@ static int lookup_style(ass_track_t *track, char *name)
|
||||||
return i; // use the first style
|
return i; // use the first style
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t string2color(ass_library_t *library, char *p)
|
static uint32_t string2color(ASS_Library *library, char *p)
|
||||||
{
|
{
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
(void) strtocolor(library, &p, &tmp);
|
(void) strtocolor(library, &p, &tmp, 0);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long long string2timecode(ass_library_t *library, char *p)
|
static long long string2timecode(ASS_Library *library, char *p)
|
||||||
{
|
{
|
||||||
unsigned h, m, s, ms;
|
unsigned h, m, s, ms;
|
||||||
long long tm;
|
long long tm;
|
||||||
|
@ -292,14 +299,14 @@ static char *next_token(char **str)
|
||||||
* \param str string to parse, zero-terminated
|
* \param str string to parse, zero-terminated
|
||||||
* \param n_ignored number of format options to skip at the beginning
|
* \param n_ignored number of format options to skip at the beginning
|
||||||
*/
|
*/
|
||||||
static int process_event_tail(ass_track_t *track, ass_event_t *event,
|
static int process_event_tail(ASS_Track *track, ASS_Event *event,
|
||||||
char *str, int n_ignored)
|
char *str, int n_ignored)
|
||||||
{
|
{
|
||||||
char *token;
|
char *token;
|
||||||
char *tname;
|
char *tname;
|
||||||
char *p = str;
|
char *p = str;
|
||||||
int i;
|
int i;
|
||||||
ass_event_t *target = event;
|
ASS_Event *target = event;
|
||||||
|
|
||||||
char *format = strdup(track->event_format);
|
char *format = strdup(track->event_format);
|
||||||
char *q = format; // format scanning pointer
|
char *q = format; // format scanning pointer
|
||||||
|
@ -355,10 +362,10 @@ static int process_event_tail(ass_track_t *track, ass_event_t *event,
|
||||||
* \param track track to apply overrides to
|
* \param track track to apply overrides to
|
||||||
* The format for overrides is [StyleName.]Field=Value
|
* The format for overrides is [StyleName.]Field=Value
|
||||||
*/
|
*/
|
||||||
void ass_process_force_style(ass_track_t *track)
|
void ass_process_force_style(ASS_Track *track)
|
||||||
{
|
{
|
||||||
char **fs, *eq, *dt, *style, *tname, *token;
|
char **fs, *eq, *dt, *style, *tname, *token;
|
||||||
ass_style_t *target;
|
ASS_Style *target;
|
||||||
int sid;
|
int sid;
|
||||||
char **list = track->library->style_overrides;
|
char **list = track->library->style_overrides;
|
||||||
|
|
||||||
|
@ -434,7 +441,7 @@ void ass_process_force_style(ass_track_t *track)
|
||||||
* \param str string to parse, zero-terminated
|
* \param str string to parse, zero-terminated
|
||||||
* Allocates a new style struct.
|
* Allocates a new style struct.
|
||||||
*/
|
*/
|
||||||
static int process_style(ass_track_t *track, char *str)
|
static int process_style(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *token;
|
char *token;
|
||||||
|
@ -443,8 +450,8 @@ static int process_style(ass_track_t *track, char *str)
|
||||||
char *format;
|
char *format;
|
||||||
char *q; // format scanning pointer
|
char *q; // format scanning pointer
|
||||||
int sid;
|
int sid;
|
||||||
ass_style_t *style;
|
ASS_Style *style;
|
||||||
ass_style_t *target;
|
ASS_Style *target;
|
||||||
|
|
||||||
if (!track->style_format) {
|
if (!track->style_format) {
|
||||||
// no style format header
|
// no style format header
|
||||||
|
@ -472,7 +479,8 @@ static int process_style(ass_track_t *track, char *str)
|
||||||
|
|
||||||
style = track->styles + sid;
|
style = track->styles + sid;
|
||||||
target = style;
|
target = style;
|
||||||
// fill style with some default values
|
|
||||||
|
// fill style with some default values
|
||||||
style->ScaleX = 100.;
|
style->ScaleX = 100.;
|
||||||
style->ScaleY = 100.;
|
style->ScaleY = 100.;
|
||||||
|
|
||||||
|
@ -480,8 +488,6 @@ static int process_style(ass_track_t *track, char *str)
|
||||||
NEXT(q, tname);
|
NEXT(q, tname);
|
||||||
NEXT(p, token);
|
NEXT(p, token);
|
||||||
|
|
||||||
// ALIAS(TertiaryColour,OutlineColour) // ignore TertiaryColour; it appears only in SSA, and is overridden by BackColour
|
|
||||||
|
|
||||||
if (0) { // cool ;)
|
if (0) { // cool ;)
|
||||||
STRVAL(Name)
|
STRVAL(Name)
|
||||||
if ((strcmp(target->Name, "Default") == 0)
|
if ((strcmp(target->Name, "Default") == 0)
|
||||||
|
@ -537,7 +543,7 @@ static int process_style(ass_track_t *track, char *str)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_styles_line(ass_track_t *track, char *str)
|
static int process_styles_line(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
if (!strncmp(str, "Format:", 7)) {
|
if (!strncmp(str, "Format:", 7)) {
|
||||||
char *p = str + 7;
|
char *p = str + 7;
|
||||||
|
@ -553,7 +559,7 @@ static int process_styles_line(ass_track_t *track, char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_info_line(ass_track_t *track, char *str)
|
static int process_info_line(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
if (!strncmp(str, "PlayResX:", 9)) {
|
if (!strncmp(str, "PlayResX:", 9)) {
|
||||||
track->PlayResX = atoi(str + 9);
|
track->PlayResX = atoi(str + 9);
|
||||||
|
@ -569,7 +575,7 @@ static int process_info_line(ass_track_t *track, char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_format_fallback(ass_track_t *track)
|
static void event_format_fallback(ASS_Track *track)
|
||||||
{
|
{
|
||||||
track->parser_priv->state = PST_EVENTS;
|
track->parser_priv->state = PST_EVENTS;
|
||||||
if (track->track_type == TRACK_TYPE_SSA)
|
if (track->track_type == TRACK_TYPE_SSA)
|
||||||
|
@ -582,7 +588,7 @@ static void event_format_fallback(ass_track_t *track)
|
||||||
"No event format found, using fallback");
|
"No event format found, using fallback");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_events_line(ass_track_t *track, char *str)
|
static int process_events_line(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
if (!strncmp(str, "Format:", 7)) {
|
if (!strncmp(str, "Format:", 7)) {
|
||||||
char *p = str + 7;
|
char *p = str + 7;
|
||||||
|
@ -594,7 +600,7 @@ static int process_events_line(ass_track_t *track, char *str)
|
||||||
// They have slightly different format and are parsed in ass_process_chunk,
|
// They have slightly different format and are parsed in ass_process_chunk,
|
||||||
// called directly from demuxer
|
// called directly from demuxer
|
||||||
int eid;
|
int eid;
|
||||||
ass_event_t *event;
|
ASS_Event *event;
|
||||||
|
|
||||||
str += 9;
|
str += 9;
|
||||||
skip_spaces(&str);
|
skip_spaces(&str);
|
||||||
|
@ -634,7 +640,7 @@ static unsigned char *decode_chars(unsigned char c1, unsigned char c2,
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_font(ass_track_t *track)
|
static int decode_font(ASS_Track *track)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
unsigned char *q;
|
unsigned char *q;
|
||||||
|
@ -682,7 +688,7 @@ static int decode_font(ass_track_t *track)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_fonts_line(ass_track_t *track, char *str)
|
static int process_fonts_line(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
@ -728,7 +734,7 @@ static int process_fonts_line(ass_track_t *track, char *str)
|
||||||
* \param track track
|
* \param track track
|
||||||
* \param str string to parse, zero-terminated
|
* \param str string to parse, zero-terminated
|
||||||
*/
|
*/
|
||||||
static int process_line(ass_track_t *track, char *str)
|
static int process_line(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
if (!strncasecmp(str, "[Script Info]", 13)) {
|
if (!strncasecmp(str, "[Script Info]", 13)) {
|
||||||
track->parser_priv->state = PST_INFO;
|
track->parser_priv->state = PST_INFO;
|
||||||
|
@ -769,7 +775,7 @@ static int process_line(ass_track_t *track, char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_text(ass_track_t *track, char *str)
|
static int process_text(ASS_Track *track, char *str)
|
||||||
{
|
{
|
||||||
char *p = str;
|
char *p = str;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -802,7 +808,7 @@ static int process_text(ass_track_t *track, char *str)
|
||||||
* \param data string to parse
|
* \param data string to parse
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
*/
|
*/
|
||||||
void ass_process_data(ass_track_t *track, char *data, int size)
|
void ass_process_data(ASS_Track *track, char *data, int size)
|
||||||
{
|
{
|
||||||
char *str = malloc(size + 1);
|
char *str = malloc(size + 1);
|
||||||
|
|
||||||
|
@ -821,7 +827,7 @@ void ass_process_data(ass_track_t *track, char *data, int size)
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
CodecPrivate section contains [Stream Info] and [V4+ Styles] ([V4 Styles] for SSA) sections
|
CodecPrivate section contains [Stream Info] and [V4+ Styles] ([V4 Styles] for SSA) sections
|
||||||
*/
|
*/
|
||||||
void ass_process_codec_private(ass_track_t *track, char *data, int size)
|
void ass_process_codec_private(ASS_Track *track, char *data, int size)
|
||||||
{
|
{
|
||||||
ass_process_data(track, data, size);
|
ass_process_data(track, data, size);
|
||||||
|
|
||||||
|
@ -833,7 +839,7 @@ void ass_process_codec_private(ass_track_t *track, char *data, int size)
|
||||||
ass_process_force_style(track);
|
ass_process_force_style(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_duplicate_event(ass_track_t *track, int ReadOrder)
|
static int check_duplicate_event(ASS_Track *track, int ReadOrder)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < track->n_events - 1; ++i) // ignoring last event, it is the one we are comparing with
|
for (i = 0; i < track->n_events - 1; ++i) // ignoring last event, it is the one we are comparing with
|
||||||
|
@ -850,14 +856,14 @@ static int check_duplicate_event(ass_track_t *track, int ReadOrder)
|
||||||
* \param timecode starting time of the event (milliseconds)
|
* \param timecode starting time of the event (milliseconds)
|
||||||
* \param duration duration of the event (milliseconds)
|
* \param duration duration of the event (milliseconds)
|
||||||
*/
|
*/
|
||||||
void ass_process_chunk(ass_track_t *track, char *data, int size,
|
void ass_process_chunk(ASS_Track *track, char *data, int size,
|
||||||
long long timecode, long long duration)
|
long long timecode, long long duration)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
int eid;
|
int eid;
|
||||||
char *p;
|
char *p;
|
||||||
char *token;
|
char *token;
|
||||||
ass_event_t *event;
|
ASS_Event *event;
|
||||||
|
|
||||||
if (!track->event_format) {
|
if (!track->event_format) {
|
||||||
ass_msg(track->library, MSGL_WARN, "Event format header missing");
|
ass_msg(track->library, MSGL_WARN, "Event format header missing");
|
||||||
|
@ -906,7 +912,7 @@ void ass_process_chunk(ass_track_t *track, char *data, int size,
|
||||||
* \param size buffer size
|
* \param size buffer size
|
||||||
* \return a pointer to recoded buffer, caller is responsible for freeing it
|
* \return a pointer to recoded buffer, caller is responsible for freeing it
|
||||||
**/
|
**/
|
||||||
static char *sub_recode(ass_library_t *library, char *data, size_t size,
|
static char *sub_recode(ASS_Library *library, char *data, size_t size,
|
||||||
char *codepage)
|
char *codepage)
|
||||||
{
|
{
|
||||||
iconv_t icdsc;
|
iconv_t icdsc;
|
||||||
|
@ -985,7 +991,7 @@ static char *sub_recode(ass_library_t *library, char *data, size_t size,
|
||||||
* \param bufsize out: file size
|
* \param bufsize out: file size
|
||||||
* \return pointer to file contents. Caller is responsible for its deallocation.
|
* \return pointer to file contents. Caller is responsible for its deallocation.
|
||||||
*/
|
*/
|
||||||
static char *read_file(ass_library_t *library, char *fname, size_t *bufsize)
|
static char *read_file(ASS_Library *library, char *fname, size_t *bufsize)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
long sz;
|
long sz;
|
||||||
|
@ -1044,9 +1050,9 @@ static char *read_file(ass_library_t *library, char *fname, size_t *bufsize)
|
||||||
/*
|
/*
|
||||||
* \param buf pointer to subtitle text in utf-8
|
* \param buf pointer to subtitle text in utf-8
|
||||||
*/
|
*/
|
||||||
static ass_track_t *parse_memory(ass_library_t *library, char *buf)
|
static ASS_Track *parse_memory(ASS_Library *library, char *buf)
|
||||||
{
|
{
|
||||||
ass_track_t *track;
|
ASS_Track *track;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
track = ass_new_track(library);
|
track = ass_new_track(library);
|
||||||
|
@ -1080,10 +1086,10 @@ static ass_track_t *parse_memory(ass_library_t *library, char *buf)
|
||||||
* \param codepage recode buffer contents from given codepage
|
* \param codepage recode buffer contents from given codepage
|
||||||
* \return newly allocated track
|
* \return newly allocated track
|
||||||
*/
|
*/
|
||||||
ass_track_t *ass_read_memory(ass_library_t *library, char *buf,
|
ASS_Track *ass_read_memory(ASS_Library *library, char *buf,
|
||||||
size_t bufsize, char *codepage)
|
size_t bufsize, char *codepage)
|
||||||
{
|
{
|
||||||
ass_track_t *track;
|
ASS_Track *track;
|
||||||
int need_free = 0;
|
int need_free = 0;
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
@ -1109,7 +1115,7 @@ ass_track_t *ass_read_memory(ass_library_t *library, char *buf,
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *read_file_recode(ass_library_t *library, char *fname,
|
static char *read_file_recode(ASS_Library *library, char *fname,
|
||||||
char *codepage, size_t *size)
|
char *codepage, size_t *size)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -1138,11 +1144,11 @@ static char *read_file_recode(ass_library_t *library, char *fname,
|
||||||
* \param codepage recode buffer contents from given codepage
|
* \param codepage recode buffer contents from given codepage
|
||||||
* \return newly allocated track
|
* \return newly allocated track
|
||||||
*/
|
*/
|
||||||
ass_track_t *ass_read_file(ass_library_t *library, char *fname,
|
ASS_Track *ass_read_file(ASS_Library *library, char *fname,
|
||||||
char *codepage)
|
char *codepage)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
ass_track_t *track;
|
ASS_Track *track;
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
|
|
||||||
buf = read_file_recode(library, fname, codepage, &bufsize);
|
buf = read_file_recode(library, fname, codepage, &bufsize);
|
||||||
|
@ -1165,10 +1171,10 @@ ass_track_t *ass_read_file(ass_library_t *library, char *fname,
|
||||||
/**
|
/**
|
||||||
* \brief read styles from file into already initialized track
|
* \brief read styles from file into already initialized track
|
||||||
*/
|
*/
|
||||||
int ass_read_styles(ass_track_t *track, char *fname, char *codepage)
|
int ass_read_styles(ASS_Track *track, char *fname, char *codepage)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
parser_state_t old_state;
|
ParserState old_state;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
buf = read_file(track->library, fname, &sz);
|
buf = read_file(track->library, fname, &sz);
|
||||||
|
@ -1193,7 +1199,7 @@ int ass_read_styles(ass_track_t *track, char *fname, char *codepage)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long ass_step_sub(ass_track_t *track, long long now, int movement)
|
long long ass_step_sub(ASS_Track *track, long long now, int movement)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1225,11 +1231,11 @@ long long ass_step_sub(ass_track_t *track, long long now, int movement)
|
||||||
return ((long long) track->events[i].Start) - now;
|
return ((long long) track->events[i].Start) - now;
|
||||||
}
|
}
|
||||||
|
|
||||||
ass_track_t *ass_new_track(ass_library_t *library)
|
ASS_Track *ass_new_track(ASS_Library *library)
|
||||||
{
|
{
|
||||||
ass_track_t *track = calloc(1, sizeof(ass_track_t));
|
ASS_Track *track = calloc(1, sizeof(ASS_Track));
|
||||||
track->library = library;
|
track->library = library;
|
||||||
track->ScaledBorderAndShadow = 1;
|
track->ScaledBorderAndShadow = 1;
|
||||||
track->parser_priv = calloc(1, sizeof(parser_priv_t));
|
track->parser_priv = calloc(1, sizeof(ASS_ParserPriv));
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,138 +25,265 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "ass_types.h"
|
#include "ass_types.h"
|
||||||
|
|
||||||
/// Libass renderer object. Contents are private.
|
#define LIBASS_VERSION 0x00907010
|
||||||
typedef struct ass_renderer_s ass_renderer_t;
|
|
||||||
|
|
||||||
/// a linked list of images produced by ass renderer
|
/*
|
||||||
typedef struct ass_image_s {
|
* A linked list of images produced by an ass renderer.
|
||||||
int w, h; // bitmap width/height
|
*
|
||||||
int stride; // bitmap stride
|
* These images have to be rendered in-order for the correct screen
|
||||||
|
* composition. The libass renderer clips these bitmaps to the frame size.
|
||||||
|
* w/h can be zero, in this case the bitmap should not be rendered at all.
|
||||||
|
* 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 {
|
||||||
|
int w, h; // Bitmap width/height
|
||||||
|
int stride; // Bitmap stride
|
||||||
unsigned char *bitmap; // 1bpp stride*h alpha buffer
|
unsigned char *bitmap; // 1bpp stride*h alpha buffer
|
||||||
uint32_t color; // RGBA
|
// Note: the last row may not be padded to
|
||||||
int dst_x, dst_y; // bitmap placement inside the video frame
|
// bitmap stride!
|
||||||
|
uint32_t color; // Bitmap color and alpha, RGBA
|
||||||
|
int dst_x, dst_y; // Bitmap placement inside the video frame
|
||||||
|
|
||||||
struct ass_image_s *next; // linked list
|
struct ass_image *next; // Next image, or NULL
|
||||||
} ass_image_t;
|
} ASS_Image;
|
||||||
|
|
||||||
/// Hinting type
|
/*
|
||||||
typedef enum { ASS_HINTING_NONE = 0,
|
* Hintint type. (see ass_set_hinting below)
|
||||||
|
*
|
||||||
|
* FreeType's native hinter is still buggy sometimes and it is recommended
|
||||||
|
* to use the light autohinter, ASS_HINTING_LIGHT, instead. For best
|
||||||
|
* compatibility with problematic fonts, disable hinting.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
ASS_HINTING_NONE = 0,
|
||||||
ASS_HINTING_LIGHT,
|
ASS_HINTING_LIGHT,
|
||||||
ASS_HINTING_NORMAL,
|
ASS_HINTING_NORMAL,
|
||||||
ASS_HINTING_NATIVE
|
ASS_HINTING_NATIVE
|
||||||
} ass_hinting_t;
|
} ASS_Hinting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief initialize the library
|
* \brief Initialize the library.
|
||||||
* \return library handle or NULL if failed
|
* \return library handle or NULL if failed
|
||||||
*/
|
*/
|
||||||
ass_library_t *ass_library_init(void);
|
ASS_Library *ass_library_init(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief finalize the library
|
* \brief Finalize the library
|
||||||
* \param priv library handle
|
* \param priv library handle
|
||||||
*/
|
*/
|
||||||
void ass_library_done(ass_library_t *);
|
void ass_library_done(ASS_Library *priv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief set private font directory
|
* \brief Set private font directory.
|
||||||
* It is used for saving embedded fonts and also in font lookup.
|
* It is used for saving embedded fonts and also in font lookup.
|
||||||
|
*
|
||||||
|
* \param priv library handle
|
||||||
|
* \param fonts_dir private directory for font extraction
|
||||||
*/
|
*/
|
||||||
void ass_set_fonts_dir(ass_library_t *priv, const char *fonts_dir);
|
void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir);
|
||||||
|
|
||||||
void ass_set_extract_fonts(ass_library_t *priv, int extract);
|
/**
|
||||||
|
* \brief Whether fonts should be extracted from track data.
|
||||||
|
* \param priv library handle
|
||||||
|
* \param extract whether to extract fonts
|
||||||
|
*/
|
||||||
|
void ass_set_extract_fonts(ASS_Library *priv, int extract);
|
||||||
|
|
||||||
void ass_set_style_overrides(ass_library_t *priv, char **list);
|
/**
|
||||||
|
* \brief Register style overrides with a library instance.
|
||||||
|
* The overrides should have the form [Style.]Param=Value, e.g.
|
||||||
|
* SomeStyle.Font=Arial
|
||||||
|
* ScaledBorderAndShadow=yes
|
||||||
|
*
|
||||||
|
* \param priv library handle
|
||||||
|
* \param list NULL-terminated list of strings
|
||||||
|
*/
|
||||||
|
void ass_set_style_overrides(ASS_Library *priv, char **list);
|
||||||
|
|
||||||
void ass_process_force_style(ass_track_t *track);
|
/**
|
||||||
|
* \brief Explicitly process style overrides for a track.
|
||||||
|
* \param track track handle
|
||||||
|
*/
|
||||||
|
void ass_process_force_style(ASS_Track *track);
|
||||||
|
|
||||||
void ass_set_message_cb(ass_library_t *priv,
|
/**
|
||||||
void (*msg_cb)(int, char *, va_list *, void *),
|
* \brief Register a callback for debug/info messages.
|
||||||
|
* If a callback is registered, it is called for every message emitted by
|
||||||
|
* libass. The callback receives a format string and a list of arguments,
|
||||||
|
* to be used for the printf family of functions. Additionally, a log level
|
||||||
|
* from 0 (FATAL errors) to 7 (verbose DEBUG) is passed. Usually, level 5
|
||||||
|
* should be used by applications.
|
||||||
|
* If no callback is set, all messages level < 5 are printed to stderr,
|
||||||
|
* prefixed with [ass].
|
||||||
|
*
|
||||||
|
* \param priv library handle
|
||||||
|
* \param msg_cb pointer to callback function
|
||||||
|
* \param data additional data, will be passed to callback
|
||||||
|
*/
|
||||||
|
void ass_set_message_cb(ASS_Library *priv, void (*msg_cb)
|
||||||
|
(int level, const char *fmt, va_list args, void *data),
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief initialize the renderer
|
* \brief Initialize the renderer.
|
||||||
* \param priv library handle
|
* \param priv library handle
|
||||||
* \return renderer handle or NULL if failed
|
* \return renderer handle or NULL if failed
|
||||||
*/
|
*/
|
||||||
ass_renderer_t *ass_renderer_init(ass_library_t *);
|
ASS_Renderer *ass_renderer_init(ASS_Library *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief finalize the renderer
|
* \brief Finalize the renderer.
|
||||||
* \param priv renderer handle
|
* \param priv renderer handle
|
||||||
*/
|
*/
|
||||||
void ass_renderer_done(ass_renderer_t *priv);
|
void ass_renderer_done(ASS_Renderer *priv);
|
||||||
|
|
||||||
void ass_set_frame_size(ass_renderer_t *priv, int w, int h);
|
|
||||||
void ass_set_margins(ass_renderer_t *priv, int t, int b, int l, int r);
|
|
||||||
void ass_set_use_margins(ass_renderer_t *priv, int use);
|
|
||||||
void ass_set_aspect_ratio(ass_renderer_t *priv, double ar, double par);
|
|
||||||
void ass_set_font_scale(ass_renderer_t *priv, double font_scale);
|
|
||||||
void ass_set_hinting(ass_renderer_t *priv, ass_hinting_t ht);
|
|
||||||
void ass_set_line_spacing(ass_renderer_t *priv, double line_spacing);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief set font lookup defaults
|
* \brief Set the frame size in pixels, including margins.
|
||||||
* \param fc bool, use fontconfig?
|
* \param priv renderer handle
|
||||||
* \param config path to fontconfig configuration file, or NULL. Only matters
|
* \param w width
|
||||||
* if fontconfig is used
|
* \param h height
|
||||||
*/
|
*/
|
||||||
int ass_set_fonts(ass_renderer_t *priv, const char *default_font,
|
void ass_set_frame_size(ASS_Renderer *priv, int w, int h);
|
||||||
const char *default_family, int fc, const char *config);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief render a frame, producing a list of ass_image_t
|
* \brief Set frame margins. These values may be negative if pan-and-scan
|
||||||
* \param priv library
|
* is used.
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param t top margin
|
||||||
|
* \param b bottom margin
|
||||||
|
* \param l left margin
|
||||||
|
* \param r right margin
|
||||||
|
*/
|
||||||
|
void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Whether margins should be used for placing regular events.
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param use whether to use the margins
|
||||||
|
*/
|
||||||
|
void ass_set_use_margins(ASS_Renderer *priv, int use);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set aspect ratio parameters.
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param dar display aspect ratio (DAR), prescaled for output PAR
|
||||||
|
* \param sar storage aspect ratio (SAR)
|
||||||
|
*/
|
||||||
|
void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set a fixed font scaling factor.
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param font_scale scaling factor, default is 1.0
|
||||||
|
*/
|
||||||
|
void ass_set_font_scale(ASS_Renderer *priv, double font_scale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set font hinting method.
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param ht hinting method
|
||||||
|
*/
|
||||||
|
void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set line spacing. Will not be scaled with frame size.
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param line_spacing line spacing in pixels
|
||||||
|
*/
|
||||||
|
void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set font lookup defaults.
|
||||||
|
* \param fc whether to use fontconfig
|
||||||
|
* \param config path to fontconfig configuration file, or NULL. Only relevant
|
||||||
|
* if fontconfig is used.
|
||||||
|
* \param update whether fontconfig cache should be built/updated now. Only
|
||||||
|
* relevant if fontconfig is used.
|
||||||
|
*/
|
||||||
|
void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
||||||
|
const char *default_family, int fc, const char *config,
|
||||||
|
int update);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Update/build font cache. This needs to be called if it was
|
||||||
|
* disabled when ass_set_fonts was set.
|
||||||
|
*
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \return success
|
||||||
|
*/
|
||||||
|
int ass_fonts_update(ASS_Renderer *priv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set hard cache limits. Do not set, or set to zero, for reasonable
|
||||||
|
* defaults.
|
||||||
|
*
|
||||||
|
* \param priv renderer handle
|
||||||
|
* \param glyph_max maximum number of cached glyphs
|
||||||
|
* \param bitmap_max_size maximum bitmap cache size (in MB)
|
||||||
|
*/
|
||||||
|
void ass_set_cache_limits(ASS_Renderer *priv, int glyph_max,
|
||||||
|
int bitmap_max_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Render a frame, producing a list of ASS_Image.
|
||||||
|
* \param priv renderer handle
|
||||||
* \param track subtitle track
|
* \param track subtitle track
|
||||||
* \param now video timestamp in milliseconds
|
* \param now video timestamp in milliseconds
|
||||||
|
* \param detect_change will be set to 1 if a change occured compared
|
||||||
|
* to the last invocation
|
||||||
*/
|
*/
|
||||||
ass_image_t *ass_render_frame(ass_renderer_t *priv, ass_track_t *track,
|
ASS_Image *ass_render_frame(ASS_Renderer *priv, ASS_Track *track,
|
||||||
long long now, int *detect_change);
|
long long now, int *detect_change);
|
||||||
|
|
||||||
|
|
||||||
// The following functions operate on track objects and do not need an ass_renderer //
|
/*
|
||||||
|
* The following functions operate on track objects and do not need
|
||||||
|
* an ass_renderer
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief allocate a new empty track object
|
* \brief Allocate a new empty track object.
|
||||||
|
* \param library handle
|
||||||
* \return pointer to empty track
|
* \return pointer to empty track
|
||||||
*/
|
*/
|
||||||
ass_track_t *ass_new_track(ass_library_t *);
|
ASS_Track *ass_new_track(ASS_Library *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief deallocate track and all its child objects (styles and events)
|
* \brief Deallocate track and all its child objects (styles and events).
|
||||||
* \param track track to deallocate
|
* \param track track to deallocate
|
||||||
*/
|
*/
|
||||||
void ass_free_track(ass_track_t *track);
|
void ass_free_track(ASS_Track *track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief allocate new style
|
* \brief Allocate new style.
|
||||||
* \param track track
|
* \param track track
|
||||||
* \return newly allocated style id
|
* \return newly allocated style id
|
||||||
*/
|
*/
|
||||||
int ass_alloc_style(ass_track_t *track);
|
int ass_alloc_style(ASS_Track *track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief allocate new event
|
* \brief Allocate new event.
|
||||||
* \param track track
|
* \param track track
|
||||||
* \return newly allocated event id
|
* \return newly allocated event id
|
||||||
*/
|
*/
|
||||||
int ass_alloc_event(ass_track_t *track);
|
int ass_alloc_event(ASS_Track *track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief delete a style
|
* \brief Delete a style.
|
||||||
* \param track track
|
* \param track track
|
||||||
* \param sid style id
|
* \param sid style id
|
||||||
* Deallocates style data. Does not modify track->n_styles.
|
* Deallocates style data. Does not modify track->n_styles.
|
||||||
*/
|
*/
|
||||||
void ass_free_style(ass_track_t *track, int sid);
|
void ass_free_style(ASS_Track *track, int sid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief delete an event
|
* \brief Delete an event.
|
||||||
* \param track track
|
* \param track track
|
||||||
* \param eid event id
|
* \param eid event id
|
||||||
* Deallocates event data. Does not modify track->n_events.
|
* Deallocates event data. Does not modify track->n_events.
|
||||||
*/
|
*/
|
||||||
void ass_free_event(ass_track_t *track, int eid);
|
void ass_free_event(ASS_Track *track, int eid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Parse a chunk of subtitle stream data.
|
* \brief Parse a chunk of subtitle stream data.
|
||||||
|
@ -164,73 +291,81 @@ void ass_free_event(ass_track_t *track, int eid);
|
||||||
* \param data string to parse
|
* \param data string to parse
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
*/
|
*/
|
||||||
void ass_process_data(ass_track_t *track, char *data, int size);
|
void ass_process_data(ASS_Track *track, char *data, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Parse Codec Private section of subtitle stream
|
* \brief Parse Codec Private section of subtitle stream.
|
||||||
* \param track target track
|
* \param track target track
|
||||||
* \param data string to parse
|
* \param data string to parse
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
*/
|
*/
|
||||||
void ass_process_codec_private(ass_track_t *track, char *data, int size);
|
void ass_process_codec_private(ASS_Track *track, char *data, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Parse a chunk of subtitle stream data. In Matroska, this contains exactly 1 event (or a commentary).
|
* \brief Parse a chunk of subtitle stream data. In Matroska,
|
||||||
|
* this contains exactly 1 event (or a commentary).
|
||||||
* \param track track
|
* \param track track
|
||||||
* \param data string to parse
|
* \param data string to parse
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
* \param timecode starting time of the event (milliseconds)
|
* \param timecode starting time of the event (milliseconds)
|
||||||
* \param duration duration of the event (milliseconds)
|
* \param duration duration of the event (milliseconds)
|
||||||
*/
|
*/
|
||||||
void ass_process_chunk(ass_track_t *track, char *data, int size,
|
void ass_process_chunk(ASS_Track *track, char *data, int size,
|
||||||
long long timecode, long long duration);
|
long long timecode, long long duration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Read subtitles from file.
|
* \brief Read subtitles from file.
|
||||||
|
* \param library library handle
|
||||||
* \param fname file name
|
* \param fname file name
|
||||||
|
* \param codepage encoding (iconv format)
|
||||||
* \return newly allocated track
|
* \return newly allocated track
|
||||||
*/
|
*/
|
||||||
ass_track_t *ass_read_file(ass_library_t *library, char *fname,
|
ASS_Track *ass_read_file(ASS_Library *library, char *fname,
|
||||||
char *codepage);
|
char *codepage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Read subtitles from memory.
|
* \brief Read subtitles from memory.
|
||||||
* \param library libass library object
|
* \param library library handle
|
||||||
* \param buf pointer to subtitles text
|
* \param buf pointer to subtitles text
|
||||||
* \param bufsize size of buffer
|
* \param bufsize size of buffer
|
||||||
* \param codepage recode buffer contents from given codepage
|
* \param codepage encoding (iconv format)
|
||||||
* \return newly allocated track
|
* \return newly allocated track
|
||||||
*/
|
*/
|
||||||
ass_track_t *ass_read_memory(ass_library_t *library, char *buf,
|
ASS_Track *ass_read_memory(ASS_Library *library, char *buf,
|
||||||
size_t bufsize, char *codepage);
|
size_t bufsize, char *codepage);
|
||||||
/**
|
/**
|
||||||
* \brief read styles from file into already initialized track
|
* \brief Read styles from file into already initialized track.
|
||||||
|
* \param fname file name
|
||||||
|
* \param codepage encoding (iconv format)
|
||||||
* \return 0 on success
|
* \return 0 on success
|
||||||
*/
|
*/
|
||||||
int ass_read_styles(ass_track_t *track, char *fname, char *codepage);
|
int ass_read_styles(ASS_Track *track, char *fname, char *codepage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Add a memory font.
|
* \brief Add a memory font.
|
||||||
|
* \param library library handle
|
||||||
* \param name attachment name
|
* \param name attachment name
|
||||||
* \param data binary font data
|
* \param data binary font data
|
||||||
* \param data_size data size
|
* \param data_size data size
|
||||||
*/
|
*/
|
||||||
void ass_add_font(ass_library_t *library, char *name, char *data,
|
void ass_add_font(ASS_Library *library, char *name, char *data,
|
||||||
int data_size);
|
int data_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Remove all fonts stored in ass_library object
|
* \brief Remove all fonts stored in an ass_library object.
|
||||||
|
* \param library library handle
|
||||||
*/
|
*/
|
||||||
void ass_clear_fonts(ass_library_t *library);
|
void ass_clear_fonts(ASS_Library *library);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Calculates timeshift from now to the start of some other subtitle event, depending on movement parameter
|
* \brief Calculates timeshift from now to the start of some other subtitle
|
||||||
|
* event, depending on movement parameter.
|
||||||
* \param track subtitle track
|
* \param track subtitle track
|
||||||
* \param now current time, ms
|
* \param now current time in milliseconds
|
||||||
* \param movement how many events to skip from the one currently displayed
|
* \param movement how many events to skip from the one currently displayed
|
||||||
* +2 means "the one after the next", -1 means "previous"
|
* +2 means "the one after the next", -1 means "previous"
|
||||||
* \return timeshift, ms
|
* \return timeshift in milliseconds
|
||||||
*/
|
*/
|
||||||
long long ass_step_sub(ass_track_t *track, long long now, int movement);
|
long long ass_step_sub(ASS_Track *track, long long now, int movement);
|
||||||
|
|
||||||
#endif /* LIBASS_ASS_H */
|
#endif /* LIBASS_ASS_H */
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "ass_utils.h"
|
#include "ass_utils.h"
|
||||||
#include "ass_bitmap.h"
|
#include "ass_bitmap.h"
|
||||||
|
|
||||||
struct ass_synth_priv_s {
|
struct ass_synth_priv {
|
||||||
int tmp_w, tmp_h;
|
int tmp_w, tmp_h;
|
||||||
unsigned short *tmp;
|
unsigned short *tmp;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ struct ass_synth_priv_s {
|
||||||
static const unsigned int maxcolor = 255;
|
static const unsigned int maxcolor = 255;
|
||||||
static const unsigned base = 256;
|
static const unsigned base = 256;
|
||||||
|
|
||||||
static int generate_tables(ass_synth_priv_t *priv, double radius)
|
static int generate_tables(ASS_SynthPriv *priv, double radius)
|
||||||
{
|
{
|
||||||
double A = log(1.0 / base) / (radius * radius * 2);
|
double A = log(1.0 / base) / (radius * radius * 2);
|
||||||
int mx, i;
|
int mx, i;
|
||||||
|
@ -101,7 +101,7 @@ static int generate_tables(ass_synth_priv_t *priv, double radius)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resize_tmp(ass_synth_priv_t *priv, int w, int h)
|
static void resize_tmp(ASS_SynthPriv *priv, int w, int h)
|
||||||
{
|
{
|
||||||
if (priv->tmp_w >= w && priv->tmp_h >= h)
|
if (priv->tmp_w >= w && priv->tmp_h >= h)
|
||||||
return;
|
return;
|
||||||
|
@ -118,14 +118,14 @@ static void resize_tmp(ass_synth_priv_t *priv, int w, int h)
|
||||||
priv->tmp = malloc((priv->tmp_w + 1) * priv->tmp_h * sizeof(short));
|
priv->tmp = malloc((priv->tmp_w + 1) * priv->tmp_h * sizeof(short));
|
||||||
}
|
}
|
||||||
|
|
||||||
ass_synth_priv_t *ass_synth_init(double radius)
|
ASS_SynthPriv *ass_synth_init(double radius)
|
||||||
{
|
{
|
||||||
ass_synth_priv_t *priv = calloc(1, sizeof(ass_synth_priv_t));
|
ASS_SynthPriv *priv = calloc(1, sizeof(ASS_SynthPriv));
|
||||||
generate_tables(priv, radius);
|
generate_tables(priv, radius);
|
||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_synth_done(ass_synth_priv_t *priv)
|
void ass_synth_done(ASS_SynthPriv *priv)
|
||||||
{
|
{
|
||||||
if (priv->tmp)
|
if (priv->tmp)
|
||||||
free(priv->tmp);
|
free(priv->tmp);
|
||||||
|
@ -136,10 +136,10 @@ void ass_synth_done(ass_synth_priv_t *priv)
|
||||||
free(priv);
|
free(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bitmap_t *alloc_bitmap(int w, int h)
|
static Bitmap *alloc_bitmap(int w, int h)
|
||||||
{
|
{
|
||||||
bitmap_t *bm;
|
Bitmap *bm;
|
||||||
bm = calloc(1, sizeof(bitmap_t));
|
bm = calloc(1, sizeof(Bitmap));
|
||||||
bm->buffer = malloc(w * h);
|
bm->buffer = malloc(w * h);
|
||||||
bm->w = w;
|
bm->w = w;
|
||||||
bm->h = h;
|
bm->h = h;
|
||||||
|
@ -147,7 +147,7 @@ static bitmap_t *alloc_bitmap(int w, int h)
|
||||||
return bm;
|
return bm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_free_bitmap(bitmap_t *bm)
|
void ass_free_bitmap(Bitmap *bm)
|
||||||
{
|
{
|
||||||
if (bm) {
|
if (bm) {
|
||||||
if (bm->buffer)
|
if (bm->buffer)
|
||||||
|
@ -156,16 +156,16 @@ void ass_free_bitmap(bitmap_t *bm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bitmap_t *copy_bitmap(const bitmap_t *src)
|
static Bitmap *copy_bitmap(const Bitmap *src)
|
||||||
{
|
{
|
||||||
bitmap_t *dst = alloc_bitmap(src->w, src->h);
|
Bitmap *dst = alloc_bitmap(src->w, src->h);
|
||||||
dst->left = src->left;
|
dst->left = src->left;
|
||||||
dst->top = src->top;
|
dst->top = src->top;
|
||||||
memcpy(dst->buffer, src->buffer, src->w * src->h);
|
memcpy(dst->buffer, src->buffer, src->w * src->h);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_glyph_area(ass_library_t *library, FT_Glyph glyph)
|
static int check_glyph_area(ASS_Library *library, FT_Glyph glyph)
|
||||||
{
|
{
|
||||||
FT_BBox bbox;
|
FT_BBox bbox;
|
||||||
long long dx, dy;
|
long long dx, dy;
|
||||||
|
@ -180,12 +180,12 @@ static int check_glyph_area(ass_library_t *library, FT_Glyph glyph)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bitmap_t *glyph_to_bitmap_internal(ass_library_t *library,
|
static Bitmap *glyph_to_bitmap_internal(ASS_Library *library,
|
||||||
FT_Glyph glyph, int bord)
|
FT_Glyph glyph, int bord)
|
||||||
{
|
{
|
||||||
FT_BitmapGlyph bg;
|
FT_BitmapGlyph bg;
|
||||||
FT_Bitmap *bit;
|
FT_Bitmap *bit;
|
||||||
bitmap_t *bm;
|
Bitmap *bm;
|
||||||
int w, h;
|
int w, h;
|
||||||
unsigned char *src;
|
unsigned char *src;
|
||||||
unsigned char *dst;
|
unsigned char *dst;
|
||||||
|
@ -235,7 +235,7 @@ static bitmap_t *glyph_to_bitmap_internal(ass_library_t *library,
|
||||||
* 1. Glyph bitmap is subtracted from outline bitmap. This way looks much better in some cases.
|
* 1. Glyph bitmap is subtracted from outline bitmap. This way looks much better in some cases.
|
||||||
* 2. Shadow bitmap is created as a sum of glyph and outline bitmaps.
|
* 2. Shadow bitmap is created as a sum of glyph and outline bitmaps.
|
||||||
*/
|
*/
|
||||||
static bitmap_t *fix_outline_and_shadow(bitmap_t *bm_g, bitmap_t *bm_o)
|
static Bitmap *fix_outline_and_shadow(Bitmap *bm_g, Bitmap *bm_o)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
const int l = bm_o->left > bm_g->left ? bm_o->left : bm_g->left;
|
const int l = bm_o->left > bm_g->left ? bm_o->left : bm_g->left;
|
||||||
|
@ -247,7 +247,7 @@ static bitmap_t *fix_outline_and_shadow(bitmap_t *bm_g, bitmap_t *bm_o)
|
||||||
bm_o->top + bm_o->h <
|
bm_o->top + bm_o->h <
|
||||||
bm_g->top + bm_g->h ? bm_o->top + bm_o->h : bm_g->top + bm_g->h;
|
bm_g->top + bm_g->h ? bm_o->top + bm_o->h : bm_g->top + bm_g->h;
|
||||||
|
|
||||||
bitmap_t *bm_s = copy_bitmap(bm_o);
|
Bitmap *bm_s = copy_bitmap(bm_o);
|
||||||
|
|
||||||
unsigned char *g =
|
unsigned char *g =
|
||||||
bm_g->buffer + (t - bm_g->top) * bm_g->w + (l - bm_g->left);
|
bm_g->buffer + (t - bm_g->top) * bm_g->w + (l - bm_g->left);
|
||||||
|
@ -261,7 +261,7 @@ static bitmap_t *fix_outline_and_shadow(bitmap_t *bm_g, bitmap_t *bm_o)
|
||||||
unsigned char c_g, c_o;
|
unsigned char c_g, c_o;
|
||||||
c_g = g[x];
|
c_g = g[x];
|
||||||
c_o = o[x];
|
c_o = o[x];
|
||||||
o[x] = (c_o > (3 * c_g) / 5) ? c_o - (3 * c_g) / 5 : 0;
|
o[x] = (c_o > c_g) ? c_o - (c_g / 2) : 0;
|
||||||
s[x] = (c_o < 0xFF - c_g) ? c_o + c_g : 0xFF;
|
s[x] = (c_o < 0xFF - c_g) ? c_o + c_g : 0xFF;
|
||||||
}
|
}
|
||||||
g += bm_g->w;
|
g += bm_g->w;
|
||||||
|
@ -472,10 +472,11 @@ static void be_blur(unsigned char *buf, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int glyph_to_bitmap(ass_library_t *library, ass_synth_priv_t *priv_blur,
|
int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
|
||||||
FT_Glyph glyph, FT_Glyph outline_glyph,
|
FT_Glyph glyph, FT_Glyph outline_glyph,
|
||||||
bitmap_t **bm_g, bitmap_t **bm_o, bitmap_t **bm_s,
|
Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s,
|
||||||
int be, double blur_radius, FT_Vector shadow_offset)
|
int be, double blur_radius, FT_Vector shadow_offset,
|
||||||
|
int border_style)
|
||||||
{
|
{
|
||||||
blur_radius *= 2;
|
blur_radius *= 2;
|
||||||
int bbord = be > 0 ? sqrt(2 * be) : 0;
|
int bbord = be > 0 ? sqrt(2 * be) : 0;
|
||||||
|
@ -496,7 +497,6 @@ int glyph_to_bitmap(ass_library_t *library, ass_synth_priv_t *priv_blur,
|
||||||
if (outline_glyph) {
|
if (outline_glyph) {
|
||||||
*bm_o = glyph_to_bitmap_internal(library, outline_glyph, bord);
|
*bm_o = glyph_to_bitmap_internal(library, outline_glyph, bord);
|
||||||
if (!*bm_o) {
|
if (!*bm_o) {
|
||||||
ass_free_bitmap(*bm_g);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,9 @@ int glyph_to_bitmap(ass_library_t *library, ass_synth_priv_t *priv_blur,
|
||||||
priv_blur->g_w);
|
priv_blur->g_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*bm_o)
|
if (*bm_o && border_style == 3)
|
||||||
|
*bm_s = copy_bitmap(*bm_o);
|
||||||
|
else if (*bm_o)
|
||||||
*bm_s = fix_outline_and_shadow(*bm_g, *bm_o);
|
*bm_s = fix_outline_and_shadow(*bm_g, *bm_o);
|
||||||
else
|
else
|
||||||
*bm_s = copy_bitmap(*bm_g);
|
*bm_s = copy_bitmap(*bm_g);
|
||||||
|
|
|
@ -26,16 +26,16 @@
|
||||||
|
|
||||||
#include "ass.h"
|
#include "ass.h"
|
||||||
|
|
||||||
typedef struct ass_synth_priv_s ass_synth_priv_t;
|
typedef struct ass_synth_priv ASS_SynthPriv;
|
||||||
|
|
||||||
ass_synth_priv_t *ass_synth_init(double);
|
ASS_SynthPriv *ass_synth_init(double);
|
||||||
void ass_synth_done(ass_synth_priv_t *priv);
|
void ass_synth_done(ASS_SynthPriv *priv);
|
||||||
|
|
||||||
typedef struct bitmap_s {
|
typedef struct {
|
||||||
int left, top;
|
int left, top;
|
||||||
int w, h; // width, height
|
int w, h; // width, height
|
||||||
unsigned char *buffer; // w x h buffer
|
unsigned char *buffer; // w x h buffer
|
||||||
} bitmap_t;
|
} Bitmap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief perform glyph rendering
|
* \brief perform glyph rendering
|
||||||
|
@ -46,11 +46,12 @@ typedef struct bitmap_s {
|
||||||
* \param bm_g out: pointer to the bitmap of glyph shadow is returned here
|
* \param bm_g out: pointer to the bitmap of glyph shadow is returned here
|
||||||
* \param be 1 = produces blurred bitmaps, 0 = normal bitmaps
|
* \param be 1 = produces blurred bitmaps, 0 = normal bitmaps
|
||||||
*/
|
*/
|
||||||
int glyph_to_bitmap(ass_library_t *library, ass_synth_priv_t *priv_blur,
|
int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
|
||||||
FT_Glyph glyph, FT_Glyph outline_glyph,
|
FT_Glyph glyph, FT_Glyph outline_glyph,
|
||||||
bitmap_t **bm_g, bitmap_t **bm_o, bitmap_t **bm_s,
|
Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s,
|
||||||
int be, double blur_radius, FT_Vector shadow_offset);
|
int be, double blur_radius, FT_Vector shadow_offset,
|
||||||
|
int border_style);
|
||||||
|
|
||||||
void ass_free_bitmap(bitmap_t *bm);
|
void ass_free_bitmap(Bitmap *bm);
|
||||||
|
|
||||||
#endif /* LIBASS_BITMAP_H */
|
#endif /* LIBASS_BITMAP_H */
|
||||||
|
|
|
@ -51,13 +51,13 @@ static void hashmap_item_dtor(void *key, size_t key_size, void *value,
|
||||||
free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *hashmap_init(ass_library_t *library, size_t key_size,
|
Hashmap *hashmap_init(ASS_Library *library, size_t key_size,
|
||||||
size_t value_size, int nbuckets,
|
size_t value_size, int nbuckets,
|
||||||
hashmap_item_dtor_t item_dtor,
|
HashmapItemDtor item_dtor,
|
||||||
hashmap_key_compare_t key_compare,
|
HashmapKeyCompare key_compare,
|
||||||
hashmap_hash_t hash)
|
HashmapHash hash)
|
||||||
{
|
{
|
||||||
hashmap_t *map = calloc(1, sizeof(hashmap_t));
|
Hashmap *map = calloc(1, sizeof(Hashmap));
|
||||||
map->library = library;
|
map->library = library;
|
||||||
map->nbuckets = nbuckets;
|
map->nbuckets = nbuckets;
|
||||||
map->key_size = key_size;
|
map->key_size = key_size;
|
||||||
|
@ -69,7 +69,7 @@ hashmap_t *hashmap_init(ass_library_t *library, size_t key_size,
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hashmap_done(hashmap_t *map)
|
void hashmap_done(Hashmap *map)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
// print stats
|
// print stats
|
||||||
|
@ -81,9 +81,9 @@ void hashmap_done(hashmap_t *map)
|
||||||
map->miss_count, map->count);
|
map->miss_count, map->count);
|
||||||
|
|
||||||
for (i = 0; i < map->nbuckets; ++i) {
|
for (i = 0; i < map->nbuckets; ++i) {
|
||||||
hashmap_item_t *item = map->root[i];
|
HashmapItem *item = map->root[i];
|
||||||
while (item) {
|
while (item) {
|
||||||
hashmap_item_t *next = item->next;
|
HashmapItem *next = item->next;
|
||||||
map->item_dtor(item->key, map->key_size, item->value,
|
map->item_dtor(item->key, map->key_size, item->value,
|
||||||
map->value_size);
|
map->value_size);
|
||||||
free(item);
|
free(item);
|
||||||
|
@ -95,17 +95,17 @@ void hashmap_done(hashmap_t *map)
|
||||||
}
|
}
|
||||||
|
|
||||||
// does nothing if key already exists
|
// does nothing if key already exists
|
||||||
void *hashmap_insert(hashmap_t *map, void *key, void *value)
|
void *hashmap_insert(Hashmap *map, void *key, void *value)
|
||||||
{
|
{
|
||||||
unsigned hash = map->hash(key, map->key_size);
|
unsigned hash = map->hash(key, map->key_size);
|
||||||
hashmap_item_t **next = map->root + (hash % map->nbuckets);
|
HashmapItem **next = map->root + (hash % map->nbuckets);
|
||||||
while (*next) {
|
while (*next) {
|
||||||
if (map->key_compare(key, (*next)->key, map->key_size))
|
if (map->key_compare(key, (*next)->key, map->key_size))
|
||||||
return (*next)->value;
|
return (*next)->value;
|
||||||
next = &((*next)->next);
|
next = &((*next)->next);
|
||||||
assert(next);
|
assert(next);
|
||||||
}
|
}
|
||||||
(*next) = malloc(sizeof(hashmap_item_t));
|
(*next) = malloc(sizeof(HashmapItem));
|
||||||
(*next)->key = malloc(map->key_size);
|
(*next)->key = malloc(map->key_size);
|
||||||
(*next)->value = malloc(map->value_size);
|
(*next)->value = malloc(map->value_size);
|
||||||
memcpy((*next)->key, key, map->key_size);
|
memcpy((*next)->key, key, map->key_size);
|
||||||
|
@ -116,10 +116,10 @@ void *hashmap_insert(hashmap_t *map, void *key, void *value)
|
||||||
return (*next)->value;
|
return (*next)->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *hashmap_find(hashmap_t *map, void *key)
|
void *hashmap_find(Hashmap *map, void *key)
|
||||||
{
|
{
|
||||||
unsigned hash = map->hash(key, map->key_size);
|
unsigned hash = map->hash(key, map->key_size);
|
||||||
hashmap_item_t *item = map->root[hash % map->nbuckets];
|
HashmapItem *item = map->root[hash % map->nbuckets];
|
||||||
while (item) {
|
while (item) {
|
||||||
if (map->key_compare(key, item->key, map->key_size)) {
|
if (map->key_compare(key, item->key, map->key_size)) {
|
||||||
map->hit_count++;
|
map->hit_count++;
|
||||||
|
@ -136,7 +136,7 @@ void *hashmap_find(hashmap_t *map, void *key)
|
||||||
|
|
||||||
static unsigned font_desc_hash(void *buf, size_t len)
|
static unsigned font_desc_hash(void *buf, size_t len)
|
||||||
{
|
{
|
||||||
ass_font_desc_t *desc = buf;
|
ASS_FontDesc *desc = buf;
|
||||||
unsigned hval;
|
unsigned hval;
|
||||||
hval = fnv_32a_str(desc->family, FNV1_32A_INIT);
|
hval = fnv_32a_str(desc->family, FNV1_32A_INIT);
|
||||||
hval = fnv_32a_buf(&desc->bold, sizeof(desc->bold), hval);
|
hval = fnv_32a_buf(&desc->bold, sizeof(desc->bold), hval);
|
||||||
|
@ -146,8 +146,8 @@ static unsigned font_desc_hash(void *buf, size_t len)
|
||||||
|
|
||||||
static int font_compare(void *key1, void *key2, size_t key_size)
|
static int font_compare(void *key1, void *key2, size_t key_size)
|
||||||
{
|
{
|
||||||
ass_font_desc_t *a = key1;
|
ASS_FontDesc *a = key1;
|
||||||
ass_font_desc_t *b = key2;
|
ASS_FontDesc *b = key2;
|
||||||
if (strcmp(a->family, b->family) != 0)
|
if (strcmp(a->family, b->family) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (a->bold != b->bold)
|
if (a->bold != b->bold)
|
||||||
|
@ -166,8 +166,8 @@ static void font_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
free(key);
|
free(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
ass_font_t *ass_font_cache_find(hashmap_t *font_cache,
|
ASS_Font *ass_font_cache_find(Hashmap *font_cache,
|
||||||
ass_font_desc_t *desc)
|
ASS_FontDesc *desc)
|
||||||
{
|
{
|
||||||
return hashmap_find(font_cache, desc);
|
return hashmap_find(font_cache, desc);
|
||||||
}
|
}
|
||||||
|
@ -176,22 +176,22 @@ ass_font_t *ass_font_cache_find(hashmap_t *font_cache,
|
||||||
* \brief Add a face struct to cache.
|
* \brief Add a face struct to cache.
|
||||||
* \param font font struct
|
* \param font font struct
|
||||||
*/
|
*/
|
||||||
void *ass_font_cache_add(hashmap_t *font_cache, ass_font_t *font)
|
void *ass_font_cache_add(Hashmap *font_cache, ASS_Font *font)
|
||||||
{
|
{
|
||||||
return hashmap_insert(font_cache, &(font->desc), font);
|
return hashmap_insert(font_cache, &(font->desc), font);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_font_cache_init(ass_library_t *library)
|
Hashmap *ass_font_cache_init(ASS_Library *library)
|
||||||
{
|
{
|
||||||
hashmap_t *font_cache;
|
Hashmap *font_cache;
|
||||||
font_cache = hashmap_init(library, sizeof(ass_font_desc_t),
|
font_cache = hashmap_init(library, sizeof(ASS_FontDesc),
|
||||||
sizeof(ass_font_t),
|
sizeof(ASS_Font),
|
||||||
1000,
|
1000,
|
||||||
font_hash_dtor, font_compare, font_desc_hash);
|
font_hash_dtor, font_compare, font_desc_hash);
|
||||||
return font_cache;
|
return font_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_font_cache_done(hashmap_t *font_cache)
|
void ass_font_cache_done(Hashmap *font_cache)
|
||||||
{
|
{
|
||||||
hashmap_done(font_cache);
|
hashmap_done(font_cache);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ void ass_font_cache_done(hashmap_t *font_cache)
|
||||||
static void bitmap_hash_dtor(void *key, size_t key_size, void *value,
|
static void bitmap_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
size_t value_size)
|
size_t value_size)
|
||||||
{
|
{
|
||||||
bitmap_hash_val_t *v = value;
|
BitmapHashValue *v = value;
|
||||||
if (v->bm)
|
if (v->bm)
|
||||||
ass_free_bitmap(v->bm);
|
ass_free_bitmap(v->bm);
|
||||||
if (v->bm_o)
|
if (v->bm_o)
|
||||||
|
@ -220,9 +220,15 @@ static void bitmap_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cache_add_bitmap(hashmap_t *bitmap_cache, bitmap_hash_key_t *key,
|
void *cache_add_bitmap(Hashmap *bitmap_cache, BitmapHashKey *key,
|
||||||
bitmap_hash_val_t *val)
|
BitmapHashValue *val)
|
||||||
{
|
{
|
||||||
|
// Note: this is only an approximation
|
||||||
|
if (val->bm_o)
|
||||||
|
bitmap_cache->cache_size += val->bm_o->w * val->bm_o->h * 3;
|
||||||
|
else if (val->bm)
|
||||||
|
bitmap_cache->cache_size += val->bm->w * val->bm->h * 3;
|
||||||
|
|
||||||
return hashmap_insert(bitmap_cache, key, val);
|
return hashmap_insert(bitmap_cache, key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,32 +237,32 @@ void *cache_add_bitmap(hashmap_t *bitmap_cache, bitmap_hash_key_t *key,
|
||||||
* \param key hash key
|
* \param key hash key
|
||||||
* \return requested hash val or 0 if not found
|
* \return requested hash val or 0 if not found
|
||||||
*/
|
*/
|
||||||
bitmap_hash_val_t *cache_find_bitmap(hashmap_t *bitmap_cache,
|
BitmapHashValue *cache_find_bitmap(Hashmap *bitmap_cache,
|
||||||
bitmap_hash_key_t *key)
|
BitmapHashKey *key)
|
||||||
{
|
{
|
||||||
return hashmap_find(bitmap_cache, key);
|
return hashmap_find(bitmap_cache, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_bitmap_cache_init(ass_library_t *library)
|
Hashmap *ass_bitmap_cache_init(ASS_Library *library)
|
||||||
{
|
{
|
||||||
hashmap_t *bitmap_cache;
|
Hashmap *bitmap_cache;
|
||||||
bitmap_cache = hashmap_init(library,
|
bitmap_cache = hashmap_init(library,
|
||||||
sizeof(bitmap_hash_key_t),
|
sizeof(BitmapHashKey),
|
||||||
sizeof(bitmap_hash_val_t),
|
sizeof(BitmapHashValue),
|
||||||
0xFFFF + 13,
|
0xFFFF + 13,
|
||||||
bitmap_hash_dtor, bitmap_compare,
|
bitmap_hash_dtor, bitmap_compare,
|
||||||
bitmap_hash);
|
bitmap_hash);
|
||||||
return bitmap_cache;
|
return bitmap_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_bitmap_cache_done(hashmap_t *bitmap_cache)
|
void ass_bitmap_cache_done(Hashmap *bitmap_cache)
|
||||||
{
|
{
|
||||||
hashmap_done(bitmap_cache);
|
hashmap_done(bitmap_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_bitmap_cache_reset(hashmap_t *bitmap_cache)
|
Hashmap *ass_bitmap_cache_reset(Hashmap *bitmap_cache)
|
||||||
{
|
{
|
||||||
ass_library_t *lib = bitmap_cache->library;
|
ASS_Library *lib = bitmap_cache->library;
|
||||||
|
|
||||||
ass_bitmap_cache_done(bitmap_cache);
|
ass_bitmap_cache_done(bitmap_cache);
|
||||||
return ass_bitmap_cache_init(lib);
|
return ass_bitmap_cache_init(lib);
|
||||||
|
@ -268,7 +274,7 @@ hashmap_t *ass_bitmap_cache_reset(hashmap_t *bitmap_cache)
|
||||||
static void glyph_hash_dtor(void *key, size_t key_size, void *value,
|
static void glyph_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
size_t value_size)
|
size_t value_size)
|
||||||
{
|
{
|
||||||
glyph_hash_val_t *v = value;
|
GlyphHashValue *v = value;
|
||||||
if (v->glyph)
|
if (v->glyph)
|
||||||
FT_Done_Glyph(v->glyph);
|
FT_Done_Glyph(v->glyph);
|
||||||
if (v->outline_glyph)
|
if (v->outline_glyph)
|
||||||
|
@ -277,8 +283,8 @@ static void glyph_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cache_add_glyph(hashmap_t *glyph_cache, glyph_hash_key_t *key,
|
void *cache_add_glyph(Hashmap *glyph_cache, GlyphHashKey *key,
|
||||||
glyph_hash_val_t *val)
|
GlyphHashValue *val)
|
||||||
{
|
{
|
||||||
return hashmap_insert(glyph_cache, key, val);
|
return hashmap_insert(glyph_cache, key, val);
|
||||||
}
|
}
|
||||||
|
@ -288,30 +294,30 @@ void *cache_add_glyph(hashmap_t *glyph_cache, glyph_hash_key_t *key,
|
||||||
* \param key hash key
|
* \param key hash key
|
||||||
* \return requested hash val or 0 if not found
|
* \return requested hash val or 0 if not found
|
||||||
*/
|
*/
|
||||||
glyph_hash_val_t *cache_find_glyph(hashmap_t *glyph_cache,
|
GlyphHashValue *cache_find_glyph(Hashmap *glyph_cache,
|
||||||
glyph_hash_key_t *key)
|
GlyphHashKey *key)
|
||||||
{
|
{
|
||||||
return hashmap_find(glyph_cache, key);
|
return hashmap_find(glyph_cache, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_glyph_cache_init(ass_library_t *library)
|
Hashmap *ass_glyph_cache_init(ASS_Library *library)
|
||||||
{
|
{
|
||||||
hashmap_t *glyph_cache;
|
Hashmap *glyph_cache;
|
||||||
glyph_cache = hashmap_init(library, sizeof(glyph_hash_key_t),
|
glyph_cache = hashmap_init(library, sizeof(GlyphHashKey),
|
||||||
sizeof(glyph_hash_val_t),
|
sizeof(GlyphHashValue),
|
||||||
0xFFFF + 13,
|
0xFFFF + 13,
|
||||||
glyph_hash_dtor, glyph_compare, glyph_hash);
|
glyph_hash_dtor, glyph_compare, glyph_hash);
|
||||||
return glyph_cache;
|
return glyph_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_glyph_cache_done(hashmap_t *glyph_cache)
|
void ass_glyph_cache_done(Hashmap *glyph_cache)
|
||||||
{
|
{
|
||||||
hashmap_done(glyph_cache);
|
hashmap_done(glyph_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_glyph_cache_reset(hashmap_t *glyph_cache)
|
Hashmap *ass_glyph_cache_reset(Hashmap *glyph_cache)
|
||||||
{
|
{
|
||||||
ass_library_t *lib = glyph_cache->library;
|
ASS_Library *lib = glyph_cache->library;
|
||||||
|
|
||||||
ass_glyph_cache_done(glyph_cache);
|
ass_glyph_cache_done(glyph_cache);
|
||||||
return ass_glyph_cache_init(lib);
|
return ass_glyph_cache_init(lib);
|
||||||
|
@ -324,16 +330,16 @@ hashmap_t *ass_glyph_cache_reset(hashmap_t *glyph_cache)
|
||||||
static void composite_hash_dtor(void *key, size_t key_size, void *value,
|
static void composite_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
size_t value_size)
|
size_t value_size)
|
||||||
{
|
{
|
||||||
composite_hash_val_t *v = value;
|
CompositeHashValue *v = value;
|
||||||
free(v->a);
|
free(v->a);
|
||||||
free(v->b);
|
free(v->b);
|
||||||
free(key);
|
free(key);
|
||||||
free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cache_add_composite(hashmap_t *composite_cache,
|
void *cache_add_composite(Hashmap *composite_cache,
|
||||||
composite_hash_key_t *key,
|
CompositeHashKey *key,
|
||||||
composite_hash_val_t *val)
|
CompositeHashValue *val)
|
||||||
{
|
{
|
||||||
return hashmap_insert(composite_cache, key, val);
|
return hashmap_insert(composite_cache, key, val);
|
||||||
}
|
}
|
||||||
|
@ -343,31 +349,31 @@ void *cache_add_composite(hashmap_t *composite_cache,
|
||||||
* \param key hash key
|
* \param key hash key
|
||||||
* \return requested hash val or 0 if not found
|
* \return requested hash val or 0 if not found
|
||||||
*/
|
*/
|
||||||
composite_hash_val_t *cache_find_composite(hashmap_t *composite_cache,
|
CompositeHashValue *cache_find_composite(Hashmap *composite_cache,
|
||||||
composite_hash_key_t *key)
|
CompositeHashKey *key)
|
||||||
{
|
{
|
||||||
return hashmap_find(composite_cache, key);
|
return hashmap_find(composite_cache, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_composite_cache_init(ass_library_t *library)
|
Hashmap *ass_composite_cache_init(ASS_Library *library)
|
||||||
{
|
{
|
||||||
hashmap_t *composite_cache;
|
Hashmap *composite_cache;
|
||||||
composite_cache = hashmap_init(library, sizeof(composite_hash_key_t),
|
composite_cache = hashmap_init(library, sizeof(CompositeHashKey),
|
||||||
sizeof(composite_hash_val_t),
|
sizeof(CompositeHashValue),
|
||||||
0xFFFF + 13,
|
0xFFFF + 13,
|
||||||
composite_hash_dtor, composite_compare,
|
composite_hash_dtor, composite_compare,
|
||||||
composite_hash);
|
composite_hash);
|
||||||
return composite_cache;
|
return composite_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_composite_cache_done(hashmap_t *composite_cache)
|
void ass_composite_cache_done(Hashmap *composite_cache)
|
||||||
{
|
{
|
||||||
hashmap_done(composite_cache);
|
hashmap_done(composite_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashmap_t *ass_composite_cache_reset(hashmap_t *composite_cache)
|
Hashmap *ass_composite_cache_reset(Hashmap *composite_cache)
|
||||||
{
|
{
|
||||||
ass_library_t *lib = composite_cache->library;
|
ASS_Library *lib = composite_cache->library;
|
||||||
|
|
||||||
ass_composite_cache_done(composite_cache);
|
ass_composite_cache_done(composite_cache);
|
||||||
return ass_composite_cache_init(lib);
|
return ass_composite_cache_init(lib);
|
||||||
|
|
|
@ -25,94 +25,95 @@
|
||||||
#include "ass_font.h"
|
#include "ass_font.h"
|
||||||
#include "ass_bitmap.h"
|
#include "ass_bitmap.h"
|
||||||
|
|
||||||
typedef void (*hashmap_item_dtor_t) (void *key, size_t key_size,
|
typedef void (*HashmapItemDtor) (void *key, size_t key_size,
|
||||||
void *value, size_t value_size);
|
void *value, size_t value_size);
|
||||||
typedef int (*hashmap_key_compare_t) (void *key1, void *key2,
|
typedef int (*HashmapKeyCompare) (void *key1, void *key2,
|
||||||
size_t key_size);
|
size_t key_size);
|
||||||
typedef unsigned (*hashmap_hash_t) (void *key, size_t key_size);
|
typedef unsigned (*HashmapHash) (void *key, size_t key_size);
|
||||||
|
|
||||||
typedef struct hashmap_item_s {
|
typedef struct hashmap_item {
|
||||||
void *key;
|
void *key;
|
||||||
void *value;
|
void *value;
|
||||||
struct hashmap_item_s *next;
|
struct hashmap_item *next;
|
||||||
} hashmap_item_t;
|
} HashmapItem;
|
||||||
typedef hashmap_item_t *hashmap_item_p;
|
typedef HashmapItem *hashmap_item_p;
|
||||||
|
|
||||||
typedef struct hashmap_s {
|
typedef struct {
|
||||||
int nbuckets;
|
int nbuckets;
|
||||||
size_t key_size, value_size;
|
size_t key_size, value_size;
|
||||||
hashmap_item_p *root;
|
hashmap_item_p *root;
|
||||||
hashmap_item_dtor_t item_dtor; // a destructor for hashmap key/value pairs
|
HashmapItemDtor item_dtor; // a destructor for hashmap key/value pairs
|
||||||
hashmap_key_compare_t key_compare;
|
HashmapKeyCompare key_compare;
|
||||||
hashmap_hash_t hash;
|
HashmapHash hash;
|
||||||
|
size_t cache_size;
|
||||||
// stats
|
// stats
|
||||||
int hit_count;
|
int hit_count;
|
||||||
int miss_count;
|
int miss_count;
|
||||||
int count;
|
int count;
|
||||||
ass_library_t *library;
|
ASS_Library *library;
|
||||||
} hashmap_t;
|
} Hashmap;
|
||||||
|
|
||||||
hashmap_t *hashmap_init(ass_library_t *library, size_t key_size,
|
Hashmap *hashmap_init(ASS_Library *library, size_t key_size,
|
||||||
size_t value_size, int nbuckets,
|
size_t value_size, int nbuckets,
|
||||||
hashmap_item_dtor_t item_dtor,
|
HashmapItemDtor item_dtor,
|
||||||
hashmap_key_compare_t key_compare,
|
HashmapKeyCompare key_compare,
|
||||||
hashmap_hash_t hash);
|
HashmapHash hash);
|
||||||
void hashmap_done(hashmap_t *map);
|
void hashmap_done(Hashmap *map);
|
||||||
void *hashmap_insert(hashmap_t *map, void *key, void *value);
|
void *hashmap_insert(Hashmap *map, void *key, void *value);
|
||||||
void *hashmap_find(hashmap_t *map, void *key);
|
void *hashmap_find(Hashmap *map, void *key);
|
||||||
|
|
||||||
hashmap_t *ass_font_cache_init(ass_library_t *library);
|
Hashmap *ass_font_cache_init(ASS_Library *library);
|
||||||
ass_font_t *ass_font_cache_find(hashmap_t *, ass_font_desc_t *desc);
|
ASS_Font *ass_font_cache_find(Hashmap *, ASS_FontDesc *desc);
|
||||||
void *ass_font_cache_add(hashmap_t *, ass_font_t *font);
|
void *ass_font_cache_add(Hashmap *, ASS_Font *font);
|
||||||
void ass_font_cache_done(hashmap_t *);
|
void ass_font_cache_done(Hashmap *);
|
||||||
|
|
||||||
// Create definitions for bitmap_hash_key and glyph_hash_key
|
// Create definitions for bitmap_hash_key and glyph_hash_key
|
||||||
#define CREATE_STRUCT_DEFINITIONS
|
#define CREATE_STRUCT_DEFINITIONS
|
||||||
#include "ass_cache_template.h"
|
#include "ass_cache_template.h"
|
||||||
|
|
||||||
typedef struct bitmap_hash_val_s {
|
typedef struct {
|
||||||
bitmap_t *bm; // the actual bitmaps
|
Bitmap *bm; // the actual bitmaps
|
||||||
bitmap_t *bm_o;
|
Bitmap *bm_o;
|
||||||
bitmap_t *bm_s;
|
Bitmap *bm_s;
|
||||||
} bitmap_hash_val_t;
|
} BitmapHashValue;
|
||||||
|
|
||||||
hashmap_t *ass_bitmap_cache_init(ass_library_t *library);
|
Hashmap *ass_bitmap_cache_init(ASS_Library *library);
|
||||||
void *cache_add_bitmap(hashmap_t *, bitmap_hash_key_t *key,
|
void *cache_add_bitmap(Hashmap *, BitmapHashKey *key,
|
||||||
bitmap_hash_val_t *val);
|
BitmapHashValue *val);
|
||||||
bitmap_hash_val_t *cache_find_bitmap(hashmap_t *bitmap_cache,
|
BitmapHashValue *cache_find_bitmap(Hashmap *bitmap_cache,
|
||||||
bitmap_hash_key_t *key);
|
BitmapHashKey *key);
|
||||||
hashmap_t *ass_bitmap_cache_reset(hashmap_t *bitmap_cache);
|
Hashmap *ass_bitmap_cache_reset(Hashmap *bitmap_cache);
|
||||||
void ass_bitmap_cache_done(hashmap_t *bitmap_cache);
|
void ass_bitmap_cache_done(Hashmap *bitmap_cache);
|
||||||
|
|
||||||
|
|
||||||
typedef struct composite_hash_val_s {
|
typedef struct {
|
||||||
unsigned char *a;
|
unsigned char *a;
|
||||||
unsigned char *b;
|
unsigned char *b;
|
||||||
} composite_hash_val_t;
|
} CompositeHashValue;
|
||||||
|
|
||||||
hashmap_t *ass_composite_cache_init(ass_library_t *library);
|
Hashmap *ass_composite_cache_init(ASS_Library *library);
|
||||||
void *cache_add_composite(hashmap_t *, composite_hash_key_t *key,
|
void *cache_add_composite(Hashmap *, CompositeHashKey *key,
|
||||||
composite_hash_val_t *val);
|
CompositeHashValue *val);
|
||||||
composite_hash_val_t *cache_find_composite(hashmap_t *composite_cache,
|
CompositeHashValue *cache_find_composite(Hashmap *composite_cache,
|
||||||
composite_hash_key_t *key);
|
CompositeHashKey *key);
|
||||||
hashmap_t *ass_composite_cache_reset(hashmap_t *composite_cache);
|
Hashmap *ass_composite_cache_reset(Hashmap *composite_cache);
|
||||||
void ass_composite_cache_done(hashmap_t *composite_cache);
|
void ass_composite_cache_done(Hashmap *composite_cache);
|
||||||
|
|
||||||
|
|
||||||
typedef struct glyph_hash_val_s {
|
typedef struct {
|
||||||
FT_Glyph glyph;
|
FT_Glyph glyph;
|
||||||
FT_Glyph outline_glyph;
|
FT_Glyph outline_glyph;
|
||||||
FT_BBox bbox_scaled; // bbox after scaling, but before rotation
|
FT_BBox bbox_scaled; // bbox after scaling, but before rotation
|
||||||
FT_Vector advance; // 26.6, advance distance to the next bitmap in line
|
FT_Vector advance; // 26.6, advance distance to the next bitmap in line
|
||||||
int asc, desc; // ascender/descender of a drawing
|
int asc, desc; // ascender/descender of a drawing
|
||||||
} glyph_hash_val_t;
|
} GlyphHashValue;
|
||||||
|
|
||||||
hashmap_t *ass_glyph_cache_init(ass_library_t *library);
|
Hashmap *ass_glyph_cache_init(ASS_Library *library);
|
||||||
void *cache_add_glyph(hashmap_t *, glyph_hash_key_t *key,
|
void *cache_add_glyph(Hashmap *, GlyphHashKey *key,
|
||||||
glyph_hash_val_t *val);
|
GlyphHashValue *val);
|
||||||
glyph_hash_val_t *cache_find_glyph(hashmap_t *glyph_cache,
|
GlyphHashValue *cache_find_glyph(Hashmap *glyph_cache,
|
||||||
glyph_hash_key_t *key);
|
GlyphHashKey *key);
|
||||||
hashmap_t *ass_glyph_cache_reset(hashmap_t *glyph_cache);
|
Hashmap *ass_glyph_cache_reset(Hashmap *glyph_cache);
|
||||||
void ass_glyph_cache_done(hashmap_t *glyph_cache);
|
void ass_glyph_cache_done(Hashmap *glyph_cache);
|
||||||
|
|
||||||
#endif /* LIBASS_CACHE_H */
|
#endif /* LIBASS_CACHE_H */
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#define FTVECTOR(member) \
|
#define FTVECTOR(member) \
|
||||||
FT_Vector member;
|
FT_Vector member;
|
||||||
#define BITMAPHASHKEY(member) \
|
#define BITMAPHASHKEY(member) \
|
||||||
bitmap_hash_key_t member;
|
BitmapHashKey member;
|
||||||
#define END(typedefnamename) \
|
#define END(typedefnamename) \
|
||||||
} typedefnamename;
|
} typedefnamename;
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@
|
||||||
|
|
||||||
|
|
||||||
// describes a bitmap; bitmaps with equivalents structs are considered identical
|
// describes a bitmap; bitmaps with equivalents structs are considered identical
|
||||||
START(bitmap, bipmap_hash_key_s)
|
START(bitmap, bitmap_hash_key)
|
||||||
GENERIC(char, bitmap) // bool : true = bitmap, false = outline
|
GENERIC(char, bitmap) // bool : true = bitmap, false = outline
|
||||||
GENERIC(ass_font_t *, font)
|
GENERIC(ASS_Font *, font)
|
||||||
GENERIC(double, size) // font size
|
GENERIC(double, size) // font size
|
||||||
GENERIC(uint32_t, ch) // character code
|
GENERIC(uint32_t, ch) // character code
|
||||||
FTVECTOR(outline) // border width, 16.16 fixed point value
|
FTVECTOR(outline) // border width, 16.16 fixed point value
|
||||||
|
@ -79,25 +79,27 @@ START(bitmap, bipmap_hash_key_s)
|
||||||
FTVECTOR(advance) // subpixel shift vector
|
FTVECTOR(advance) // subpixel shift vector
|
||||||
FTVECTOR(shadow_offset) // shadow subpixel shift
|
FTVECTOR(shadow_offset) // shadow subpixel shift
|
||||||
GENERIC(unsigned, drawing_hash) // hashcode of a drawing
|
GENERIC(unsigned, drawing_hash) // hashcode of a drawing
|
||||||
END(bitmap_hash_key_t)
|
GENERIC(unsigned, flags) // glyph decoration
|
||||||
|
GENERIC(unsigned, border_style)
|
||||||
|
END(BitmapHashKey)
|
||||||
|
|
||||||
// describes an outline glyph
|
// describes an outline glyph
|
||||||
START(glyph, glyph_hash_key_s)
|
START(glyph, glyph_hash_key)
|
||||||
GENERIC(ass_font_t *, font)
|
GENERIC(ASS_Font *, font)
|
||||||
GENERIC(double, size) // font size
|
GENERIC(double, size) // font size
|
||||||
GENERIC(uint32_t, ch) // character code
|
GENERIC(uint32_t, ch) // character code
|
||||||
GENERIC(int, bold)
|
GENERIC(int, bold)
|
||||||
GENERIC(int, italic)
|
GENERIC(int, italic)
|
||||||
GENERIC(unsigned, scale_x) // 16.16
|
GENERIC(unsigned, scale_x) // 16.16
|
||||||
GENERIC(unsigned, scale_y) // 16.16
|
GENERIC(unsigned, scale_y) // 16.16
|
||||||
FTVECTOR(advance) // subpixel shift vector
|
|
||||||
FTVECTOR(outline) // border width, 16.16
|
FTVECTOR(outline) // border width, 16.16
|
||||||
GENERIC(unsigned, drawing_hash) // hashcode of a drawing
|
GENERIC(unsigned, drawing_hash) // hashcode of a drawing
|
||||||
GENERIC(unsigned, flags) // glyph decoration flags
|
GENERIC(unsigned, flags) // glyph decoration flags
|
||||||
END(glyph_hash_key_t)
|
GENERIC(unsigned, border_style)
|
||||||
|
END(GlyphHashKey)
|
||||||
|
|
||||||
// Cache for composited bitmaps
|
// Cache for composited bitmaps
|
||||||
START(composite, composite_hash_key_s)
|
START(composite, composite_hash_key)
|
||||||
GENERIC(int, aw)
|
GENERIC(int, aw)
|
||||||
GENERIC(int, ah)
|
GENERIC(int, ah)
|
||||||
GENERIC(int, bw)
|
GENERIC(int, bw)
|
||||||
|
@ -106,9 +108,11 @@ START(composite, composite_hash_key_s)
|
||||||
GENERIC(int, ay)
|
GENERIC(int, ay)
|
||||||
GENERIC(int, bx)
|
GENERIC(int, bx)
|
||||||
GENERIC(int, by)
|
GENERIC(int, by)
|
||||||
BITMAPHASHKEY(a)
|
GENERIC(int, as)
|
||||||
BITMAPHASHKEY(b)
|
GENERIC(int, bs)
|
||||||
END(composite_hash_key_t)
|
GENERIC(unsigned char *, a)
|
||||||
|
GENERIC(unsigned char *, b)
|
||||||
|
END(CompositeHashKey)
|
||||||
|
|
||||||
|
|
||||||
#undef START
|
#undef START
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
/*
|
/*
|
||||||
* \brief Get and prepare a FreeType glyph
|
* \brief Get and prepare a FreeType glyph
|
||||||
*/
|
*/
|
||||||
static void drawing_make_glyph(ass_drawing_t *drawing, void *fontconfig_priv,
|
static void drawing_make_glyph(ASS_Drawing *drawing, void *fontconfig_priv,
|
||||||
ass_font_t *font, ass_hinting_t hint)
|
ASS_Font *font, ASS_Hinting hint)
|
||||||
{
|
{
|
||||||
FT_OutlineGlyph glyph;
|
FT_OutlineGlyph glyph;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ static void drawing_make_glyph(ass_drawing_t *drawing, void *fontconfig_priv,
|
||||||
/*
|
/*
|
||||||
* \brief Add a single point to a contour.
|
* \brief Add a single point to a contour.
|
||||||
*/
|
*/
|
||||||
static inline void drawing_add_point(ass_drawing_t *drawing,
|
static inline void drawing_add_point(ASS_Drawing *drawing,
|
||||||
FT_Vector *point)
|
FT_Vector *point)
|
||||||
{
|
{
|
||||||
FT_Outline *ol = &drawing->glyph->outline;
|
FT_Outline *ol = &drawing->glyph->outline;
|
||||||
|
@ -76,7 +76,7 @@ static inline void drawing_add_point(ass_drawing_t *drawing,
|
||||||
/*
|
/*
|
||||||
* \brief Close a contour and check glyph size overflow.
|
* \brief Close a contour and check glyph size overflow.
|
||||||
*/
|
*/
|
||||||
static inline void drawing_close_shape(ass_drawing_t *drawing)
|
static inline void drawing_close_shape(ASS_Drawing *drawing)
|
||||||
{
|
{
|
||||||
FT_Outline *ol = &drawing->glyph->outline;
|
FT_Outline *ol = &drawing->glyph->outline;
|
||||||
|
|
||||||
|
@ -86,14 +86,16 @@ static inline void drawing_close_shape(ass_drawing_t *drawing)
|
||||||
drawing->max_contours);
|
drawing->max_contours);
|
||||||
}
|
}
|
||||||
|
|
||||||
ol->contours[ol->n_contours] = ol->n_points - 1;
|
if (ol->n_points) {
|
||||||
ol->n_contours++;
|
ol->contours[ol->n_contours] = ol->n_points - 1;
|
||||||
|
ol->n_contours++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Prepare drawing for parsing. This just sets a few parameters.
|
* \brief Prepare drawing for parsing. This just sets a few parameters.
|
||||||
*/
|
*/
|
||||||
static void drawing_prepare(ass_drawing_t *drawing)
|
static void drawing_prepare(ASS_Drawing *drawing)
|
||||||
{
|
{
|
||||||
// Scaling parameters
|
// Scaling parameters
|
||||||
drawing->point_scale_x = drawing->scale_x *
|
drawing->point_scale_x = drawing->scale_x *
|
||||||
|
@ -106,7 +108,7 @@ static void drawing_prepare(ass_drawing_t *drawing)
|
||||||
* \brief Finish a drawing. This only sets the horizontal advance according
|
* \brief Finish a drawing. This only sets the horizontal advance according
|
||||||
* to the glyph's bbox at the moment.
|
* to the glyph's bbox at the moment.
|
||||||
*/
|
*/
|
||||||
static void drawing_finish(ass_drawing_t *drawing)
|
static void drawing_finish(ASS_Drawing *drawing, int raw_mode)
|
||||||
{
|
{
|
||||||
int i, offset;
|
int i, offset;
|
||||||
FT_BBox bbox;
|
FT_BBox bbox;
|
||||||
|
@ -127,6 +129,13 @@ static void drawing_finish(ass_drawing_t *drawing)
|
||||||
printf("contour %d\n", ol->contours[i]);
|
printf("contour %d\n", ol->contours[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ass_msg(drawing->library, MSGL_V,
|
||||||
|
"Parsed drawing with %d points and %d contours", ol->n_points,
|
||||||
|
ol->n_contours);
|
||||||
|
|
||||||
|
if (raw_mode)
|
||||||
|
return;
|
||||||
|
|
||||||
FT_Outline_Get_CBox(&drawing->glyph->outline, &bbox);
|
FT_Outline_Get_CBox(&drawing->glyph->outline, &bbox);
|
||||||
drawing->glyph->root.advance.x = d6_to_d16(bbox.xMax - bbox.xMin);
|
drawing->glyph->root.advance.x = d6_to_d16(bbox.xMax - bbox.xMin);
|
||||||
|
|
||||||
|
@ -138,16 +147,12 @@ static void drawing_finish(ass_drawing_t *drawing)
|
||||||
drawing->scale_y);
|
drawing->scale_y);
|
||||||
for (i = 0; i < ol->n_points; i++)
|
for (i = 0; i < ol->n_points; i++)
|
||||||
ol->points[i].y += offset;
|
ol->points[i].y += offset;
|
||||||
|
|
||||||
ass_msg(drawing->library, MSGL_V,
|
|
||||||
"Parsed drawing with %d points and %d contours", ol->n_points,
|
|
||||||
ol->n_contours);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Check whether a number of items on the list is available
|
* \brief Check whether a number of items on the list is available
|
||||||
*/
|
*/
|
||||||
static int token_check_values(ass_drawing_token_t *token, int i, int type)
|
static int token_check_values(ASS_DrawingToken *token, int i, int type)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
|
@ -159,16 +164,16 @@ static int token_check_values(ass_drawing_token_t *token, int i, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Tokenize a drawing string into a list of ass_drawing_token_t
|
* \brief Tokenize a drawing string into a list of ASS_DrawingToken
|
||||||
* This also expands points for closing b-splines
|
* This also expands points for closing b-splines
|
||||||
*/
|
*/
|
||||||
static ass_drawing_token_t *drawing_tokenize(char *str)
|
static ASS_DrawingToken *drawing_tokenize(char *str)
|
||||||
{
|
{
|
||||||
char *p = str;
|
char *p = str;
|
||||||
int i, val, type = -1, is_set = 0;
|
int i, val, type = -1, is_set = 0;
|
||||||
FT_Vector point = {0, 0};
|
FT_Vector point = {0, 0};
|
||||||
|
|
||||||
ass_drawing_token_t *root = NULL, *tail = NULL, *spline_start = NULL;
|
ASS_DrawingToken *root = NULL, *tail = NULL, *spline_start = NULL;
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (*p == 'c' && spline_start) {
|
if (*p == 'c' && spline_start) {
|
||||||
|
@ -176,7 +181,7 @@ static ass_drawing_token_t *drawing_tokenize(char *str)
|
||||||
// back to the end
|
// back to the end
|
||||||
if (token_check_values(spline_start->next, 2, TOKEN_B_SPLINE)) {
|
if (token_check_values(spline_start->next, 2, TOKEN_B_SPLINE)) {
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
tail->next = calloc(1, sizeof(ass_drawing_token_t));
|
tail->next = calloc(1, sizeof(ASS_DrawingToken));
|
||||||
tail->next->prev = tail;
|
tail->next->prev = tail;
|
||||||
tail = tail->next;
|
tail = tail->next;
|
||||||
tail->type = TOKEN_B_SPLINE;
|
tail->type = TOKEN_B_SPLINE;
|
||||||
|
@ -211,11 +216,11 @@ static ass_drawing_token_t *drawing_tokenize(char *str)
|
||||||
|
|
||||||
if (type != -1 && is_set == 2) {
|
if (type != -1 && is_set == 2) {
|
||||||
if (root) {
|
if (root) {
|
||||||
tail->next = calloc(1, sizeof(ass_drawing_token_t));
|
tail->next = calloc(1, sizeof(ASS_DrawingToken));
|
||||||
tail->next->prev = tail;
|
tail->next->prev = tail;
|
||||||
tail = tail->next;
|
tail = tail->next;
|
||||||
} else
|
} else
|
||||||
root = tail = calloc(1, sizeof(ass_drawing_token_t));
|
root = tail = calloc(1, sizeof(ASS_DrawingToken));
|
||||||
tail->type = type;
|
tail->type = type;
|
||||||
tail->point = point;
|
tail->point = point;
|
||||||
is_set = 0;
|
is_set = 0;
|
||||||
|
@ -227,7 +232,7 @@ static ass_drawing_token_t *drawing_tokenize(char *str)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Check tokens
|
// Check tokens
|
||||||
ass_drawing_token_t *t = root;
|
ASS_DrawingToken *t = root;
|
||||||
while(t) {
|
while(t) {
|
||||||
printf("token %d point (%d, %d)\n", t->type, t->point.x, t->point.y);
|
printf("token %d point (%d, %d)\n", t->type, t->point.x, t->point.y);
|
||||||
t = t->next;
|
t = t->next;
|
||||||
|
@ -240,10 +245,10 @@ static ass_drawing_token_t *drawing_tokenize(char *str)
|
||||||
/*
|
/*
|
||||||
* \brief Free a list of tokens
|
* \brief Free a list of tokens
|
||||||
*/
|
*/
|
||||||
static void drawing_free_tokens(ass_drawing_token_t *token)
|
static void drawing_free_tokens(ASS_DrawingToken *token)
|
||||||
{
|
{
|
||||||
while (token) {
|
while (token) {
|
||||||
ass_drawing_token_t *at = token;
|
ASS_DrawingToken *at = token;
|
||||||
token = token->next;
|
token = token->next;
|
||||||
free(at);
|
free(at);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +258,7 @@ static void drawing_free_tokens(ass_drawing_token_t *token)
|
||||||
* \brief Translate and scale a point coordinate according to baseline
|
* \brief Translate and scale a point coordinate according to baseline
|
||||||
* offset and scale.
|
* offset and scale.
|
||||||
*/
|
*/
|
||||||
static inline void translate_point(ass_drawing_t *drawing, FT_Vector *point)
|
static inline void translate_point(ASS_Drawing *drawing, FT_Vector *point)
|
||||||
{
|
{
|
||||||
point->x = drawing->point_scale_x * point->x;
|
point->x = drawing->point_scale_x * point->x;
|
||||||
point->y = drawing->point_scale_y * -point->y;
|
point->y = drawing->point_scale_y * -point->y;
|
||||||
|
@ -264,8 +269,8 @@ static inline void translate_point(ass_drawing_t *drawing, FT_Vector *point)
|
||||||
* This curve evaluator is also used in VSFilter (RTS.cpp); it's a simple
|
* This curve evaluator is also used in VSFilter (RTS.cpp); it's a simple
|
||||||
* implementation of the De Casteljau algorithm.
|
* implementation of the De Casteljau algorithm.
|
||||||
*/
|
*/
|
||||||
static void drawing_evaluate_curve(ass_drawing_t *drawing,
|
static void drawing_evaluate_curve(ASS_Drawing *drawing,
|
||||||
ass_drawing_token_t *token, char spline,
|
ASS_DrawingToken *token, char spline,
|
||||||
int started)
|
int started)
|
||||||
{
|
{
|
||||||
double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
|
double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
|
||||||
|
@ -355,13 +360,13 @@ static void drawing_evaluate_curve(ass_drawing_t *drawing,
|
||||||
/*
|
/*
|
||||||
* \brief Create and initialize a new drawing and return it
|
* \brief Create and initialize a new drawing and return it
|
||||||
*/
|
*/
|
||||||
ass_drawing_t *ass_drawing_new(void *fontconfig_priv, ass_font_t *font,
|
ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
||||||
ass_hinting_t hint, FT_Library lib)
|
ASS_Hinting hint, FT_Library lib)
|
||||||
{
|
{
|
||||||
ass_drawing_t* drawing;
|
ASS_Drawing* drawing;
|
||||||
|
|
||||||
drawing = calloc(1, sizeof(*drawing));
|
drawing = calloc(1, sizeof(*drawing));
|
||||||
drawing->text = malloc(DRAWING_INITIAL_SIZE);
|
drawing->text = calloc(1, DRAWING_INITIAL_SIZE);
|
||||||
drawing->size = DRAWING_INITIAL_SIZE;
|
drawing->size = DRAWING_INITIAL_SIZE;
|
||||||
|
|
||||||
drawing->ftlibrary = lib;
|
drawing->ftlibrary = lib;
|
||||||
|
@ -379,8 +384,9 @@ ass_drawing_t *ass_drawing_new(void *fontconfig_priv, ass_font_t *font,
|
||||||
/*
|
/*
|
||||||
* \brief Free a drawing
|
* \brief Free a drawing
|
||||||
*/
|
*/
|
||||||
void ass_drawing_free(ass_drawing_t* drawing)
|
void ass_drawing_free(ASS_Drawing* drawing)
|
||||||
{
|
{
|
||||||
|
FT_Done_Glyph((FT_Glyph) drawing->glyph);
|
||||||
free(drawing->text);
|
free(drawing->text);
|
||||||
free(drawing);
|
free(drawing);
|
||||||
}
|
}
|
||||||
|
@ -388,7 +394,7 @@ void ass_drawing_free(ass_drawing_t* drawing)
|
||||||
/*
|
/*
|
||||||
* \brief Add one ASCII character to the drawing text buffer
|
* \brief Add one ASCII character to the drawing text buffer
|
||||||
*/
|
*/
|
||||||
void ass_drawing_add_char(ass_drawing_t* drawing, char symbol)
|
void ass_drawing_add_char(ASS_Drawing* drawing, char symbol)
|
||||||
{
|
{
|
||||||
drawing->text[drawing->i++] = symbol;
|
drawing->text[drawing->i++] = symbol;
|
||||||
drawing->text[drawing->i] = 0;
|
drawing->text[drawing->i] = 0;
|
||||||
|
@ -403,7 +409,7 @@ void ass_drawing_add_char(ass_drawing_t* drawing, char symbol)
|
||||||
* \brief Create a hashcode for the drawing
|
* \brief Create a hashcode for the drawing
|
||||||
* XXX: To avoid collisions a better hash algorithm might be useful.
|
* XXX: To avoid collisions a better hash algorithm might be useful.
|
||||||
*/
|
*/
|
||||||
void ass_drawing_hash(ass_drawing_t* drawing)
|
void ass_drawing_hash(ASS_Drawing* drawing)
|
||||||
{
|
{
|
||||||
drawing->hash = fnv_32a_str(drawing->text, FNV1_32A_INIT);
|
drawing->hash = fnv_32a_str(drawing->text, FNV1_32A_INIT);
|
||||||
}
|
}
|
||||||
|
@ -411,10 +417,10 @@ void ass_drawing_hash(ass_drawing_t* drawing)
|
||||||
/*
|
/*
|
||||||
* \brief Convert token list to outline. Calls the line and curve evaluators.
|
* \brief Convert token list to outline. Calls the line and curve evaluators.
|
||||||
*/
|
*/
|
||||||
FT_OutlineGlyph *ass_drawing_parse(ass_drawing_t *drawing)
|
FT_OutlineGlyph *ass_drawing_parse(ASS_Drawing *drawing, int raw_mode)
|
||||||
{
|
{
|
||||||
int started = 0;
|
int started = 0;
|
||||||
ass_drawing_token_t *token;
|
ASS_DrawingToken *token;
|
||||||
FT_Vector pen = {0, 0};
|
FT_Vector pen = {0, 0};
|
||||||
|
|
||||||
drawing->tokens = drawing_tokenize(drawing->text);
|
drawing->tokens = drawing_tokenize(drawing->text);
|
||||||
|
@ -474,9 +480,7 @@ FT_OutlineGlyph *ass_drawing_parse(ass_drawing_t *drawing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drawing_finish(drawing);
|
drawing_finish(drawing, raw_mode);
|
||||||
drawing_free_tokens(drawing->tokens);
|
drawing_free_tokens(drawing->tokens);
|
||||||
return &drawing->glyph;
|
return &drawing->glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#define DRAWING_INITIAL_SIZE 256
|
#define DRAWING_INITIAL_SIZE 256
|
||||||
|
|
||||||
enum ass_token_type {
|
typedef enum {
|
||||||
TOKEN_MOVE,
|
TOKEN_MOVE,
|
||||||
TOKEN_MOVE_NC,
|
TOKEN_MOVE_NC,
|
||||||
TOKEN_LINE,
|
TOKEN_LINE,
|
||||||
|
@ -35,16 +35,16 @@ enum ass_token_type {
|
||||||
TOKEN_B_SPLINE,
|
TOKEN_B_SPLINE,
|
||||||
TOKEN_EXTEND_SPLINE,
|
TOKEN_EXTEND_SPLINE,
|
||||||
TOKEN_CLOSE
|
TOKEN_CLOSE
|
||||||
};
|
} ASS_TokenType;
|
||||||
|
|
||||||
typedef struct ass_drawing_token_s {
|
typedef struct ass_drawing_token {
|
||||||
enum ass_token_type type;
|
ASS_TokenType type;
|
||||||
FT_Vector point;
|
FT_Vector point;
|
||||||
struct ass_drawing_token_s *next;
|
struct ass_drawing_token *next;
|
||||||
struct ass_drawing_token_s *prev;
|
struct ass_drawing_token *prev;
|
||||||
} ass_drawing_token_t;
|
} ASS_DrawingToken;
|
||||||
|
|
||||||
typedef struct ass_drawing_s {
|
typedef struct {
|
||||||
char *text; // drawing string
|
char *text; // drawing string
|
||||||
int i; // text index
|
int i; // text index
|
||||||
int scale; // scale (1-64) for subpixel accuracy
|
int scale; // scale (1-64) for subpixel accuracy
|
||||||
|
@ -58,20 +58,20 @@ typedef struct ass_drawing_s {
|
||||||
|
|
||||||
// private
|
// private
|
||||||
FT_Library ftlibrary; // FT library instance, needed for font ops
|
FT_Library ftlibrary; // FT library instance, needed for font ops
|
||||||
ass_library_t *library;
|
ASS_Library *library;
|
||||||
int size; // current buffer size
|
int size; // current buffer size
|
||||||
ass_drawing_token_t *tokens; // tokenized drawing
|
ASS_DrawingToken *tokens; // tokenized drawing
|
||||||
int max_points; // current maximum size
|
int max_points; // current maximum size
|
||||||
int max_contours;
|
int max_contours;
|
||||||
double point_scale_x;
|
double point_scale_x;
|
||||||
double point_scale_y;
|
double point_scale_y;
|
||||||
} ass_drawing_t;
|
} ASS_Drawing;
|
||||||
|
|
||||||
ass_drawing_t *ass_drawing_new(void *fontconfig_priv, ass_font_t *font,
|
ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
||||||
ass_hinting_t hint, FT_Library lib);
|
ASS_Hinting hint, FT_Library lib);
|
||||||
void ass_drawing_free(ass_drawing_t* drawing);
|
void ass_drawing_free(ASS_Drawing* drawing);
|
||||||
void ass_drawing_add_char(ass_drawing_t* drawing, char symbol);
|
void ass_drawing_add_char(ASS_Drawing* drawing, char symbol);
|
||||||
void ass_drawing_hash(ass_drawing_t* drawing);
|
void ass_drawing_hash(ASS_Drawing* drawing);
|
||||||
FT_OutlineGlyph *ass_drawing_parse(ass_drawing_t *drawing);
|
FT_OutlineGlyph *ass_drawing_parse(ASS_Drawing *drawing, int raw_mode);
|
||||||
|
|
||||||
#endif /* LIBASS_DRAWING_H */
|
#endif /* LIBASS_DRAWING_H */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include FT_SYNTHESIS_H
|
#include FT_SYNTHESIS_H
|
||||||
#include FT_GLYPH_H
|
#include FT_GLYPH_H
|
||||||
#include FT_TRUETYPE_TABLES_H
|
#include FT_TRUETYPE_TABLES_H
|
||||||
|
#include FT_OUTLINE_H
|
||||||
|
|
||||||
#include "ass.h"
|
#include "ass.h"
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
|
@ -39,15 +40,15 @@
|
||||||
* Select Microfost Unicode CharMap, if the font has one.
|
* Select Microfost Unicode CharMap, if the font has one.
|
||||||
* Otherwise, let FreeType decide.
|
* Otherwise, let FreeType decide.
|
||||||
*/
|
*/
|
||||||
static void charmap_magic(ass_library_t *library, FT_Face face)
|
static void charmap_magic(ASS_Library *library, FT_Face face)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < face->num_charmaps; ++i) {
|
for (i = 0; i < face->num_charmaps; ++i) {
|
||||||
FT_CharMap cmap = face->charmaps[i];
|
FT_CharMap cmap = face->charmaps[i];
|
||||||
unsigned pid = cmap->platform_id;
|
unsigned pid = cmap->platform_id;
|
||||||
unsigned eid = cmap->encoding_id;
|
unsigned eid = cmap->encoding_id;
|
||||||
if (pid == 3 /*microsoft */
|
if (pid == 3 /*microsoft */
|
||||||
&& (eid == 1 /*unicode bmp */
|
&& (eid == 1 /*unicode bmp */
|
||||||
|| eid == 10 /*full unicode */ )) {
|
|| eid == 10 /*full unicode */ )) {
|
||||||
FT_Set_Charmap(face, cmap);
|
FT_Set_Charmap(face, cmap);
|
||||||
return;
|
return;
|
||||||
|
@ -66,7 +67,7 @@ static void charmap_magic(ass_library_t *library, FT_Face face)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_transform(ass_font_t *font)
|
static void update_transform(ASS_Font *font)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FT_Matrix m;
|
FT_Matrix m;
|
||||||
|
@ -80,7 +81,7 @@ static void update_transform(ass_font_t *font)
|
||||||
/**
|
/**
|
||||||
* \brief find a memory font by name
|
* \brief find a memory font by name
|
||||||
*/
|
*/
|
||||||
static int find_font(ass_library_t *library, char *name)
|
static int find_font(ASS_Library *library, char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < library->num_fontdata; ++i)
|
for (i = 0; i < library->num_fontdata; ++i)
|
||||||
|
@ -111,10 +112,10 @@ static void buggy_font_workaround(FT_Face face)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Select a face with the given charcode and add it to ass_font_t
|
* \brief Select a face with the given charcode and add it to ASS_Font
|
||||||
* \return index of the new face in font->faces, -1 if failed
|
* \return index of the new face in font->faces, -1 if failed
|
||||||
*/
|
*/
|
||||||
static int add_face(void *fc_priv, ass_font_t *font, uint32_t ch)
|
static int add_face(void *fc_priv, ASS_Font *font, uint32_t ch)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
int index;
|
int index;
|
||||||
|
@ -166,17 +167,17 @@ static int add_face(void *fc_priv, ass_font_t *font, uint32_t ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create a new ass_font_t according to "desc" argument
|
* \brief Create a new ASS_Font according to "desc" argument
|
||||||
*/
|
*/
|
||||||
ass_font_t *ass_font_new(void *font_cache, ass_library_t *library,
|
ASS_Font *ass_font_new(void *font_cache, ASS_Library *library,
|
||||||
FT_Library ftlibrary, void *fc_priv,
|
FT_Library ftlibrary, void *fc_priv,
|
||||||
ass_font_desc_t *desc)
|
ASS_FontDesc *desc)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
ass_font_t *fontp;
|
ASS_Font *fontp;
|
||||||
ass_font_t font;
|
ASS_Font font;
|
||||||
|
|
||||||
fontp = ass_font_cache_find((hashmap_t *) font_cache, desc);
|
fontp = ass_font_cache_find((Hashmap *) font_cache, desc);
|
||||||
if (fontp)
|
if (fontp)
|
||||||
return fontp;
|
return fontp;
|
||||||
|
|
||||||
|
@ -197,19 +198,21 @@ ass_font_t *ass_font_new(void *font_cache, ass_library_t *library,
|
||||||
free(font.desc.family);
|
free(font.desc.family);
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
return ass_font_cache_add((hashmap_t *) font_cache, &font);
|
return ass_font_cache_add((Hashmap *) font_cache, &font);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set font transformation matrix and shift vector
|
* \brief Set font transformation matrix and shift vector
|
||||||
**/
|
**/
|
||||||
void ass_font_set_transform(ass_font_t *font, double scale_x,
|
void ass_font_set_transform(ASS_Font *font, double scale_x,
|
||||||
double scale_y, FT_Vector *v)
|
double scale_y, FT_Vector *v)
|
||||||
{
|
{
|
||||||
font->scale_x = scale_x;
|
font->scale_x = scale_x;
|
||||||
font->scale_y = scale_y;
|
font->scale_y = scale_y;
|
||||||
font->v.x = v->x;
|
if (v) {
|
||||||
font->v.y = v->y;
|
font->v.x = v->x;
|
||||||
|
font->v.y = v->y;
|
||||||
|
}
|
||||||
update_transform(font);
|
update_transform(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +249,7 @@ static void face_set_size(FT_Face face, double size)
|
||||||
/**
|
/**
|
||||||
* \brief Set font size
|
* \brief Set font size
|
||||||
**/
|
**/
|
||||||
void ass_font_set_size(ass_font_t *font, double size)
|
void ass_font_set_size(ASS_Font *font, double size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (font->size != size) {
|
if (font->size != size) {
|
||||||
|
@ -261,15 +264,22 @@ void ass_font_set_size(ass_font_t *font, double size)
|
||||||
* \param ch character code
|
* \param ch character code
|
||||||
* The values are extracted from the font face that provides glyphs for the given character
|
* The values are extracted from the font face that provides glyphs for the given character
|
||||||
**/
|
**/
|
||||||
void ass_font_get_asc_desc(ass_font_t *font, uint32_t ch, int *asc,
|
void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc,
|
||||||
int *desc)
|
int *desc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < font->n_faces; ++i) {
|
for (i = 0; i < font->n_faces; ++i) {
|
||||||
FT_Face face = font->faces[i];
|
FT_Face face = font->faces[i];
|
||||||
|
TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
|
||||||
if (FT_Get_Char_Index(face, ch)) {
|
if (FT_Get_Char_Index(face, ch)) {
|
||||||
*asc = face->size->metrics.ascender;
|
int y_scale = face->size->metrics.y_scale;
|
||||||
*desc = -face->size->metrics.descender;
|
if (os2) {
|
||||||
|
*asc = FT_MulFix(os2->usWinAscent, y_scale);
|
||||||
|
*desc = FT_MulFix(os2->usWinDescent, y_scale);
|
||||||
|
} else {
|
||||||
|
*asc = FT_MulFix(face->ascender, y_scale);
|
||||||
|
*desc = FT_MulFix(-face->descender, y_scale);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,13 +294,16 @@ void ass_font_get_asc_desc(ass_font_t *font, uint32_t ch, int *asc,
|
||||||
* being accurate.
|
* being accurate.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int ass_strike_outline_glyph(FT_Face face, ass_font_t *font,
|
static int ass_strike_outline_glyph(FT_Face face, ASS_Font *font,
|
||||||
FT_Glyph glyph, int under, int through)
|
FT_Glyph glyph, int under, int through)
|
||||||
{
|
{
|
||||||
TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
|
TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
|
||||||
TT_Postscript *ps = FT_Get_Sfnt_Table(face, ft_sfnt_post);
|
TT_Postscript *ps = FT_Get_Sfnt_Table(face, ft_sfnt_post);
|
||||||
FT_Outline *ol = &((FT_OutlineGlyph) glyph)->outline;
|
FT_Outline *ol = &((FT_OutlineGlyph) glyph)->outline;
|
||||||
int bear, advance, y_scale, i;
|
int bear, advance, y_scale, i, dir;
|
||||||
|
|
||||||
|
if (!under && !through)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Grow outline
|
// Grow outline
|
||||||
i = (under ? 4 : 0) + (through ? 4 : 0);
|
i = (under ? 4 : 0) + (through ? 4 : 0);
|
||||||
|
@ -308,15 +321,18 @@ static int ass_strike_outline_glyph(FT_Face face, ass_font_t *font,
|
||||||
advance = d16_to_d6(glyph->advance.x) + 32;
|
advance = d16_to_d6(glyph->advance.x) + 32;
|
||||||
y_scale = face->size->metrics.y_scale;
|
y_scale = face->size->metrics.y_scale;
|
||||||
|
|
||||||
|
// Reverse drawing direction for non-truetype fonts
|
||||||
|
dir = FT_Outline_Get_Orientation(ol);
|
||||||
|
|
||||||
// Add points to the outline
|
// Add points to the outline
|
||||||
if (under) {
|
if (under && ps) {
|
||||||
int pos, size;
|
int pos, size;
|
||||||
pos = FT_MulFix(ps->underlinePosition, y_scale * font->scale_y);
|
pos = FT_MulFix(ps->underlinePosition, y_scale * font->scale_y);
|
||||||
size = FT_MulFix(ps->underlineThickness,
|
size = FT_MulFix(ps->underlineThickness,
|
||||||
y_scale * font->scale_y / 2);
|
y_scale * font->scale_y / 2);
|
||||||
|
|
||||||
if (pos > 0 || size <= 0)
|
if (pos > 0 || size <= 0)
|
||||||
return 0;
|
return 1;
|
||||||
|
|
||||||
FT_Vector points[4] = {
|
FT_Vector points[4] = {
|
||||||
{.x = bear, .y = pos + size},
|
{.x = bear, .y = pos + size},
|
||||||
|
@ -325,20 +341,28 @@ static int ass_strike_outline_glyph(FT_Face face, ass_font_t *font,
|
||||||
{.x = bear, .y = pos - size},
|
{.x = bear, .y = pos - size},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
if (dir == FT_ORIENTATION_TRUETYPE) {
|
||||||
ol->points[ol->n_points] = points[i];
|
for (i = 0; i < 4; i++) {
|
||||||
ol->tags[ol->n_points++] = 1;
|
ol->points[ol->n_points] = points[i];
|
||||||
|
ol->tags[ol->n_points++] = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 3; i >= 0; i--) {
|
||||||
|
ol->points[ol->n_points] = points[i];
|
||||||
|
ol->tags[ol->n_points++] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ol->contours[ol->n_contours++] = ol->n_points - 1;
|
ol->contours[ol->n_contours++] = ol->n_points - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (through) {
|
if (through && os2) {
|
||||||
int pos, size;
|
int pos, size;
|
||||||
pos = FT_MulFix(os2->yStrikeoutPosition, y_scale * font->scale_y);
|
pos = FT_MulFix(os2->yStrikeoutPosition, y_scale * font->scale_y);
|
||||||
size = FT_MulFix(os2->yStrikeoutSize, y_scale * font->scale_y / 2);
|
size = FT_MulFix(os2->yStrikeoutSize, y_scale * font->scale_y / 2);
|
||||||
|
|
||||||
if (pos < 0 || size <= 0)
|
if (pos < 0 || size <= 0)
|
||||||
return 0;
|
return 1;
|
||||||
|
|
||||||
FT_Vector points[4] = {
|
FT_Vector points[4] = {
|
||||||
{.x = bear, .y = pos + size},
|
{.x = bear, .y = pos + size},
|
||||||
|
@ -347,23 +371,46 @@ static int ass_strike_outline_glyph(FT_Face face, ass_font_t *font,
|
||||||
{.x = bear, .y = pos - size},
|
{.x = bear, .y = pos - size},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
if (dir == FT_ORIENTATION_TRUETYPE) {
|
||||||
ol->points[ol->n_points] = points[i];
|
for (i = 0; i < 4; i++) {
|
||||||
ol->tags[ol->n_points++] = 1;
|
ol->points[ol->n_points] = points[i];
|
||||||
|
ol->tags[ol->n_points++] = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 3; i >= 0; i--) {
|
||||||
|
ol->points[ol->n_points] = points[i];
|
||||||
|
ol->tags[ol->n_points++] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ol->contours[ol->n_contours++] = ol->n_points - 1;
|
ol->contours[ol->n_contours++] = ol->n_points - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slightly embold a glyph without touching its metrics
|
||||||
|
*/
|
||||||
|
static void ass_glyph_embolden(FT_GlyphSlot slot)
|
||||||
|
{
|
||||||
|
int str;
|
||||||
|
|
||||||
|
if (slot->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
str = FT_MulFix(slot->face->units_per_EM,
|
||||||
|
slot->face->size->metrics.y_scale) / 64;
|
||||||
|
|
||||||
|
FT_Outline_Embolden(&slot->outline, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get a glyph
|
* \brief Get a glyph
|
||||||
* \param ch character code
|
* \param ch character code
|
||||||
**/
|
**/
|
||||||
FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ass_font_t *font,
|
FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
uint32_t ch, ass_hinting_t hinting, int deco)
|
uint32_t ch, ASS_Hinting hinting, int deco)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -434,6 +481,11 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ass_font_t *font,
|
||||||
(font->desc.italic > 55)) {
|
(font->desc.italic > 55)) {
|
||||||
FT_GlyphSlot_Oblique(face->glyph);
|
FT_GlyphSlot_Oblique(face->glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(face->style_flags & FT_STYLE_FLAG_BOLD) &&
|
||||||
|
(font->desc.bold > 80)) {
|
||||||
|
ass_glyph_embolden(face->glyph);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
error = FT_Get_Glyph(face->glyph, &glyph);
|
error = FT_Get_Glyph(face->glyph, &glyph);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -451,7 +503,7 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ass_font_t *font,
|
||||||
/**
|
/**
|
||||||
* \brief Get kerning for the pair of glyphs.
|
* \brief Get kerning for the pair of glyphs.
|
||||||
**/
|
**/
|
||||||
FT_Vector ass_font_get_kerning(ass_font_t *font, uint32_t c1, uint32_t c2)
|
FT_Vector ass_font_get_kerning(ASS_Font *font, uint32_t c1, uint32_t c2)
|
||||||
{
|
{
|
||||||
FT_Vector v = { 0, 0 };
|
FT_Vector v = { 0, 0 };
|
||||||
int i;
|
int i;
|
||||||
|
@ -472,9 +524,9 @@ FT_Vector ass_font_get_kerning(ass_font_t *font, uint32_t c1, uint32_t c2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Deallocate ass_font_t
|
* \brief Deallocate ASS_Font
|
||||||
**/
|
**/
|
||||||
void ass_font_free(ass_font_t *font)
|
void ass_font_free(ASS_Font *font)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < font->n_faces; ++i)
|
for (i = 0; i < font->n_faces; ++i)
|
||||||
|
|
|
@ -31,36 +31,36 @@
|
||||||
#define DECO_UNDERLINE 1
|
#define DECO_UNDERLINE 1
|
||||||
#define DECO_STRIKETHROUGH 2
|
#define DECO_STRIKETHROUGH 2
|
||||||
|
|
||||||
typedef struct ass_font_desc_s {
|
typedef struct {
|
||||||
char *family;
|
char *family;
|
||||||
unsigned bold;
|
unsigned bold;
|
||||||
unsigned italic;
|
unsigned italic;
|
||||||
int treat_family_as_pattern;
|
int treat_family_as_pattern;
|
||||||
} ass_font_desc_t;
|
} ASS_FontDesc;
|
||||||
|
|
||||||
typedef struct ass_font_s {
|
typedef struct {
|
||||||
ass_font_desc_t desc;
|
ASS_FontDesc desc;
|
||||||
ass_library_t *library;
|
ASS_Library *library;
|
||||||
FT_Library ftlibrary;
|
FT_Library ftlibrary;
|
||||||
FT_Face faces[ASS_FONT_MAX_FACES];
|
FT_Face faces[ASS_FONT_MAX_FACES];
|
||||||
int n_faces;
|
int n_faces;
|
||||||
double scale_x, scale_y; // current transform
|
double scale_x, scale_y; // current transform
|
||||||
FT_Vector v; // current shift
|
FT_Vector v; // current shift
|
||||||
double size;
|
double size;
|
||||||
} ass_font_t;
|
} ASS_Font;
|
||||||
|
|
||||||
// FIXME: passing the hashmap via a void pointer is very ugly.
|
// FIXME: passing the hashmap via a void pointer is very ugly.
|
||||||
ass_font_t *ass_font_new(void *font_cache, ass_library_t *library,
|
ASS_Font *ass_font_new(void *font_cache, ASS_Library *library,
|
||||||
FT_Library ftlibrary, void *fc_priv,
|
FT_Library ftlibrary, void *fc_priv,
|
||||||
ass_font_desc_t *desc);
|
ASS_FontDesc *desc);
|
||||||
void ass_font_set_transform(ass_font_t *font, double scale_x,
|
void ass_font_set_transform(ASS_Font *font, double scale_x,
|
||||||
double scale_y, FT_Vector * v);
|
double scale_y, FT_Vector *v);
|
||||||
void ass_font_set_size(ass_font_t *font, double size);
|
void ass_font_set_size(ASS_Font *font, double size);
|
||||||
void ass_font_get_asc_desc(ass_font_t *font, uint32_t ch, int *asc,
|
void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc,
|
||||||
int *desc);
|
int *desc);
|
||||||
FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ass_font_t *font,
|
FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
uint32_t ch, ass_hinting_t hinting, int flags);
|
uint32_t ch, ASS_Hinting hinting, int flags);
|
||||||
FT_Vector ass_font_get_kerning(ass_font_t *font, uint32_t c1, uint32_t c2);
|
FT_Vector ass_font_get_kerning(ASS_Font *font, uint32_t c1, uint32_t c2);
|
||||||
void ass_font_free(ass_font_t *font);
|
void ass_font_free(ASS_Font *font);
|
||||||
|
|
||||||
#endif /* LIBASS_FONT_H */
|
#endif /* LIBASS_FONT_H */
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <fontconfig/fcfreetype.h>
|
#include <fontconfig/fcfreetype.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct fc_instance_s {
|
struct fc_instance {
|
||||||
#ifdef CONFIG_FONTCONFIG
|
#ifdef CONFIG_FONTCONFIG
|
||||||
FcConfig *config;
|
FcConfig *config;
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +71,7 @@ struct fc_instance_s {
|
||||||
* \param code: the character that should be present in the font, can be 0
|
* \param code: the character that should be present in the font, can be 0
|
||||||
* \return font file path
|
* \return font file path
|
||||||
*/
|
*/
|
||||||
static char *_select_font(ass_library_t *library, fc_instance_t *priv,
|
static char *_select_font(ASS_Library *library, FCInstance *priv,
|
||||||
const char *family, int treat_family_as_pattern,
|
const char *family, int treat_family_as_pattern,
|
||||||
unsigned bold, unsigned italic, int *index,
|
unsigned bold, unsigned italic, int *index,
|
||||||
uint32_t code)
|
uint32_t code)
|
||||||
|
@ -242,7 +242,7 @@ static char *_select_font(ass_library_t *library, fc_instance_t *priv,
|
||||||
* \param code: the character that should be present in the font, can be 0
|
* \param code: the character that should be present in the font, can be 0
|
||||||
* \return font file path
|
* \return font file path
|
||||||
*/
|
*/
|
||||||
char *fontconfig_select(ass_library_t *library, fc_instance_t *priv,
|
char *fontconfig_select(ASS_Library *library, FCInstance *priv,
|
||||||
const char *family, int treat_family_as_pattern,
|
const char *family, int treat_family_as_pattern,
|
||||||
unsigned bold, unsigned italic, int *index,
|
unsigned bold, unsigned italic, int *index,
|
||||||
uint32_t code)
|
uint32_t code)
|
||||||
|
@ -331,7 +331,7 @@ static char *validate_fname(char *name)
|
||||||
* With FontConfig >= 2.4.2, builds a font pattern in memory via FT_New_Memory_Face/FcFreeTypeQueryFace.
|
* With FontConfig >= 2.4.2, builds a font pattern in memory via FT_New_Memory_Face/FcFreeTypeQueryFace.
|
||||||
* With older FontConfig versions, save the font to ~/.mplayer/fonts.
|
* With older FontConfig versions, save the font to ~/.mplayer/fonts.
|
||||||
*/
|
*/
|
||||||
static void process_fontdata(fc_instance_t *priv, ass_library_t *library,
|
static void process_fontdata(FCInstance *priv, ASS_Library *library,
|
||||||
FT_Library ftlibrary, int idx)
|
FT_Library ftlibrary, int idx)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -427,14 +427,18 @@ static void process_fontdata(fc_instance_t *priv, ass_library_t *library,
|
||||||
* \param ftlibrary freetype library object
|
* \param ftlibrary freetype library object
|
||||||
* \param family default font family
|
* \param family default font family
|
||||||
* \param path default font path
|
* \param path default font path
|
||||||
|
* \param fc whether fontconfig should be used
|
||||||
|
* \param config path to a fontconfig configuration file, or NULL
|
||||||
|
* \param update whether the fontconfig cache should be built/updated
|
||||||
* \return pointer to fontconfig private data
|
* \return pointer to fontconfig private data
|
||||||
*/
|
*/
|
||||||
fc_instance_t *fontconfig_init(ass_library_t *library,
|
FCInstance *fontconfig_init(ASS_Library *library,
|
||||||
FT_Library ftlibrary, const char *family,
|
FT_Library ftlibrary, const char *family,
|
||||||
const char *path, int fc, const char *config)
|
const char *path, int fc, const char *config,
|
||||||
|
int update)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
fc_instance_t *priv = calloc(1, sizeof(fc_instance_t));
|
FCInstance *priv = calloc(1, sizeof(FCInstance));
|
||||||
const char *dir = library->fonts_dir;
|
const char *dir = library->fonts_dir;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -444,20 +448,23 @@ fc_instance_t *fontconfig_init(ass_library_t *library,
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config) {
|
priv->config = FcConfigCreate();
|
||||||
priv->config = FcConfigCreate();
|
rc = FcConfigParseAndLoad(priv->config, (unsigned char *) config, FcTrue);
|
||||||
rc = FcConfigParseAndLoad(priv->config, (unsigned char *)config,
|
if (!rc) {
|
||||||
FcTrue);
|
ass_msg(library, MSGL_WARN, "No usable fontconfig configuration "
|
||||||
|
"file found, using fallback.");
|
||||||
|
FcConfigDestroy(priv->config);
|
||||||
|
priv->config = FcInitLoadConfig();
|
||||||
|
rc++;
|
||||||
|
}
|
||||||
|
if (rc && update) {
|
||||||
FcConfigBuildFonts(priv->config);
|
FcConfigBuildFonts(priv->config);
|
||||||
FcConfigSetCurrent(priv->config);
|
|
||||||
} else {
|
|
||||||
rc = FcInit();
|
|
||||||
assert(rc);
|
|
||||||
priv->config = FcConfigGetCurrent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rc || !priv->config) {
|
if (!rc || !priv->config) {
|
||||||
ass_msg(library, MSGL_FATAL, "%s failed", "FcInitLoadConfigAndFonts");
|
ass_msg(library, MSGL_FATAL,
|
||||||
|
"No valid fontconfig configuration found!");
|
||||||
|
FcConfigDestroy(priv->config);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,44 +514,60 @@ fc_instance_t *fontconfig_init(ass_library_t *library,
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->family_default = family ? strdup(family) : NULL;
|
priv->family_default = family ? strdup(family) : NULL;
|
||||||
exit:
|
exit:
|
||||||
priv->path_default = path ? strdup(path) : NULL;
|
priv->path_default = path ? strdup(path) : NULL;
|
||||||
priv->index_default = 0;
|
priv->index_default = 0;
|
||||||
|
|
||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fontconfig_update(FCInstance *priv)
|
||||||
|
{
|
||||||
|
return FcConfigBuildFonts(priv->config);
|
||||||
|
}
|
||||||
|
|
||||||
#else /* CONFIG_FONTCONFIG */
|
#else /* CONFIG_FONTCONFIG */
|
||||||
|
|
||||||
char *fontconfig_select(fc_instance_t *priv, const char *family,
|
char *fontconfig_select(ASS_Library *library, FCInstance *priv,
|
||||||
int treat_family_as_pattern, unsigned bold,
|
const char *family, int treat_family_as_pattern,
|
||||||
unsigned italic, int *index, uint32_t code)
|
unsigned bold, unsigned italic, int *index,
|
||||||
|
uint32_t code)
|
||||||
{
|
{
|
||||||
*index = priv->index_default;
|
*index = priv->index_default;
|
||||||
return priv->path_default;
|
return priv->path_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc_instance_t *fontconfig_init(ass_library_t *library,
|
FCInstance *fontconfig_init(ASS_Library *library,
|
||||||
FT_Library ftlibrary, const char *family,
|
FT_Library ftlibrary, const char *family,
|
||||||
const char *path, int fc)
|
const char *path, int fc, const char *config,
|
||||||
|
int update)
|
||||||
{
|
{
|
||||||
fc_instance_t *priv;
|
FCInstance *priv;
|
||||||
|
|
||||||
ass_msg(library, MSGL_WARN,
|
ass_msg(library, MSGL_WARN,
|
||||||
"Fontconfig disabled, only default font will be used.");
|
"Fontconfig disabled, only default font will be used.");
|
||||||
|
|
||||||
priv = calloc(1, sizeof(fc_instance_t));
|
priv = calloc(1, sizeof(FCInstance));
|
||||||
|
|
||||||
priv->path_default = strdup(path);
|
priv->path_default = strdup(path);
|
||||||
priv->index_default = 0;
|
priv->index_default = 0;
|
||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fontconfig_update(FCInstance *priv)
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void fontconfig_done(fc_instance_t *priv)
|
void fontconfig_done(FCInstance *priv)
|
||||||
{
|
{
|
||||||
// don't call FcFini() here, library can still be used by some code
|
#ifdef CONFIG_FONTCONFIG
|
||||||
|
if (priv && priv->config)
|
||||||
|
FcConfigDestroy(priv->config);
|
||||||
|
#endif
|
||||||
if (priv && priv->path_default)
|
if (priv && priv->path_default)
|
||||||
free(priv->path_default);
|
free(priv->path_default);
|
||||||
if (priv && priv->family_default)
|
if (priv && priv->family_default)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "ass_types.h"
|
#include "ass_types.h"
|
||||||
|
#include "ass.h"
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
@ -30,15 +31,17 @@
|
||||||
#include <fontconfig/fontconfig.h>
|
#include <fontconfig/fontconfig.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct fc_instance_s fc_instance_t;
|
typedef struct fc_instance FCInstance;
|
||||||
|
|
||||||
fc_instance_t *fontconfig_init(ass_library_t *library,
|
FCInstance *fontconfig_init(ASS_Library *library,
|
||||||
FT_Library ftlibrary, const char *family,
|
FT_Library ftlibrary, const char *family,
|
||||||
const char *path, int fc, const char *config);
|
const char *path, int fc, const char *config,
|
||||||
char *fontconfig_select(ass_library_t *library, fc_instance_t *priv,
|
int update);
|
||||||
|
char *fontconfig_select(ASS_Library *library, FCInstance *priv,
|
||||||
const char *family, int treat_family_as_pattern,
|
const char *family, int treat_family_as_pattern,
|
||||||
unsigned bold, unsigned italic, int *index,
|
unsigned bold, unsigned italic, int *index,
|
||||||
uint32_t code);
|
uint32_t code);
|
||||||
void fontconfig_done(fc_instance_t *priv);
|
void fontconfig_done(FCInstance *priv);
|
||||||
|
int fontconfig_update(FCInstance *priv);
|
||||||
|
|
||||||
#endif /* LIBASS_FONTCONFIG_H */
|
#endif /* LIBASS_FONTCONFIG_H */
|
||||||
|
|
|
@ -28,24 +28,24 @@
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
#include "ass_utils.h"
|
#include "ass_utils.h"
|
||||||
|
|
||||||
static void ass_msg_handler(int level, char *fmt, va_list *va, void *data)
|
static void ass_msg_handler(int level, const char *fmt, va_list va, void *data)
|
||||||
{
|
{
|
||||||
if (level > MSGL_INFO)
|
if (level > MSGL_INFO)
|
||||||
return;
|
return;
|
||||||
fprintf(stderr, "[ass] ");
|
fprintf(stderr, "[ass] ");
|
||||||
vfprintf(stderr, fmt, *va);
|
vfprintf(stderr, fmt, va);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ass_library_t *ass_library_init(void)
|
ASS_Library *ass_library_init(void)
|
||||||
{
|
{
|
||||||
ass_library_t* lib = calloc(1, sizeof(ass_library_t));
|
ASS_Library* lib = calloc(1, sizeof(*lib));
|
||||||
lib->msg_callback = ass_msg_handler;
|
lib->msg_callback = ass_msg_handler;
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_library_done(ass_library_t *priv)
|
void ass_library_done(ASS_Library *priv)
|
||||||
{
|
{
|
||||||
if (priv) {
|
if (priv) {
|
||||||
ass_set_fonts_dir(priv, NULL);
|
ass_set_fonts_dir(priv, NULL);
|
||||||
|
@ -55,7 +55,7 @@ void ass_library_done(ass_library_t *priv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_set_fonts_dir(ass_library_t *priv, const char *fonts_dir)
|
void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir)
|
||||||
{
|
{
|
||||||
if (priv->fonts_dir)
|
if (priv->fonts_dir)
|
||||||
free(priv->fonts_dir);
|
free(priv->fonts_dir);
|
||||||
|
@ -63,12 +63,12 @@ void ass_set_fonts_dir(ass_library_t *priv, const char *fonts_dir)
|
||||||
priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0;
|
priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_set_extract_fonts(ass_library_t *priv, int extract)
|
void ass_set_extract_fonts(ASS_Library *priv, int extract)
|
||||||
{
|
{
|
||||||
priv->extract_fonts = !!extract;
|
priv->extract_fonts = !!extract;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_set_style_overrides(ass_library_t *priv, char **list)
|
void ass_set_style_overrides(ASS_Library *priv, char **list)
|
||||||
{
|
{
|
||||||
char **p;
|
char **p;
|
||||||
char **q;
|
char **q;
|
||||||
|
@ -98,7 +98,7 @@ static void grow_array(void **array, int nelem, size_t elsize)
|
||||||
*array = realloc(*array, (nelem + 32) * elsize);
|
*array = realloc(*array, (nelem + 32) * elsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_add_font(ass_library_t *priv, char *name, char *data, int size)
|
void ass_add_font(ASS_Library *priv, char *name, char *data, int size)
|
||||||
{
|
{
|
||||||
int idx = priv->num_fontdata;
|
int idx = priv->num_fontdata;
|
||||||
if (!name || !data || !size)
|
if (!name || !data || !size)
|
||||||
|
@ -116,7 +116,7 @@ void ass_add_font(ass_library_t *priv, char *name, char *data, int size)
|
||||||
priv->num_fontdata++;
|
priv->num_fontdata++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_clear_fonts(ass_library_t *priv)
|
void ass_clear_fonts(ASS_Library *priv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < priv->num_fontdata; ++i) {
|
for (i = 0; i < priv->num_fontdata; ++i) {
|
||||||
|
@ -136,8 +136,8 @@ void ass_clear_fonts(ass_library_t *priv)
|
||||||
* \param msg_cb the callback function
|
* \param msg_cb the callback function
|
||||||
* \param data additional data that will be passed to the callback
|
* \param data additional data that will be passed to the callback
|
||||||
*/
|
*/
|
||||||
void ass_set_message_cb(ass_library_t *priv,
|
void ass_set_message_cb(ASS_Library *priv,
|
||||||
void (*msg_cb)(int, char *, va_list *, void *),
|
void (*msg_cb)(int, const char *, va_list, void *),
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
if (msg_cb) {
|
if (msg_cb) {
|
||||||
|
@ -145,4 +145,3 @@ void ass_set_message_cb(ass_library_t *priv,
|
||||||
priv->msg_callback_data = data;
|
priv->msg_callback_data = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,20 +23,20 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
typedef struct ass_fontdata_s {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
char *data;
|
char *data;
|
||||||
int size;
|
int size;
|
||||||
} ass_fontdata_t;
|
} ASS_Fontdata;
|
||||||
|
|
||||||
struct ass_library_s {
|
struct ass_library {
|
||||||
char *fonts_dir;
|
char *fonts_dir;
|
||||||
int extract_fonts;
|
int extract_fonts;
|
||||||
char **style_overrides;
|
char **style_overrides;
|
||||||
|
|
||||||
ass_fontdata_t *fontdata;
|
ASS_Fontdata *fontdata;
|
||||||
int num_fontdata;
|
int num_fontdata;
|
||||||
void (*msg_callback)(int, char *, va_list *, void *);
|
void (*msg_callback)(int, const char *, va_list, void *);
|
||||||
void *msg_callback_data;
|
void *msg_callback_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,8 +30,14 @@
|
||||||
#define HALIGN_CENTER 2
|
#define HALIGN_CENTER 2
|
||||||
#define HALIGN_RIGHT 3
|
#define HALIGN_RIGHT 3
|
||||||
|
|
||||||
/// ass Style: line
|
/* Opaque objects internally used by libass. Contents are private. */
|
||||||
typedef struct ass_style_s {
|
typedef struct ass_renderer ASS_Renderer;
|
||||||
|
typedef struct render_priv ASS_RenderPriv;
|
||||||
|
typedef struct parser_priv ASS_ParserPriv;
|
||||||
|
typedef struct ass_library ASS_Library;
|
||||||
|
|
||||||
|
/* ASS Style: line */
|
||||||
|
typedef struct ass_style {
|
||||||
char *Name;
|
char *Name;
|
||||||
char *FontName;
|
char *FontName;
|
||||||
double FontSize;
|
double FontSize;
|
||||||
|
@ -54,16 +60,15 @@ typedef struct ass_style_s {
|
||||||
int MarginL;
|
int MarginL;
|
||||||
int MarginR;
|
int MarginR;
|
||||||
int MarginV;
|
int MarginV;
|
||||||
// int AlphaLevel;
|
|
||||||
int Encoding;
|
int Encoding;
|
||||||
int treat_fontname_as_pattern;
|
int treat_fontname_as_pattern;
|
||||||
} ass_style_t;
|
} ASS_Style;
|
||||||
|
|
||||||
typedef struct render_priv_s render_priv_t;
|
/*
|
||||||
|
* ASS_Event corresponds to a single Dialogue line;
|
||||||
/// ass_event_t corresponds to a single Dialogue line
|
* text is stored as-is, style overrides will be parsed later.
|
||||||
/// Text is stored as-is, style overrides will be parsed later
|
*/
|
||||||
typedef struct ass_event_s {
|
typedef struct ass_event {
|
||||||
long long Start; // ms
|
long long Start; // ms
|
||||||
long long Duration; // ms
|
long long Duration; // ms
|
||||||
|
|
||||||
|
@ -77,42 +82,43 @@ typedef struct ass_event_s {
|
||||||
char *Effect;
|
char *Effect;
|
||||||
char *Text;
|
char *Text;
|
||||||
|
|
||||||
render_priv_t *render_priv;
|
ASS_RenderPriv *render_priv;
|
||||||
} ass_event_t;
|
} ASS_Event;
|
||||||
|
|
||||||
typedef struct parser_priv_s parser_priv_t;
|
/*
|
||||||
|
* ass track represent either an external script or a matroska subtitle stream
|
||||||
typedef struct ass_library_s ass_library_t;
|
* (no real difference between them); it can be used in rendering after the
|
||||||
|
* headers are parsed (i.e. events format line read).
|
||||||
/// 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 {
|
||||||
typedef struct ass_track_s {
|
int n_styles; // amount used
|
||||||
int n_styles; // amount used
|
int max_styles; // amount allocated
|
||||||
int max_styles; // amount allocated
|
|
||||||
int n_events;
|
int n_events;
|
||||||
int max_events;
|
int max_events;
|
||||||
ass_style_t *styles; // array of styles, max_styles length, n_styles used
|
ASS_Style *styles; // array of styles, max_styles length, n_styles used
|
||||||
ass_event_t *events; // the same as styles
|
ASS_Event *events; // the same as styles
|
||||||
|
|
||||||
char *style_format; // style format line (everything after "Format: ")
|
char *style_format; // style format line (everything after "Format: ")
|
||||||
char *event_format; // event format line
|
char *event_format; // event format line
|
||||||
|
|
||||||
enum { TRACK_TYPE_UNKNOWN =
|
enum {
|
||||||
0, TRACK_TYPE_ASS, TRACK_TYPE_SSA } track_type;
|
TRACK_TYPE_UNKNOWN = 0,
|
||||||
|
TRACK_TYPE_ASS,
|
||||||
|
TRACK_TYPE_SSA
|
||||||
|
} track_type;
|
||||||
|
|
||||||
// script header fields
|
// Script header fields
|
||||||
int PlayResX;
|
int PlayResX;
|
||||||
int PlayResY;
|
int PlayResY;
|
||||||
double Timer;
|
double Timer;
|
||||||
int WrapStyle;
|
int WrapStyle;
|
||||||
char ScaledBorderAndShadow;
|
int ScaledBorderAndShadow;
|
||||||
|
|
||||||
|
int default_style; // index of default style
|
||||||
|
char *name; // file name in case of external subs, 0 for streams
|
||||||
|
|
||||||
int default_style; // index of default style
|
ASS_Library *library;
|
||||||
char *name; // file name in case of external subs, 0 for streams
|
ASS_ParserPriv *parser_priv;
|
||||||
|
} ASS_Track;
|
||||||
|
|
||||||
ass_library_t *library;
|
#endif /* LIBASS_TYPES_H */
|
||||||
parser_priv_t *parser_priv;
|
|
||||||
} ass_track_t;
|
|
||||||
|
|
||||||
#endif /* LIBASS_TYPES_H */
|
|
||||||
|
|
|
@ -74,11 +74,12 @@ int mystrtod(char **p, double *res)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strtocolor(ass_library_t *library, char **q, uint32_t *res)
|
int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex)
|
||||||
{
|
{
|
||||||
uint32_t color = 0;
|
uint32_t color = 0;
|
||||||
int result;
|
int result;
|
||||||
char *p = *q;
|
char *p = *q;
|
||||||
|
int base = hex ? 16 : 10;
|
||||||
|
|
||||||
if (*p == '&')
|
if (*p == '&')
|
||||||
++p;
|
++p;
|
||||||
|
@ -89,7 +90,7 @@ int strtocolor(ass_library_t *library, char **q, uint32_t *res)
|
||||||
++p;
|
++p;
|
||||||
result = mystrtou32(&p, 16, &color);
|
result = mystrtou32(&p, 16, &color);
|
||||||
} else {
|
} else {
|
||||||
result = mystrtou32(&p, 0, &color);
|
result = mystrtou32(&p, base, &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -122,11 +123,11 @@ char parse_bool(char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_msg(ass_library_t *priv, int lvl, char *fmt, ...)
|
void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
priv->msg_callback(lvl, fmt, &va, priv->msg_callback_data);
|
priv->msg_callback(lvl, fmt, va, priv->msg_callback_data);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ unsigned ass_utf8_get_char(char **str)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ENCA
|
#ifdef CONFIG_ENCA
|
||||||
void *ass_guess_buffer_cp(ass_library_t *library, unsigned char *buffer,
|
void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer,
|
||||||
int buflen, char *preferred_language,
|
int buflen, char *preferred_language,
|
||||||
char *fallback)
|
char *fallback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,17 +43,18 @@
|
||||||
|
|
||||||
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
|
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
|
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
|
||||||
|
#define FFMINMAX(c,a,b) FFMIN(FFMAX(c, a), b)
|
||||||
|
|
||||||
int mystrtoi(char **p, int *res);
|
int mystrtoi(char **p, int *res);
|
||||||
int mystrtoll(char **p, long long *res);
|
int mystrtoll(char **p, long long *res);
|
||||||
int mystrtou32(char **p, int base, uint32_t *res);
|
int mystrtou32(char **p, int base, uint32_t *res);
|
||||||
int mystrtod(char **p, double *res);
|
int mystrtod(char **p, double *res);
|
||||||
int strtocolor(ass_library_t *library, char **q, uint32_t *res);
|
int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex);
|
||||||
char parse_bool(char *str);
|
char parse_bool(char *str);
|
||||||
unsigned ass_utf8_get_char(char **str);
|
unsigned ass_utf8_get_char(char **str);
|
||||||
void ass_msg(ass_library_t *priv, int lvl, char *fmt, ...);
|
void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...);
|
||||||
#ifdef CONFIG_ENCA
|
#ifdef CONFIG_ENCA
|
||||||
void *ass_guess_buffer_cp(ass_library_t *library, unsigned char *buffer,
|
void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer,
|
||||||
int buflen, char *preferred_language,
|
int buflen, char *preferred_language,
|
||||||
char *fallback);
|
char *fallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -62,12 +62,12 @@ LibassSubtitlesProvider::LibassSubtitlesProvider() {
|
||||||
if (first) {
|
if (first) {
|
||||||
ass_library = ass_library_init();
|
ass_library = ass_library_init();
|
||||||
if (!ass_library) throw _T("ass_library_init failed");
|
if (!ass_library) throw _T("ass_library_init failed");
|
||||||
|
|
||||||
wxString fonts_dir = StandardPaths::DecodePath(_T("?user/libass_fonts/"));
|
wxString fonts_dir = StandardPaths::DecodePath(_T("?user/libass_fonts/"));
|
||||||
if (!wxDirExists(fonts_dir))
|
if (!wxDirExists(fonts_dir))
|
||||||
// It's only one level below the user dir, and we assume the user dir already exists at this point.
|
// It's only one level below the user dir, and we assume the user dir already exists at this point.
|
||||||
wxMkdir(fonts_dir);
|
wxMkdir(fonts_dir);
|
||||||
|
|
||||||
ass_set_fonts_dir(ass_library, fonts_dir.mb_str(wxConvFile));
|
ass_set_fonts_dir(ass_library, fonts_dir.mb_str(wxConvFile));
|
||||||
ass_set_extract_fonts(ass_library, 0);
|
ass_set_extract_fonts(ass_library, 0);
|
||||||
ass_set_style_overrides(ass_library, NULL);
|
ass_set_style_overrides(ass_library, NULL);
|
||||||
|
@ -91,7 +91,7 @@ LibassSubtitlesProvider::LibassSubtitlesProvider() {
|
||||||
const char *config_path = NULL;
|
const char *config_path = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ass_set_fonts(ass_renderer, NULL, "Sans", 1, config_path);
|
ass_set_fonts(ass_renderer, NULL, "Sans", 1, config_path, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ void LibassSubtitlesProvider::DrawSubtitles(AegiVideoFrame &frame,double time) {
|
||||||
ass_set_frame_size(ass_renderer, frame.w, frame.h);
|
ass_set_frame_size(ass_renderer, frame.w, frame.h);
|
||||||
|
|
||||||
// Get frame
|
// Get frame
|
||||||
ass_image_t* img = ass_render_frame(ass_renderer, ass_track, int(time * 1000), NULL);
|
ASS_Image* img = ass_render_frame(ass_renderer, ass_track, int(time * 1000), NULL);
|
||||||
|
|
||||||
// libass actually returns several alpha-masked monochrome images.
|
// libass actually returns several alpha-masked monochrome images.
|
||||||
// Here, we loop through their linked list, get the colour of the current, and blend into the frame.
|
// Here, we loop through their linked list, get the colour of the current, and blend into the frame.
|
||||||
|
@ -178,7 +178,7 @@ void LibassSubtitlesProvider::DrawSubtitles(AegiVideoFrame &frame,double time) {
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// Static
|
// Static
|
||||||
ass_library_t* LibassSubtitlesProvider::ass_library;
|
ASS_Library* LibassSubtitlesProvider::ass_library;
|
||||||
|
|
||||||
|
|
||||||
#endif // WITH_LIBASS
|
#endif // WITH_LIBASS
|
||||||
|
|
|
@ -51,9 +51,9 @@ extern "C" {
|
||||||
// libass provider
|
// libass provider
|
||||||
class LibassSubtitlesProvider : public SubtitlesProvider {
|
class LibassSubtitlesProvider : public SubtitlesProvider {
|
||||||
private:
|
private:
|
||||||
static ass_library_t* ass_library;
|
static ASS_Library* ass_library;
|
||||||
ass_renderer_t* ass_renderer;
|
ASS_Renderer* ass_renderer;
|
||||||
ass_track_t* ass_track;
|
ASS_Track* ass_track;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LibassSubtitlesProvider();
|
LibassSubtitlesProvider();
|
||||||
|
|
Loading…
Reference in New Issue