mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-26 04:59:30 +08:00
Add public functions for removal of styles and events.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19480 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
+22
-21
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,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
|
||||
|
||||
Reference in New Issue
Block a user