summaryrefslogtreecommitdiffstats
path: root/player/command.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/command.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/command.c')
-rw-r--r--player/command.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/player/command.c b/player/command.c
index 25b9a90e4a..3e6a4da9f1 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2595,25 +2595,14 @@ static int mp_property_vf_fps(void *ctx, struct m_property *prop,
MPContext *mpctx = ctx;
if (!mpctx->d_video)
return M_PROPERTY_UNAVAILABLE;
- double next_pts = mpctx->vo_pts_history_pts[0];
- if (mpctx->vo_pts_history_seek[0] != mpctx->vo_pts_history_seek_ts)
+ double durations[10];
+ int num = get_past_frame_durations(mpctx, durations, MP_ARRAY_SIZE(durations));
+ if (num < MP_ARRAY_SIZE(durations))
return M_PROPERTY_UNAVAILABLE;
- if (next_pts == MP_NOPTS_VALUE)
- return M_PROPERTY_UNAVAILABLE;
- int num_samples = 10;
- assert(num_samples + 1 <= MAX_NUM_VO_PTS);
double duration = 0;
- for (int n = 1; n < 1 + num_samples; 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)
- return M_PROPERTY_UNAVAILABLE;
- if (frame_pts == MP_NOPTS_VALUE)
- return M_PROPERTY_UNAVAILABLE;
- duration += next_pts - frame_pts;
- next_pts = frame_pts;
- }
- return m_property_double_ro(action, arg, num_samples / duration);
+ for (int n = 0; n < num; n++)
+ duration += durations[n];
+ return m_property_double_ro(action, arg, num / duration);
}
/// Video aspect (RO)