summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-08-21 16:33:13 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-08-21 16:33:13 +0000
commitcd59e2161098cc5aacc2ec76247c49a42104d5ee (patch)
tree04f2a440b0201a2fb545734b3fdbbd3ffab475dc /libass
parent09024649419bee4365ca39b2f279b35c42ac0e63 (diff)
downloadmpv-cd59e2161098cc5aacc2ec76247c49a42104d5ee.tar.bz2
mpv-cd59e2161098cc5aacc2ec76247c49a42104d5ee.tar.xz
Add public functions for removal of styles and events.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19480 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass.c43
-rw-r--r--libass/ass.h16
2 files changed, 38 insertions, 21 deletions
diff --git a/libass/ass.c b/libass/ass.c
index 3eeb755fad..e5f9f5b8f4 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -37,25 +37,13 @@ void ass_free_track(ass_track_t* track) {
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 @@ int ass_alloc_event(ass_track_t* track) {
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 @@ void ass_process_line(ass_track_t* track, char *data, int size, long long timeco
// dump_events(tid);
} while (0);
// some error
- free_event(track, eid);
+ ass_free_event(track, eid);
+ track->n_events--;
free(str);
}
diff --git a/libass/ass.h b/libass/ass.h
index 6049fd184b..54fef6a719 100644
--- a/libass/ass.h
+++ b/libass/ass.h
@@ -110,6 +110,22 @@ int ass_alloc_style(ass_track_t* track);
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