summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sub/ass_mp.c14
-rw-r--r--sub/ass_mp.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index b30b9964de..8d40b5256a 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -163,3 +163,17 @@ ASS_Library *mp_ass_init(struct mpv_global *global, struct mp_log *log)
talloc_free(path);
return priv;
}
+
+void mp_ass_flush_old_events(ASS_Track *track, long long ts)
+{
+ int n = 0;
+ for (; n < track->n_events; n++) {
+ if ((track->events[n].Start + track->events[n].Duration) >= ts)
+ break;
+ ass_free_event(track, n);
+ track->n_events--;
+ }
+ for (int i = 0; n > 0 && i < track->n_events; i++) {
+ track->events[i] = track->events[i+n];
+ }
+}
diff --git a/sub/ass_mp.h b/sub/ass_mp.h
index 98311824ab..789a53acb1 100644
--- a/sub/ass_mp.h
+++ b/sub/ass_mp.h
@@ -44,6 +44,7 @@ struct mpv_global;
struct mp_osd_res;
struct osd_style_opts;
+void mp_ass_flush_old_events(ASS_Track *track, long long ts);
void mp_ass_set_style(ASS_Style *style, double res_y,
const struct osd_style_opts *opts);