summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-13 22:48:32 +0100
committerwm4 <wm4@nowhere>2015-11-13 22:48:32 +0100
commitd5981924feb02384f9facbedc9fff2fb89ac8db3 (patch)
tree2d501f4193d89f594e694cdce207770b300facb3 /player/command.c
parent62b386c2fdb6d113c2c1042f0b3a973f3fb11828 (diff)
downloadmpv-d5981924feb02384f9facbedc9fff2fb89ac8db3.tar.bz2
mpv-d5981924feb02384f9facbedc9fff2fb89ac8db3.tar.xz
command: add vsync-ratio property
This is very "illustrative", unlike the video-speed-correction property, and thus useful. It can also be used to observe scheduling errors, which are not detected by the core. (These happen due to rounding errors; possibly not evne our fault, but coming from files with rounded timestamps and so on.)
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c
index e3b8feab98..eadcc27296 100644
--- a/player/command.c
+++ b/player/command.c
@@ -567,12 +567,34 @@ static int mp_property_mistimed_frame_count(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->d_video || !mpctx->display_sync_active)
+ if (!mpctx->d_video || !mpctx->display_sync_active)
return M_PROPERTY_UNAVAILABLE;
return m_property_int_ro(action, arg, mpctx->mistimed_frames_total);
}
+static int mp_property_vsync_ratio(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ if (!mpctx->d_video || !mpctx->display_sync_active)
+ return M_PROPERTY_UNAVAILABLE;
+
+ int vsyncs = 0, frames = 0;
+ for (int n = 0; n < mpctx->num_past_frames; n++) {
+ int vsync = mpctx->past_frames[n].num_vsyncs;
+ if (vsync < 0)
+ break;
+ vsyncs += vsync;
+ frames += 1;
+ }
+
+ if (!frames)
+ return M_PROPERTY_UNAVAILABLE;
+
+ return m_property_double_ro(action, arg, vsyncs / (double)frames);
+}
+
static int mp_property_vo_drop_frame_count(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3394,6 +3416,7 @@ static const struct m_property mp_properties[] = {
{"total-avsync-change", mp_property_total_avsync_change},
{"drop-frame-count", mp_property_drop_frame_cnt},
{"mistimed-frame-count", mp_property_mistimed_frame_count},
+ {"vsync-ratio", mp_property_vsync_ratio},
{"vo-drop-frame-count", mp_property_vo_drop_frame_count},
{"vo-delayed-frame-count", mp_property_vo_delayed_frame_count},
{"percent-pos", mp_property_percent_pos},
@@ -3612,7 +3635,7 @@ static const char *const *const mp_event_property_change[] = {
"percent-pos", "time-remaining", "playtime-remaining", "playback-time",
"estimated-vf-fps", "drop-frame-count", "vo-drop-frame-count",
"total-avsync-change", "audio-speed-correction", "video-speed-correction",
- "vo-delayed-frame-count", "mistimed-frame-count"),
+ "vo-delayed-frame-count", "mistimed-frame-count", "vsync-ratio"),
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
"width", "height", "fps", "aspect", "vo-configured", "current-vo",