Mercurial > mplayer.hg
changeset 5930:68cac7ecaf05
Fix frame_time for variable fps movies as it was the last frame duration.
author | albeu |
---|---|
date | Thu, 02 May 2002 10:25:48 +0000 |
parents | 9e7d54e7be58 |
children | 95c14d5dbb22 |
files | libmpdemux/demuxer.c libmpdemux/demuxer.h libmpdemux/video.c |
diffstat | 3 files changed, 27 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demuxer.c Thu May 02 02:03:59 2002 +0000 +++ b/libmpdemux/demuxer.c Thu May 02 10:25:48 2002 +0000 @@ -438,6 +438,25 @@ } } +float ds_get_next_pts(demux_stream_t *ds) { + demuxer_t* demux = ds->demuxer; + while(!ds->first) { + if(demux->audio->packs>=MAX_PACKS || demux->audio->bytes>=MAX_PACK_BYTES){ + mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes); + mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); + return -1; + } + if(demux->video->packs>=MAX_PACKS || demux->video->bytes>=MAX_PACK_BYTES){ + mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes); + mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); + return -1; + } + if(!demux_fill_buffer(demux,ds)) + return -1; + } + return ds->first->pts; +} + // ==================================================================== // feed-back from demuxers: @@ -696,7 +715,7 @@ mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedMPEGPSfile); file_format=DEMUXER_TYPE_MPEG_PS; } else { - printf("MPEG packet stats: p100: %d p101: %d PES: %d MP3: %d \n", + mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d p101: %d PES: %d MP3: %d \n", num_elementary_packets100,num_elementary_packets101,num_elementary_packetsPES,num_mp3audio_packets); //MPEG packet stats: p100: 458 p101: 458 PES: 0 MP3: 1103 (.m2v) if(num_mp3audio_packets>50 && num_mp3audio_packets>2*num_elementary_packets100
--- a/libmpdemux/demuxer.h Thu May 02 02:03:59 2002 +0000 +++ b/libmpdemux/demuxer.h Thu May 02 10:25:48 2002 +0000 @@ -173,6 +173,7 @@ void ds_free_packs(demux_stream_t *ds); int ds_get_packet(demux_stream_t *ds,unsigned char **start); int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start); +float ds_get_next_pts(demux_stream_t *ds); // This is defined here because demux_stream_t ins't defined in stream.h stream_t* new_ds_stream(demux_stream_t *ds);
--- a/libmpdemux/video.c Thu May 02 02:03:59 2002 +0000 +++ b/libmpdemux/video.c Thu May 02 10:25:48 2002 +0000 @@ -291,14 +291,18 @@ case DEMUXER_TYPE_FILM: case DEMUXER_TYPE_VIVO: case DEMUXER_TYPE_ASF: { - float d=d_video->pts-pts1; - if(d>0 && d<5) frame_time=d; + float next_pts = ds_get_next_pts(d_video); + float d= next_pts > 0 ? next_pts - d_video->pts : d_video->pts-pts1; if(d>0){ if(verbose) if((int)sh_video->fps==1000) mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\navg. framerate: %d fps \n",(int)(1.0f/d)); sh_video->frametime=d; // 1ms sh_video->fps=1.0f/d; + frame_time = d; + } else { + mp_msg(MSGT_CPLAYER,MSGL_WARN,"\nInvalid frame duration value. Defaulting to 1/25 sec.\n"); + frame_time = 1/25.0; } } }