From: rcombs <rcombs@rcombs.me> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 4/7] ffmpeg: add filter_jobs and filter_complex_jobs args Date: Tue, 20 Sep 2022 12:50:18 -0500 Message-ID: <20220920175021.60790-5-rcombs@rcombs.me> (raw) In-Reply-To: <20220920175021.60790-1-rcombs@rcombs.me> These are similar to filter_threads and filter_complex_threads, but control job count. --- doc/ffmpeg.texi | 12 ++++++++++++ fftools/ffmpeg.c | 1 + fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 7 +++++++ fftools/ffmpeg_opt.c | 13 +++++++++++++ 5 files changed, 35 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 42440d93b4..6b8248df3b 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -789,6 +789,13 @@ Defines how many threads are used to process a filter pipeline. Each pipeline will produce a thread pool with this many threads available for parallel processing. The default is the number of available CPUs. +@item -filter_jobs @var{nb_jobs} (@emph{global}) +Defines how many jobs are used to process a filter pipeline. Each filter's work +may be split into up to this many tasks for parallel processing, which are then +dispatched to the thread pool of size @var{nb_threads}. +The default is the number of available CPUs, times a multiplier determined based on +the detected CPU topology. For homogenous systems, this multiplier is 1. + @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream}) Specify the preset for matching stream(s). @@ -1916,6 +1923,11 @@ Defines how many threads are used to process a filter_complex graph. Similar to filter_threads but used for @code{-filter_complex} graphs only. The default is the number of available CPUs. +@item -filter_complex_jobs @var{nb_jobs} (@emph{global}) +Defines how many jobs are used to process a filter_complex graph. +Similar to filter_jobs but used for @code{-filter_complex} graphs only. +The default is the number of available CPUs times a topology multiplier. + @item -lavfi @var{filtergraph} (@emph{global}) Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs. Equivalent to @option{-filter_complex}. diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0e1477299d..9ff48141cd 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -621,6 +621,7 @@ static void ffmpeg_cleanup(int ret) } av_freep(&vstats_filename); av_freep(&filter_nbthreads); + av_freep(&filter_nbjobs); av_freep(&input_streams); av_freep(&input_files); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ede0b2bd96..89ee9caca7 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -679,7 +679,9 @@ extern AVIOContext *progress_avio; extern float max_error_rate; extern char *filter_nbthreads; +extern char *filter_nbjobs; extern int filter_complex_nbthreads; +extern int filter_complex_nbjobs; extern int vstats_version; extern int auto_conversion_filters; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 7a5308425d..34e0fce7ab 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -998,6 +998,12 @@ int configure_filtergraph(FilterGraph *fg) av_opt_set(fg->graph, "threads", e->value, 0); } + if (filter_nbjobs) { + ret = av_opt_set(fg->graph, "jobs", filter_nbjobs, 0); + if (ret < 0) + goto fail; + } + args[0] = 0; e = NULL; while ((e = av_dict_get(ost->sws_dict, "", e, @@ -1020,6 +1026,7 @@ int configure_filtergraph(FilterGraph *fg) av_opt_set(fg->graph, "aresample_swr_opts", args, 0); } else { fg->graph->nb_threads = filter_complex_nbthreads; + fg->graph->nb_jobs = filter_complex_nbjobs; } if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 5febe319e4..196064d1b9 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -175,7 +175,9 @@ int qp_hist = 0; int stdin_interaction = 1; float max_error_rate = 2.0/3; char *filter_nbthreads; +char *filter_nbjobs; int filter_complex_nbthreads = 0; +int filter_complex_nbjobs = 0; int vstats_version = 2; int auto_conversion_filters = 1; int64_t stats_period = 500000; @@ -352,6 +354,13 @@ static int opt_filter_threads(void *optctx, const char *opt, const char *arg) return 0; } +static int opt_filter_jobs(void *optctx, const char *opt, const char *arg) +{ + av_free(filter_nbjobs); + filter_nbjobs = av_strdup(arg); + return 0; +} + static int opt_abort_on(void *optctx, const char *opt, const char *arg) { static const AVOption opts[] = { @@ -3961,6 +3970,8 @@ const OptionDef options[] = { "set stream filtergraph", "filter_graph" }, { "filter_threads", HAS_ARG, { .func_arg = opt_filter_threads }, "number of non-complex filter threads" }, + { "filter_jobs", HAS_ARG, { .func_arg = opt_filter_jobs }, + "number of non-complex filter jobs" }, { "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) }, "read stream filtergraph description from a file", "filename" }, { "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(reinit_filters) }, @@ -3969,6 +3980,8 @@ const OptionDef options[] = { "create a complex filtergraph", "graph_description" }, { "filter_complex_threads", HAS_ARG | OPT_INT, { &filter_complex_nbthreads }, "number of threads for -filter_complex" }, + { "filter_complex_jobs", HAS_ARG | OPT_INT, { &filter_complex_nbjobs }, + "number of jobs for -filter_complex" }, { "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex }, "create a complex filtergraph", "graph_description" }, { "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script }, -- 2.37.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-09-20 17:51 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-20 17:50 [FFmpeg-devel] [PATCH] lavfi: make job count configurable separately from thread count rcombs 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 1/7] lavu/cpu: add av_cpu_job_count() rcombs 2022-09-22 13:49 ` Anton Khirnov 2022-09-22 14:56 ` Ronald S. Bultje 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 2/7] sws: add jobs option, distinct from threads rcombs 2022-09-21 8:37 ` Michael Niedermayer 2022-09-21 9:04 ` Michael Niedermayer 2022-09-21 18:25 ` James Almer 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 3/7] lavfi: add jobs args rcombs 2022-09-20 17:50 ` rcombs [this message] 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 5/7] ffplay: add filter_jobs arg rcombs 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 6/7] lavfi/vf_unsharp: use ff_filter_get_nb_jobs rcombs 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 7/7] lavfi/vf_scale: set sws job count using ff_filter_get_nb_jobs rcombs
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220920175021.60790-5-rcombs@rcombs.me \ --to=rcombs@rcombs.me \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git