changeset 2598:a937f0024514

-idx fixes: support for divx4 and ignoring bad movi_end
author arpi
date Wed, 31 Oct 2001 20:43:13 +0000
parents dfb13228e18b
children 8286ce06dfa1
files libmpdemux/aviheader.c
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/aviheader.c	Wed Oct 31 20:15:19 2001 +0000
+++ b/libmpdemux/aviheader.c	Wed Oct 31 20:43:13 2001 +0000
@@ -122,6 +122,13 @@
 	case mmioFOURCC('D', 'I', 'V', '2'):
         case mmioFOURCC('A', 'P', '4', '1'):
           idxfix_divx=1; // we can fix keyframes only for divx coded files!
+	  mp_msg(MSGT_HEADER,MSGL_V,"Regenerating keyframe table for DIVX 3 video\n");
+	  break;
+        case mmioFOURCC('D', 'I', 'V', 'X'):
+        case mmioFOURCC('d', 'i', 'v', 'x'):
+          idxfix_divx=2; // we can fix keyframes only for divx coded files!
+	  mp_msg(MSGT_HEADER,MSGL_V,"Regenerating keyframe table for DIVX 4 video\n");
+	  break;
         }
       } else
       if(last_fccType==streamtypeAUDIO){
@@ -181,9 +188,9 @@
   while(1){
     int id,len,skip;
     AVIINDEXENTRY* idx;
-    unsigned char c;
+    unsigned int c;
     demuxer->filepos=stream_tell(demuxer->stream);
-    if(demuxer->filepos>=demuxer->movi_end) break;
+    if(demuxer->filepos>=demuxer->movi_end && demuxer->movi_start<demuxer->movi_end) break;
     id=stream_read_dword_le(demuxer->stream);
     len=stream_read_dword_le(demuxer->stream);
     if(id==mmioFOURCC('L','I','S','T')){
@@ -205,15 +212,17 @@
     idx->dwChunkOffset=demuxer->filepos;
     idx->dwChunkLength=len;
     
-    c=stream_read_char(demuxer->stream);
+    c=stream_read_dword(demuxer->stream);
 
     // Fix keyframes for DivX files:
     if(idxfix_divx)
       if(avi_stream_id(id)==idxfix_videostream){
-        if(c&0x40) idx->dwFlags=0;
+        switch(idxfix_divx){
+    	    case 1: if(c&0x40000000) idx->dwFlags=0;break; // divx 3
+	    case 2: if(c==0x1B6) idx->dwFlags=0;break; // divx 4
+	}
       }
-    
-    mp_dbg(MSGT_HEADER,MSGL_DBG2,"%08X %08X %.4s %02X %X\n",demuxer->filepos,id,(char *) &id,c,(unsigned int) idx->dwFlags);
+    mp_dbg(MSGT_HEADER,MSGL_DBG2,"%08X %08X %.4s %08X %X\n",(int)demuxer->filepos,id,(char *) &id,(int)c,(unsigned int) idx->dwFlags);
 #if 0
     { unsigned char tmp[64];
       int i;