[MPlayer-cvslog] r19480 - in trunk/libass: ass.c ass.h

eugeni subversion at mplayerhq.hu
Mon Aug 21 18:33:13 CEST 2006


Author: eugeni
Date: Mon Aug 21 18:33:13 2006
New Revision: 19480

Modified:
   trunk/libass/ass.c
   trunk/libass/ass.h

Log:
Add public functions for removal of styles and events.


Modified: trunk/libass/ass.c
==============================================================================
--- trunk/libass/ass.c	(original)
+++ trunk/libass/ass.c	Mon Aug 21 18:33:13 2006
@@ -37,25 +37,13 @@
 	if (track->event_format)
 		free(track->event_format);
 	if (track->styles) {
-		for (i = 0; i < track->n_styles; ++i) {
-			ass_style_t* style = track->styles + i;
-			if (style->Name)
-				free(style->Name);
-			if (style->FontName)
-				free(style->FontName);
-		}
+		for (i = 0; i < track->n_styles; ++i)
+			ass_free_style(track, i);
 		free(track->styles);
 	}
 	if (track->events) {
-		for (i = 0; i < track->n_events; ++i) {
-			ass_event_t* event = track->events + i;
-			if (event->Name)
-				free(event->Name);
-			if (event->Effect)
-				free(event->Effect);
-			if (event->Text)
-				free(event->Text);
-		}
+		for (i = 0; i < track->n_events; ++i)
+			ass_free_event(track, i);
 		free(track->events);
 	}
 }
@@ -96,10 +84,22 @@
 	return eid;
 }
 
-static void free_event(ass_track_t* track, int eid) {
-	if (track->n_events > eid + 1) // not last event
-		memcpy(track->events + eid, track->events + eid + 1, sizeof(ass_event_t) * (track->n_events - eid - 1));
-	track->n_events--;
+void ass_free_event(ass_track_t* track, int eid) {
+	ass_event_t* event = track->events + eid;
+	if (event->Name)
+		free(event->Name);
+	if (event->Effect)
+		free(event->Effect);
+	if (event->Text)
+		free(event->Text);
+}
+
+void ass_free_style(ass_track_t* track, int sid) {
+	ass_style_t* style = track->styles + sid;
+	if (style->Name)
+		free(style->Name);
+	if (style->FontName)
+		free(style->FontName);
 }
 
 static int events_compare_f(const void* a_, const void* b_) {
@@ -530,7 +530,8 @@
 //		dump_events(tid);
 	} while (0);
 	// some error
-	free_event(track, eid);
+	ass_free_event(track, eid);
+	track->n_events--;
 	free(str);
 }
 

Modified: trunk/libass/ass.h
==============================================================================
--- trunk/libass/ass.h	(original)
+++ trunk/libass/ass.h	Mon Aug 21 18:33:13 2006
@@ -110,6 +110,22 @@
 int ass_alloc_event(ass_track_t* track);
 
 /**
+ * \brief delete a style
+ * \param track track
+ * \param sid style id
+ * Deallocates style data. Does not modify track->n_styles.
+ */
+void ass_free_style(ass_track_t* track, int sid);
+
+/**
+ * \brief delete an event
+ * \param track track
+ * \param eid event id
+ * Deallocates event data. Does not modify track->n_events.
+ */
+void ass_free_event(ass_track_t* track, int eid);
+
+/**
  * \brief Process Codec Private section of subtitle stream
  * \param track target track
  * \param data string to parse



More information about the MPlayer-cvslog mailing list