[Mplayer-cvslog] CVS: main demux_avi.c,1.11,1.12

Arpi of Ize arpi at mplayer.dev.hu
Tue Aug 7 01:59:25 CEST 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv13999

Modified Files:
	demux_avi.c 
Log Message:
interleaved AVI: audio preload PTS compensation

Index: demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_avi.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- demux_avi.c	1 Aug 2001 09:14:02 -0000	1.11
+++ demux_avi.c	6 Aug 2001 23:59:22 -0000	1.12
@@ -58,6 +58,11 @@
   return NULL;
 }
 
+static float pts_correction=0.0;
+static int pts_corrected=0;
+static int pts_has_video=0;
+static unsigned int pts_corr_bytes=0;
+
 static int demux_avi_read_packet(demuxer_t *demux,unsigned int id,unsigned int len,int idxpos,int flags){
   int skip;
   float pts=0;
@@ -66,7 +71,21 @@
   if(verbose>=3) printf("demux_avi.read_packet: %X\n",id);
 
   if(ds==demux->audio){
-            pts=avi_audio_pts;
+
+      if(pts_corrected==0){
+//          printf("\rYYY-A  A: %5.3f  V: %5.3f  \n",avi_audio_pts,avi_video_pts);
+          if(pts_has_video){
+	      // we have video pts now
+	      float delay=(float)pts_corr_bytes/((sh_audio_t*)(ds->sh))->wf->nAvgBytesPerSec;
+	      printf("XXX initial  v_pts=%5.3f  a_pos=%d (%5.3f) \n",avi_audio_pts,pts_corr_bytes,delay);
+	      //pts_correction=-avi_audio_pts+delay;
+	      pts_correction=delay-avi_audio_pts;
+	      pts_corrected=1;
+	  } else
+          pts_corr_bytes+=len;
+      }
+
+            pts=avi_audio_pts+pts_correction;
             avi_audio_pts=0;
   } else 
   if(ds==demux->video){
@@ -94,7 +113,10 @@
      avi_video_pts+=(float)((sh_video_t*)(demux->video->sh))->video.dwScale/(float)((sh_video_t*)(demux->video->sh))->video.dwRate;
 //     avi_video_pts+=avi_video_ftime;
 #endif
+//          printf("\rYYY-V  A: %5.3f  V: %5.3f  \n",avi_audio_pts,avi_video_pts);
      avi_audio_pts=avi_video_pts;
+     pts_has_video=1;
+
   }
   
 //  len=stream_read_dword_le(demux->stream);




More information about the MPlayer-cvslog mailing list