diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-01-04 21:38:45 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-01-04 21:38:45 +0000 |
commit | 5e1b88a019de70b93b280f263ccbd1dbd8a0dce0 (patch) | |
tree | f7dbee18650b5fa466fb52fceaf85cd8e4351283 | |
parent | e57a8e10402a350f5bbbbe0769fd64e0e4e0986a (diff) | |
download | mpv-5e1b88a019de70b93b280f263ccbd1dbd8a0dce0.tar.bz2 mpv-5e1b88a019de70b93b280f263ccbd1dbd8a0dce0.tar.xz |
At startup and while seeking avoid to introduce pointless sleeps and possibly
desync due to codec delay.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30218 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | mp_core.h | 2 | ||||
-rw-r--r-- | mplayer.c | 12 |
2 files changed, 14 insertions, 0 deletions
@@ -72,6 +72,8 @@ typedef struct MPContext { // struct. int num_buffered_frames; + // used to retry decoding after startup/seeking to compensate for codec delay + int startup_decode_retry; // how long until we need to display the "current" frame float time_frame; @@ -203,6 +203,7 @@ static int drop_frame_cnt=0; // total number of dropped frames int benchmark=0; // options: +#define DEFAULT_STARTUP_DECODE_RETRY 8 int auto_quality=0; static int output_quality=0; @@ -2539,6 +2540,7 @@ static int seek(MPContext *mpctx, double amount, int style) if (demux_seek(mpctx->demuxer, amount, audio_delay, style) == 0) return -1; + mpctx->startup_decode_retry = DEFAULT_STARTUP_DECODE_RETRY; if (mpctx->sh_video) { current_module = "seek_video_reset"; resync_video_stream(mpctx->sh_video); @@ -3697,6 +3699,7 @@ total_time_usage_start=GetTimer(); audio_time_usage=0; video_time_usage=0; vout_time_usage=0; total_frame_cnt=0; drop_frame_cnt=0; // fix for multifile fps benchmark play_n_frames=play_n_frames_mf; +mpctx->startup_decode_retry = DEFAULT_STARTUP_DECODE_RETRY; if(play_n_frames==0){ mpctx->eof=PT_NEXT_ENTRY; goto goto_next_file; @@ -3769,6 +3772,15 @@ if(!mpctx->sh_video) { if (!mpctx->num_buffered_frames) { double frame_time = update_video(&blit_frame); + while (!blit_frame && mpctx->startup_decode_retry > 0) { + double delay = mpctx->delay; + // these initial decode failures are probably due to codec delay, + // ignore them and also their probably nonsense durations + update_video(&blit_frame); + mpctx->delay = delay; + mpctx->startup_decode_retry--; + } + mpctx->startup_decode_retry = 0; mp_dbg(MSGT_AVSYNC,MSGL_DBG2,"*** ftime=%5.3f ***\n",frame_time); if (mpctx->sh_video->vf_initialized < 0) { mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NotInitializeVOPorVO); |