From 970606e49198594c243edf4a85c426693676f6a3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 6 Dec 2015 18:22:30 +0100 Subject: sd_ass: slightly better heuristic for applying --sub-fix-timing Fixes a reported sample, that has a sign interrupted by a few frames (for which --sub-fix-timing would remove the wanted gap). The list of tags in has_overrides() is taken from libass. It has a similar function (which even checks whether the tag are within the { } delimiters). Unfortunately, this function is not public, so we just have a simpler one which does roughly the same. It doesn't matter that this function sometimes returns false positives. --- sub/sd_ass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 261d0e1b2d..9e4da9a379 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -258,6 +258,14 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, ass_set_line_spacing(priv, set_line_spacing); } +static bool has_overrides(char *s) +{ + if (!s) + return false; + return strstr(s, "\\pos") || strstr(s, "\\move") || strstr(s, "\\clip") || + strstr(s, "\\iclip") || strstr(s, "\\org") || strstr(s, "\\p"); +} + #define END(ev) ((ev)->Start + (ev)->Duration) static long long find_timestamp(struct sd *sd, double pts) @@ -294,7 +302,8 @@ static long long find_timestamp(struct sd *sd, double pts) return ts; // Simple/minor heuristic against destroying typesetting. - if (ev[0]->Style != ev[1]->Style) + if (ev[0]->Style != ev[1]->Style || has_overrides(ev[0]->Text) || + has_overrides(ev[1]->Text)) return ts; // Sort by start timestamps. -- cgit v1.2.3