From 88255b06dcf99ca37ae2493c1618dafb84837b2f Mon Sep 17 00:00:00 2001 From: Oneric Date: Sun, 30 May 2021 23:20:01 +0200 Subject: ass: treat 'Name' and 'Actor' as synonyms in format lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- libass/ass.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 } -- cgit v1.2.3