From 3d1cc17ab27b98294f5710e69250e95347d84598 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 10 Aug 2015 18:38:57 +0200 Subject: player: redo estimated-vf-fps calculation Additionally to taking the average, this tries to use the demuxer FPS to eliminate jitter, and applies some other heuristics to check if the result is sane. This code will also be used for the display sync code (it will actually make use of the require_exact parameter). (The value of doing this over keeping the simpler demux_mkv hack is somewhat questionable. But at least it allows us to deal with other container formats that use jittery timestamps, such as mp4 remuxed from mkv.) --- player/command.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index cb565df896..c87d9378b7 100644 --- a/player/command.c +++ b/player/command.c @@ -2625,14 +2625,10 @@ static int mp_property_vf_fps(void *ctx, struct m_property *prop, MPContext *mpctx = ctx; if (!mpctx->d_video) return M_PROPERTY_UNAVAILABLE; - double durations[10]; - int num = get_past_frame_durations(mpctx, durations, MP_ARRAY_SIZE(durations)); - if (num < MP_ARRAY_SIZE(durations)) + double res = stabilize_frame_duration(mpctx, false); + if (res <= 0) return M_PROPERTY_UNAVAILABLE; - double duration = 0; - for (int n = 0; n < num; n++) - duration += durations[n]; - return m_property_double_ro(action, arg, num / duration); + return m_property_double_ro(action, arg, 1 / res); } /// Video aspect (RO) -- cgit v1.2.3