Mercurial > mplayer.hg
changeset 1498:6174b815b5f4
PTS calc updates, fixes, cleanups, mess...
author | arpi |
---|---|
date | Sun, 12 Aug 2001 20:52:35 +0000 |
parents | ad4d402b3d29 |
children | c3517acc0497 |
files | demux_avi.c mplayer.c |
diffstat | 2 files changed, 42 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/demux_avi.c Sun Aug 12 17:28:16 2001 +0000 +++ b/demux_avi.c Sun Aug 12 20:52:35 2001 +0000 @@ -54,7 +54,6 @@ return NULL; } - static int demux_avi_read_packet(demuxer_t *demux,unsigned int id,unsigned int len,int idxpos,int flags){ avi_priv_t *priv=demux->priv; int skip; @@ -87,8 +86,8 @@ // drop frame (seeking) --priv->skip_video_frames; ds=NULL; - } else { - pts=priv->avi_video_pts; +// } else { +// pts=priv->avi_video_pts; } // ezt a 2 sort lehet hogy fell kell majd cserelni: //priv->avi_video_pts+=avi_pts_frametime; @@ -110,6 +109,10 @@ priv->avi_audio_pts=priv->avi_video_pts+priv->pts_correction; priv->pts_has_video=1; + pts=priv->avi_video_pts; + + //printf("read pack_no: %d pts %5.3f \n",demux->video->pack_no+demux->video->packs,pts); + } // len=stream_read_dword_le(demux->stream); @@ -500,7 +503,7 @@ } } else { // seek backward - while(video_chunk_pos>=0){ + while(video_chunk_pos>0){ int id=((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].ckid; if(avi_stream_id(id)==d_video->id){ // video frame if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; @@ -519,6 +522,8 @@ sh_video->num_frames=d_video->pack_no; priv->avi_video_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; d_video->pos=video_chunk_pos; + + printf("V_SEEK: pack=%d pts=%5.3f chunk=%d \n",d_video->pack_no,priv->avi_video_pts,video_chunk_pos); // ------------ STEP 2: seek audio, find the right chunk & pos ------------ @@ -622,6 +627,8 @@ priv->idx_pos_v=video_chunk_pos; priv->idx_pos=(audio_chunk_pos<video_chunk_pos)?audio_chunk_pos:video_chunk_pos; } + + d_video->pts=priv->avi_video_pts; // OSD if(verbose) printf("SEEK: idx=%d (a:%d v:%d) v.skip=%d a.skip=%d/%4.3f \n", priv->idx_pos,audio_chunk_pos,video_chunk_pos,
--- a/mplayer.c Sun Aug 12 17:28:16 2001 +0000 +++ b/mplayer.c Sun Aug 12 20:52:35 2001 +0000 @@ -227,13 +227,14 @@ static int video_id=-1; static int dvdsub_id=-1; static int vcd_track=0; -char *stream_dump_name=NULL; -int stream_dump_type=0; +static char *stream_dump_name=NULL; +static int stream_dump_type=0; + int index_mode=-1; // -1=untouched 0=don't use index 1=use (geneate) index int force_ni=0; -float default_max_pts_correction=-1;//0.01f; -float max_pts_correction=0;//default_max_pts_correction; +static float default_max_pts_correction=-1;//0.01f; +static float max_pts_correction=0;//default_max_pts_correction; #ifdef AVI_SYNC_BPS int pts_from_bps=1; #else @@ -1031,6 +1032,7 @@ //==================== START PLAYING ======================= if(file_format==DEMUXER_TYPE_AVI && sh_audio){ +#if 0 //a_pts=d_audio->pts; if(verbose) printf("Initial frame delay A: %d V: %d\n",(int)sh_audio->audio.dwInitialFrames,(int)sh_video->video.dwInitialFrames); if(!pts_from_bps){ @@ -1045,6 +1047,7 @@ printf("START: a_pts=%5.3f v_pts=%5.3f \n",d_audio->pts,d_video->pts); } d_video->pts=0;d_audio->pts=0; // PTS is outdated now! +#endif } else { pts_from_bps=0; // it must be 0 for mpeg/asf ! } @@ -1330,45 +1333,37 @@ float delay=(float)delay_bytes/(float)sh_audio->o_bps; if(pts_from_bps){ - // PTS = (audio position)/(bytes per sec) -// a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; +#if 1 + unsigned int samples=(sh_audio->audio.dwSampleSize)? + ((ds_tell(d_audio)-sh_audio->a_in_buffer_len)/sh_audio->audio.dwSampleSize) : + (d_audio->pack_no); // <- used for VBR audio + a_pts=samples*(float)sh_audio->audio.dwScale/(float)sh_audio->audio.dwRate; +#else if(sh_audio->audio.dwSampleSize) a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->wf->nAvgBytesPerSec; else // VBR: a_pts=d_audio->pack_no*(float)sh_audio->audio.dwScale/(float)sh_audio->audio.dwRate; - v_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; -// if(verbose)printf("%5.3f|",v_pts-d_video->pts); +#endif +// v_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; +// printf("V_PTS: PTS: %8.3f BPS: %8.3f \n",d_video->pts,v_pts); + delay_corrected=1; } else { - if(!delay_corrected && d_audio->pts){ -// float x=d_audio->pts-d_video->pts-(delay); - float x=d_audio->pts-d_video->pts-(delay+audio_delay); -// float y=-(delay+audio_delay); - float bps_a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->wf->nAvgBytesPerSec; - float bps_v_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; - printf("Initial PTS delay: %5.3f sec ->%5.3f (bps: %5.3f) audio_delay=%5.3f\n",x,2*sh_video->frametime,bps_a_pts-bps_v_pts-(delay+audio_delay),audio_delay); - x=0; //2*sh_video->frametime; -// initial_pts_delay+=x; audio_delay+=x; - delay_corrected=1; - if(verbose) - printf("v: audio_delay=%5.3f buffer_delay=%5.3f a.pts=%5.3f v.pts=%5.3f\n", - audio_delay,delay,d_audio->pts,d_video->pts); - } // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec) a_pts=d_audio->pts; + if(!delay_corrected) if(a_pts) delay_corrected=1; //printf("*** %5.3f ***\n",a_pts); a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; // v_pts=d_video->pts-frame_time; - v_pts=d_video->pts; +// v_pts=d_video->pts; } + v_pts=d_video->pts; - if(verbose>1)printf("### A:%8.3f (%8.3f) V:%8.3f A-V:%7.4f \n",a_pts,a_pts-audio_delay-delay,v_pts,(a_pts-delay-audio_delay)-v_pts); + if(verbose>1) + printf("### A:%8.3f (%8.3f) V:%8.3f A-V:%7.4f \n",a_pts,a_pts-audio_delay-delay,v_pts,(a_pts-delay-audio_delay)-v_pts); if(delay_corrected){ float x; AV_delay=(a_pts-delay-audio_delay)-v_pts; -// printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts-audio_delay-delay,v_pts,x); - if(!quiet) - printf("A:%6.1f (%6.1f) V:%6.1f A-V:%7.3f",a_pts,a_pts-audio_delay-delay,v_pts,AV_delay); x=AV_delay*0.1f; if(x<-max_pts_correction) x=-max_pts_correction; else if(x> max_pts_correction) x= max_pts_correction; @@ -1377,13 +1372,14 @@ else max_pts_correction=sh_video->frametime*0.10; // +-10% of time sh_audio->timer+=x; c_total+=x; - if(!quiet) printf(" ct:%7.3f %3d %2d%% %2d%% %4.1f%% %d %d\r",c_total, - (int)sh_video->num_frames, - (sh_video->timer>0.5)?(int)(100.0*video_time_usage/(double)sh_video->timer):0, - (sh_video->timer>0.5)?(int)(100.0*vout_time_usage/(double)sh_video->timer):0, - (sh_video->timer>0.5)?(100.0*audio_time_usage/(double)sh_video->timer):0 - ,drop_frame_cnt - ,output_quality + if(!quiet) printf("A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d %2d%% %2d%% %4.1f%% %d %d\r", + a_pts-audio_delay-delay,v_pts,AV_delay,c_total, + (int)sh_video->num_frames, + (sh_video->timer>0.5)?(int)(100.0*video_time_usage/(double)sh_video->timer):0, + (sh_video->timer>0.5)?(int)(100.0*vout_time_usage/(double)sh_video->timer):0, + (sh_video->timer>0.5)?(100.0*audio_time_usage/(double)sh_video->timer):0 + ,drop_frame_cnt + ,output_quality ); fflush(stdout); } @@ -1695,7 +1691,7 @@ c_total=0; max_pts_correction=0.1; - force_redraw=5; +// force_redraw=5; audio_time_usage=0; video_time_usage=0; vout_time_usage=0; drop_frame_cnt=0;