diff options
author | Oneric <oneric@oneric.stub> | 2021-05-30 23:20:01 +0200 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2021-09-14 21:59:33 +0300 |
commit | 88255b06dcf99ca37ae2493c1618dafb84837b2f (patch) | |
tree | 0719631601d9c0f4733faf83f667a39ec43a5a8d | |
parent | ed462af3fdd8867ab6dc1f8664aa392f21a494bf (diff) | |
download | libass-88255b06dcf99ca37ae2493c1618dafb84837b2f.tar.bz2 libass-88255b06dcf99ca37ae2493c1618dafb84837b2f.tar.xz |
ass: treat 'Name' and 'Actor' as synonyms in format lines
Commit b3339152db5b80991966911fe2efc8a6174b0071 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 https://github.com/libass/libass/issues/516
-rw-r--r-- | libass/ass.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libass/ass.c b/libass/ass.c index 51fa201..8581141 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -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) @@ -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; @@ -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 } |