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.
This commit is contained in:
wm4 2015-12-06 18:22:30 +01:00
parent 7d7ea72854
commit 970606e491
1 changed files with 10 additions and 1 deletions

View File

@ -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.