From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 2/7] sws: add jobs option, distinct from threads Date: Wed, 21 Sep 2022 15:25:02 -0300 Message-ID: <18093382-08c9-d44f-0d0d-683e82bd27fb@gmail.com> (raw) In-Reply-To: <20220920175021.60790-3-rcombs@rcombs.me> On 9/20/2022 2:50 PM, rcombs wrote: > This allows for more efficient use of asymmetric-multiprocessing systems. > --- > libswscale/options.c | 2 ++ > libswscale/swscale_internal.h | 1 + > libswscale/utils.c | 9 ++++++--- > libswscale/version.h | 2 +- > 4 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/libswscale/options.c b/libswscale/options.c > index 4d41b835b1..5765daa100 100644 > --- a/libswscale/options.c > +++ b/libswscale/options.c > @@ -81,6 +81,8 @@ static const AVOption swscale_options[] = { > > { "threads", "number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, INT_MAX, VE, "threads" }, > { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = VE, "threads" }, > + { "jobs", "number of jobs", OFFSET(nb_jobs), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, VE, "jobs" }, Default should probably be 1. > + { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = VE, "jobs" }, > > { NULL } > }; > diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h > index abeebbb002..602082e12c 100644 > --- a/libswscale/swscale_internal.h > +++ b/libswscale/swscale_internal.h > @@ -339,6 +339,7 @@ typedef struct SwsContext { > int vChrDrop; ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user. > int sliceDir; ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top). > int nb_threads; ///< Number of threads used for scaling > + int nb_jobs; ///< Number of slice jobs used for scaling > double param[2]; ///< Input parameters for scaling algorithms that need them. > > AVFrame *frame_src; > diff --git a/libswscale/utils.c b/libswscale/utils.c > index 45baa22b23..c9ff9db957 100644 > --- a/libswscale/utils.c > +++ b/libswscale/utils.c > @@ -1277,18 +1277,21 @@ static int context_init_threaded(SwsContext *c, > ff_sws_slice_worker, NULL, c->nb_threads); > if (ret == AVERROR(ENOSYS)) { > c->nb_threads = 1; > + c->nb_jobs = 1; > return 0; > } else if (ret < 0) > return ret; > > c->nb_threads = ret; > + if (c->nb_jobs < 1) Can c->nb_jobs even be -1? The AVOption range above is 0..INT_MAX > + c->nb_jobs = av_cpu_job_count(); > > - c->slice_ctx = av_calloc(c->nb_threads, sizeof(*c->slice_ctx)); > - c->slice_err = av_calloc(c->nb_threads, sizeof(*c->slice_err)); > + c->slice_ctx = av_calloc(c->nb_jobs, sizeof(*c->slice_ctx)); > + c->slice_err = av_calloc(c->nb_jobs, sizeof(*c->slice_err)); > if (!c->slice_ctx || !c->slice_err) > return AVERROR(ENOMEM); > > - for (int i = 0; i < c->nb_threads; i++) { > + for (int i = 0; i < c->nb_jobs; i++) { > c->slice_ctx[i] = sws_alloc_context(); > if (!c->slice_ctx[i]) > return AVERROR(ENOMEM); > diff --git a/libswscale/version.h b/libswscale/version.h > index 9bb3b171a7..4529a2d7d4 100644 > --- a/libswscale/version.h > +++ b/libswscale/version.h > @@ -29,7 +29,7 @@ > #include "version_major.h" > > #define LIBSWSCALE_VERSION_MINOR 8 > -#define LIBSWSCALE_VERSION_MICRO 112 > +#define LIBSWSCALE_VERSION_MICRO 113 > > #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ > LIBSWSCALE_VERSION_MINOR, \ _______________________________________________ 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-21 18:25 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 [this message] 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 3/7] lavfi: add jobs args rcombs 2022-09-20 17:50 ` [FFmpeg-devel] [PATCH 4/7] ffmpeg: add filter_jobs and filter_complex_jobs args rcombs 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=18093382-08c9-d44f-0d0d-683e82bd27fb@gmail.com \ --to=jamrial@gmail.com \ --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