mirror of https://github.com/mpv-player/mpv
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:
parent
7d7ea72854
commit
970606e491
11
sub/sd_ass.c
11
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);
|
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)
|
#define END(ev) ((ev)->Start + (ev)->Duration)
|
||||||
|
|
||||||
static long long find_timestamp(struct sd *sd, double pts)
|
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;
|
return ts;
|
||||||
|
|
||||||
// Simple/minor heuristic against destroying typesetting.
|
// 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;
|
return ts;
|
||||||
|
|
||||||
// Sort by start timestamps.
|
// Sort by start timestamps.
|
||||||
|
|
Loading…
Reference in New Issue