changeset 1421:ea0a0b9e6fbc

nosound avi seeking fixed
author arpi
date Sun, 29 Jul 2001 21:07:34 +0000
parents d97816161256
children d02e0dcaf077
files demux_avi.c demuxer.c mplayer.c seek.c
diffstat 4 files changed, 26 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/demux_avi.c	Sun Jul 29 17:42:06 2001 +0000
+++ b/demux_avi.c	Sun Jul 29 21:07:34 2001 +0000
@@ -126,12 +126,14 @@
 do{
   int flags=0;
   AVIINDEXENTRY *idx=NULL;
+#if 0
   demux->filepos=stream_tell(demux->stream);
   if(demux->filepos>=demux->movi_end){
           demux->stream->eof=1;
           return 0;
   }
   if(stream_eof(demux->stream)) return 0;
+#endif
   if(demux->idx_size>0 && demux->idx_pos<demux->idx_size){
     unsigned int pos;
     
@@ -155,7 +157,7 @@
 
     pos=idx->dwChunkOffset+demux->idx_offset;
     if(pos<demux->movi_start || pos>=demux->movi_end){
-      printf("ChunkOffset out of range!  current=0x%X  idx=0x%X  \n",demux->filepos,pos);
+      printf("ChunkOffset out of range!   idx=0x%X  \n",pos);
       continue;
     }
 #if 0
@@ -164,7 +166,10 @@
     }
 #endif
     stream_seek(demux->stream,pos);
+    demux->filepos=stream_tell(demux->stream);
     id=stream_read_dword_le(demux->stream);
+    if(stream_eof(demux->stream)) return 0; // EOF!
+    
     if(id!=idx->ckid){
       printf("ChunkID mismatch! raw=%.4s idx=%.4s  \n",(char *)&id,(char *)&idx->ckid);
       continue;
@@ -178,8 +183,15 @@
     }
     if(idx->dwFlags&AVIIF_KEYFRAME) flags=1;
   } else {
+    demux->filepos=stream_tell(demux->stream);
+    if(demux->filepos>=demux->movi_end){
+          demux->stream->eof=1;
+          return 0;
+    }
     id=stream_read_dword_le(demux->stream);
     len=stream_read_dword_le(demux->stream);
+    if(stream_eof(demux->stream)) return 0; // EOF!
+    
     if(id==mmioFOURCC('L','I','S','T')){
       id=stream_read_dword_le(demux->stream);      // list type
       continue;
--- a/demuxer.c	Sun Jul 29 17:42:06 2001 +0000
+++ b/demuxer.c	Sun Jul 29 21:07:34 2001 +0000
@@ -180,7 +180,10 @@
       printf("(maybe you play a non-interleaved stream/file or video codec failed)\n");
       break;
     }
-    if(!demux_fill_buffer(demux,ds)) break; // EOF
+    if(!demux_fill_buffer(demux,ds)){
+       if(verbose) printf("ds_fill_buffer()->demux_fill_buffer() failed\n");
+       break; // EOF
+    }
   }
   ds->buffer_pos=ds->buffer_size=0;
   ds->buffer=NULL;
--- a/mplayer.c	Sun Jul 29 17:42:06 2001 +0000
+++ b/mplayer.c	Sun Jul 29 21:07:34 2001 +0000
@@ -1166,16 +1166,16 @@
               videobuffer[videobuf_len+3]=0xFF;
               videobuf_len+=4;
 #endif
-              if(!i) eof=1; // EOF
+              if(!i) eof=2; // EOF
               break;
             }
           } else {
             //if(i==0x100) in_frame=1; // picture startcode
             if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode
-            else if(!i){ eof=1; break;} // EOF
+            else if(!i){ eof=3; break;} // EOF
           }
 	  if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1;
-          if(!read_video_packet(d_video)){ eof=1; break;} // EOF
+          if(!read_video_packet(d_video)){ eof=4; break;} // EOF
           //printf("read packet 0x%X, len=%d\n",i,videobuf_len);
 	  if(sh_video->codec->driver!=VFM_MPEG){
 	    // if not libmpeg2:
@@ -1212,7 +1212,7 @@
       // frame-based file formats: (AVI,ASF,MOV)
     unsigned char* start=NULL;
     int in_size=ds_get_packet(d_video,&start);
-    if(in_size<0){ eof=1;break;}
+    if(in_size<0){ eof=5;break;}
     if(in_size>max_framesize) max_framesize=in_size;
     blit_frame=decode_video(video_out,sh_video,start,in_size,drop_frame);
   }
@@ -1545,7 +1545,7 @@
   rel_seek_secs=0;
   
 //================= Update OSD ====================
-{ if(osd_level>=2){
+  if(osd_level>=2){
       int pts=d_video->pts;
       if(pts==osd_last_pts-1) ++pts; else osd_last_pts=pts;
       vo_osd_text=osd_text_buffer;
@@ -1581,9 +1581,9 @@
     }
   }
   
-}
+} // while(!eof)
 
-} // while(!eof)
+if(verbose) printf("EOF code: %d  \n",eof);
 
 exit_player("End of file");
 }
--- a/seek.c	Sun Jul 29 17:42:06 2001 +0000
+++ b/seek.c	Sun Jul 29 21:07:34 2001 +0000
@@ -51,6 +51,8 @@
     if(sh_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;}
     ds_free_packs(d_video);
     
+    demuxer->stream->eof=0; // clear eof flag
+    
 //    printf("sh_audio->a_buffer_len=%d  \n",sh_audio->a_buffer_len);