diff options
author | wm4 <wm4@nowhere> | 2013-11-25 23:12:18 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-25 23:12:18 +0100 |
commit | d8b59aa17fda6aff7bf3031abbd716adc1268422 (patch) | |
tree | 6e8c87b03ebcd32cb7cd1c95736cb2bc37515d2f /mpvcore | |
parent | 88fa420b200bef230c446c65d4cc1a038c4eaf2d (diff) | |
download | mpv-d8b59aa17fda6aff7bf3031abbd716adc1268422.tar.bz2 mpv-d8b59aa17fda6aff7bf3031abbd716adc1268422.tar.xz |
player: merge no-correct-pts with correct-pts code
Now the --no-correct-pts mode is like the normal mode, just with
different timestamp calculations. The semantics should be about the
same as before this commit.
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/player/playloop.c | 1 | ||||
-rw-r--r-- | mpvcore/player/video.c | 63 |
2 files changed, 12 insertions, 52 deletions
diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c index ad32371699..701443c8cb 100644 --- a/mpvcore/player/playloop.c +++ b/mpvcore/player/playloop.c @@ -176,6 +176,7 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao) vf_chain_seek_reset(mpctx->d_video->vfilter); mpctx->d_video->num_buffered_pts = 0; mpctx->d_video->last_pts = MP_NOPTS_VALUE; + mpctx->d_video->last_packet_pts = MP_NOPTS_VALUE; mpctx->d_video->pts = MP_NOPTS_VALUE; mpctx->video_pts = MP_NOPTS_VALUE; mpctx->delay = 0; diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index 362ee94c75..c162cfa51a 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -119,6 +119,7 @@ int reinit_video_chain(struct MPContext *mpctx) struct dec_video *d_video = talloc_zero(NULL, struct dec_video); mpctx->d_video = d_video; d_video->last_pts = MP_NOPTS_VALUE; + d_video->last_packet_pts = MP_NOPTS_VALUE; d_video->opts = mpctx->opts; d_video->header = sh; d_video->fps = sh->video->fps; @@ -266,56 +267,6 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time) return 0; } -static struct demux_packet *video_read_frame(struct MPContext *mpctx) -{ - struct dec_video *d_video = mpctx->d_video; - double frame_time = 1.0f / (d_video->fps > 0 ? d_video->fps : 25); - struct demux_packet *pkt = demux_read_packet(d_video->header); - if (!pkt) - return NULL; // EOF - - if (d_video->last_pts == MP_NOPTS_VALUE) { - d_video->last_pts = pkt->pts == MP_NOPTS_VALUE ? 0 : pkt->pts; - d_video->pts = d_video->last_pts; - } - - double prev = d_video->pts; - d_video->pts = d_video->pts + frame_time; - d_video->last_pts = prev; - return pkt; -} - -static double update_video_nocorrect_pts(struct MPContext *mpctx) -{ - struct dec_video *d_video = mpctx->d_video; - double frame_time = 0; - while (1) { - // In nocorrect-pts mode there is no way to properly time these frames - if (load_next_vo_frame(mpctx, false)) - break; - frame_time = d_video->pts - d_video->last_pts; - if (mpctx->restart_playback) - frame_time = 0; - struct demux_packet *pkt = video_read_frame(mpctx); - if (!pkt) - return -1; - if (mpctx->d_audio) - mpctx->delay -= frame_time; - // video_read_frame can change fps (e.g. for ASF video) - update_fps(mpctx); - int framedrop_type = check_framedrop(mpctx, frame_time); - - pkt->pts = d_video->pts; - void *decoded_frame = video_decode(d_video, pkt, framedrop_type); - talloc_free(pkt); - if (decoded_frame) { - filter_video(mpctx, decoded_frame); - } - break; - } - return frame_time; -} - static double update_video_attached_pic(struct MPContext *mpctx) { struct dec_video *d_video = mpctx->d_video; @@ -338,6 +289,16 @@ static void determine_frame_pts(struct MPContext *mpctx) struct dec_video *d_video = mpctx->d_video; struct MPOpts *opts = mpctx->opts; + if (!opts->correct_pts) { + double frame_time = 1.0f / (d_video->fps > 0 ? d_video->fps : 25); + double pkt_pts = d_video->last_packet_pts; + if (d_video->pts == MP_NOPTS_VALUE) + d_video->pts = pkt_pts == MP_NOPTS_VALUE ? 0 : pkt_pts; + + d_video->pts = d_video->pts + frame_time; + return; + } + if (opts->user_pts_assoc_mode) d_video->pts_assoc_mode = opts->user_pts_assoc_mode; else if (d_video->pts_assoc_mode == 0) { @@ -369,8 +330,6 @@ double update_video(struct MPContext *mpctx, double endpts) struct dec_video *d_video = mpctx->d_video; struct vo *video_out = mpctx->video_out; vf_control(d_video->vfilter, VFCTRL_SET_OSD_OBJ, mpctx->osd); // for vf_sub - if (!mpctx->opts->correct_pts) - return update_video_nocorrect_pts(mpctx); if (d_video->header->attached_picture) return update_video_attached_pic(mpctx); |