diff options
authorwm4 <wm4@nowhere>2015-12-06 18:22:30 +0100
committerwm4 <wm4@nowhere>2015-12-06 18:22:30 +0100
commit970606e49198594c243edf4a85c426693676f6a3 (patch)
parent7d7ea72854ba3576bd6a05901dd1de39b16b5efe (diff)
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.
1 files changed, 10 insertions, 1 deletions
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.