From e123aecb4825db7da60e67eae3a01d9222593d95 Mon Sep 17 00:00:00 2001 From: aurel Date: Mon, 31 May 2010 19:10:57 +0000 Subject: [PATCH] backport ass_flush_events() from upstream libass and make use of it This fixes subtitles duplication when seeking back in ass stream formated with the "standard" format FFmpeg uses. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31293 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass.c | 14 ++++++++++++++ libass/ass.h | 6 ++++++ mplayer.c | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/libass/ass.c b/libass/ass.c index 6becb39e8e..1e8cddd00d 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -909,6 +909,20 @@ void ass_process_chunk(ASS_Track *track, char *data, int size, free(str); } +/** + * \brief Flush buffered events. + * \param track track +*/ +void ass_flush_events(ASS_Track *track) +{ + if (track->events) { + int eid; + for (eid = 0; eid < track->n_events; eid++) + ass_free_event(track, eid); + track->n_events = 0; + } +} + #ifdef CONFIG_ICONV /** \brief recode buffer to utf-8 * constraint: codepage != 0 diff --git a/libass/ass.h b/libass/ass.h index e7674a736c..03b690c063 100644 --- a/libass/ass.h +++ b/libass/ass.h @@ -316,6 +316,12 @@ void ass_process_codec_private(ASS_Track *track, char *data, int size); void ass_process_chunk(ASS_Track *track, char *data, int size, long long timecode, long long duration); +/** + * \brief Flush buffered events. + * \param track track +*/ +void ass_flush_events(ASS_Track *track); + /** * \brief Read subtitles from file. * \param library library handle diff --git a/mplayer.c b/mplayer.c index 98d36586ee..1c56ba3c19 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2581,6 +2581,11 @@ static int seek(MPContext *mpctx, double amount, int style) vobsub_seek(vo_vobsub, mpctx->sh_video->pts); } +#ifdef CONFIG_ASS + if (ass_enabled && mpctx->d_sub->sh && ((sh_sub_t *)mpctx->d_sub->sh)->ass_track) + ass_flush_events(((sh_sub_t *)mpctx->d_sub->sh)->ass_track); +#endif + edl_seek_reset(mpctx); c_total = 0;