[MPlayer-cvslog] CVS: main/libmpdemux demux_mpg.c,1.77,1.78

Reimar Döffinger CVS syncmail at mplayerhq.hu
Mon Apr 10 18:18:20 CEST 2006


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv9920

Modified Files:
	demux_mpg.c 
Log Message:
make sure the check for valid timestamps does not accidentially search through
several hundered MB (e.g. happens under MinGW with certain DVDs due to movi_end
overflowing).


Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- demux_mpg.c	12 Mar 2006 12:28:09 -0000	1.77
+++ demux_mpg.c	10 Apr 2006 16:18:17 -0000	1.78
@@ -99,11 +99,14 @@
   return 1;
 }
 
+// 500000 is a wild guess
+#define TIMESTAMP_PROBE_LEN 500000
+
 /// Open an mpg physical stream
 static demuxer_t* demux_mpg_open(demuxer_t* demuxer) {
   stream_t *s = demuxer->stream;
   off_t pos = stream_tell(s);
-  off_t end_seq_start = demuxer->movi_end-500000; // 500000 is a wild guess
+  off_t end_seq_start = demuxer->movi_end-TIMESTAMP_PROBE_LEN;
   float half_pts = 0.0;
   mpg_demuxer_t* mpg_d;
 
@@ -114,13 +117,18 @@
   mpg_d->has_valid_timestamps = 1;
   mpg_d->num_a_streams = 0;
   if (demuxer->seekable && stream_tell(demuxer->stream) < end_seq_start) {
-    stream_seek(s,(pos + end_seq_start / 2));
+    off_t half_pos = pos + end_seq_start / 2;
+    stream_seek(s, half_pos);
     while ((!s->eof) && ds_fill_buffer(demuxer->video) && half_pts == 0.0) {
       half_pts = mpg_d->last_pts;
+      if (stream_tell(s) > half_pos + TIMESTAMP_PROBE_LEN)
+        break;
     }
     stream_seek(s,end_seq_start);
     while ((!s->eof) && ds_fill_buffer(demuxer->video)) {
       if (mpg_d->final_pts < mpg_d->last_pts) mpg_d->final_pts = mpg_d->last_pts;
+      if (stream_tell(s) > demuxer->movi_end)
+        break;
     }
     // educated guess about validity of timestamps
     if (mpg_d->final_pts > 3 * half_pts || mpg_d->final_pts < 1.5 * half_pts) {




More information about the MPlayer-cvslog mailing list