changeset 31227:ee7beb1a3a6e

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.
author aurel
date Mon, 31 May 2010 19:10:57 +0000
parents 1f607394598a
children b07b7bf70b71
files libass/ass.c libass/ass.h mplayer.c
diffstat 3 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass.c	Mon May 31 17:12:27 2010 +0000
+++ b/libass/ass.c	Mon May 31 19:10:57 2010 +0000
@@ -909,6 +909,20 @@
     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
--- a/libass/ass.h	Mon May 31 17:12:27 2010 +0000
+++ b/libass/ass.h	Mon May 31 19:10:57 2010 +0000
@@ -317,6 +317,12 @@
                        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
  * \param fname file name
--- a/mplayer.c	Mon May 31 17:12:27 2010 +0000
+++ b/mplayer.c	Mon May 31 19:10:57 2010 +0000
@@ -2581,6 +2581,11 @@
 	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;