1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 01:52:19 +00:00

vf_vapoursynth: autodetect CPU count

This adds an "auto" choice to the concurrent-frames suboption, and makes
it the default.

I'm not so sure about making this the default, though. It could lead to
excessive buffering with large CPU counts. But we'll see.
This commit is contained in:
wm4 2015-01-05 12:49:13 +01:00
parent d7dfbc8610
commit 589e70e17d
2 changed files with 12 additions and 4 deletions

View File

@ -753,13 +753,16 @@ Available filters are:
filters work anyway.)
``concurrent-frames``
Number of frames that should be requested in parallel (default: 2). The
Number of frames that should be requested in parallel. The
level of concurrency depends on the filter and how quickly mpv can
decode video to feed the filter. This value should probably be
proportional to the number of cores on your machine. Most time,
making it higher than the number of cores can actually make it
slower.
By default, this uses the special value ``auto``, which sets the option
to the number of detected logical CPU cores.
The following variables are defined by mpv:
``video_in``

View File

@ -26,6 +26,7 @@
#include <VSHelper.h>
#include <libavutil/rational.h>
#include <libavutil/cpu.h>
#include "config.h"
@ -700,9 +701,12 @@ static int vf_open(vf_instance_t *vf)
vf->query_format = query_format;
vf->control = control;
vf->uninit = uninit;
int maxbuffer = p->cfg_maxbuffer * p->cfg_maxrequests;
p->buffered = talloc_array(vf, struct mp_image *, maxbuffer);
p->max_requests = p->cfg_maxrequests;
if (p->max_requests < 0)
p->max_requests = av_cpu_count();
MP_VERBOSE(vf, "using %d concurrent requests.\n", p->max_requests);
int maxbuffer = p->cfg_maxbuffer * p->max_requests;
p->buffered = talloc_array(vf, struct mp_image *, maxbuffer);
p->requested = talloc_zero_array(vf, struct mp_image *, p->max_requests);
return 1;
}
@ -711,7 +715,8 @@ static int vf_open(vf_instance_t *vf)
static const m_option_t vf_opts_fields[] = {
OPT_STRING("file", cfg_file, 0),
OPT_INTRANGE("buffered-frames", cfg_maxbuffer, 0, 1, 9999, OPTDEF_INT(4)),
OPT_INTRANGE("concurrent-frames", cfg_maxrequests, 0, 1, 99, OPTDEF_INT(2)),
OPT_CHOICE_OR_INT("concurrent-frames", cfg_maxrequests, 0, 1, 99,
({"auto", -1}), OPTDEF_INT(-1)),
{0}
};