diff options
author | wm4 <wm4@nowhere> | 2015-01-05 12:49:13 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-05 12:49:13 +0100 |
commit | 589e70e17d677d4bb763c10bf93ecd5d0db6f82b (patch) | |
tree | 0770a4fdfa239ca0a13e3bd3922b63916f719cc7 | |
parent | d7dfbc86105ae2ad04a547042140cd12353e65e5 (diff) | |
download | mpv-589e70e17d677d4bb763c10bf93ecd5d0db6f82b.tar.bz2 mpv-589e70e17d677d4bb763c10bf93ecd5d0db6f82b.tar.xz |
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.
-rw-r--r-- | DOCS/man/vf.rst | 5 | ||||
-rw-r--r-- | video/filter/vf_vapoursynth.c | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index e0427bd88d..bc95d0e1c5 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -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`` diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index 178ebb2bc1..ea5e86d599 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -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} }; |