Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse override tag arguments exactly like VSFilter #94

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 2 additions & 30 deletions libass/ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,6 @@ void ass_free_style(ASS_Track *track, int sid)

// ==============================================================================================

static void skip_spaces(char **str)
{
char *p = *str;
while ((*p == ' ') || (*p == '\t'))
++p;
*str = p;
}

static void rskip_spaces(char **str, char *limit)
{
char *p = *str;
while ((p >= limit) && ((*p == ' ') || (*p == '\t')))
--p;
*str = p;
}

/**
* \brief Set up default style
* \param style style to edit to defaults
Expand All @@ -195,13 +179,6 @@ static void set_default_style(ASS_Style *style)
style->MarginL = style->MarginR = style->MarginV = 20;
}

static uint32_t string2color(ASS_Library *library, char *p)
{
uint32_t tmp;
(void) strtocolor(library, &p, &tmp, 0);
return tmp;
}

static long long string2timecode(ASS_Library *library, char *p)
{
unsigned h, m, s, ms;
Expand Down Expand Up @@ -267,7 +244,7 @@ static int numpad2align(int val)

#define COLORVAL(name) \
} else if (strcasecmp(tname, #name) == 0) { \
target->name = string2color(track->library, token);
target->name = string2color(track->library, token, 0);

#define INTVAL(name) ANYVAL(name,atoi)
#define FPVAL(name) ANYVAL(name,ass_atof)
Expand Down Expand Up @@ -297,12 +274,7 @@ static char *next_token(char **str)
*p = '\0';
*str = p + 1; // ',' found, str will point to the next char (beginning of the next token)
}
--p; // end of current token
rskip_spaces(&p, start);
if (p < start)
p = start; // empty token
else
++p; // the first space character, or '\0'
rskip_spaces(&p, start); // end of current token: the first space character, or '\0'
*p = '\0';
return start;
}
Expand Down
14 changes: 14 additions & 0 deletions libass/ass_drawing.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,20 @@ void ass_drawing_add_char(ASS_Drawing* drawing, char symbol)
}
}

/*
* \brief Add an ASCII string to the drawing text buffer
*/
void ass_drawing_add_chars(ASS_Drawing* drawing, char *str, int n)
{
if (drawing->i + n + 1 >= drawing->size) {
drawing->size = drawing->i + n + 1;
drawing->text = realloc(drawing->text, drawing->size);
}

memcpy(drawing->text + drawing->i, str, n);
drawing->text[drawing->i += n] = 0;
}

/*
* \brief Create a hashcode for the drawing
* XXX: To avoid collisions a better hash algorithm might be useful.
Expand Down
1 change: 1 addition & 0 deletions libass/ass_drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typedef struct {
ASS_Drawing *ass_drawing_new(ASS_Library *lib, FT_Library ftlib);
void ass_drawing_free(ASS_Drawing* drawing);
void ass_drawing_add_char(ASS_Drawing* drawing, char symbol);
void ass_drawing_add_chars(ASS_Drawing* drawing, char *str, int n);
void ass_drawing_hash(ASS_Drawing* drawing);
FT_Outline *ass_drawing_parse(ASS_Drawing *drawing, int raw_mode);

Expand Down