[MPlayer-cvslog] r37760 - trunk/libmpdemux/demux_mpg.c

reimar subversion at mplayerhq.hu
Sat Feb 20 12:37:20 CET 2016


Author: reimar
Date: Sat Feb 20 12:37:20 2016
New Revision: 37760

Log:
demux_mpg: Limit how much data probing reads.

Limits data read during probe to 4 MB.
Reading more data can take a long time and also
causes issues with non-seekable streams that only
have the cache to seek back in.
It also increases the chances for false positives.
It might break autodetection of heavily corrupted
files, but that seems like a reasonable compromise.

Modified:
   trunk/libmpdemux/demux_mpg.c

Modified: trunk/libmpdemux/demux_mpg.c
==============================================================================
--- trunk/libmpdemux/demux_mpg.c	Sat Feb 20 12:34:11 2016	(r37759)
+++ trunk/libmpdemux/demux_mpg.c	Sat Feb 20 12:37:20 2016	(r37760)
@@ -318,7 +318,6 @@ static int demux_mpg_read_packet(demuxer
 //  if(id==0x1BA) packet_start_pos=stream_tell(demux->stream);
   if((id<0x1BC || id>=0x1F0) && id != 0x1FD) return -1;
   if(id==0x1BE) return -1; // padding stream
-  if(id==0x1BF) return -1; // private2
 
   len=stream_read_word(demux->stream);
   mp_dbg(MSGT_DEMUX,MSGL_DBG3,"PACKET len=%d",len);
@@ -330,6 +329,9 @@ static int demux_mpg_read_packet(demuxer
 
   mpeg_pts_error=0;
 
+  if(id==0x1BF) { // private2
+    return -1;
+  }
   if(id==0x1BC) {
     parse_psm(demux, len);
     return 0;
@@ -688,6 +690,7 @@ static int demux_mpg_probe(demuxer_t *de
   off_t tmppos;
   int file_format = DEMUXER_TYPE_UNKNOWN;
 
+  demuxer->synced = -1;
   tmppos=stream_tell(demuxer->stream);
   tmp=stream_read_dword(demuxer->stream);
   if(tmp==0x1E0 || tmp==0x1C0) {
@@ -832,6 +835,12 @@ unsigned int head=0;
 int skipped=0;
 int max_packs=2048;
 int ret=0;
+uint64_t end_pos = 0;
+if (demux->synced == -1) {
+  // limit to 4 MB during probing
+  end_pos = stream_tell(demux->stream) + 4*1024*1024;
+  demux->synced = 0;
+}
 
 // System stream
 do{
@@ -858,6 +867,8 @@ do{
    }
    demux->filepos+=skipped;
   }
+  if (end_pos && end_pos < demux->filepos)
+    demux->stream->eof = 1;
   if(stream_eof(demux->stream)) break;
   // sure: head=0x000001XX
   mp_dbg(MSGT_DEMUX,MSGL_DBG4,"*** head=0x%X\n",head);


More information about the MPlayer-cvslog mailing list