@@ -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);
@@ -633,7 +633,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;
@@ -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);
@@ -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[] = {
@@ -3620,7 +3627,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" },
This way it accepts the same values as the libavcodec specific option "threads" Fixes FATE with THREADS=auto which was broken in bdc1bdf3f5. Signed-off-by: James Almer <jamrial@gmail.com> --- fftools/ffmpeg.c | 1 + fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 7 +++++-- fftools/ffmpeg_opt.c | 11 +++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-)