[Mplayer-cvslog] CVS: main/libmpdemux demux_mkv.c,1.2,1.3
Moritz Bunkus CVS
mosu at mplayerhq.hu
Tue Jan 20 10:57:21 CET 2004
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/scsi/2/tmp/cvs-serv23876
Modified Files:
demux_mkv.c
Log Message:
Fixed subtitle clearing.
Index: demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- demux_mkv.c 19 Jan 2004 19:51:07 -0000 1.2
+++ demux_mkv.c 20 Jan 2004 09:57:19 -0000 1.3
@@ -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)
More information about the MPlayer-cvslog
mailing list