Mercurial > mplayer.hg
changeset 11812:322e2b0a1815
Fixed subtitle clearing.
author | mosu |
---|---|
date | Tue, 20 Jan 2004 09:57:19 +0000 |
parents | 30507afa1cf6 |
children | 629063044de5 |
files | libmpdemux/demux_mkv.c |
diffstat | 1 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c Tue Jan 20 05:39:12 2004 +0000 +++ b/libmpdemux/demux_mkv.c Tue Jan 20 09:57:19 2004 +0000 @@ -2222,8 +2222,14 @@ } 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 @@ } 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 @@ (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 @@ 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 @@ 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)