mirror of https://github.com/mpv-player/mpv
sub: remove check_duplicate_plaintext_event()
This was once needed to handle subtitle packages coming from a demuxer, where seeking back might repeat previous events. This doesn't happen anymore, and this code is used to convert complete files. So if there are any duplicate lines, they must have been duplicated in the file, and the old subtitle renderer would have shown them twice as well. Today checking for duplicate events happens in sd_ass.c (and has been for a while). There's no reason to keep this code, and it actually causes trouble. Loading big subtitle files is extremely slow because this makes adding n subtitles O(n^2).
This commit is contained in:
parent
b44202b69f
commit
38bd757e4f
19
sub/ass_mp.c
19
sub/ass_mp.c
|
@ -102,19 +102,6 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
|
|||
return track;
|
||||
}
|
||||
|
||||
static int check_duplicate_plaintext_event(ASS_Track *track)
|
||||
{
|
||||
int i;
|
||||
ASS_Event *evt = track->events + track->n_events - 1;
|
||||
|
||||
for (i = 0; i < track->n_events - 1; ++i) // ignoring last event, it is the one we are comparing with
|
||||
if (track->events[i].Start == evt->Start &&
|
||||
track->events[i].Duration == evt->Duration &&
|
||||
strcmp(track->events[i].Text, evt->Text) == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Convert subtitle to ASS_Events for the given track
|
||||
* \param track track
|
||||
|
@ -159,12 +146,6 @@ static int ass_process_subtitle(ASS_Track *track, subtitle *sub)
|
|||
p -= 2; // remove last "\N"
|
||||
*p = 0;
|
||||
|
||||
if (check_duplicate_plaintext_event(track)) {
|
||||
ass_free_event(track, eid);
|
||||
track->n_events--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mp_msg(MSGT_ASS, MSGL_V,
|
||||
"plaintext event at %" PRId64 ", +%" PRId64 ": %s \n",
|
||||
(int64_t) event->Start, (int64_t) event->Duration, event->Text);
|
||||
|
|
Loading…
Reference in New Issue