Skip to content

Commit

Permalink
ass: treat 'Name' and 'Actor' as synonyms in format lines
Browse files Browse the repository at this point in the history
Commit b333915 explicitly defaulted
ScaledBorderAndShadow to "yes" for files with custom format lines to
allow a subsequent commit to change the global default to "no" to match
VSFilter, while trying to avoid breaking files expecting libass' prior
default. This commit also changed the fallback ASS event format line to
use 'Name' instead of 'Actor' to match what we are actually parsing,
what Aegisub is emitting and what is used in the "specification".

However, as it turns out, PopSub and files _converted_ by VSFilter
actually do use 'Actor', but are expecting the VSFilter-compatible
default "no".
Thus, treat both variants as synonyms in event parsing and format line
comparison. There is a slight inconsistency here, that _Style_ format
lines which use _Actor_ instead of _Name_ are not recognised as a custom
format line — but a Style Format without a 'Name' won't be able to be
used in rendering anyway.

fixes #516
  • Loading branch information
TheOneric authored and astiob committed Sep 14, 2021
1 parent ed462af commit 88255b0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libass/ass.c
Expand Up @@ -363,6 +363,7 @@ static int process_event_tail(ASS_Track *track, ASS_Event *event,
NEXT(p, token);

ALIAS(End, Duration) // temporarily store end timecode in event->Duration
ALIAS(Actor, Name) // both variants are used in files
PARSE_START
INTVAL(Layer)
STYLEVAL(Style)
Expand Down Expand Up @@ -579,6 +580,14 @@ static int process_style(ASS_Track *track, char *str)

static bool format_line_compare(const char *fmt1, const char *fmt2)
{
#define TOKEN_ALIAS1(token, name, alias) \
if (token ## _end - token ## _start == sizeof( #alias ) - 1 && \
!strncmp(token ## _start, #alias, sizeof( #alias ) - 1)) { \
token ## _start = #name; \
token ## _end = token ## _start + sizeof( #name ) - 1; \
}
#define TOKEN_ALIAS(name, alias) TOKEN_ALIAS1(tk1, name, alias) TOKEN_ALIAS1(tk2, name, alias)

while (true) {
const char *tk1_start, *tk2_start;
const char *tk1_end, *tk2_end;
Expand All @@ -591,12 +600,16 @@ static bool format_line_compare(const char *fmt1, const char *fmt2)
advance_token_pos(&fmt1, &tk1_start, &tk1_end);
advance_token_pos(&fmt2, &tk2_start, &tk2_end);

TOKEN_ALIAS(Name, Actor)
if ((tk1_end-tk1_start) != (tk2_end-tk2_start))
return false;
if (ass_strncasecmp(tk1_start, tk2_start, tk1_end-tk1_start))
return false;
}
return *fmt1 == *fmt2;

#undef TOKEN_ALIAS
#undef TOKEN_ALIAS1
}


Expand Down

0 comments on commit 88255b0

Please sign in to comment.