summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-25 23:10:18 +0100
committerwm4 <wm4@nowhere>2013-11-25 23:10:18 +0100
commit88fa420b200bef230c446c65d4cc1a038c4eaf2d (patch)
treea559cb31fa2c983f76bc5182c92ac6bf2e1015aa
parent83dc3a81f18aed146063b8f410b6d0517cf57b87 (diff)
downloadmpv-88fa420b200bef230c446c65d4cc1a038c4eaf2d.tar.bz2
mpv-88fa420b200bef230c446c65d4cc1a038c4eaf2d.tar.xz
player: change semantics of --no-correct-pts
Before this commit, this mode estimated the frame time by subtracting successive packet PTS values. This is complete non-sense for video codecs which use reordering. The code compensated frame times for these non-sense using the FPS value, but confused the rest of the player with non-sense jumping around timestamps. So, all in all this mode is not very useful. Repurpose this mode for fixed frame rate playback. This gives almost the same behavior as the old mode with forced framerate (--fps option). The result is simpler and often more robust.
-rw-r--r--mpvcore/player/video.c34
-rw-r--r--video/decode/dec_video.h1
2 files changed, 8 insertions, 27 deletions
diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c
index f858106750..362ee94c75 100644
--- a/mpvcore/player/video.c
+++ b/mpvcore/player/video.c
@@ -269,37 +269,19 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time)
static struct demux_packet *video_read_frame(struct MPContext *mpctx)
{
struct dec_video *d_video = mpctx->d_video;
- demuxer_t *demuxer = d_video->header->demuxer;
- float pts1 = d_video->last_pts;
-
+ 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 (pkt->pts != MP_NOPTS_VALUE)
- d_video->last_pts = pkt->pts;
-
- float frame_time = d_video->fps > 0 ? 1.0f / d_video->fps : 0;
-
- // override frame_time for variable/unknown FPS formats:
- if (!mpctx->opts->force_fps) {
- double next_pts = demux_get_next_pts(d_video->header);
- double d = next_pts == MP_NOPTS_VALUE ? d_video->last_pts - pts1
- : next_pts - d_video->last_pts;
- if (d >= 0) {
- if (demuxer->type == DEMUXER_TYPE_TV) {
- if (d > 0)
- d_video->fps = 1.0f / d;
- frame_time = d;
- } else {
- if ((int)d_video->fps <= 1)
- frame_time = d;
- }
- }
+ 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;
}
- d_video->pts = d_video->last_pts;
- d_video->next_frame_time = frame_time;
+ double prev = d_video->pts;
+ d_video->pts = d_video->pts + frame_time;
+ d_video->last_pts = prev;
return pkt;
}
@@ -311,7 +293,7 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx)
// 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->next_frame_time;
+ frame_time = d_video->pts - d_video->last_pts;
if (mpctx->restart_playback)
frame_time = 0;
struct demux_packet *pkt = video_read_frame(mpctx);
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index 9802e4c300..3856d12043 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -59,7 +59,6 @@ struct dec_video {
float initial_decoder_aspect;
// State used only by player/video.c
- float next_frame_time;
double last_pts;
};