summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-24 18:00:34 +0200
committerwm4 <wm4@nowhere>2015-05-24 23:27:23 +0200
commit58e7d0a30be40efbdce93d9a79b6a7def4d36451 (patch)
treed7ddc0defa40ddbbc5bb1ab1ba65a46d481cebd6 /player/playloop.c
parent0d0444fed02fb0f1ebd2cc7ab98a0ce5fd8740d7 (diff)
downloadmpv-58e7d0a30be40efbdce93d9a79b6a7def4d36451.tar.bz2
mpv-58e7d0a30be40efbdce93d9a79b6a7def4d36451.tar.xz
player: add function to compute past frame durations
And use it for the estimated-vf-fps property (it should be doing the same as before).
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/player/playloop.c b/player/playloop.c
index c9d74c2950..4f42b17e97 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -691,6 +691,27 @@ void add_frame_pts(struct MPContext *mpctx, double pts)
mpctx->vo_pts_history_pts[0] = pts;
}
+// Return the last (at most num) frame duration in fd[]. Return the number of
+// entries written to fd[] (range [0, num]). fd[0] is the most recent frame.
+int get_past_frame_durations(struct MPContext *mpctx, double *fd, int num)
+{
+ double next_pts = mpctx->vo_pts_history_pts[0];
+ if (mpctx->vo_pts_history_seek[0] != mpctx->vo_pts_history_seek_ts ||
+ next_pts == MP_NOPTS_VALUE)
+ return 0;
+ int num_ret = 0;
+ for (int n = 1; n < MAX_NUM_VO_PTS && num_ret < num; n++) {
+ double frame_pts = mpctx->vo_pts_history_pts[n];
+ // Discontinuity -> refuse to return a value.
+ if (mpctx->vo_pts_history_seek[n] != mpctx->vo_pts_history_seek_ts ||
+ next_pts <= frame_pts || frame_pts == MP_NOPTS_VALUE)
+ break;
+ fd[num_ret++] = next_pts - frame_pts;
+ next_pts = frame_pts;
+ }
+ return num_ret;
+}
+
static double find_previous_pts(struct MPContext *mpctx, double pts)
{
for (int n = 0; n < MAX_NUM_VO_PTS - 1; n++) {