diff options
author | Aman Gupta <aman@tmm1.net> | 2016-01-07 13:31:09 -0800 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2016-01-18 12:12:34 -0800 |
commit | 1781bf26f101442be06d72243e8cbeffcaa47658 (patch) | |
tree | 05153d1ee8886ff7d46647f534aec7a351c56fce | |
parent | 5053f4cc3f48538c3d9a3ba13dc98442f3302052 (diff) |
ass_mp: add mp_ass_flush_old_events()
-rw-r--r-- | sub/ass_mp.c | 14 | ||||
-rw-r--r-- | sub/ass_mp.h | 1 |
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); |