1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-30 11:42:04 +00:00

video: add --display-fps switch to control framedrop FPS

Since the display FPS is currently detected on X11 only (and even there
it's known to be wrong on certain setups), it seems like a good idea to
make this user-configurable.
This commit is contained in:
wm4 2014-08-16 00:05:02 +02:00
parent 07aba86b37
commit 4f984b987c
4 changed files with 17 additions and 3 deletions

View File

@ -464,6 +464,13 @@ Video
mode enabled. It doesn't increment the ``D:`` field in the statusline
either.
``--display-fps=<fps>``
Set the maximum assumed display FPS used with ``--framedrop``. By default
a detected value is used (X11 only, not correct on multi-monitor systems),
or infinite display FPS if that fails. Infinite FPS means only frames too
late are dropped. If a correct FPS is provided, frames that are predicted
to be too late are dropped too.
``--hwdec=<api>``
Specify the hardware video decoding API that should be used if possible.
Whether hardware decoding is actually done depends on the video codec. If

View File

@ -462,6 +462,8 @@ const m_option_t mp_opts[] = {
{"decoder", 2},
{"decoder+vo", 3})),
OPT_DOUBLE("display-fps", frame_drop_fps, M_OPT_MIN, .min = 0),
OPT_FLAG("audiodrop", insert_silence, 0),
OPT_FLAG("untimed", untimed, M_OPT_FIXED),

View File

@ -137,6 +137,7 @@ typedef struct MPOpts {
float default_max_pts_correction;
int autosync;
int frame_dropping;
double frame_drop_fps;
int insert_silence;
int term_osd;
int term_osd_bar;

View File

@ -332,8 +332,12 @@ static void run_reconfig(void *p)
forget_frames(vo); // implicitly synchronized
double display_fps = 1000.0; // assume infinite if unset
vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &display_fps);
vo->in->vsync_interval = 1e6 / display_fps;
if (vo->global->opts->frame_drop_fps > 0) {
display_fps = vo->global->opts->frame_drop_fps;
} else {
vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &display_fps);
}
vo->in->vsync_interval = MPMAX((int64_t)(1e6 / display_fps), 1);
MP_VERBOSE(vo, "Assuming %f FPS for framedrop.\n", display_fps);
}
@ -515,7 +519,7 @@ static int64_t prev_sync(struct vo *vo, int64_t ts)
struct vo_internal *in = vo->in;
int64_t diff = (int64_t)(ts - in->last_flip);
int64_t offset = diff % MPMAX(in->vsync_interval, 1);
int64_t offset = diff % in->vsync_interval;
if (offset < 0)
offset += in->vsync_interval;
return ts - offset;