summaryrefslogtreecommitdiffstats
path: root/video/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-05 12:49:13 +0100
committerwm4 <wm4@nowhere>2015-01-05 12:49:13 +0100
commit589e70e17d677d4bb763c10bf93ecd5d0db6f82b (patch)
tree0770a4fdfa239ca0a13e3bd3922b63916f719cc7 /video/filter
parentd7dfbc86105ae2ad04a547042140cd12353e65e5 (diff)
downloadmpv-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.
Diffstat (limited to 'video/filter')
-rw-r--r--video/filter/vf_vapoursynth.c11
1 files changed, 8 insertions, 3 deletions
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}
};