changeset 3526:cf787373f0aa

vivo A-V sync fixed
author arpi
date Sun, 16 Dec 2001 14:51:04 +0000
parents 03304fcb0090
children 5a88b21cfe8a
files libmpdemux/demux_viv.c libmpdemux/video.c
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_viv.c	Sun Dec 16 14:10:37 2001 +0000
+++ b/libmpdemux/demux_viv.c	Sun Dec 16 14:51:04 2001 +0000
@@ -290,6 +290,9 @@
 return 1;
 }
 
+static audio_pos=0;
+static audio_rate=0;
+
 // return value:
 //     0 = EOF or no stream found
 //     1 = successfully read a packet
@@ -348,6 +351,7 @@
       else
         len=40;	/* 40kbps */
       ds=demux->audio;
+      audio_pos+=len;
       break;
   case 0x40:  // audio packet
       if (prefix == 1)
@@ -355,6 +359,7 @@
       else
         len=24;	/* 24kbps */
       ds=demux->audio;
+      audio_pos+=len;
       break;
   default:
       mp_msg(MSGT_DEMUX,MSGL_WARN,"VIVO - unknown ID found: %02X at pos %lu contact author!\n",
@@ -395,7 +400,7 @@
       dp=new_demux_packet(len);
       //memcpy(dp->buffer,data,len);
       stream_read(demux->stream,dp->buffer,len);
-//      dp->pts=time*0.001f;
+      dp->pts=audio_rate?((float)audio_pos/(float)audio_rate):0;
 //      dp->flags=keyframe;
 //      if(ds==demux->video) printf("ASF time: %8d  dur: %5d  \n",time,dur);
       dp->pos=demux->filepos;
@@ -545,6 +550,8 @@
     mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingVideoStreamBug);
     return;
   }
+
+    audio_pos=0;
   
   h263_decode_picture_header(demuxer->video->buffer);
   
@@ -693,6 +700,7 @@
 		}
 		if (vivo_param_abitrate != -1)
 		    sh->wf->nAvgBytesPerSec = vivo_param_abitrate;
+		audio_rate=sh->wf->nAvgBytesPerSec;
 
 		if (!priv->audio_bytesperblock)
 		{
--- a/libmpdemux/video.c	Sun Dec 16 14:10:37 2001 +0000
+++ b/libmpdemux/video.c	Sun Dec 16 14:51:04 2001 +0000
@@ -237,6 +237,12 @@
     if(demuxer->file_format==DEMUXER_TYPE_MOV && !force_fps){
         // .MOV files has no fixed FPS - just frame durations!
 	frame_time=d_video->pts-pts1;
+    } else
+    if(demuxer->file_format==DEMUXER_TYPE_VIVO && !force_fps){
+        // .VIVO files has no fixed FPS - just frame durations!
+	if(d_video->pts-pts1>0)
+	    frame_time=d_video->pts-pts1;
+	mp_msg(MSGT_CPLAYER,MSGL_V,"vivo frame_time=%5.3f   \n",frame_time);
     }
 
     if(demuxer->file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time;