summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-09-03 10:30:32 -0300
committerJames Almer <jamrial@gmail.com>2021-09-04 10:35:07 -0300
commit7453d3482a02452d67ca2fa2a2ed1e6094fdddeb (patch)
treef7be2b74c37d982e307b441d7293bbb5d58a6d8f /fftools
parentf599ae88c25d2c84c4f3be1abe30777b68e249d5 (diff)
ffmpeg: let AVFilterGraph parse the filter_threads option
This way the CLI accepts for "filter_threads" the same values as for the libavcodec specific option "threads". Fixes FATE with THREADS=auto which was broken in bdc1bdf3f5. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg.c1
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_filter.c7
-rw-r--r--fftools/ffmpeg_opt.c11
4 files changed, 16 insertions, 5 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index c3df955a6a..fb2d9a81e7 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -653,6 +653,7 @@ static void ffmpeg_cleanup(int ret)
av_err2str(AVERROR(errno)));
}
av_freep(&vstats_filename);
+ av_freep(&filter_nbthreads);
av_freep(&input_streams);
av_freep(&input_files);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8184099b05..1194bb0cae 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -629,7 +629,7 @@ extern AVIOContext *progress_avio;
extern float max_error_rate;
extern char *videotoolbox_pixfmt;
-extern int filter_nbthreads;
+extern char *filter_nbthreads;
extern int filter_complex_nbthreads;
extern int vstats_version;
extern int auto_conversion_filters;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 4b9ad3071b..6b7b6ca1b3 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -968,8 +968,11 @@ int configure_filtergraph(FilterGraph *fg)
char args[512];
AVDictionaryEntry *e = NULL;
- fg->graph->nb_threads = filter_nbthreads;
- if (!fg->graph->nb_threads) {
+ if (filter_nbthreads) {
+ ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
+ if (ret < 0)
+ goto fail;
+ } else {
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
if (e)
av_opt_set(fg->graph, "threads", e->value, 0);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index bd8f26ce2f..6ca28cf974 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -169,7 +169,7 @@ int qp_hist = 0;
int stdin_interaction = 1;
int frame_bits_per_raw_sample = 0;
float max_error_rate = 2.0/3;
-int filter_nbthreads = 0;
+char *filter_nbthreads;
int filter_complex_nbthreads = 0;
int vstats_version = 2;
int auto_conversion_filters = 1;
@@ -264,6 +264,13 @@ static AVDictionary *strip_specifiers(AVDictionary *dict)
return ret;
}
+static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
+{
+ av_free(filter_nbthreads);
+ filter_nbthreads = av_strdup(arg);
+ return 0;
+}
+
static int opt_abort_on(void *optctx, const char *opt, const char *arg)
{
static const AVOption opts[] = {
@@ -3618,7 +3625,7 @@ const OptionDef options[] = {
"set profile", "profile" },
{ "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) },
"set stream filtergraph", "filter_graph" },
- { "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads },
+ { "filter_threads", HAS_ARG, { .func_arg = opt_filter_threads },
"number of non-complex filter threads" },
{ "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) },
"read stream filtergraph description from a file", "filename" },