[FFmpeg-devel] [PATCH] sws: implement slice threading
Michael Niedermayer
michael at niedermayer.cc
Thu Sep 2 18:32:17 EEST 2021
On Sun, Aug 29, 2021 at 06:40:47PM +0200, Anton Khirnov wrote:
> ---
> Updated to conform to the slice alignment requirements
> ---
> libswscale/options.c | 3 ++
> libswscale/swscale.c | 59 +++++++++++++++++++++++++
> libswscale/swscale_internal.h | 14 ++++++
> libswscale/utils.c | 82 +++++++++++++++++++++++++++++++++++
> 4 files changed, 158 insertions(+)
>
> diff --git a/libswscale/options.c b/libswscale/options.c
> index 7eb2752543..4b71a23e37 100644
> --- a/libswscale/options.c
> +++ b/libswscale/options.c
> @@ -81,6 +81,9 @@ static const AVOption swscale_options[] = {
> { "uniform_color", "blend onto a uniform color", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_ALPHA_BLEND_UNIFORM},INT_MIN, INT_MAX, VE, "alphablend" },
> { "checkerboard", "blend onto a checkerboard", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_ALPHA_BLEND_CHECKERBOARD},INT_MIN, INT_MAX, VE, "alphablend" },
>
> + { "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" },
> +
> { NULL }
> };
>
> diff --git a/libswscale/swscale.c b/libswscale/swscale.c
> index ca5c612b18..c233818dcf 100644
> --- a/libswscale/swscale.c
> +++ b/libswscale/swscale.c
> @@ -1113,6 +1113,9 @@ int sws_send_slice(struct SwsContext *c, unsigned int slice_start,
>
> unsigned int sws_receive_slice_alignment(const struct SwsContext *c)
> {
> + if (c->slice_ctx)
> + return c->slice_ctx[0]->dst_slice_align;
> +
> return c->dst_slice_align;
> }
>
> @@ -1136,6 +1139,27 @@ int sws_receive_slice(struct SwsContext *c, unsigned int slice_start,
> return AVERROR(EINVAL);
> }
>
> + if (c->slicethread) {
> + int nb_jobs = c->slice_ctx[0]->dither == SWS_DITHER_ED ? 1 : c->nb_slice_ctx;
This may merrit some sort of info/debug av_log() explaining why only 1 job is used
so a user knows why scaling is slower
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The day soldiers stop bringing you their problems is the day you have stopped
leading them. They have either lost confidence that you can help or concluded
you do not care. Either case is a failure of leadership. - Colin Powell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210902/e94579d8/attachment.sig>
More information about the ffmpeg-devel
mailing list