1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-14 10:55:43 +00:00

Fixed subtitle clearing.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11813 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
mosu 2004-01-20 09:57:19 +00:00
parent 5ac6e2092c
commit ef7a6695c7

View File

@ -2222,8 +2222,14 @@ handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
}
ptr1 = block;
while ((*ptr1 == '\n' || *ptr1 == '\r') && ptr1 - block <= size)
while (ptr1 - block <= size && (*ptr1 == '\n' || *ptr1 == '\r'))
ptr1++;
ptr2 = block + size - 1;
while (ptr2 >= block && (*ptr2 == '\n' || *ptr2 == '\r'))
{
*ptr2 = 0;
ptr2--;
}
if (mkv_d->subs.lines > SUB_MAX_TEXT - 2)
{
@ -2325,12 +2331,25 @@ handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
}
static void
clear_subtitles(demuxer_t *demuxer, uint64_t timecode)
clear_subtitles(demuxer_t *demuxer, uint64_t timecode, int clear_all)
{
mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
int i, lines_cut = 0;
char *tmp;
/* Clear all? */
if (clear_all)
{
lines_cut = mkv_d->subs.lines;
mkv_d->subs.lines = 0;
if (lines_cut)
{
vo_sub = &mkv_d->subs;
vo_osd_changed (OSDTYPE_SUBTITLE);
}
return;
}
/* Clear the subtitles if they're obsolete now. */
for (i=0; i < mkv_d->subs.lines; i++)
{
@ -2341,7 +2360,7 @@ clear_subtitles(demuxer_t *demuxer, uint64_t timecode)
(mkv_d->subs.lines-i-1) * sizeof (*mkv_d->subs.text));
memmove (mkv_d->clear_subs_at+i, mkv_d->clear_subs_at+i+1,
(mkv_d->subs.lines-i-1) * sizeof (*mkv_d->clear_subs_at));
mkv_d->subs.text[mkv_d->subs.lines--] = tmp;
mkv_d->subs.text[--mkv_d->subs.lines] = tmp;
i--;
lines_cut = 1;
}
@ -2499,7 +2518,7 @@ handle_block (demuxer_t *demuxer, uint8_t *block, uint64_t length,
return -1;
current_pts = tc / 1000.0;
clear_subtitles(demuxer, tc);
clear_subtitles(demuxer, tc, 0);
for (i=0; i<mkv_d->num_tracks; i++)
if (mkv_d->tracks[i]->tnum == num)
@ -2815,6 +2834,10 @@ demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, int flags)
mkv_d->skip_to_timecode = target_timecode;
mkv_d->a_skip_to_keyframe = 1;
/* Clear subtitles. */
if (target_timecode <= mkv_d->last_pts * 1000)
clear_subtitles(demuxer, 0, 1);
demux_mkv_fill_buffer(demuxer);
if(demuxer->audio->sh != NULL)